Command Reference · July 2026

Specifying and Running Harnesses and Loops in Claude Code, Codex, and Antigravity CLI

CLI and in-session commands for harness setup and loop execution across the three major AI coding agents. Scope is limited to terminal primitives: slash commands, CLI flags, and context files. For API-level constructs, follow the per-platform links in each section.

Claude Code v2.1.199+ Codex 0.142+ Antigravity CLI v1.0.10+

Cross-platform comparison

Capability Claude Code Codex Antigravity CLI
Interval loop /loop 5m … Not built-in; use codex exec + cron Not built-in; use agy -p + cron
Goal-conditioned loop /goal <condition> /goal (features.goals flag) /goal + /schedule
Parallel fan-out /batch, /background Subagents (/agent) /agents + subagents
Non-interactive / CI mode claude -p "…" + --print codex exec "…" agy -p "…"
Scheduled / persistent runs /schedule (Managed Agents) External scheduler + codex exec /schedule
Harness context file CLAUDE.md AGENTS.md AGENTS.md or GEMINI.md
Session state / resume /resume, /branch codex resume, /fork /resume, /fork
Approval / permission gate /permissions --ask-for-approval, /permissions /permissions presets
Context compaction /compact /compact /clear (resets)
Claude Code claude v2.1.199 · Official docs ↗
Harness context files
CLAUDE.md Stable project harness: stack, build commands, conventions, and session protocol. Loaded at every session start. Run /init to scaffold, /memory to refine. Global variant at ~/.claude/CLAUDE.md.
PROGRESS.md Per-feature loop state: tasks done, next steps, blockers, and test-gate status. Rewritten after every completed task so sessions resume from the last commit checkpoint, not from a half-applied edit.
.claude/commands/ Project-scoped custom slash commands (Markdown files). Use ~/.claude/commands/ for global availability. Reference with $ARGUMENTS placeholder for parameterized commands.
.claude/settings.json Permission allowlist, tool rules, and hook configurations. Populated automatically by /permissions and /fewer-permission-prompts.
/loop Loop Skill

Repeat a prompt on a fixed interval while the session stays open. Omit the interval and Claude self-paces between iterations. Omit the prompt and Claude runs an autonomous maintenance check or the prompt in .claude/loop.md (where available). Stops when the session ends or you press Esc.

/loop [interval] [prompt]
ParameterDescription
intervaloptionalRepeat cadence. Units: m minutes, h hours, d days. Minimum 1 minute. Can lead or trail the prompt text. Omit to let Claude self-pace.
promptoptionalInstruction to repeat each iteration. Omit to use .claude/loop.md or the default maintenance prompt.
Example
/loop 5m check if the deploy to staging finished and report status

Polls every 5 minutes. Claude reports each iteration without requiring manual re-prompting.

Gotcha Intervals shorter than 5 minutes hit API rate limits quickly. Each iteration consumes tokens; set intervals proportional to task weight. Loops die when the session ends — use /schedule for persistence beyond a session.
/goal Loop

Register a session-level completion condition. Claude keeps working across turns until a separate evaluator model (defaults to Haiku) reads the transcript and confirms the condition is met. A live overlay shows elapsed time, turn count, and token usage. Clear with /goal clear.

/goal [condition | clear | stop | off | reset | none | cancel]
ParameterDescription
conditionoptionalPlain-language completion criterion. Must be verifiable from the conversation transcript — the evaluator cannot inspect your filesystem or run commands independently. Omit to show the current or most recently achieved goal.
clear / stop / off …Any of these keywords removes an active goal early.
Example
/goal all tests in src/auth pass and the lint step is clean

Claude iterates until the evaluator confirms both conditions. No "keep going" prompts needed.

Gotcha The evaluator judges only what Claude has shown in the conversation. If a verification step runs silently (no visible output), the evaluator cannot confirm it. Make outcomes explicit in Claude's responses.
Requires Claude Code v2.1.139 or later. Works in interactive mode, claude -p, and Remote Control.
/batch Harness Skill

Decompose a large codebase change into 5–30 independent units and run each in a parallel background subagent in an isolated git worktree. Each subagent implements its unit, runs tests, and opens a pull request. Requires a git repository.

/batch <instruction>
ParameterDescription
instructionrequiredDescription of the codebase-wide change. Claude researches the codebase, decomposes the work, presents a plan for approval, then spawns subagents.
Example
/batch migrate src/ from Solid to React

Claude decomposes by component, spawns one agent per unit, and opens a PR per unit.

