harness
Agents

Claude Code

Using Claude Code with harness — flags, output format, and event mapping

Claude Code is Anthropic's official CLI for Claude. It supports both interactive and headless operation.

Installation

npm install -g @anthropic-ai/claude-code

The binary is named claude.

Headless mode

Claude Code's headless mode is invoked with the -p (print) flag:

claude -p "explain this codebase" --output-format stream-json --verbose

How harness maps to Claude Code

harnessClaude Code
PermissionMode::FullAccess--dangerously-skip-permissions
PermissionMode::ReadOnly--permission-mode plan
config.prompt-p <prompt>
config.model--model <model>
config.max_turns--max-turns <n>
config.max_budget_usd--max-budget-usd <n>
config.system_prompt--system-prompt <text>
config.append_system_prompt--append-system-prompt <text>
config.resume_session--resume <session-id>
Output format--output-format stream-json --verbose

Key flags

FlagDescription
-p <prompt>Required for headless. Run non-interactively with this prompt.
--output-format <fmt>Output format: text, json, stream-json
--verboseInclude detailed events in stream output
--model <model>Model to use (e.g. claude-opus-4-6)
--max-turns <n>Maximum agentic turns before stopping
--max-budget-usd <n>Maximum spend in USD
--system-prompt <text>Replace the default system prompt
--append-system-prompt <text>Append to the default system prompt
--resume <session-id>Resume a previous session

Permission modes

FlagEffect
(none)Default — may prompt for tool approvals
--permission-mode acceptEditsAuto-approve file edits
--permission-mode planRead-only / plan mode
--dangerously-skip-permissionsAuto-approve everything

Stream-JSON output format

With --output-format stream-json, Claude Code emits NDJSON. Event types:

System init

{
  "type": "system",
  "subtype": "init",
  "session_id": "abc-123",
  "model": "claude-opus-4-6",
  "cwd": "/path/to/project"
}

Assistant message

{
  "type": "assistant",
  "message": {
    "role": "assistant",
    "content": [
      { "type": "text", "text": "I found the bug in line 42." }
    ]
  }
}

Stream event (partial delta)

{
  "type": "stream_event",
  "event": {
    "delta": {
      "type": "text_delta",
      "text": "Hi"
    }
  }
}

Result

{
  "type": "result",
  "subtype": "success",
  "result": "Task completed successfully.",
  "session_id": "abc-123",
  "duration_ms": 12345,
  "total_cost_usd": 0.05
}

Environment variables

VariablePurpose
ANTHROPIC_API_KEYAPI key for Claude models

On this page