---
name: Cmux Socket Policy
slug: cmux-socket-policy
category: Quality
description: Cmux Socket Policy defines threading and focus rules for cmux socket and CLI commands to keep telemetry off the main thread and prevent commands from stealing macOS app focus.
github: "https://github.com/manaflow-ai/cmux/tree/main/skills/cmux-socket-policy"
language: Swift
stars: 26034
forks: 2205
install: "npx degit https://github.com/manaflow-ai/cmux/tree/main/skills/cmux-socket-policy ~/.claude/skills/cmux-socket-policy"
installs_to: ~/.claude/skills/cmux-socket-policy
source_path: skills/cmux-socket-policy/SKILL.md
collection_size: 20
category_size: 1354
collection_url: "https://dirskills.com/collections/manaflow-ai/cmux"
added: 2026-08-14T07:12:10.648Z
last_synced: 2026-08-14T07:12:10.648Z
canonical_url: "https://dirskills.com/skills/cmux-socket-policy"
---

# Cmux Socket Policy

Cmux Socket Policy defines threading and focus rules for cmux socket and CLI commands to keep telemetry off the main thread and prevent commands from stealing macOS app focus.

**Install:**

```bash
npx degit https://github.com/manaflow-ai/cmux/tree/main/skills/cmux-socket-policy ~/.claude/skills/cmux-socket-policy
```

## README

# cmux Socket Policy

## Threading policy

- Do not use `DispatchQueue.main.sync` for high-frequency socket telemetry commands such as `report_*`, `ports_kick`, status/progress updates, or log metadata updates.
- For telemetry hot paths, parse and validate arguments off-main.
- Dedupe and coalesce off-main first.
- Schedule minimal UI/model mutation with `DispatchQueue.main.async` only when needed.
- Commands that directly manipulate AppKit/Ghostty UI state are allowed to run on the main actor.
- If adding a new socket command, default to off-main handling and require an explicit reason in code comments when main-thread execution is necessary.

## Focus policy

- Socket/CLI commands must not steal macOS app focus.
- Do not activate the app or raise windows unless the command has explicit focus intent.
- Only explicit focus-intent commands may mutate in-app focus/selection.
- Explicit focus-intent commands include `window.focus`, `workspace.select/next/previous/last`, `surface.focus`, `pane.focus/last`, browser focus commands, and v1 focus equivalents.
- All non-focus commands should preserve the current user focus context while still applying data/model changes.

## Detailed reference

- Read [references/threading-and-focus.md](references/threading-and-focus.md) when adding a command, changing command execution context, or deciding whether focus changes are allowed.
