Global flags

All commands accept:

FlagDescription
--config <path>Use a specific config file
--jsonOutput in JSON format
--agent-modeForce agent mode (auto-enables JSON output)

Agent mode is auto-detected when running inside a graith session or other AI agent environment (Claude Code, Cursor, Copilot, Amazon Q, OpenCode). Override with GR_AGENT_MODE=0 to disable or GR_AGENT_MODE=1 to force.

Session management

gr new <name> (alias: n)

Create a new agent session.

FlagDescription
--agent <name>Agent to run (default: default_agent from config)
--base <branch>Base branch to fork the worktree from (default: repo default branch)
-C, --repo <path>Path to git repo (default: current directory)
--no-repoCreate session without a git repo or worktree
--in-placeRun agent directly in the repo without creating a worktree
--allow-concurrentAllow multiple in-place sessions on the same repo (requires --in-place)
--mirror <session>Mount another session’s worktree read-only (requires sandbox)
--backgroundCreate without attaching
-p, --prompt <text>Initial prompt for the agent
--prompt-file <path>Read initial prompt from file
-m, --model <name>Model for the agent (expands {model} in agent args)
--headlessRun the agent headless (stream-json) instead of an interactive PTY, for fire-and-forget sessions (experimental; Claude only)

The --headless flag runs the agent in Claude Code’s stream-json mode rather than an interactive terminal — suited to fire-and-forget sessions no human will attach to (tribunal judges, trigger briefings). graith parses the typed event stream, so gr logs -f shows rendered output and the run’s cost/token usage is captured from the result envelope. It is experimental and inert unless [headless] experimental = true is set in config; it is Claude-only in v1, requires a prompt (-p), runs one-shot (one prompt, run to completion, exit), and is incompatible with the sandbox in v1 (a --headless request with the sandbox enabled is an error). Asking for --headless on an agent that can’t do it is an error, not a silent downgrade to PTY. Because a headless session can’t be attached, --headless implies --background. See Configuration → Headless sessions and Session Lifecycle → Headless sessions.

When a session is created:

  1. Fetches origin (if fetch_on_create is true)
  2. Creates branch <branch_prefix>/<session-name>-<session-id> from the base branch
  3. Creates a worktree at <data_dir>/worktrees/<repo-name>/<repo-hash>/<session-id>/
  4. Starts the agent process in the worktree
  5. Attaches (unless --background)

gr attach [name-or-id] (alias: a)

Attach to a session. If no name is given, opens the session picker overlay.

