cmux-socket-policy
manaflow-ai/cmux
Socket command threading and focus policy for cmux CLI/socket work.
What is cmux-socket-policy?
Defines threading and focus policies for cmux socket commands, CLI commands, and telemetry. Use when adding or modifying socket commands, focus behavior, or automation to ensure commands don't steal app focus and execute on appropriate threads.
- Enforces off-main-thread execution for high-frequency telemetry commands (report_*, ports_kick, status updates)
- Prevents socket/CLI commands from stealing macOS app focus unless explicitly intended
- Allows main-thread execution only for commands that directly manipulate AppKit/Ghostty UI state
- Requires explicit code comments justifying main-thread execution for new socket commands
- Defines which commands have explicit focus intent (window.focus, workspace.select, pane.focus, etc.)
How to install cmux-socket-policy
npx skills add null --skill cmux-socket-policyHow to use cmux-socket-policy
- 1.Review the threading policy: avoid DispatchQueue.main.sync for high-frequency telemetry; parse/validate arguments off-main
- 2.Review the focus policy: socket commands must not steal focus unless they are explicit focus-intent commands
- 3.Consult references/threading-and-focus.md when adding a new command or changing execution context
- 4.Add explicit code comments if main-thread execution is necessary for a new command
- 5.Test that non-focus commands preserve user focus context while applying data changes
Use cases
- Adding a new socket command to cmux and determining its threading context
- Modifying existing CLI/socket command behavior to comply with focus policies
- Implementing telemetry or status-update commands that must run off-main
- Debugging focus-stealing behavior in socket-based automation
- Refactoring command execution to reduce main-thread contention
- cmux CLI/socket command developers
- macOS app automation engineers
- Developers working on Ghostty integration
- Teams building socket-based control systems
cmux-socket-policy FAQ
Only when the command directly manipulates AppKit/Ghostty UI state. All other commands should default to off-main execution with an explicit code comment explaining why main-thread is necessary.
Only explicit focus-intent commands: window.focus, workspace.select/next/previous/last, surface.focus, pane.focus/last, browser focus commands, and v1 focus equivalents.
Parse and validate arguments off-main, dedupe and coalesce off-main first, then schedule minimal UI/model mutation with DispatchQueue.main.async only when needed.
It violates the focus policy. Non-focus commands must preserve the current user focus context while still applying data/model changes.
Read references/threading-and-focus.md in the cmux repository when adding a command, changing execution context, or deciding whether focus changes are allowed.
Full instructions (SKILL.md)
Source of truth, from manaflow-ai/cmux.
name: cmux-socket-policy description: "Socket command threading and focus policy for cmux CLI/socket work. Use when adding or changing socket commands, CLI commands, telemetry commands, focus/select/open/close/send-key behavior, or automation that could steal app focus."
cmux Socket Policy
Threading policy
- Do not use
DispatchQueue.main.syncfor high-frequency socket telemetry commands such asreport_*,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.asynconly 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 when adding a command, changing command execution context, or deciding whether focus changes are allowed.
Related skills
More from manaflow-ai/cmux and the wider catalog.
cmux-testing
Swift Testing rules and validation guidance for cmux regression tests and package changes.
cmux-workspace
Work within the current cmux workspace and terminal without disrupting user focus.
cmux
Control cmux topology, panes, workspaces, and focus for deterministic multi-pane terminal navigation.
cmux-architecture
Swift package architecture, layering, dependency inversion, and concurrency patterns for cmux.

extract-design
Extract complete design systems from any website into 8 ready-to-use formats.

market-research-analysis
|