claude-code
Claude Code — anthropic‘s CLI / agent harness for using Claude as a coding collaborator. Distributed as a CLI (claude), desktop app, web app, and IDE extensions.
The wiki treats Claude Code as a system, not a chat UI. The reference frame is tw93‘s six-layer-agent-architecture: CLAUDE.md / rules / memory + Tools / MCP + claude-skills + claude-hooks + claude-subagents + Verifiers (2026-04-27-claude-code-architecture-governance-engineering).
Runtime architecture (as currently understood)
- Agent loop: collect context → take action → verify → done-or-loop. Failure modes are almost always context (wrong inputs) or verification (no signal whether the output is right) — rarely the model itself (2026-04-27-claude-code-architecture-governance-engineering).
- Context budget: 200K total, with ~15–20K fixed overhead before the user types anything. Largest hidden cost is MCP tool definitions (5 servers ≈ 25K tokens / 12.5%); see context-engineering.
- Built around prompt-caching: the prompt layout (system prompt → tool definitions → chat history → user input) is ordered to maximize cache hits; mid-session model switching breaks it.
- Compaction: implemented as a forked summarization call against the cached prefix (~1/10 the cost of a fresh call).
- Plan Mode: a model-callable tool (plan-mode) rather than a tool-set switch — chosen specifically so cache survives the mode change.
- Built-in Subagents: Explore (read-only, default Haiku for cost), Plan, General-purpose. Custom Subagents configured via
tools/disallowedTools/model/maxTurns/isolation: worktree(claude-subagents). - Two quality dials: the model setting (which frozen weights; capability + per-token price) and the effort level (how much work per turn — files read, verification depth, how far it pushes before checking in). Effort behavior is trained into the weights and reconsidered every turn; defaults recommended for most tasks (model-and-effort-selection, 2026-07-12-claude-model-effort-level).
Loop primitives (as of mid-2026)
The team’s own taxonomy of loops built on these primitives is at loop-engineering (2026-07-12-loop-engineering-getting-started):
/goal— define completion criteria + turn cap; an evaluator model checks the condition each time Claude tries to stop and sends it back until met. Bare/goalreports turns + token usage so far./loop— re-run a prompt on a time interval, locally (dies with the machine)./schedule(research preview) — move a routine to the cloud.- Dynamic workflows (research preview) — orchestrate agents at scale (can spawn hundreds; pilot on a small slice first); inspect / stop per-agent via
/workflows. - Auto mode — run without stopping for permission; the ingredient that makes proactive loops possible.
/usage— usage breakdown by skills, subagents, MCPs.- Built-in
/code-reviewskill + Code Review for GitHub — the productized second-reviewer (ralph-wiggum-loop).
Configuration surface
CLAUDE.mdat project root → the project contract (claude-md)..claude/rules/*→ path- or language-scoped rules..claude/skills/*/SKILL.md→ on-demand workflows (claude-skills)..claude/agents/*→ custom Subagents (claude-subagents)..claude/settings.json→ permissions, hooks, allowed-tools list (claude-hooks).~/.claude/projects/<path-with-dashes>/*.jsonl→ all session history; greppable locally (2026-04-27-claude-code-architecture-governance-engineering).
High-frequency commands
/context (token-occupancy view), /clear (new session), /compact (summarize keeping pinned items), /memory (which CLAUDE.md files actually loaded), /mcp, /hooks, /permissions, /sandbox, /model. Less common but useful: /simplify (post-edit code review), /rewind (resume from a checkpoint), /btw (quick side-question without polluting main task), /insight (analyze the session for things worth promoting into CLAUDE.md). Double-ESC to edit and resubmit the previous message (2026-04-27-claude-code-architecture-governance-engineering).
CLI flags: claude --continue (resume latest in cwd), claude --resume (picker), claude --continue --fork, claude --worktree, claude -p "..." (non-interactive, for CI / pre-commit / scripts), claude -p --output-format json|stream-json (2026-04-27-claude-code-architecture-governance-engineering).