Skip to content
FlyCockpit
Cockpit Code/ TUI, Headless & Goals
Cockpit Code logo

TUI, Headless Runs & Autonomous Goals

Repository

Master the interactive terminal UI, keybindings, slash commands, headless automation, autonomous goals, subagent trees, and durable sessions.

Platforms: Linux (static musl) · macOS (Apple Silicon & Intel)

Cockpit Code provides a responsive terminal UI for interactive work, a scriptable headless runner (-p) for CI and automation, an autonomous goal engine (/goal / --goal) with explicit budgets and review panels, multi-agent delegation, and durable forkable sessions on disk.

Interactive TUI Workflow

Running cockpit-code with no subcommand opens the full-screen TUI:

  • Message queueing & escalation: Press enter while a turn is running to queue a message (queueDefault defaults to next-turn). Press enter on an empty composer to escalate the newest queued message (next-turn → steer → interrupt), or ctrl+↑ to inspect, edit, toggle, or cancel queued items.
  • Path completion & attachments: Type @ to complete paths (@src/, @~/, @../, @/abs/) or fuzzy-search project files. Paste or drop image paths, press ctrl+v to attach a clipboard image, or type @path + space to attach files. Large pastes automatically collapse into clickable chips (pasteCollapseLines, default 8).
  • Local shell escape (!command): Prefixing a line with ! runs a shell command directly in the working directory. Its stdout/stderr renders in the transcript and is never sent to the model (the viewed agent sees only the command, exit code, duration, and output size).
  • Clipboard over SSH: Copies use local clipboard, tmux buffers, and OSC 52 so selections reach your local terminal over SSH (enable set -g set-clipboard on inside tmux).
  • Dialog safety: Destructive or approval dialog options (allow, approve, apply, compact, delete, quit) require alt+<key> or arrow-key navigation + enter—plain letters never trigger them, and dialogs open on a safe option.

Core Keybindings

Key Action
enter Send message (queues while running; empty composer escalates newest queued item)
shift+enter / alt+enter / ctrl+j Insert newline
ctrl+↑ Manage queued messages (s send now, t toggle next-turn/steer, e edit, x cancel)
esc Dismiss popup/selection → clear composer (restorable with ↑) → stop running turn on empty box
ctrl+c Cancel current turn (press twice while idle to quit)
shift+tab Cycle permission mode (manual → auto → unattended → yolo)
ctrl+e Cycle model reasoning effort
ctrl+r Toggle reasoning visibility (in /model: refresh command-provider discovery)
ctrl+f Search transcript (enter older, shift+enter newer, tab keep position, esc restore)
ctrl+t Focus the agent strip (↑↓ select, enter open, ⌫/esc up a level, x kill child)
ctrl+g Open composer in $VISUAL / $EDITOR
ctrl+v Attach image from clipboard
ctrl+shift+c Copy chat selection
alt+↑ / alt+↓ Jump between your messages (fork here / copy)
shift+alt+↑ / ↓ Focus transcript entries (←→ copy buttons, space expand)
F12 Toggle TUI mouse capture (off restores native terminal selection)
ctrl+] Focus private user terminal sidebar (press again for panel keys, again/esc for composer)

Enable vim keybindings in the composer for the current session with /vim, or permanently with "vim": true in config.json (esc normal mode, i/a/o insert, v/V visual, d/c/y + motion/text object, p/P put).

Private User Terminal Sidebar (ctrl+], /terminal)

When an agent invokes the terminal tool (for example, asking you to sign in or enter a password), Cockpit Code opens a private PTY sidebar on the right (at ≥ 100 columns beside the chat, or overlaying chat on narrower screens):

  • Privacy by default: Keystrokes are never recorded, the PTY uses your login shell with startup files/history/core dumps disabled, and private PTY bytes never touch output files on disk.
  • Sharing modes: The sidebar header shows who asked, the proposed command (typed, not executed), cwd, and sharing mode—either status only (default: agent receives exit status + your note) or output shared on close (last 64 KiB).
  • Fine-grained control: Press ctrl+] to type in the terminal, and ctrl+] again for panel keys: i type, s select rows to share just an excerpt, p force private, r revoke sharing, c close with a note, k/x kill or remove a job tab, ←→ or 1–8 switch tabs, </> resize. Nothing is sent until you close it, and the screen is discarded on close.
  • Agent TTY jobs: Interactive bash jobs started with tty: true appear as red agent-visible output tabs you can watch and type into.
  • Toggle sidebar visibility anytime with /terminal. The terminal tool is automatically excluded in headless, ACP, and unattended sessions.

TUI Slash Commands