Gotcha Running 5–30 subagents simultaneously multiplies token usage. Each subagent does its own model and tool work. Reserve for genuine fan-out tasks, not for sequential work.
/background Loop

Detach the current session to run as a background agent and free the terminal. Monitor with claude agents. Pass a prompt to send one final instruction before detaching. Alias: /bg.

/background [prompt]
Example
/background run the full test suite and commit if clean

Terminal is freed immediately. Attach later with claude agents to review output.

/schedule Loop

Create, update, list, or run routines that execute on Anthropic-managed cloud infrastructure (Managed Agents). Claude walks through setup conversationally: cron expression, timezone, and vault environment variables. Each scheduled fire starts a new agent session. Alias: /routines.

/schedule [description]
Example
/schedule run the pricing-fetch job every day at 06:00 UTC

Runs on Anthropic servers without an open local session. Pairs with vault environment variables for secret injection.

/compact Harness

Summarize the conversation so far to free context window space without losing continuity. Optionally pass focus instructions to weight the summary. Use this mid-loop before context pressure causes degraded output rather than waiting for it to fail.

/compact [focus instructions]
Example
/compact focus on test results and open blockers
/permissions Harness

Manage allow, ask, and deny rules for tool permissions. Controls which shell commands, file edits, and MCP tool calls Claude can run autonomously vs. requiring approval. Rules persist in .claude/settings.json.

/permissions
Example
/permissions # opens interactive dialog — add allow rule for npm run test
Read more Permissions and tool trust (Claude Code docs) ↗ · Also see /fewer-permission-prompts to build an allowlist automatically from transcript history.
Ralph loop Ancestor / Gemini CLI

The Ralph loop was a Gemini CLI extension (/ralph-loop) that ran an agent in a self-correcting cycle: act, verify via hook, feed result back, repeat up to a configurable iteration limit. It is not available in Claude Code or Antigravity CLI.

In Claude Code, the equivalent pattern is /goal with a verifiable exit condition, or a custom slash command in .claude/commands/ that embeds assess-act-verify logic. In Antigravity CLI, replicate it with hooks and subagents.

Codex codex v0.142+ · Official docs ↗
Harness context files
AGENTS.md Project harness: task instructions, conventions, and tool guidance. Loaded automatically from the repo root and any active subdirectory. Run /init to scaffold. Supports a precedence chain: global (~/.codex/AGENTS.md) → repo root → subdirectory overrides.
~/.codex/config.toml User-level configuration: default model, approval policy, sandbox mode, MCP servers, and profile definitions. Per-invocation overrides with -c key=value.
Skills Reusable workflow definitions invoked with $skill-name in the composer. The recommended replacement for deprecated custom prompts (~/.codex/prompts/).
/goal Loop Feature flag

Set a persistent objective that Codex works toward until it finishes the task, pauses, or needs input. Use /plan first to shape the goal before committing to it. Progress shows above the composer; pause, resume, edit, or clear from there.

/goal [condition]
ParameterDescription
conditionoptionalPlain-language objective. Omit to view current goal status.
Example
/goal migrate the payments service from REST to gRPC with passing integration tests
Enable If /goal is absent from the slash list, add [features] goals = true to ~/.codex/config.toml, or run codex features enable goals.
/review Harness

Start code review mode. A separate Codex reviewer agent inspects uncommitted changes or a base branch diff and returns prioritized findings. Use /diff to inspect exact changes before or after review.

/review
Example
/review # reviews working tree against HEAD
/permissions Harness

Adjust what Codex can do without asking for approval in the current session. Use /approve to retry a recently denied action once under the current session policy.

/permissions
--ask-for-approval Harness

CLI flag controlling when Codex pauses for human confirmation before running a command. Set at invocation; also configurable in config.toml as the default approval policy.

codex --ask-for-approval <mode> "prompt"
ModeBehavior
on-requestPauses and asks before each tool call. Recommended for interactive runs.
neverRuns all commands without pausing. Use inside an isolated CI environment or sandbox VM.
on-failure deprecatedPauses only on failure. Deprecated; prefer on-request or never.
Safety Combine --ask-for-approval never with --sandbox workspace-write for unattended local runs. Avoid --dangerously-bypass-approvals-and-sandbox (--yolo) outside a hardened environment.
codex exec Loop

Run a single prompt non-interactively. The primary mechanism for scripting Codex in CI pipelines and external orchestrators. Combine with a system scheduler (cron, GitHub Actions, etc.) to build interval loops outside a session.

