learning-cmux-with-agents: Command for Claude Code

.claude/commands/cmux-fresh.md

cmux-fresh is a command for Claude Code from disler/learning-cmux-with-agents. It costs 45 tokens per session (1,011 once invoked), scanned A, original, MIT.

A procedure for clearing cmux's saved window and workspace session so the next launch starts blank. It first quits cmux, backs up the saved files, and empties their window lists without deleting the files.

In plain words
What is it for?
Use it to reset cmux's persisted session, handle both the current and previous session files, and report whether cmux had to be stopped before the reset.
Why use it?
It prevents old panes and workspaces from returning when cmux opens. Backups preserve the previous layout in case it needs to be restored.

Command for Claude Code

Written for Claude Code: allowed-tools in frontmatter. Also seen: model in frontmatter.

This is disler/learning-cmux-with-agents's own configuration. It tells Claude Code how to work on learning-cmux-with-agents itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything learning-cmux-with-agents configures →

Reuse

Borrowing it

Nothing to install: this file belongs to disler/learning-cmux-with-agents. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/disler/learning-cmux-with-agents/main/.claude/commands/cmux-fresh.md
Clone the repo
git clone --depth 1 https://github.com/disler/learning-cmux-with-agents

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for cmux-fresh

README.md
[![agentmods](https://agentmods.dev/badge/commands/disler/learning-cmux-with-agents/cmux-fresh/github.svg)](https://agentmods.dev/commands/disler/learning-cmux-with-agents/cmux-fresh)
Your own site
<a href="https://agentmods.dev/commands/disler/learning-cmux-with-agents/cmux-fresh"><img src="https://agentmods.dev/badge/commands/disler/learning-cmux-with-agents/cmux-fresh/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for cmux-fresh

Your own site · 80×15
<a href="https://agentmods.dev/commands/disler/learning-cmux-with-agents/cmux-fresh"><img src="https://agentmods.dev/badge/commands/disler/learning-cmux-with-agents/cmux-fresh.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 45 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,011 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00045 $0.01011
Opus 5 $0.00023 $0.00505
Sonnet 5 $0.00009 $0.00202
Haiku 4.5 $0.00005 $0.00101

Measured 10d ago against content hash 91db1cb314a0, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-10, from the pricing page.

Security

Grade A, and why

cmux-fresh scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 10d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/commands/cmux-fresh.md · 87 lines

How it starts

The opening of the file, as written. The whole thing — 87 lines — stays where its author put it; the contents beside it link to each section on GitHub.

cmux Fresh

Purpose

Wipe cmux's saved session so it boots with fresh, blank windows next time — no restored workspaces or panes. cmux replays its window/workspace/pane tree from a session JSON on launch and rewrites it on quit; this command empties that tree (after backing it up) so there's nothing to restore.

Variables

Static configuration

STATE_DIR: ~/Library/Application Support/cmux SESSION: $STATE_DIR/session-com.cmuxterm.app.json PREVIOUS: $STATE_DIR/session-com.cmuxterm.app-previous.json

Instructions

  • Quit cmux first — automatically. While cmux runs it owns the session file and rewrites it, so a clear won't stick. If it's up, pkill it and wait for it to exit before backing up/clearing. cmux flushes its session on a clean quit, so kill it, then operate on the file it leaves behind. Report whether you had to kill it.
  • Back up before clearing. Copy each session file to <file>.bak-<epoch> before touching it, so the prior layout can be restored.
  • Clear by setting the top-level windows array to [] — keep the rest of the JSON (version, createdAt) intact. Do not delete the file outright.
  • Handle the -previous.json sibling too; it's cmux's one-step-back snapshot.
  • If a file doesn't exist, skip it quietly — that's fine, not an error.
  • This is a destructive-to-layout op on the user's machine; only clear these two session files, nothing else under STATE_DIR.

Workflow

  1. If cmux is running, quit it and wait for it to fully exit (so the clear sticks). Try a graceful quit first, then force-kill if it lingers:
    if pgrep -xi cmux >/dev/null; then
      echo "was RUNNING — quitting"
      osascript -e 'quit app "cmux"' 2>/dev/null || pkill -xi cmux
      for i in $(seq 1 20); do pgrep -xi cmux >/dev/null || break; sleep 0.5; done
      pgrep -xi cmux >/dev/null && { pkill -9 -xi cmux; sleep 1; }
      pgrep -xi cmux >/dev/null && echo "STILL RUNNING — abort" || echo "quit OK"
    else
      echo "not running"
    fi
    
    If it still reports running after the force-kill, stop and tell the user — don't clear, since cmux would just overwrite it.
  2. Back up and clear both session files (epoch suffix; skip missing ones):
    STATE="$HOME/Library/Application Support/cmux"; TS=$(date +%s)
    for f in "$STATE/session-com.cmuxterm.app.json" "$STATE/session-com.cmuxterm.app-previous.json"; do
      [ -f "$f" ] || { echo "skip (absent): $f"; continue; }
      cp "$f" "$f.bak-$TS"
      tmp="$f.tmp.$TS"
      jq '.windows = []' "$f" > "$tmp" && mv "$tmp" "$f" \
        && echo "cleared: $f  (backup: $f.bak-$TS)" \
        || echo "FAILED: $f"
    done
    
  3. Confirm each cleared file now has an empty windows array:
    STATE="$HOME/Library/Application Support/cmux"
    for f in "$STATE/session-com.cmuxterm.app.json" "$STATE/session-com.cmuxterm.app-previous.json"; do
      [ -f "$f" ] && echo "$f -> windows: $(jq '.windows | length' "$f")"
    done
    
  4. Now follow the Report section.

Read the full file on GitHub · 87 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 10d ago First seen · 87 lines · 45 tokens per session scan A 91db1cb314a0

Subscribe to this mod's changes

cmux-fresh is a command published in the GitHub repository disler/learning-cmux-with-agents (109 stars, last pushed 2mo ago), licensed MIT. It adds 45 tokens to every session and 1,011 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.