PluginBench
Skill
Pass
Audit score 90

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-policy
Claude Code
Cursor
Windsurf
Cline

How to use cmux-socket-policy

  1. 1.Review the threading policy: avoid DispatchQueue.main.sync for high-frequency telemetry; parse/validate arguments off-main
  2. 2.Review the focus policy: socket commands must not steal focus unless they are explicit focus-intent commands
  3. 3.Consult references/threading-and-focus.md when adding a new command or changing execution context
  4. 4.Add explicit code comments if main-thread execution is necessary for a new command
  5. 5.Test that non-focus commands preserve user focus context while applying data changes

Use cases

Good for
  • 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
Who it's for
  • cmux CLI/socket command developers
  • macOS app automation engineers
  • Developers working on Ghostty integration
  • Teams building socket-based control systems

cmux-socket-policy FAQ

When should a socket command run on the main thread?

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.

Which commands are allowed to change app focus?

Only explicit focus-intent commands: window.focus, workspace.select/next/previous/last, surface.focus, pane.focus/last, browser focus commands, and v1 focus equivalents.

How should high-frequency telemetry commands be handled?

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.

What happens if a non-focus command changes app focus?

It violates the focus policy. Non-focus commands must preserve the current user focus context while still applying data/model changes.

Where is the detailed reference for these policies?

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.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 when adding a command, changing command execution context, or deciding whether focus changes are allowed.