Command Purpose
/model Switch model or toggle provider/model availability for subagents
/effort Pick reasoning effort level
/permissions Change session permission mode
/goal [text|pause|resume|edit|clear] Start or control an autonomous goal contract
/criteria View the active agent’s criteria checklist
/agents Inspect the live subagent tree (filter, search /, a ask status, f finalize, s stop)
/subagents [tree|flat] Select tree vs one-layer flat subagents (must be set before the first message)
/decisions Review decisions agents made on your behalf (keep, change, discuss)
/answer Reply to pending agent questions, scope requests, or decisions
/btw [question] Side chat with the viewed agent via a hidden prompt-cache-sharing fork
/jobs View output from or kill background shell jobs
/terminal Show or hide the private user terminal sidebar
/mcp Toggle MCP servers and inspect connection state and tools
/diff [staged|turn] Inspect worktree, staged, or current-turn diffs
/cost Breakdown of cost and tokens by model and agent
/usage View provider quota limits, resets, credits, and soft budgets (r refreshes)
/compact [focus] Summarize conversation history into a compacted context
/prune Preview and stub old delegation prompts/tool outputs (breaks prompt cache; originals stay on disk)
/guidance Show contextual guidance injected per agent and why
/resume, /fork, /new, /rename <title> Switch, fork, create, or rename sessions
/exclusive [model|off] Restrict everything to one model (also disables http/sse MCP servers when blocking network)
/copy, /mouse, /vim, /help, /quit (/exit) Utility toggles, help, and exit

Headless Mode (-p)

Pass -p / --prompt to run a single task and exit—ideal for shell scripts and CI pipelines:

# Basic headless task
cockpit-code -p "audit error handling in src/server.rs"

# Machine-readable JSON output with model, effort, mode, and attachments
cockpit-code -p "reproduce the layout bug shown in this screenshot" \
  --attach ./bug.png \
  --model anthropic/claude-opus-5-5 \
  --effort high \
  --mode auto \
  --json

# Compact an existing session before sending a new prompt
cockpit-code --resume a1b2c3d4 --compact --focus "keep API contract" -p "implement v2"

Common headless flags:

  • --json: Emit structured JSON output instead of plain text (also supported on sessions, guidance, compact, prune, and init).
  • --attach <FILE>: Attach images, PDFs, UTF-8 text files, or binaries (repeatable; relative paths resolve against --cwd; conflicts with --goal).
  • --cwd <DIR>: Run in the specified working directory.
  • --model <provider/model>, --effort <LEVEL>, --mode <manual|auto|unattended|yolo>, --flat: Override session settings.

Autonomous Goals (/goal & --goal)

Autonomous goals let Cockpit Code draft a structured criteria contract and iterate independently—with optional review panels—until criteria pass or a safety/budget limit pauses execution.

  • Interactive TUI: Run /goal <objective> to draft and approve the contract, then control it with /goal pause, /goal resume, /goal edit, or /goal clear.
  • Headless CLI: Run cockpit-code -p "<objective>" --goal (automatically drafts and approves the contract; add --json to emit the final contract and exit code).

Goal Policy & Budgets (config.json)

Default goal settings in config.json (frozen when a goal starts; restarting the process always pauses an active goal):

{
  "goal": {
    "limits": { "maxUsd": null, "maxMinutes": null, "maxTokens": null },
    "noProgressTurns": 3,
    "repeatedGapRounds": 3,
    "reviewPanel": true,
    "maxReviewRounds": 3,
    "usageResume": { "max": 3, "backoffSecs": 30 }
  }
}
  • limits: Set maxUsd, maxMinutes (active work time only—excludes owner approvals, blocking questions, and usage backoff), or maxTokens (null disables each limit). Hitting a limit pauses the run cleanly.
  • Stall detection & reviews: noProgressTurns (3) and repeatedGapRounds (3) detect lack of progress; reviewPanel (true for root goals, opt-in for child tasks via review=true) runs up to maxReviewRounds (3) independent verification passes.
  • Usage backoff: usageResume retries temporary usage limits up to max (3) times starting at backoffSecs (30), doubling up to 300 seconds.

Headless --goal Exit Codes

Exit Code Meaning
0 Goal completed and contract criteria met
3 Roadblocked (requires owner decision/unblocking)
4 Paused (budget limit reached or paused manually)
75 Persistent usage/rate limit after exhausting usageResume retries
1 Error

Subagent Delegation

Agents can delegate tasks to child agents using different models (for example, delegating exploration to a fast, low-cost model while keeping a stronger model at the root):

  • Layouts: tree (default—children may spawn grandchildren up to subagents.maxDepth) or flat (one layer only, set via --flat or /subagents flat before the first message).
  • Write scopes: Children assigned scope directories can write only inside those directories. Out-of-scope edits generate ⇄ scope request diffs reviewed by the parent (or escalated to you).
  • Live tree management: Open /agents (or press ctrl+t for the strip) to view partial reports, open any child’s transcript to steer it directly, press a to ask a child’s status via a read-only fork without interrupting it, f to finalize a subtree bottom-up, or s to stop it.

Durable & Forkable Sessions

Every session is persisted under the DATA directory (shown by cockpit-code doctor) with owner-only (0700 / 0600) permissions. Session IDs accept any unique prefix (the TUI displays 8 characters):

# List sessions for the current directory (or all directories)
cockpit-code sessions
cockpit-code sessions --all

# Resume by ID prefix or continue the most recent session in this cwd
cockpit-code --resume a1b2c3d4
cockpit-code --continue

# Claim a session lock held by another process
cockpit-code --resume a1b2c3d4 --claim-lock

# Fork a session (at tip, or at a specific agent/context/line anchor)
cockpit-code --fork a1b2c3d4
cockpit-code --fork a1b2c3d4@root:0:42

# Manage saved session history from the CLI
cockpit-code compact a1b2c3d4 --focus "preserve migration notes"
cockpit-code prune a1b2c3d4
cockpit-code guidance a1b2c3d4