A headless session has no PTY to stream, so gr attach on one is not supported yet — graith directs you to gr logs -f <name>, which streams its rendered output read-only. Convert-to-interactive on attach (relaunching the agent in a PTY via claude --resume <session-id>, preserving history) is a planned follow-up (issue #1075).

gr stop <name-or-id>

Stop a running session. The agent process is killed but the worktree and branch are preserved for later resumption.

FlagDescription
--childrenAlso stop all descendant sessions
--repo <name>Filter by repo name (batch mode)
--stoppedMatch stopped and errored sessions (batch mode)
--stale <duration>Match sessions not attached for this duration, e.g. 7d, 24h (batch mode)
-f, --forceSkip confirmation prompt (batch mode)

When --children is used without a positional argument inside a graith session, it auto-resolves the current session from GRAITH_SESSION_ID and excludes it from the stop.

gr restart <name-or-id>

Restart a stopped session. The agent process is restarted in the existing worktree using the agent’s resume_args.

FlagDescription
--backgroundRestart without attaching

gr delete <name-or-id> (alias: rm)

Delete a session. Kills the agent process, removes the worktree, and deletes the branch. Prompts for confirmation if there are uncommitted changes or unpushed commits.

FlagDescription
--childrenAlso delete all descendant sessions
-f, --forceSkip confirmation prompt
--repo <name>Filter by repo name (batch mode)
--stoppedMatch stopped and errored sessions (batch mode)
--stale <duration>Match sessions not attached for this duration (batch mode)

gr fork <source-session> <new-name>

Fork a session. Creates a new worktree (from the source session’s branch), a new branch, and a new agent process. If the agent has fork_args configured, the new agent inherits the source agent’s conversation history.

FlagDescription
--backgroundFork without attaching

gr migrate <name-or-id>

Migrate a session to a different agent in place — for example, switch from Claude to Codex during a provider outage without losing your work. The current agent’s conversation is rendered to a neutral context file, the agent is stopped, and the target agent is started in the same worktree seeded with that history. The session keeps its id, name, worktree, and branch, so all code state (commits and uncommitted edits) carries over with no branching.

This is a lossy reseed, not a native resume: reasoning/thinking and exact tool-call replay are not carried over, and the agent process is restarted (attached clients re-attach to the new agent). If the target agent fails to start, the original agent is restored. Claude and Codex are supported as migration sources; any configured agent can be a target.

FlagDescription
--agent <name>Target agent to migrate to (required)
--model <model>Model for the target agent (default: the target’s default)
--backgroundMigrate without attaching

gr rename <name-or-id> <new-name>

Rename a session.

gr star <name-or-id>

Star a session. Starred sessions are protected from accidental deletion and appear in the Starred view.

gr unstar <name-or-id>

Remove the star from a session.

Information and monitoring

gr list (alias: ls)

List all sessions with status.

FlagDescription
--repo <path>Filter by repo path
--treeShow parent-child hierarchy
--children <name-or-id>Filter to descendants of a session
--starredShow only starred sessions
--wideShow all columns, including per-session token usage

The --wide view adds a Tokens column with the compact total token usage for each session’s current agent (a trailing ~ marks an approximate count). See gr tokens for the full breakdown.

gr tokens [session]

Show per-session token usage — input, output, and cache tokens — extracted from each agent’s on-disk transcript. With no argument it lists every session and a grand total; with a session name or ID it shows just that session.

Counts reflect the session’s current agent and are updated by a background poll, so they lag by up to ~30 seconds. Agents without a transcript reader (currently anything other than Claude Code and Codex) show / (unsupported); a session that hasn’t been observed yet shows (unknown), distinct from a real zero. USD cost is not shown (a planned opt-in via a user-supplied price table).

  $ gr tokens
SESSION   AGENT   INPUT    OUTPUT   CACHE-R    CACHE-W   OTHER   TOTAL
braw      claude  12,431   48,209   1,204,882  96,004    0       1,361,526
canny     codex   69,131   3,517    756,224    0         0       828,872
  

Use --json (implied in agent mode) for a structured per-session projection.

gr logs <name-or-id> (alias: l)

Show session output without attaching.

FlagDescription
-f, --followFollow output (like tail -f)
-n, --lines <num>Number of lines to show (default: 300)

gr info

Show info for the current session. Auto-detects the session by matching the current working directory against session worktree paths.

gr dashboard

Live-updating TUI dashboard of all sessions. Supports inline attach, stop, delete, and resume.

gr approvals

List sessions waiting for approval.

gr doctor (alias: doc)

Run health checks and diagnostics. Checks daemon status, safehouse availability, orphaned worktrees, oversized scrollback files, and stale PID files.

By default gr doctor avoids walking the data dir to measure on-disk sizes — that walk can take tens of seconds on a large install (worktrees full of node_modules and .git objects), so it’s opt-in. Pass --disk to report the size of the data dir, tmp repos, and orphaned worktrees. When it finds leftover artifacts whose size is worth knowing (orphaned worktrees, a legacy directory), the default run recommends re-running with --disk. In --json output, the disk_measured field indicates whether sizes were computed.

FlagDescription
--autofixAutomatically fix issues
--diskMeasure on-disk sizes (walks the data dir; can be slow on large installs)

gr sandbox why

Explain whether the configured sandbox would allow or deny a filesystem or network access, without launching an agent. Builds the nono profile graith would generate from config and queries nono’s policy oracle. Requires the nono backend.

FlagDescription
--path <p>Filesystem path to check (use with --op)
--op <read|write|readwrite>Operation for --path
--host <h>Network host to check (e.g. github.com)
--port <n>Network port for --host (default 443)
--agent <name>Resolve the merged (global + per-agent) policy for this agent
  gr sandbox why --path ~/.ssh/id_rsa --op read
gr sandbox why --host github.com --port 443
  

Remote interaction

gr type <name-or-id> <text> (alias: t)

Type text into a session’s PTY stdin. Appends a newline by default.

FlagDescription
--no-newlineDo not append a newline after the text

gr status [session] <message>

Set a status summary for a session, visible in the session picker overlay and gr list. When run inside a graith session, the session is auto-detected.

FlagDescription
--clearClear the status summary
--ttl <duration>Override TTL for this status update (e.g. 10m, 1h)

gr notify <message>

Send a proactive desktop/push notification via the configured [notifications] backend. Unlike an inbox message, a notification proactively gets the human’s attention. Only the orchestrator session and the human may send notifications (plain agent sessions are rejected).

FlagDescription
--title <text>Notification title (default graith)
--priority <level>low, normal (default), or high; high plays a sound and bypasses quiet hours and the rate limit
  gr notify "Morning briefing ready" --priority low
gr notify "CI failing on main after 3 retries" --priority high
  

See Configuration → Notifications for backends, rate limiting, and quiet hours.

Messaging

See Inter-Agent Messaging for full details.

gr msg pub <body>

Publish a message to a stream.

FlagDescription
-t, --topic <name>Stream/topic name (required)
-f, --file <path>Read body from file
--thread <id>Thread ID to continue
--reply-to <stream>Stream for replies

gr msg send <session> [body]

Send a message to a session’s inbox. By default, also types a notification into the session’s PTY.

FlagDescription
-f, --file <path>Read body from file
--thread <id>Thread ID to continue
--reply-to <stream>Stream for replies
-q, --quietDon’t type a notification into the session
--childrenSend to all descendant sessions
--parentSend to the parent session

gr msg sub

Read messages from a stream.

FlagDescription
-t, --topic <name>Stream/topic name (required)
-w, --waitBlock until a message arrives
-F, --followStream continuously
--ackAcknowledge after reading
-a, --allShow all messages, not just unread
--thread <id>Filter to a specific thread

gr msg ack

Acknowledge all messages in a stream.

FlagDescription
-t, --topic <name>Stream/topic name (required)

gr msg topics

List streams with total and unread message counts.

FlagDescription
--systemInclude _system.* streams

gr msg jail list

List PR comments quarantined by the author-trust gate (see Comment author-trust gate).

FlagDescription
--releasedInclude already-released comments

gr msg jail show <id>

Show a single quarantined comment, including its body.

gr msg jail release [id]

Release a quarantined comment — deliver its content to the target session’s inbox. Restricted to the human or the orchestrator; a plain agent session is rejected.

FlagDescription
--allRelease all jailed comments from an author (requires --author)
--author <login>Author login to release (with --all)

Document store

See Document Store for full details.

gr store put <key> [body]

Store a document. Reads from stdin if no body or --file is given.

FlagDescription
-f, --file <path>Read body from file

gr store get <key>

Retrieve a document. Outputs the raw body.

gr store list [prefix] (alias: ls)

List documents, optionally filtered by key prefix.

FlagDescription
-a, --allList across all repos

gr store append <key> [line]

Append a line to a document. Creates the document if it does not exist. Reads from stdin if no body or --file is given.

FlagDescription
-f, --file <path>Read line from file

gr store rm <key>

Remove a document from the store.

Store persistent flags

All store subcommands accept:

FlagDescription
--repo <path>Repo path (default: auto-detect)
--sharedUse the global store (not scoped to any repo)

Scenarios

See Scenarios for full details.

gr scenario start <file>

Start a scenario from a TOML file. Pass - to read from stdin. Only the orchestrator session can start scenarios.

  gr scenario start tracing.toml
cat tracing.toml | gr scenario start -
  

gr scenario status <name>

Show the status of each session in a scenario.

gr scenario list

List all scenarios with their aggregate status.

gr scenario stop <name>

Stop all running sessions in a scenario.

gr scenario delete <name>

Delete a scenario and all its sessions, including worktrees and branches.

Triggers

Daemon-fired automation on a schedule or on file changes. Triggers are defined in config.toml; these commands inspect and control them. See Triggers for the full model.

gr trigger list

List all configured triggers with their source, action, next fire / watch scope, and state.

gr trigger status <name>

Show detail for one trigger: next fire, last run/result/error, and (for watch triggers) live bindings.

gr trigger run <name>

Fire a schedule trigger once, now (respects the overlap policy).

gr trigger pause <name> / gr trigger resume <name>

Pause a trigger (persists across restart) or resume a paused one. Requires the orchestrator or a descendant.

Daemon management

gr daemon start

Start the daemon. This is normally automatic and rarely needed.

gr daemon stop

Stop the daemon gracefully.

gr daemon restart

Restart the daemon, preserving live sessions via exec.

FlagDescription
--forceClean stop/start that kills running sessions

After rebuilding gr, run gr daemon restart to pick up the new daemon binary.

gr daemon reload

Reload configuration without restarting the daemon.

Other commands

gr config show

Print the effective (merged) configuration.

gr config diff

Show changes from built-in defaults.

gr config reset

Write built-in defaults to the config file.

FlagDescription
--forceOverwrite without confirmation

gr mcp

Run graith as an MCP (Model Context Protocol) server over stdio. See MCP Server.

Subcommands inspect and control the daemon-managed MCP servers declared under [[mcp_servers]]:

CommandDescription
gr mcp listList configured MCP servers with sandbox state, source (config/auto), live connection count, and uptime
gr mcp restart <name>Stop the running processes for a server; agent proxies reconnect and the daemon starts fresh processes with the current config
gr mcp logs <name>Show the captured stderr for a server (one section per proxy connection). Use -n/--lines to cap the lines shown

gr mcp list and gr mcp logs are read-only; gr mcp restart requires the caller to be the human, the orchestrator, or one of its descendants.

gr completion <shell>

Generate a shell completion script. Supported shells: bash, zsh, fish, powershell.

gr version

Print version information.

Hidden/internal commands

These are used by graith internally and are not intended for direct use:

CommandPurpose
gr report-statusReport agent status (used by hooks)
gr check-inboxCheck unread inbox messages (used by hooks)
gr approve-requestHandle approval requests
gr mcp-proxyMCP proxy for session-scoped MCP connections