codex exec [flags] "prompt"
FlagDescription
--full-autoRuns without approvals or interactive prompts. Requires a sandboxed environment.
--sandboxSandbox mode: workspace-write (write inside workspace only), danger-full-access (no restriction — isolated VM only).
--jsonStream newline-delimited JSON events instead of formatted text. Pair with --output-last-message for machine-readable CI output.
--modelOverride the configured model for this run.
Example (GitHub Actions step)
codex exec --full-auto --sandbox workspace-write "fix any ESLint errors, don't change logic"
Subagents Harness

Codex spawns subagents only when explicitly asked. Each subagent does its own model and tool work; subagent workflows consume more tokens than single-agent runs. Use /agent to switch between active agent threads, and configure roles and parallelism under [agents] in config.toml.

/agent # open agent thread picker
Antigravity CLI agy v1.0.10 · Official docs ↗
Note Antigravity CLI (agy) replaced Gemini CLI on June 18, 2026 for free, Pro, and Ultra users. Enterprise/Standard Gemini Code Assist access is unchanged. The /ralph-loop extension from Gemini CLI is not available in Antigravity CLI — replace it with hooks and subagents.
Harness context files
AGENTS.md Standard cross-agent harness file. Loaded automatically. Preferred for portability across Claude Code, Codex, and Antigravity CLI. No changes needed when migrating from Gemini CLI.
GEMINI.md Legacy Gemini CLI context file. Still recognized as a fallback. Rename to AGENTS.md for cross-platform portability.
~/.gemini/antigravity-cli/settings.json User-level settings: color theme, permission behavior (toolPermission), artifact review policy, sandbox, verbosity, and telemetry. Edit via /config or directly.
.antigravityignore Exclusion rules for files the agent should not read or modify. Falls back to .geminiignore if absent.
/goal Loop

Set a persistent objective that Antigravity works toward until the task is complete, paused, or needs input. Use /planning first to shape complex goals before committing. Progress shows above the composer. Pair with /schedule for recurrent goal execution.

/goal [condition]
Example
/goal scan the provider pricing catalogue for stale entries and open a PR with corrections
Quota Antigravity CLI shares quota across the desktop app, CLI, and SDK. The agent cannot see its own remaining quota. Monitor with /usage and avoid over-parallelizing subagents — Pro/Ultra quotas support 3–5 parallel subagents comfortably. Use /grill-me (plan-before-spend) on expensive goals.
/planning Harness

Enable multi-turn plan mode for complex tasks. The agent produces a structured plan before executing, equivalent to Claude Code's /plan. Use before setting a /goal on work that spans many files or subagents.

/planning
Example
/planning # then describe task; review plan; /goal to execute
/agents Harness

Open the Agent Manager panel to review subagent approvals and activity. Antigravity CLI is multi-agent by default; subagents are dispatched automatically based on task complexity. Use Alt+J to switch focus to the next subagent awaiting confirmation, and Ctrl+K to approve from the fast-path alert.

/agents
/tasks Harness

Open the Task Manager panel to view shell execution logs from the current session. Use this to inspect what tool calls subagents have made and verify gate conditions (tests, linting, security scans) without switching terminals.

/tasks
/permissions Harness

Switch the permission preset controlling which tool calls require approval. Four presets are available. Changes persist to settings.json. Add, edit, or remove granular rules directly from this panel (added v1.0.5).

/permissions
PresetBehavior
request-reviewDefault. Pauses for confirmation on non-read tool calls.
proceed-in-sandboxAuto-proceeds inside a sandbox environment; pauses outside.
always-proceedNo confirmation prompts. Use only in a controlled, isolated workspace.
strictPrompts for every non-read tool call, including low-risk ones.
agy -p Loop

Run a single prompt non-interactively and print the response. The primary mechanism for scripting Antigravity CLI in CI pipelines and external schedulers. Combine with cron or a scheduler for interval-based loops outside a session. Pair with --model to select a tier appropriate to the task.

agy -p "prompt" [--model model-name] [--print-timeout 5m]
FlagDescription
-p / --printNon-interactive mode. Prints response and exits. Alias: --prompt.
--modelSet the model for this session only. List available models with agy models.
--print-timeoutWait timeout for print mode. Default 5 minutes.
--dangerously-skip-permissionsAuto-approve all tool requests. Use only in an isolated environment.
Example
agy -p "check whether the nightly pricing-fetch job succeeded and summarize any failures" --model gemini-3-pro