Summary: Claude Code is Anthropic's command-line interface for software engineering powered by the Agent SDK. It exposes the same 5-step autonomous loop (receive → evaluate → execute → feedback → repeat) with production-grade controls: turn limits, cost budgets, permission modes, session continuity, and streaming.


Overview

Property Value
Provider Anthropic
Type CLI + Agent SDK
Loop Turn-based (same as Agent SDK)
Context Mgmt Auto-compaction, prompt caching, subagents
Permissions 6 modes: default, acceptEdits, plan, dontAsk, auto, bypassPermissions
Budget Controls max_turns, max_budget_usd
Session Resumable via session_id

Key Features

Agent Loop (Shared with SDK)

1. RECEIVE PROMPT → System prompt + user intent + tools + history
2. EVALUATE & RESPOND → Text, tool calls, or both
3. EXECUTE TOOLS → Parallel reads, sequential writes
4. FEED BACK RESULTS → Tool outputs → UserMessage → back to Claude
5. REPEAT until text-only response → ResultMessage (cost, turns, session_id)

Context Management

  • Prompt Caching — Static prefixes (system prompt, tools, CLAUDE.md) cached across requests
  • Auto-Compaction — Summarizes old history near limit; emits compact_boundary message
  • Subagents — Offload subtasks to fresh context; only summary returns
  • CLAUDE.md — Workspace instructions loaded automatically; guides compactor

Permission Modes

Mode Behavior
default Uncovered tools → approval callback
acceptEdits Auto-approve file edits + common fs; others → default
plan Explore only; edits never auto-approved
dontAsk Pre-approved only; everything else denied
auto Model classifier approves/denies (varies by region)
bypassPermissions Dangerous — all allowed tools run without prompts; CI/containers only

Budget Controls

# Example (Python SDK)
agent = Agent(
    max_turns=30,
    max_budget_usd=2.0,
    effort="high",
    permission_mode="acceptEdits",
    allowed_tools=["Read", "Edit", "Bash", "Glob", "Grep"]
)

SDK vs CLI

  • CLI (claude command) — Interactive REPL, human-in-the-loop by default
  • SDK (@anthropic-ai/claude-code Python/TypeScript) — Programmatic, embeddable, same loop primitives
  • Both share: session continuity, compaction, permissions, budget, message stream

Real Session Example (from SDK docs)

Turn Action Tools Result
1 Run tests Bash(npm test) 3 failures
2 Inspect code Read(auth.ts), Read(auth.test.ts) Files loaded
3 Fix & verify Edit(auth.ts), Bash(npm test) All pass
4 Complete (none) "Fixed auth bug, 3 tests pass"

4 turns. Autonomous. Cost tracked in ResultMessage.


Related


Sources