agent:~/.claude$ cat agent-architecture.md

Agent Architecture: Building AI-Powered Development Harnesses

# The complete system for building production AI agent harnesses. Skills, hooks, memory, subagents, multi-agent orchestration, and the patterns that make AI coding agents reliable infrastructure.

author: words: 32719 read_time: 164m updated: 2026-08-01 00:00

Part 2 of Agentic Engineering

$ less agent-architecture.md

TL;DR: Claude Code is not a chat box with file access. It is a programmable runtime with 30 documented lifecycle events, each hookable with shell scripts the model cannot skip. Stack hooks into dispatchers, dispatchers into skills, skills into agents, agents into workflows, and you get an autonomous development harness that enforces constraints, delegates work, persists memory across sessions, and orchestrates multi-agent deliberation. Claude Code v2.1.147 added the off-by-default Workflow tool (CLAUDE_CODE_WORKFLOWS=1), moving deterministic multi-agent orchestration from pure userland scripts toward a first-party runtime primitive; v2.1.149 reinforces the same lesson from the security side with PowerShell permission-bypass fixes and a git-worktree sandbox allowlist fix. Hooks and evidence gates still own correctness.5253 This guide covers every layer of that stack: from a single hook to a 10-agent consensus system. Zero frameworks required. All bash and JSON.

Andrej Karpathy coined a term for what grows around an LLM agent: claws. The hooks, scripts, and orchestration that let the agent grip the world outside its context window.1 Most developers treat AI coding agents as interactive assistants. They type a prompt, watch it edit a file, and move on. That framing caps productivity at whatever you can personally oversee.

The infrastructure mental model is different: an AI coding agent is a programmable runtime with an LLM kernel. Every action the model takes passes through hooks you control. You define policies, not prompts. The model operates within your infrastructure the same way a web server operates within nginx rules. You do not sit at nginx and type requests. You configure it, deploy it, and monitor it.

The distinction matters because infrastructure compounds. A hook that blocks credentials in bash commands protects every session, every agent, every autonomous run. A skill that encodes your evaluation rubric applies consistently whether you invoke it or an agent does. An agent that reviews code for security runs the same checks whether you are watching or not.2


Key Takeaways

  • Hooks guarantee execution; prompts do not. Use hooks for linting, formatting, security checks, and anything that must run every time regardless of model behavior. Exit code 2 blocks actions. Exit code 1 only warns.3
  • Skills encode domain expertise that auto-activates. The description field determines everything. Claude uses LLM reasoning (not keyword matching) to decide when to apply a skill.4
  • Subagents prevent context bloat. Isolated context windows for exploration and analysis keep the main session lean. Run independent subagents in parallel, and use agent teams when workers need sustained coordination.5
  • Memory lives in the filesystem. Files persist across context windows. CLAUDE.md, MEMORY.md, rules directories, and handoff documents form a structured external memory system.6
  • Multi-agent deliberation catches blind spots. Single agents cannot challenge their own assumptions. Two independent agents with different evaluation priorities catch structural failures that quality gates cannot address.7
  • The harness pattern is the system. CLAUDE.md, hooks, skills, agents, and memory are not independent features. They compose into a deterministic layer between you and the model that scales with automation.

How to Use This Guide

Experience Start Here Then Explore
Using Claude Code daily, want more The Harness Pattern Skills System, Hook Architecture
Building autonomous workflows Subagent Patterns Multi-Agent Orchestration, Production Patterns
Evaluating agent architecture Why Agent Architecture Matters Decision Framework, Security Considerations
Setting up a team harness CLAUDE.md Design Hook Architecture, Quick Reference Card

Each section builds on the previous. The Decision Framework at the end provides a lookup table for choosing the right mechanism for each problem type.


Five-Minute Golden Path

Before the deep dive, here is the shortest path from zero to a working harness. One hook, one skill, one subagent, one outcome.

Step 1: Create a security hook (2 minutes)

Create .claude/hooks/block-secrets.sh:

#!/bin/bash
INPUT=$(cat)
CMD=$(echo "$INPUT" | jq -r '.tool_input.command // empty')
if echo "$CMD" | grep -qEi '(AKIA|sk-|ghp_|password=)'; then
    echo "BLOCKED: Potential secret in command" >&2
    exit 2
fi

Wire it in .claude/settings.json:

{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "Bash",
        "hooks": [{ "type": "command", "command": ".claude/hooks/block-secrets.sh" }]
      }
    ]
  }
}

Result: Every bash command Claude runs is now screened for leaked credentials. The model cannot skip this check.

Step 2: Create a code review skill (1 minute)

Create .claude/skills/reviewer/SKILL.md with frontmatter (name: reviewer, description: Review code for security issues, bugs, and quality problems. Use when examining changes, reviewing PRs, or auditing code., allowed-tools: Read, Grep, Glob) and a checklist: SQL injection, XSS, hardcoded secrets, missing error handling, functions over 50 lines.

Result: Claude auto-activates this expertise whenever you mention review, check, or audit.

Step 3: Spawn a subagent (30 seconds)

In any Claude Code session, ask Claude to review the last 3 commits for security issues using a separate agent. Claude spawns an Explore agent that reads the diff, applies your review skill, and returns a summary. Your main context stays clean.

What you now have

A three-layer harness: a deterministic security gate (hook), domain expertise that auto-activates (skill), and isolated analysis that protects your context (subagent). Every section below expands one of these three layers.


Why Agent Architecture Matters

Simon Willison frames the current moment around a single observation: writing code is cheap now.8 Correct. But the corollary is that verification is now the expensive part. Cheap code without verification infrastructure produces bugs at scale. The investment that pays off is not a better prompt. It is the system around the model that catches what the model misses.

Three forces make agent architecture necessary:

Context windows are finite and lossy. Every file read, tool output, and conversation turn consumes tokens. Microsoft Research and Salesforce tested 15 LLMs across 200,000+ simulated conversations and found a 39% average performance drop from single-turn to multi-turn interaction.9 The degradation starts in as few as two turns and follows a predictable curve: precise multi-file edits in the first 30 minutes degrade into single-file tunnel vision by minute 90. Longer context windows do not fix this. The same study’s “Concat” condition (full conversation as a single prompt) achieved 95.1% of single-turn performance with identical content. The degradation comes from turn boundaries, not token limits.

Model behavior is probabilistic, not deterministic. Telling Claude “always run Prettier after editing files” works roughly 80% of the time.3 The model might forget, prioritize speed, or decide the change is “too small.” For compliance, security, and team standards, 80% is not acceptable. Hooks guarantee execution: every Edit or Write triggers your formatter, every time, no exceptions. Deterministic beats probabilistic.

Single perspectives miss multi-dimensional problems. A single agent reviewing an API endpoint checked authentication, validated input sanitization, and verified CORS headers. Clean bill of health. A second agent, prompted separately as a penetration tester, found the endpoint accepted unbounded query parameters that could trigger denial-of-service through database query amplification.7 The first agent never checked because nothing in its evaluation framework treated query complexity as a security surface. That gap is structural. No amount of prompt engineering fixes it.

Agent architecture addresses all three: hooks enforce deterministic constraints, subagents manage context isolation, and multi-agent orchestration provides independent perspectives. Together they form the harness.


The Harness Pattern

The harness is not a framework. It is a pattern: a composable set of files, scripts, and conventions that wrap an AI coding agent in deterministic infrastructure. The components:

┌──────────────────────────────────────────────────────────────┐
│                      THE HARNESS PATTERN                      │
├──────────────────────────────────────────────────────────────┤
│  ORCHESTRATION                                                │
│  ┌────────────┐  ┌────────────┐  ┌────────────┐             │
│  │   Agent     │  │   Agent    │  │  Consensus │             │
│  │   Teams     │  │  Spawning  │  │  Validation│             │
│  └────────────┘  └────────────┘  └────────────┘             │
│  Multi-agent deliberation, parallel research, voting          │
├──────────────────────────────────────────────────────────────┤
│  EXTENSION LAYER                                              │
│  ┌──────────┐  ┌──────────┐  ┌──────────┐  ┌──────────┐    │
│  │  Skills   │  │  Hooks   │  │  Memory  │  │  Agents  │    │
│  └──────────┘  └──────────┘  └──────────┘  └──────────┘    │
│  Domain expertise, deterministic gates, persistent state,     │
│  specialized subagents                                        │
├──────────────────────────────────────────────────────────────┤
│  INSTRUCTION LAYER                                            │
│  ┌──────────────────────────────────────────────────────┐    │
│  │     CLAUDE.md  +  .claude/rules/  +  MEMORY.md       │    │
│  └──────────────────────────────────────────────────────┘    │
│  Project context, operational policy, cross-session memory    │
├──────────────────────────────────────────────────────────────┤
│  CORE LAYER                                                   │
│  ┌──────────────────────────────────────────────────────┐    │
│  │           Main Conversation Context (LLM)             │    │
│  └──────────────────────────────────────────────────────┘    │
│  Your primary interaction; finite context; costs money        │
└──────────────────────────────────────────────────────────────┘

Instruction Layer: CLAUDE.md files and rules directories define what the agent knows about your project. They load automatically at session start and after every compaction. This is the agent’s long-term architectural memory.

Extension Layer: Skills provide domain expertise that auto-activates based on context. Hooks provide deterministic gates that fire on every matching tool call. Memory files persist state across sessions. Custom agents provide specialized subagent configurations.

Orchestration Layer: Multi-agent patterns coordinate independent agents for research, review, and deliberation. Spawn budgets prevent runaway recursion. Consensus validation ensures quality.

The key insight: most users work entirely in the Core Layer, watching context bloat and costs climb. Power users configure the Instruction and Extension layers, then use the Core Layer only for orchestration and final decisions.2

Managed vs. Self-Hosted Harnesses (April 2026)

Throughout early 2026, the “build your own harness” path was the only real option. In April 2026, that changed. Anthropic shipped Claude Managed Agents in public beta (April 8): harness loop + tool execution + sandbox container + state persistence as a REST API, billed at standard tokens plus $0.08/session-hour. OpenAI’s Agents SDK update (April 16) formalized the same split — harness and compute as separate layers, with native sandbox providers (Blaxel, Cloudflare, Daytona, E2B, Modal, Runloop, Vercel) and snapshot/rehydrate for surviving container loss.2324

The deeper SDK surface for the OpenAI side landed in openai-agents Python v0.14.0 (released April 15, 2026; announced April 16): a SandboxAgent subclass of Agent with default_manifest, sandbox instructions, and capabilities; a Manifest describing the fresh-workspace contract (files, dirs, local files, Git repos, env, users, mounts); a SandboxRunConfig for per-run wiring of sandbox client, live session injection, manifest overrides, snapshots, and materialization concurrency limits. Built-in capabilities cover shell access, filesystem editing, image inspection, skills, sandbox memory, and compaction. Sandbox memory persists extracted lessons across runs and progressively discloses them; workspaces support local files, Git repo entries, and remote mounts (S3, R2, GCS, Azure Blob, S3 Files); snapshots are portable across providers. Backends: UnixLocalSandboxClient, DockerSandboxClient, and hosted clients for Blaxel, Cloudflare, Daytona, E2B, Modal, Runloop, and Vercel via optional extras.24

For Python projects that want to embed the Claude Code runtime as a library — between “shell out to claude” and “REST API to Managed Agents” — claude-agent-sdk-python is the third option. The April 28-29 series (v0.1.69 → v0.1.71) bumped the bundled CLI to v2.1.123, raised the floor on the mcp dependency to >=1.19.0 (older versions silently dropped CallToolResult returns from in-process MCP tools, leaving the model with a validation-error blob), and brought SandboxNetworkConfig to schema parity with the TypeScript SDK (allowedDomains, deniedDomains, allowManagedDomainsOnly, allowMachLookup).30 As of 2026-08-01 the package sits at v0.2.128 on PyPI (bundling Claude CLI v2.1.220, with the mcp floor now >=1.23.0), and the TypeScript SDK at v0.3.220; the 0.2.x line is incremental over the 0.1.x surface described here — the include_hook_events, skills, and sandbox-config options below remain current — with recent releases focused on subprocess-cleanup and NDJSON-stream reliability.86

If your harness includes a voice or realtime layer, openai-agents-python v0.17.0 (May 8, 2026) updated RealtimeAgent to default to gpt-realtime-2.41 Existing realtime sessions pick up the new default automatically; pin the previous model explicitly if you need to hold the old behavior for evaluation.

In July 2026 the managed column gained a multi-agent story on the OpenAI side too: openai-agents-python v0.18.2 (July 11) and openai-agents-js v0.13.2 (July 10) add hosted multi-agent support in beta — OpenAI-managed orchestration of multiple agents as a hosted service, the direct counterpart to Anthropic’s Managed Multiagent Orchestration public beta covered in the Multi-Agent Orchestration section.73 Both vendors now offer the same trade on the multi-agent tier that the table below describes for single agents: the vendor runs the delegation loop, you give up the hook surface.

The architectural fork is now real:

Dimension Self-hosted harness (this guide’s default) Managed harness (Claude Managed Agents / OpenAI Agents SDK)
Operational burden You run everything Vendor runs loop, sandbox, state
Customization Total — your hooks, your skills, your memory Bounded — vendor-defined extension points
Cost model Token + self-hosted compute Token + runtime-hour premium
State durability You design it Vendor checkpoints across disconnects
Agent team orchestration Build your own Vendor-provided multi-agent coordination

When to pick which: self-hosted remains right for teams that already have infrastructure muscle, want skills/hooks they control, or are optimizing a specific workflow deeply. Managed is right for teams without dedicated platform engineers, when time-to-value matters more than customization, or when agent runs need to survive laptop closures reliably without you building that persistence layer. The two are compatible — you can run a self-hosted harness that delegates specific long-running tasks to Managed Agents via its REST API.

What the Harness Looks Like on Disk

~/.claude/
├── CLAUDE.md                    # Personal global instructions
├── settings.json                # User-level hooks and permissions
├── skills/                      # Personal skills (44+)
   ├── code-reviewer/SKILL.md
   ├── security-auditor/SKILL.md
   └── api-designer/SKILL.md
├── agents/                      # Custom subagent definitions
   ├── security-reviewer.md
   └── code-explorer.md
├── rules/                       # Categorized rule files
   ├── security.md
   ├── testing.md
   └── git-workflow.md
├── hooks/                       # Hook scripts
   ├── validate-bash.sh
   ├── auto-format.sh
   └── recursion-guard.sh
├── configs/                     # JSON configuration
   ├── recursion-limits.json
   └── deliberation-config.json
├── state/                       # Runtime state
   ├── recursion-depth.json
   └── agent-lineage.json
├── handoffs/                    # Session handoff documents
   └── deliberation-prd-7.md
└── projects/                    # Per-project memory
    └── {project}/memory/MEMORY.md

.claude/                         # Project-level (in repo)
├── CLAUDE.md                    # Project instructions
├── settings.json                # Project hooks
├── skills/                      # Team-shared skills
├── agents/                      # Team-shared agents
└── rules/                       # Project rules

Every file in this structure serves a purpose. The ~/.claude/ tree is personal infrastructure that applies to all projects. The .claude/ tree in each repository is project-specific and shared via git. Together, they form the complete harness.


Skills System

Skills are model-invoked extensions. Claude discovers and applies them automatically based on context, without you explicitly calling them.4 The moment you catch yourself re-explaining the same context across sessions is the moment you should build a skill.

When to Build a Skill

Situation Build a… Why
You paste the same checklist every session Skill Domain expertise that auto-activates
You run the same command sequence explicitly Slash command User-invoked action with predictable trigger
You need isolated analysis that shouldn’t pollute context Subagent Separate context window for focused work
You need a one-time prompt with specific instructions Nothing Just type it. Not everything needs abstraction.

Skills are for knowledge Claude always has available. Slash commands are for actions you explicitly trigger. If you are deciding between the two, ask: “Should Claude apply this automatically, or should I decide when to run it?”

Creating a Skill

Skills live in four possible locations, from broadest to narrowest scope:4

Scope Location Applies to
Enterprise Managed settings All users in organization
Personal ~/.claude/skills/<name>/SKILL.md All your projects
Project .claude/skills/<name>/SKILL.md This project only
Plugin <plugin>/skills/<name>/SKILL.md Where plugin is enabled

Every skill requires a SKILL.md file with YAML frontmatter:

---
name: code-reviewer
description: Review code for security vulnerabilities, performance issues,
  and best practice violations. Use when examining code changes, reviewing
  PRs, analyzing code quality, or when asked to review, audit, or check code.
allowed-tools: Read, Grep, Glob
---

# Code Review Expertise

## Security Checks
When reviewing code, verify:

### Input Validation
- All user input sanitized before database operations
- Parameterized queries (no string interpolation in SQL)
- Output encoding for rendered HTML content

### Authentication
- Session tokens validated on every protected endpoint
- Permission checks before data mutations
- No hardcoded credentials or API keys in source

Frontmatter Reference

Field Required Purpose
name Yes Unique identifier (lowercase, hyphens, max 64 chars)
description Yes Discovery trigger (max 1024 chars). Claude uses this to decide when to apply the skill
allowed-tools No Restrict Claude’s capabilities (e.g., Read, Grep, Glob for read-only)
disable-model-invocation No Prevents auto-activation; skill only activates via /skill-name
user-invocable No Set false to hide from the / menu entirely
model No Override which model to use when the skill is active
context No Set to fork to run in isolated context window
agent No Run as a subagent with its own isolated context
hooks No Define lifecycle hooks scoped to this skill
$ARGUMENTS No String substitution: replaced with user’s input after /skill-name

The Description Field Is Everything

At session start, Claude Code extracts every skill’s name and description and injects them into Claude’s context. When you send a message, Claude uses language model reasoning to decide if any skill is relevant. Independent analysis of the Claude Code source confirms the mechanism: skill descriptions are injected into an available_skills section of the system prompt, and the model uses standard language understanding to select relevant skills.10

Bad description:

description: Helps with code

Effective description:

description: Review code for security vulnerabilities, performance issues,
  and best practice violations. Use when examining code changes, reviewing
  PRs, analyzing code quality, or when asked to review, audit, or check code.

The effective description includes: what it does (review code for specific issue types), when to use it (examining changes, PRs, quality analysis), and trigger phrases (review, audit, check) that users naturally type.

Note that auto-activation is a dial, not a law: as of v2.1.215, Claude no longer self-invokes the bundled /verify and /code-review skills — they run on explicit invocation only, a deliberate walk-back of description-driven activation for heavyweight review skills whose unprompted runs cost more than they earned.74

Context Budget

All skill descriptions share a context budget that scales dynamically at 1% of the context window, with a fallback of 8,000 characters.4 If you have many skills, keep each description concise and put the key use case first. You can override the budget via the SLASH_COMMAND_TOOL_CHAR_BUDGET environment variable,11 but the better fix is shorter, more precise descriptions. Run /context during a session to check whether any skills are being excluded.

Supporting Files and Organization

Skills can reference additional files in the same directory:

~/.claude/skills/code-reviewer/
├── SKILL.md                    # Required: frontmatter + core expertise
├── SECURITY_PATTERNS.md        # Referenced: detailed vulnerability patterns
└── PERFORMANCE_CHECKLIST.md    # Referenced: optimization guidelines

Reference them from SKILL.md with relative links. Claude reads these files on-demand when the skill activates. Keep SKILL.md under 500 lines and move detailed reference material to supporting files.12

Sharing Skills via Git

Project skills (.claude/skills/ in the repo root) are shared via version control:4

mkdir -p .claude/skills/domain-expert
# ... write SKILL.md ...
git add .claude/skills/
git commit -m "feat: add domain-expert skill for payment processing rules"
git push

When teammates pull, they get the skill automatically. No installation, no configuration. This is the most effective way to standardize expertise across a team.

Skills as a Prompt Library

Beyond single-purpose skills, the directory structure works as an organized prompt library:

~/.claude/skills/
├── code-reviewer/          # Activates on: review, audit, check
├── api-designer/           # Activates on: design API, endpoint, schema
├── sql-analyst/            # Activates on: query, database, migration
├── deploy-checker/         # Activates on: deploy, release, production
└── incident-responder/     # Activates on: error, failure, outage, debug

Each skill encodes a different facet of your expertise. Together, they form a knowledge base that Claude draws from automatically based on context. A junior developer gets senior-level guidance without asking for it.

Skills Compose with Hooks

Skills can define their own hooks in frontmatter that activate only while the skill runs. This creates domain-specific behavior that does not pollute other sessions:2

---
name: deploy-checker
description: Verify deployment readiness. Use when preparing to deploy,
  release, or push to production.
hooks:
  PreToolUse:
    - matcher: Bash
      hooks:
        - type: command
          command: "bash -c 'INPUT=$(cat); CMD=$(echo \"$INPUT\" | jq -r \".tool_input.command\"); if echo \"$CMD\" | grep -qE \"deploy|release|publish\"; then echo \"DEPLOYMENT COMMAND DETECTED. Running pre-flight checks.\" >&2; fi'"
---

Philosophy skills auto-activate via SessionStart hooks, injecting quality constraints into every session without explicit invocation. The skill itself is knowledge. The hook is enforcement. Together, they form a policy layer.

Common Skill Mistakes

Too-broad descriptions. A git-rebase-helper skill that activates on any git-related prompt (rebases, merges, cherry-picks, even git status) pollutes context on 80% of sessions. The fix is either tightening the description or adding disable-model-invocation: true and requiring explicit /skill-name invocation.4

Too many skills competing for budget. More skills means more descriptions competing for the 1% context budget. If you notice skills not activating, check /context for excluded ones. Prioritize fewer, well-described skills over many vague ones.

Critical information buried in supporting files. Claude reads SKILL.md immediately but only accesses supporting files when needed. If critical information is in a supporting file, Claude might not find it. Put essential information in SKILL.md directly.4

SDK Skill Surface (May 8, 2026)

Self-hosted harnesses on claude-agent-sdk-python v0.1.77+ should use the skills option on ClaudeAgentOptions to declare available skills, not the legacy "Skill" value in allowed_tools.37 The "Skill" shorthand is deprecated and the dedicated option gives Claude Code more structured information about which skills are available. Bundled CLI in v0.1.77 is v2.1.133.

Plugin and Skill Convergence in .claude/skills/ (May 29, 2026)

Skills have always loaded from a project’s .claude/skills/ directory. Claude Code v2.1.157 extends that directory to plugins: a plugin placed in .claude/skills/ now loads automatically with no marketplace registration, and claude plugin init <name> scaffolds a fresh one there with the manifest and SKILL.md already wired.58 That closes the gap between the two project-tooling shapes that used to live in different places — a bare skill committed straight to the repo, versus a plugin that bundles a skill plus hooks plus an MCP server but previously needed a marketplace to install. The practical effect for harness design: project-scoped tooling no longer needs a registry detour to ship — write it, commit it, and teammates get the same surface on git pull. Plugins still own the bundled-installable use case (hooks + skills + MCP servers + agents in one ZIP); the change is that a project no longer has to stand up a marketplace just to load one from its own tree.

Hiding the Bundled Surface as Governance (June 8, 2026)

Skills are capability, and capability is attack surface. Claude Code v2.1.169 adds a disableBundledSkills setting (and the matching CLAUDE_CODE_DISABLE_BUNDLED_SKILLS environment variable) that hides the bundled skills, workflows, and built-in slash commands from the model entirely.60 For a hardened or regulated harness, this is a deliberate attack-surface reduction: an operator who has audited and approved a specific set of project and personal skills can suppress everything Anthropic ships in the box, so the model only ever reasons over the surface the operator vetted. Treat it the same way you treat a tool allowlist — the default is broad capability, and turning the default off is a governance decision, not a convenience toggle.

Nested .claude/skills and Closest-Wins Resolution (June 16, 2026)

Claude Code v2.1.178 made project tooling location-aware. Skills in nested .claude/skills directories now load when you are working on files under that directory, not just from the repo root; on a name clash the nested skill appears as <dir>:<name> so both stay reachable.63 The same release made the rest of the project surface resolve closest-to-the-working-directory: when an agent, workflow, or output-style name collides across nested .claude/ directories, the one nearest the working directory wins, and a project-scope workflow save targets the closest existing .claude/workflows/ rather than always the root.63 For a monorepo or a repo-of-repos this is the difference between one flat global surface and per-package tooling that activates in context — a services/api/.claude/skills/ can carry API-specific skills that surface only while you work in that tree, without colliding with a services/web/ skill of the same name.


Hook Architecture

Hooks are shell commands triggered by Claude Code lifecycle events.3 They run outside the LLM as plain scripts, not prompts interpreted by the model. The model wants to run rm -rf /? A 10-line bash script checks the command against a blocklist and rejects it before the shell ever sees it. The hook fires whether the model wants it to or not.

Available Events

Claude Code exposes 30 documented lifecycle events across eight categories as of this guide update. The event list grows with releases, so treat the reference docs as the source of truth and check the cheat sheet for the current full table before wiring production hooks:13

Category Events Can Block?
Session SessionStart, Setup, SessionEnd No
User / completion UserPromptSubmit, UserPromptExpansion, Stop, StopFailure, TeammateIdle Prompt/expansion/stop/idle can block; StopFailure cannot
Tool PreToolUse, PermissionRequest, PermissionDenied, PostToolUse, PostToolUseFailure, PostToolBatch Pre/permission/batch can block; post events cannot
Subagent / task SubagentStart, SubagentStop, TaskCreated, TaskCompleted Stop/task events can block; start cannot
Context PreCompact, PostCompact, InstructionsLoaded PreCompact can block; post/load cannot
Filesystem / workspace CwdChanged, DirectoryAdded, FileChanged, WorktreeCreate, WorktreeRemove Worktree creation can block; others cannot
Configuration / notification ConfigChange, Notification Config changes can block except policy settings; notifications cannot
MCP Elicitation, ElicitationResult Yes

Two recent refinements matter for background and multi-agent harnesses. As of v2.1.198, background claude agents sessions fire the Notification hook with trigger values agent_needs_input and agent_completed, so a coordinator can react the moment a fleet member blocks on a prompt or finishes — the notification-driven equivalent of polling claude agents --json. And as of v2.1.199, the SessionStart, Setup, and SubagentStart hooks surface stderr when they exit with code 2 (previously that output was silently discarded), so a startup or subagent-launch hook that fails now explains why instead of failing blind.

DirectoryAdded (v2.1.219) closes the mid-session workspace gap. The event list has been stable since MessageDisplay arrived in v2.1.152; DirectoryAdded is the first new lifecycle event since, and it fires after /add-dir — or the SDK’s register_repo_root control request — registers a new working directory partway through a session.84 The gap it closes is real: until now a harness could validate a workspace exhaustively at SessionStart and then watch a second repository get bolted on with no hook firing at all. Anything you assert about the workspace at startup — trust checks, secret scans, path-scoping rules derived from the tree, per-repo policy loading — needs to re-run here, because a session’s directory set is no longer fixed at launch. The event is informational rather than blocking, so treat it as a trigger to re-derive state and to record provenance, not as a gate; if a directory must never be addable, deny it in settings rather than trying to veto it from a hook. The SDK side landed the same release (TypeScript v0.3.219 adds DirectoryAdded to the control-protocol lifecycle events), so SDK-hosted harnesses see it on the same footing as CLI ones.85

Exit Code Semantics

Exit codes determine whether hooks block actions:3

Exit Code Meaning Action
0 Success Operation proceeds. Stdout shown in verbose mode.
2 Blocking error Operation stops. Stderr becomes error message fed to Claude.
1, 3, etc. Non-blocking error Operation continues. Stderr shown in verbose mode only (Ctrl+O).

Critical: Every security hook must use exit 2, not exit 1. Exit 1 is a non-blocking warning. The dangerous command still executes. This is the most common hook mistake across teams.14

Hook Configuration

Hooks live in settings files. Project-level (.claude/settings.json) for shared hooks. User-level (~/.claude/settings.json) for personal hooks:

{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "Bash",
        "hooks": [
          {
            "type": "command",
            "command": ".claude/hooks/validate-bash.sh"
          }
        ]
      }
    ],
    "PostToolUse": [
      {
        "matcher": "Write|Edit",
        "hooks": [
          {
            "type": "command",
            "command": "bash -c 'if [[ \"$FILE_PATH\" == *.py ]]; then black --quiet \"$FILE_PATH\" 2>/dev/null; fi'"
          }
        ]
      }
    ]
  }
}

The matcher field filters an event-specific value. For tool events, it matches tool_name values such as Bash, Edit, Write, Read, Glob, Grep, MCP tool names like mcp__server__tool, or * for all tools. Simple names and |-separated lists are exact matches; values with other characters are JavaScript regular expressions. Some events do not support matchers and always fire when configured.13 As of Claude Code v2.1.195, matchers containing hyphenated identifiers (code-reviewer, mcp__brave-search) exact-match instead of accidentally substring-matching — a hook aimed at one agent or server no longer fires on every name that merely contains the string; to cover all tools from a hyphenated MCP server, write the explicit pattern mcp__brave-search__.*.66 v2.1.214 applied the same discipline to path patterns: a hook if: condition using a single-segment dir/** pattern now matches only <cwd>/dir, not every directory named dir anywhere in the tree — write **/dir/** when you genuinely mean any depth.74 As with the v2.1.195 change, the fix trades accidental breadth for declared intent; audit any hook conditions that were silently relying on the old any-depth behavior.

Hook Input/Output Protocol

Hooks receive JSON on stdin with full context:

{
  "tool_name": "Bash",
  "tool_input": {
    "command": "npm test",
    "description": "Run test suite"
  },
  "session_id": "abc-123",
  "agent_id": "main",
  "agent_type": "main"
}

For advanced control, PreToolUse hooks can output JSON to modify tool input, inject context, or make permission decisions. Use the hookSpecificOutput wrapper — the older top-level decision/reason format is deprecated for PreToolUse:

{
  "hookSpecificOutput": {
    "hookEventName": "PreToolUse",
    "permissionDecision": "allow",
    "permissionDecisionReason": "Command validated and modified",
    "updatedInput": {
      "command": "npm test -- --coverage --ci"
    },
    "additionalContext": "Note: This database has a 5-second query timeout."
  }
}

Three Types of Guarantees

Before writing any hook, ask: what kind of guarantee do I need?14

Formatting guarantees ensure consistency after the fact. PostToolUse hooks on Write/Edit run your formatter after every file change. The model’s output does not matter because the formatter normalizes everything.

{
  "hooks": {
    "PostToolUse": [
      {
        "matcher": "Write|Edit",
        "hooks": [
          {
            "type": "command",
            "command": "bash -c 'if [[ \"$FILE_PATH\" == *.py ]]; then black --quiet \"$FILE_PATH\" 2>/dev/null; elif [[ \"$FILE_PATH\" == *.js ]] || [[ \"$FILE_PATH\" == *.ts ]]; then npx prettier --write \"$FILE_PATH\" 2>/dev/null; fi'"
          }
        ]
      }
    ]
  }
}

Safety guarantees prevent dangerous actions before they execute. PreToolUse hooks on Bash inspect commands and block destructive patterns with exit code 2:

#!/bin/bash
# validate-bash.sh — block dangerous commands
INPUT=$(cat)
CMD=$(echo "$INPUT" | jq -r '.tool_input.command')

if echo "$CMD" | grep -qE "rm\s+-rf\s+/|git\s+push\s+(-f|--force)\s+(origin\s+)?main|git\s+reset\s+--hard|DROP\s+TABLE"; then
    echo "BLOCKED: Dangerous command detected: $CMD" >&2
    exit 2
fi

Quality guarantees validate state at decision points. PreToolUse hooks on git commit commands run your linter or test suite and block the commit if quality checks fail:

#!/bin/bash
# quality-gate.sh — lint before commit
INPUT=$(cat)
CMD=$(echo "$INPUT" | jq -r '.tool_input.command')

if echo "$CMD" | grep -qE "^git\s+commit"; then
    if ! LINT_OUTPUT=$(ruff check . --select E,F,W 2>&1); then
        echo "LINT FAILED -- fix before committing:" >&2
        echo "$LINT_OUTPUT" >&2
        exit 2
    fi
fi

Hook Types Beyond Shell Commands

Claude Code supports five hook types:13

Command hooks (type: "command") run shell scripts. Fast, deterministic, no token cost.

MCP tool hooks (type: "mcp_tool") call a tool on an already-connected MCP server. Use them when validation logic already lives behind an MCP boundary and does not need a separate shell script.

Prompt hooks (type: "prompt") send a single-turn prompt to a fast Claude model. The model returns { "ok": true } to allow or { "ok": false, "reason": "..." } to block. Use for nuanced evaluation that regex cannot express.

Agent hooks (type: "agent") spawn a subagent with tool access (Read, Grep, Glob) for multi-turn verification. They are experimental; prefer command hooks for production gates and reserve agent hooks for checks that genuinely require inspecting actual files or test output:

{
  "hooks": {
    "Stop": [
      {
        "hooks": [
          {
            "type": "agent",
            "prompt": "Verify all unit tests pass. Run the test suite and check results. $ARGUMENTS",
            "timeout": 120
          }
        ]
      }
    ]
  }
}

As of Claude Code v2.1.140, agent hook input includes subagent_type, which lets a shared hook distinguish a security-reviewer run from an explorer or generic worker without guessing from prompt text.49

HTTP hooks (type: "http") send the event’s JSON input as a POST request to a URL and receive JSON back. Use for webhooks, external notification services, or API-based validation (v2.1.63+). Not supported for SessionStart events:

{
  "hooks": {
    "PostToolUse": [
      {
        "hooks": [
          {
            "type": "http",
            "url": "https://your-webhook.example.com/hook",
            "headers": { "Authorization": "Bearer $WEBHOOK_TOKEN" },
            "allowedEnvVars": ["WEBHOOK_TOKEN"],
            "timeout": 10
          }
        ]
      }
    ]
  }
}

Async Hooks

Hooks can run in the background without blocking execution. Add async: true for non-critical operations like notifications and logging:13

{
  "type": "command",
  "command": ".claude/hooks/notify-slack.sh",
  "async": true
}

Use async for notifications, telemetry, and backups. Never use async for formatting, validation, or anything that must complete before the next action.

Dispatchers Over Independent Hooks

Running seven hooks all firing on the same event, each reading stdin independently, creates race conditions. Two hooks writing to the same JSON state file concurrently will truncate the JSON. Every downstream hook that parses that file breaks.2

The fix: one dispatcher per event that runs hooks sequentially from cached stdin:

#!/bin/bash
# dispatcher.sh — run hooks sequentially with cached stdin
INPUT=$(cat)
HOOK_DIR="$HOME/.claude/hooks/pre-tool-use.d"

for hook in "$HOOK_DIR"/*.sh; do
    [ -x "$hook" ] || continue
    echo "$INPUT" | "$hook"
    EXIT_CODE=$?
    if [ "$EXIT_CODE" -eq 2 ]; then
        exit 2  # Propagate block
    fi
done

Debugging Hooks

Five techniques for debugging hooks that fail silently:14

  1. Test scripts independently. Pipe sample JSON: echo '{"tool_input":{"command":"git commit -m test"}}' | bash your-hook.sh
  2. Use stderr for debug output. Exit code 2 stderr is fed back to Claude as an error message. Non-blocking stderr (exit 1, 3, etc.) appears only in verbose mode (Ctrl+O).
  3. Watch for jq failures. Wrong JSON paths return null silently. Test jq expressions against real tool input.
  4. Verify exit codes. A PreToolUse hook that uses exit 1 provides zero enforcement while appearing to work.
  5. Keep hooks fast. Hooks run synchronously. Keep all hooks under 2 seconds, ideally under 500ms.

SDK-Side Hook Event Streaming

Self-hosted harnesses built on claude-agent-sdk-python (v0.1.74+, May 6, 2026) can subscribe to hook events directly from the message stream rather than going through shell-script callbacks.36 Set include_hook_events=True on ClaudeAgentOptions and HookEventMessage objects (PreToolUse, PostToolUse, Stop, and others) yield from the same iterator as assistant messages and tool results. This mirrors the TypeScript SDK’s includeHookEvents option; bundled CLI was bumped to v2.1.129 in the same release.

The event-stream pattern is the right fit when your harness already lives in Python and you want hook signals in the same control flow as model output. The shell-script hook contract (exit codes, stdin JSON, dispatchers) remains the right answer for harnesses that compose multiple tools, share hooks across Claude Code and Codex, or need exit-code semantics for blocking.

The TypeScript SDK’s July 2026 series (v0.3.205–v0.3.208) made the streamed protocol itself more contractual.70 Interrupts now return typed receipts: an interrupt acknowledges which queued messages are still pending via still_queued UUIDs, and sessions advertise the interrupt_receipt_v1 capability in system/init, so a coordinator can distinguish “interrupt landed” from “interrupt raced past a message already in flight.” command_lifecycle frames report queued/started/completed/cancelled/discarded per message — the first first-party answer to “what happened to the message I sent” without transcript inference. Smaller surfaces landed too: an AgentToolCompletedOutput type for subagent completion payloads, and canUseTool callbacks may now return {behavior: 'allow'} without an updatedInput field.

One line in that series is a security floor, not a feature: v0.3.208 fixed a caller abort arriving during a pending hook being converted into hook success — which meant a tool gated by a PreToolUse hook could execute after the caller had aborted.70 If your harness uses SDK-side hooks as a permission gate and relies on abort to cancel in-flight work, treat v0.3.208 as the minimum version; below it, “aborted” did not reliably mean “blocked.” Python v0.2.127 (July 24, 2026) is the second bypass of this shape in a month — query() closed stdin on the first result frame while background subagents were still running, so their SDK-MCP tool calls failed with "Stream closed" and bypassed PreToolUse hooks entirely.85 Name the pattern and watch for it: SDK-side hook enforcement fails open at lifecycle edges — abort, teardown, stream close — where the transport dies before the hook verdict is collected, and it fails silently, because a bypassed hook looks exactly like a hook that approved. Pin both SDK floors, and keep the shell-hook layer as the enforcement you can prove.

Effort and Session Provenance (May 7-8, 2026)

Two additions in Claude Code v2.1.132 and v2.1.133 give hooks and subprocesses better signal about their execution context:3839

  • effort.level in hook input. Hooks now receive an effort.level JSON field on the same input that carries tool_input and session_id. The same value is exported as the $CLAUDE_EFFORT env var, so Bash commands can read it without parsing JSON. Use this to scale hook cost with effort tier: skip expensive validation on low, run the full security gate on xhigh or max.
  • CLAUDE_CODE_SESSION_ID env var on Bash subprocesses. Bash tool subprocesses now see the same session_id value the hooks see, exposed as CLAUDE_CODE_SESSION_ID. This closes the provenance gap for tools that log per-session state and were previously unable to correlate subprocess events with hook events.

Both signals are available without code changes; existing hooks that ignore the new fields keep working.

autoMode.hard_deny and v2.1.136 Hook/Plugin Fixes (May 8, 2026)

Claude Code v2.1.136 added a new hard-deny tier to auto mode and fixed a cluster of plugin and MCP issues that affected long-running harnesses:40

  • settings.autoMode.hard_deny. Auto mode classifier rules that block unconditionally, regardless of user intent or allow exceptions. This sits above the existing allow/deny matchers as a non-negotiable governance lever. Use it for rules that must never be overridden (force-push to main, secret-bearing files, production database access) even when an operator has approved the broader category in their personal settings.
  • autoMode.classifyAllShell (v2.1.193). By default the auto-mode classifier only reviews shell commands matching arbitrary-code-execution patterns. This setting routes every Bash/PowerShell command through the classifier — the maximal-coverage posture for a governed harness — and the same release surfaces denial reasons in the transcript, the toast, and /permissions, which turns silent blocks into auditable decisions. Codex tightened the equivalent surface in v0.142.2: PowerShell commands containing executable AST regions its safety classifier cannot inspect now require approval instead of passing silently.66
  • Hook ask floors the classifier (v2.1.211). The hook-versus-auto-mode precedence question is now settled: a PreToolUse hook that returns an ask permission decision floors the final outcome at a prompt — auto mode cannot escalate it back to allow for unsandboxed Bash commands.69 For a governed harness this is the missing guarantee tier: a hook’s ask is a deterministic human-in-the-loop stop that survives even fully automatic permission postures. Use ask (not just exit-2 blocks) for the operations where you want a human decision rather than a refusal.
  • The classifier model is pinned per session (v2.1.210). The auto-mode classifier defaults to Sonnet 5 and is pinned for the session, so mid-session model switches no longer change which model is making permission classifications.69 Classification consistency is a governance property; this removes a quiet source of drift.
  • MCP servers no longer disappear after /clear. Servers configured in .mcp.json, plugins, and claude.ai connectors had been silently dropping out of the active set after a /clear in the VS Code extension, JetBrains plugin, and Agent SDK. The fix lands in v2.1.136. If you saw “MCP server X went missing mid-session,” this was the cause.
  • MCP OAuth refresh-token loss on concurrent refresh. Users with several remote MCP servers should no longer need daily re-authentication. Concurrent refresh writes were overwriting each other.
  • Plan mode now blocks file writes correctly. A matching Edit(...) allow rule was bypassing plan-mode write protection. Plan mode is now enforced regardless of allow rules.
  • Plugin Stop and UserPromptSubmit hooks no longer fail mid-session. Cache cleanup was deleting plugin-version files still in use by the running session, breaking these two hook events specifically. The fix keeps in-use versions pinned.
  • skills entry in plugin.json. Setting skills was hiding the plugin’s default skills/ directory. Now the entry composes correctly, and pointing it at a file path raises an explicit error instead of failing silently.
  • CLAUDE_ENV_FILE SessionStart hook env vars going stale. Vars exported by SessionStart hooks via CLAUDE_ENV_FILE were going stale after /resume or /clear. Fixed in v2.1.136. Sessions now re-source the env file on these events.

For governance harnesses, the operationally interesting line items are autoMode.hard_deny (new lever) and the MCP-disappearance fix (silent failure that broke long sessions). Everything else is a quality-of-life cleanup.

Structured Hook Arguments and Block Continuation (May 11, 2026)

Claude Code v2.1.139 added two hook details that matter for production harnesses: an args: string[] exec form for command hooks, and continueOnBlock for PostToolUse hooks.4244 Prefer args when a hook needs dynamic values or path placeholders. It spawns the command directly without a shell, which removes a whole class of quoting and injection mistakes.

Use continueOnBlock when a PostToolUse hook should feed its rejection reason back to Claude and continue the turn instead of ending the flow. Treat it as an operator-experience feature, not a security bypass. A blocking gate should still block the unsafe outcome.

The same release passes CLAUDE_PROJECT_DIR to MCP stdio servers and lets plugin configs reference ${CLAUDE_PROJECT_DIR} in commands.42 MCP tools should resolve project-relative paths from that value rather than from whichever process working directory happened to launch the server. The early-July 2026 releases (v2.1.203–v2.1.206) extended the same principle to the protocol level: MCP roots/list now includes the session’s additional working directories, with roots/list_changed notifications when they change — so a server that respects MCP roots tracks the real multi-directory workspace shape instead of assuming a single project directory.68

Claude Code v2.1.140 is mostly a reliability release for harness operators: it fixes ConfigChange hooks not firing on settings changes, closes edge cases where disableAllHooks and allowManagedHooksOnly did not compose correctly across settings levels, and stops permission dialogs from exposing unintended environment variables returned by hook results.49 That makes the existing governance patterns in this section more dependable; it does not require a new hook architecture.

Claude Code v2.1.141 adds a hook-output terminalSequence field for desktop notifications, window titles, and bells without a controlling terminal.50 Treat that as operator signaling, not enforcement. Security and quality gates should still communicate failures through the normal blocking contract: structured hook output plus the exit behavior that prevents the unsafe action. The same release adds claude agents --cwd <path> for scoping Agent View to one directory, CLAUDE_CODE_PLUGIN_PREFER_HTTPS for plugin installs in environments without GitHub SSH keys, and ANTHROPIC_WORKSPACE_ID for workload-identity federation rules that cover more than one workspace.50 Those are architecture details for team harnesses: narrower operational views, fewer plugin-install assumptions, and explicit enterprise token scoping.

Claude Code v2.1.142 is more important for background-session orchestration than for hook semantics.51 claude agents can now dispatch background sessions with explicit directory, settings, MCP, plugin, permission, model, and effort flags instead of depending on wrapper state. Fast mode defaulted to Opus 4.7 at that release, with CLAUDE_CODE_OPUS_4_6_FAST_MODE_OVERRIDE=1 as the pin for a harness with measured dependence on Opus 4.6’s behavior — as of v2.1.219, Opus 4.7 is out of fast mode entirely and /fast applies to Opus 5 and Opus 4.8.84 Root-level plugin SKILL.md discovery and plugin-provided LSP visibility reduce packaging ambiguity. Fixes to MCP_TOOL_TIMEOUT, pre-existing background-session worktrees, daemon sleep/wake and post-upgrade cleanup, and plugin cache cleanup close reliability gaps that otherwise look like orchestration bugs.

Stop-hook steering, cross-session authority, and multi-agent v2 (June 2026)

Four changes from early June matter for harness and multi-agent design.59

Stop/SubagentStop hooks gained a steering channel. As of Claude Code v2.1.163, a Stop or SubagentStop hook can return hookSpecificOutput.additionalContext to hand Claude feedback and keep the turn going, without the response being labeled a hook error. Before this, a Stop hook’s only real lever was the exit-2 block, which reads as an error and counts toward the consecutive-block cap. For a quality-gate harness this is the cleaner primitive: a Stop hook that detects “you said done but the tests are red” can now inject “here is what is still failing, continue” instead of hard-blocking. Use the block for genuine stop conditions and additionalContext for “not done yet, here is why.”

Cross-session messaging no longer carries borrowed authority. v2.1.166 hardened the multi-session case: messages relayed via SendMessage from another Claude session no longer carry the originating user’s authority, so a receiving session refuses relayed permission requests and auto mode blocks them. If your orchestration has agents message each other, treat an inbound message as untrusted data, not as an authenticated instruction. This is the same principle the security section applies to tool output, extended to inter-agent messaging. As of v2.1.199, Claude Code also detects and warns when a SendMessage is misrouted because two agents share the same name — a reliability complement to this authority boundary, since a message reaching the wrong same-named agent is its own class of orchestration bug.

Model resilience became a first-class setting. The fallbackModel setting now chains up to three backup models, tried in order when the primary is overloaded or unavailable, and a turn auto-retries once on the fallback for unexpected non-retryable API errors. For a long-running autonomous harness, this turns a transient primary-model outage into a graceful degradation rather than a dropped run. claude agents --json also added a waitingFor field (v2.1.162) that surfaces what a blocked background session is waiting on, such as a permission prompt — an observability win for any coordinator polling a fleet of agents.

Safe mode for clean-room governance and troubleshooting. Claude Code v2.1.169 adds a --safe-mode flag (and the matching CLAUDE_CODE_SAFE_MODE environment variable) that starts a session with every customization disabled at once: CLAUDE.md, plugins, skills, hooks, and MCP servers.60 This is the inverse of the harness — a deliberate clean-room. Use it to answer the question every operator eventually asks: “is this behavior coming from the model, or from something I configured?” When a hook misfires, a skill activates when it should not, or an MCP server poisons context, --safe-mode gives you a known-empty baseline to diff against. It is also a governance primitive: a way to run the bare model with none of the persistent authority your harness normally grants, which matters when you need to reproduce a result without any operator-defined scaffolding influencing it.

A note on model tiers. As of Claude Code v2.1.197 (June 30, 2026), Claude Sonnet 5 is the shipped default model for new sessions — native 1M context, promotional $2/$10 per-MTok pricing through August 31 — replacing Opus 4.8 as the out-of-the-box choice. This guide treats Opus 5 (claude-opus-5) as the recommended agentic default: the model to run autonomous harnesses on unless you deliberately choose otherwise, because long-horizon, high-stakes agent loops are exactly where Opus’s reasoning depth earns its cost. Opus 5 shipped July 24, 2026 as the new default Opus in Claude Code v2.1.219 — 1M context, $5/$25 per MTok (the same price as Opus 4.8 it replaces), fast mode at $10/$50 for roughly 2.5× the default speed — and Anthropic reports it more than doubling Opus 4.8 on Frontier-Bench v0.1 while landing within 0.5% of Fable 5’s CursorBench 3.2 score at half the cost.8487 Same price, more capability, and a model Anthropic characterizes as “much stronger at verifying its work and iterating carefully” is the rare upgrade that needs no cost argument for harness work; the migration from 4.8 is an id change. Drop to Sonnet 5 for cost-sensitive or high-throughput work where its speed-to-intelligence ratio wins. Above Opus sits Claude Fable 5 (claude-fable-5), launched June 9, 2026 — a new tier described as Anthropic’s most powerful model, a “Mythos-class” system made safe for general use, selectable in Claude Code v2.1.170 via /model claude-fable-5.60 Reach for the higher tier deliberately, on the decisions where raw reasoning depth justifies the cost, not as a blanket setting for a fleet. Two housekeeping consequences of the Opus 5 cutover: Opus 4.7 is out of fast mode (/fast now applies to Opus 5 and Opus 4.8), and the auto-mode classifier’s Fable-5 fallback — “the best available Opus model” since v2.1.176 — now resolves to Opus 5.84

Codex shipped multi-agent v2. Codex CLI v0.137.0 keeps the runtime choice with each thread, exposes cleaner follow-up and metadata defaults for spawned agents (hide_spawn_agent_metadata now defaults to true), and propagates raw parent events to child listeners. Its subagent model stays explicit: built-in default/worker/explorer agent types, TOML-defined custom agents, and concurrency controls (agents.max_threads default 6, agents.max_depth default 1). The same release adds a v1 skills extension with per-turn skill-catalog resolution and new thread-start/turn-error lifecycle contributor events, narrowing the gap with Claude Code’s hook/skill surface while keeping the kernel-sandbox posture as the default boundary. Codex v0.138.0–v0.139.0 then hardened multi-agent v2 for production: inter-agent message payloads are now encrypted, a v2 agent config catalog plus an agent-residency LRU manage which agents stay resident, and concurrency is counted by active execution rather than by spawned threads, so idle agents no longer consume a slot.61 The lifecycle API matured too — close_agent was renamed interrupt_agent (v0.139.0) to reflect that it interrupts a running agent rather than merely closing a handle — and MCP startup warnings raised by a subagent now stay scoped to the owning thread instead of duplicating up into the parent’s transcript.61 For anyone building Codex-side orchestration, these are the difference between a demo and a fleet: encrypted message transport, bounded residency, execution-counted concurrency, and warnings that do not leak across the thread boundary. Codex v0.140.0 then opened a cross-tool seam: /import selectively pulls setup, project config, and recent chats from Claude Code into Codex, and sessions became permanently deletable (codex delete / /delete, with confirmation safeguards).64 /import is the first official acknowledgment that operators move between harnesses — the configuration you build for one is no longer trapped there.


Memory and Context

Every AI conversation operates within a finite context window. As the conversation grows, the system compresses earlier turns to make room for new content. The compression is lossy. Architectural decisions documented in turn 3 may not survive to turn 15.9

The Three Mechanisms of Multi-Turn Collapse

The MSR/Salesforce study identified three independent mechanisms, each requiring a different intervention:9

Mechanism What Happens Intervention
Context compression Earlier information discarded to fit new content State checkpointing to filesystem
Reasoning coherence loss Model contradicts its own earlier decisions across turns Fresh-context iteration (Ralph loop)
Coordination failure Multiple agents hold different state snapshots Shared state protocols between agents

Strategy 1: Filesystem as Memory

The most reliable memory across context boundaries lives in the filesystem. Claude Code reads CLAUDE.md and memory files at the start of every session and after every compaction.6

~/.claude/
├── configs/           # 14 JSON configs (thresholds, rules, budgets)
│   ├── deliberation-config.json
│   ├── recursion-limits.json
│   └── consensus-profiles.json
├── hooks/             # 95 lifecycle event handlers
├── skills/            # 44 reusable knowledge modules
├── state/             # Runtime state (recursion depth, agent lineage)
├── handoffs/          # 49 multi-session context documents
├── docs/              # 40+ system documentation files
└── projects/          # Per-project memory directories
    └── {project}/memory/
        └── MEMORY.md  # Always loaded into context

The MEMORY.md file captures errors, decisions, and patterns across sessions. When you discover that ((VAR++)) fails with set -e in bash when VAR is 0, you record it. Three sessions later, when you encounter a similar integer edge case in Python, the MEMORY.md entry surfaces the pattern.15

Auto Memory (v2.1.32+): Claude Code automatically records and recalls project context. As you work, Claude writes observations to ~/.claude/projects/{project-path}/memory/MEMORY.md. Auto memory loads the first 200 lines into your system prompt at session start. Keep it concise and link to separate topic files for detailed notes.6 As of v2.1.210, a MEMORY.md write that exceeds the size limit errors instead of silently truncating69 — the failure surfaces at write time rather than as memory entries that quietly vanished. If your harness automates memory writes, handle that error; it is the platform telling you the file needs curation, not a retry.

Memory curation over memory volume (May 2026): A recent arXiv preprint on LLM-agent cooperation frames expanded recall as a possible failure mode: in the authors’ experiments, longer visible history degraded cooperation in 18 of 28 model-game settings.48 Treat this as a design warning, not a finished law. The production rule is already clear enough: keep MEMORY.md short, link out to details, and put decision-ready summaries in handoffs. Raw transcript dumps, tool logs, and long recall feeds belong in searchable storage, not automatically in the active prompt.

Strategy 2: Proactive Compaction

Claude Code’s /compact command summarizes the conversation and frees context space while preserving key decisions, file contents, and task state.15

When to compact: - After completing a distinct subtask (feature implemented, bug fixed) - Before starting a new area of the codebase - When Claude starts repeating or forgetting earlier context - Roughly every 25-30 minutes during intensive sessions

Custom compaction instructions in CLAUDE.md:

# Summary Instructions
When using compact, focus on:
- Recent code changes
- Test results
- Architecture decisions made this session

Compaction protects the conversation; the /cd command (Claude Code v2.1.169) protects the prompt cache. It moves a session to a new working directory mid-stream without breaking the cache that has accumulated over the turn.60 Before this, changing directories meant a fresh session and a cold cache. For a long-running session that pivots from one repository to a sibling — common in monorepo and multi-service work — /cd keeps the expensive cached prefix intact while repointing the filesystem context.

Strategy 3: Session Handoffs

For tasks spanning multiple sessions, create handoff documents that capture the full state:

## Handoff: Deliberation Infrastructure PRD-7
**Status:** Hook wiring complete, 81 Python unit tests passing
**Files changed:** hooks/post-deliberation.sh, hooks/deliberation-pride-check.sh
**Decision:** Placed post-deliberation in PostToolUse:Task, pride-check in Stop
**Blocked:** Spawn budget model needs inheritance instead of depth increment
**Next:** PRD-8 integration tests in tests/test_deliberation_lib.py

The Status/Files/Decision/Blocked/Next structure provides the successor session with full context at minimal token cost. Starting a new session with claude -c (continue) or reading the handoff document goes straight to implementation.15

Strategy 4: Fresh-Context Iteration (The Ralph Loop)

For sessions exceeding 60-90 minutes, spawn a fresh Claude instance per iteration. State persists through the filesystem, not through conversational memory. Each iteration gets the full context budget:16

Iteration 1: [200K tokens] -> writes code, creates files, updates state
Iteration 2: [200K tokens] -> reads state from disk, continues
Iteration 3: [200K tokens] -> reads updated state, continues
...
Iteration N: [200K tokens] -> reads final state, verifies criteria

Compare with a single long session:

Minute 0:   [200K tokens available] -> productive
Minute 30:  [150K tokens available] -> somewhat productive
Minute 60:  [100K tokens available] -> degraded
Minute 90:  [50K tokens available]  -> significantly degraded
Minute 120: [compressed, lossy]     -> errors accumulate

The fresh-context-per-iteration approach trades 15-20% overhead for the orient step (reading state files, scanning git history) against full cognitive resources per iteration.16 The cost-benefit calculation: for sessions under 60 minutes, a single conversation is more efficient. Beyond 90 minutes, fresh-context produces higher-quality output despite the overhead.

Strategy 5: Managed Memory Curation (Dreaming)

Anthropic’s Claude Managed Agents added Dreaming as a Research Preview on May 6, 2026.35 Per Anthropic: “Dreaming is a scheduled process that reviews your agent sessions and memory stores, extracts patterns, and curates memories so your agents improve over time.”35

Dreaming runs in the background between sessions, not on the critical path. It complements rather than replaces the filesystem-as-memory pattern: your MEMORY.md file remains the load-bearing surface; Dreaming writes curated memory entries into the Managed Agents memory store, which the agent reads at session start. The two patterns coexist for harnesses that mix self-hosted filesystem state with managed-side curation.

Filesystem Memory Dreaming (Managed)
Where memory lives Your repo, version-controlled Anthropic-managed memory store
When it updates You write entries by hand or via hooks Background process between sessions
What it captures Decisions, errors, patterns you flag Patterns extracted from session history
Best for Project-specific institutional knowledge Cross-session pattern discovery you would not catch by hand

Dreaming is in Research Preview, so behavior may change. The session-handoffs and CLAUDE.md patterns documented above remain the authoritative memory mechanism for self-hosted harnesses.

The Anti-Patterns

Reading entire files when you need 10 lines. A single 2,000-line file read consumes 15,000-20,000 tokens. Use line offsets: Read file.py offset=100 limit=20 saves the vast majority of that cost.15

Keeping verbose error output in context. After debugging a bug, your context holds 40+ stack traces from failed iterations. A single /compact after fixing the bug frees that dead weight.

Starting every session by reading every file. Let Claude Code’s glob and grep tools find relevant files on demand, saving 100,000+ tokens of unnecessary pre-loading.15


Subagent Patterns

Subagents are specialized Claude instances that handle complex tasks independently. They start with a clean context (no pollution from the main conversation), operate with specified tools, and return results as summaries. The exploration results do not bloat your main conversation; only the conclusions return.5

Built-In Subagent Types

Type Model Mode Tools Use For
Explore Haiku (fast) Read-only Glob, Grep, Read, safe bash Codebase exploration, finding files
General-purpose Inherits Full read/write All available Complex research + modification
Plan Inherits (or Opus) Read-only Read, Glob, Grep, Bash Planning before execution

Creating Custom Subagents

Define subagents in .claude/agents/ (project) or ~/.claude/agents/ (personal):

---
name: security-reviewer
description: Expert security code reviewer. Use PROACTIVELY after any code
  changes to authentication, authorization, or data handling.
tools: Read, Grep, Glob, Bash
model: opus
permissionMode: plan
---

You are a senior security engineer reviewing code for vulnerabilities.

When invoked:
1. Identify the files that were recently changed
2. Analyze for OWASP Top 10 vulnerabilities
3. Check for secrets, hardcoded credentials, SQL injection
4. Report findings with severity levels and remediation steps

Focus on actionable security findings, not style issues.

Subagent Configuration Fields

Field Required Purpose
name Yes Unique identifier (lowercase + hyphens)
description Yes When to invoke (include “PROACTIVELY” to encourage auto-delegation)
tools No Comma-separated. Inherits all tools if omitted. Supports Agent(agent_type) to restrict spawnable agents
disallowedTools No Tools to deny, removed from inherited or specified list. As of v2.1.178, MCP server-level specs (mcp__server, mcp__server__*, mcp__*) are matched correctly here — earlier versions silently ignored them, so a deny rule meant to block an MCP server quietly did nothing.63
model No sonnet, opus, haiku, inherit (default: inherit)
permissionMode No default (labeled “Manual” across the CLI/IDEs since v2.1.200; manual is an accepted alias for the unchanged config value), acceptEdits, delegate, dontAsk, bypassPermissions, plan. As of v2.1.212 the Task tool’s per-invocation mode parameter is deprecated — subagents inherit the parent session’s permission mode, and this frontmatter field is the per-agent override69
maxTurns No Maximum agentic turns before the subagent stops
memory No Persistent memory scope: user, project, local
skills No Auto-load skill content into subagent context at startup. As of v2.1.133, subagents also discover project, user, and plugin skills via the Skill tool the same way the parent session does. Earlier versions silently dropped these from subagent context.39
hooks No Lifecycle hooks scoped to this subagent’s execution
background No Force a background task. As of v2.1.198 subagents run in the background by default — the lead session keeps working and is notified on completion — so this now pins the behavior explicitly rather than opting into it
isolation No Set to worktree for isolated git worktree copy

Worktree Isolation

Subagents can operate in temporary git worktrees, providing a complete isolated copy of the repository:5

---
name: experimental-refactor
description: Attempt risky refactoring in isolation
isolation: worktree
tools: Read, Write, Edit, Bash, Grep, Glob
---

You have an isolated copy of the repository. Make changes freely.
If the refactoring succeeds, the changes can be merged back.
If it fails, the worktree is discarded with no impact on the main branch.

Worktree isolation is essential for experimental work that might break the codebase.

Isolation is only isolation if it holds. Claude Code v2.1.210 fixed a bug where worktree-isolated subagents could mutate the main checkout — the exact failure the mechanism exists to prevent.69 If you rely on isolation: worktree as a safety boundary rather than a convenience, treat v2.1.210 as the floor. The companion permission change cuts the other way: as of v2.1.211, “always allow” rules persist at the repository root across worktrees, so a rule accepted inside one worktree applies to sibling worktrees of the same repository.69 That is the right ergonomics for parallel worktree agents, but it means an allow granted during a throwaway experiment outlives the experiment — grant with the whole repository in mind, not just the worktree in front of you.

v2.1.216 finished the job, moving worktree isolation from bug-fix to enforcement-grade.74 The v2.1.210 fix stopped worktree subagents from mutating the main checkout through ordinary git invocation, but git itself offers explicit redirection — git -C <path>, --git-dir, and the GIT_DIR/GIT_WORK_TREE environment variables — and a worktree-isolated subagent could still aim any of them at the shared checkout. All of those escape hatches are now closed. The same release fixed worktree sessions occasionally landing in a different project’s leftover worktree, stopped workflow and scheduled-task writes from following a symlink planted at .claude to a target outside the project, and made /rewind refuse to traverse symlinks and hard links. The pattern across all four fixes is the same: an isolation boundary must hold against deliberate redirection — git environment overrides, symlink planting — not just against default behavior. If isolation: worktree is a safety boundary in your harness rather than a convenience, v2.1.216 is the new floor.

Parallel Subagents

Use parallel subagents for independent research tasks that do not need to coordinate with each other:5

> Have three explore agents search in parallel:
> 1. Authentication code
> 2. Database models
> 3. API routes

Each agent runs in its own context window, finds relevant code, and returns a summary. The main context stays clean.

The Recursion Guard

Without spawn limits, agents delegate to agents that delegate to agents, each one losing context and burning tokens. The recursion guard pattern enforces budgets:16

#!/bin/bash
# recursion-guard.sh — enforce spawn budget
CONFIG_FILE="${HOME}/.claude/configs/recursion-limits.json"
STATE_FILE="${HOME}/.claude/state/recursion-depth.json"

MAX_DEPTH=2
MAX_CHILDREN=5
DELIB_SPAWN_BUDGET=2
DELIB_MAX_AGENTS=12

# Read current depth
current_depth=$(jq -r '.depth // 0' "$STATE_FILE" 2>/dev/null)

if [[ "$current_depth" -ge "$MAX_DEPTH" ]]; then
    echo "BLOCKED: Maximum recursion depth ($MAX_DEPTH) reached" >&2
    exit 2
fi

# Increment depth using safe arithmetic (not ((VAR++)) with set -e)
new_depth=$((current_depth + 1))
jq --argjson d "$new_depth" '.depth = $d' "$STATE_FILE" > "${STATE_FILE}.tmp"
mv "${STATE_FILE}.tmp" "$STATE_FILE"

Critical lesson: Use spawn budgets, not just depth limits. Depth-based limits track parent-child chains (blocked at depth 3) but miss width: 23 agents at depth 1 is still “depth 1.” A spawn budget tracks total active children per parent, capped at a configurable maximum. The budget model maps to the actual failure mode (too many total agents) rather than a proxy metric (too many nesting levels).7

The nesting-depth default has moved three times; do not build on it. Claude Code v2.1.172 (June 10, 2026) let sub-agents spawn their own sub-agents, nesting up to 5 levels deep — where delegation was previously effectively one level.62 That held from v2.1.172 through v2.1.216. v2.1.217 (July 21, 2026) cut it to 1, turning nested spawning off by default. Then v2.1.219 (July 24, 2026) settled it in the middle: “Subagents can now spawn nested subagents up to depth 3 by default (was 1); set CLAUDE_CODE_MAX_SUBAGENT_SPAWN_DEPTH=1 to disable nesting.”84 Five, then one, then three — the last two moves inside three days.

The useful reading is not that any one of those numbers is correct. It is that the platform is still searching for the right default, which makes “whatever ships” the wrong thing for a harness to inherit. Treat nesting depth as an explicit budget line: set CLAUDE_CODE_MAX_SUBAGENT_SPAWN_DEPTH to the depth your architecture actually needs — for most orchestration that is 1 or 2 — so an upgrade cannot quietly change how deep your fleet delegates. The standing argument is unchanged by any of this churn: agents-delegating-to-agents chains burn context and tokens faster than they produce results, and depth is a hazard to budget for, not a capability to reach for. The recursion guard above is what keeps a deep tree from fanning out into hundreds of active agents whichever way the default drifts next, and a limit you set yourself is the only depth number that still means what you think it means after the next release.

Auto mode now vets spawns before they launch. Claude Code v2.1.178 closed the matching governance gap: in auto mode, subagent spawns are evaluated by the permission classifier before the subagent launches, not only once it starts taking actions.63 Previously a subagent could be spawned to request an action the parent session would have been blocked from taking — the spawn itself was the bypass. Vetting at spawn time means the recursion guard and the permission model finally meet: a child cannot be used as a laundering step for an action the policy forbids.

The platform now ships a native spawn budget. Claude Code v2.1.212 (July 2026) added first-party runaway-loop guardrails: sessions are capped at 200 subagent spawns by default (CLAUDE_CODE_MAX_SUBAGENTS_PER_SESSION to tune, /clear resets the counter), and WebSearch is capped at 200 calls per session (CLAUDE_CODE_MAX_WEB_SEARCHES_PER_SESSION).69 The spawn-budget pattern this section has documented as userland scripting since v1.0 is now platform-provided — validation of the budget model over the depth model. But note the calibration: 200 spawns is an order of magnitude above the 12-agent budget in the config above. The native caps are fuses against a truly runaway loop, not budgets tuned to your architecture. Keep the userland guard for per-parent budgets, depth tracking, and limits that match what your orchestration should actually do; let the platform cap catch whatever slips past it.

The first-party guardrail set now covers four axes. Three of them backstop exactly what the userland guard in this section tracks: total spawns per session (v2.1.212, cap 200, CLAUDE_CODE_MAX_SUBAGENTS_PER_SESSION), nesting depth (CLAUDE_CODE_MAX_SUBAGENT_SPAWN_DEPTH, default currently 3 and demonstrably unstable), and concurrent execution (v2.1.217, default 20, CLAUDE_CODE_MAX_CONCURRENT_SUBAGENTS — one message can no longer fan out unbounded background agents).7884 v2.1.219 adds a fourth that userland guards generally did not have: orchestration width, the number of agents a single planned workflow is allowed to contain, shipped as a default guideline of “aim for fewer than 15 agents” and settable from any settings file via workflowSizeGuideline (covered in the Workflow Tool section below). The spawn-budget pattern is now backstopped on every axis it was designed for, plus one it wasn’t.

The calibration note still applies, but unevenly. 200 spawns and 20 concurrent agents are fuses — an order of magnitude above the 12-agent deliberation budget in the config above, sized to catch a runaway loop rather than to shape an architecture. The width guideline is the first native number in the same register as a real budget: 15 agents per workflow sits right next to this guide’s 12, close enough that adopting the platform default costs you nothing and disagreeing with it means you have an actual reason. Set the three fuses to values you can defend; set the width guideline to the shape of the orchestration you meant to build.

Agent Teams (Research Preview)

Agent Teams coordinate multiple Claude Code instances that work independently, communicate via a shared mailbox and task list, and can challenge each other’s findings:5

Component Role
Team lead Main session that creates the team, spawns teammates, coordinates work
Teammates Separate Claude Code instances working on assigned tasks
Task list Shared work items that teammates claim and complete (file-locked)
Mailbox Messaging system for inter-agent communication

Enable with: export CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1

When to use agent teams vs subagents:

Subagents Agent Teams
Communication Report results back only Teammates message each other directly
Coordination Main agent manages all work Shared task list with self-coordination
Best for Focused tasks where only result matters Complex work requiring discussion and collaboration
Token cost Lower Higher (each teammate = separate context window)

Agent View and Goal Loops (May 2026)

Claude Code v2.1.139 added Agent View, a research-preview interface started with claude agents that shows running, blocked, and completed Claude Code sessions from one screen.4243 The official docs frame it as a way to dispatch and manage many sessions, see what each session is doing, and identify which ones need operator input.43 This gives multi-agent work an operations view that final summaries cannot provide.

Use Agent View when promoting a subagent or team pattern: inspect which sessions are blocked, which are still running, and whether the work distribution matches the intended architecture. Do not treat it as proof of quality. It is observability; tests, review gates, and evidence reports still decide whether the work is sound.

The same release added /goal, which sets a completion condition and lets Claude continue across turns until the condition is met, including interactive, -p, and Remote Control use.42 Treat /goal as a session-scoped completion loop, not a substitute for deterministic gates. It is useful for keeping an agent focused on a target, but tests, citation checks, deploy checks, and security hooks should remain command- or script-backed where failure must block.

Workflow Tool (v2.1.147+)

Claude Code v2.1.147 adds an off-by-default Workflow tool for deterministic multi-agent orchestration. Enable it with CLAUDE_CODE_WORKFLOWS=1.52 Architecturally, this is important because it gives Claude Code a first-party orchestration primitive for flows that previously required custom dispatch scripts, mailbox state, and subagent coordination conventions.

Do not delete the harness around it. A Workflow can structure execution, but it does not replace your safety model. Keep PreToolUse and PostToolUse hooks as the blocking layer, keep spawn budgets or workflow step budgets to prevent runaway width, keep filesystem state auditable, and keep final evidence reports outside the model’s self-assessment. In practice: use Workflow for orchestration shape; use hooks, tests, and review gates for truth.

Dynamic workflows now ship an opinion about width (v2.1.219). Dynamic workflows default to a medium size guideline — “aim for fewer than 15 agents” — with other sizes and an unrestricted option available under Dynamic workflow size in /config, and the current guideline shown in the running-workflow status line.84 The number is advisory, not enforced; it steers the planner rather than blocking a wide plan. What makes it worth configuring is the delivery mechanism: the new workflowSizeGuideline settings key can be set from any settings file — including managed settings and project settings, and it is in the TypeScript SDK settings types as of v0.3.219 — so orchestration width becomes something a team or an org can standardize instead of something each operator rediscovers.85 Set it at the project level to encode what your codebase’s work actually decomposes into. Two operator notes: the /config row hides itself while a settings file is driving the value, which is the correct behavior but reads as a missing setting if you don’t know why; and because the guideline steers the planner rather than gating execution, it belongs in the shape column, not the safety column. Runaway width is still the spawn cap’s job.

The framing worth keeping is that this is a fourth first-party guardrail axis — orchestration width, alongside spawn count, nesting depth, and concurrent execution — and the first one Anthropic has calibrated at a plausible working size rather than as a runaway fuse. Fifteen agents per workflow is the same order of magnitude as the 12-agent deliberation budget this guide has used since v1.0. When the platform’s default and your own budget converge from opposite directions, that is the closest thing to independent corroboration these numbers ever get.

Session Forking and Auto-Backgrounded MCP (July 2026)

Claude Code v2.1.212 reshaped two orchestration primitives.69 /fork now creates a new background session from the current conversation state — the forked line runs independently while the original keeps working — and the previous in-session behavior was renamed /subtask. The distinction matters for orchestration design: /subtask is a scoped detour inside one session’s lifecycle; /fork is a cheap way to mint a parallel background session that inherits full context, closer to a Ralph-loop spawn than to a subagent. If your harness scripts assumed /fork stayed in-session, they now dispatch background work.

The same release auto-backgrounds slow MCP calls: an MCP tool call that runs longer than two minutes is moved to background execution automatically (tune the threshold with CLAUDE_CODE_MCP_AUTO_BACKGROUND_MS).69 A slow MCP server no longer stalls the agentic loop — but it also means “the tool returned” and “the turn continued” are no longer the same event, so hooks or scripts that assumed synchronous MCP completion should key off the tool result, not the turn boundary.

For headless orchestration, v2.1.211 added --forward-subagent-text (env: CLAUDE_CODE_FORWARD_SUBAGENT_TEXT), which forwards subagent assistant text into stream-json output.69 A coordinator process consuming the parent’s stream can now observe subagent progress directly instead of polling transcripts or waiting for the final summary — the observability complement to background-by-default subagents. v2.1.219 extended it past the first level: subagents spawned at depth 2 or deeper now appear in the forwarded stream as well, keyed by their spawning Agent tool_use id.84 That key is the part to build on. With nesting back on by default, a flat stream of subagent text is ambiguous — the id tells a coordinator which parent produced which child, so the delegation tree can be reconstructed from the stream instead of inferred. If your stream consumer was written against one level of subagents, it will now see text from agents it never knew existed; group by the spawning tool_use id rather than assuming every forwarded line belongs to a direct child.


Multi-Agent Orchestration

Single-agent AI systems have a structural blind spot: they cannot challenge their own assumptions.7 Multi-agent deliberation forces independent evaluation from multiple perspectives before any decision locks.

Cross-tool orchestration (April 2026): Google open-sourced Scion on April 7 — a multi-agent hypervisor that runs Claude Code, Gemini CLI, and other “deep agents” as concurrent processes, each with isolated container, git worktree, and credentials. Runs local, hub, or Kubernetes. Explicit philosophy: “isolation over constraints” — agents run with high autonomy inside boundaries enforced at the infrastructure layer, not in the prompt.25 This directly extends the subagent-isolation argument across different tool vendors. If your workflow spans Claude and OpenAI models, Scion is the first real reference implementation for cross-tool subagents with per-agent worktree + credential isolation.

Debate is not a silver bullet: The M3MAD-Bench research cluster (early 2026) found that multi-agent debate plateaus and can be subverted by misleading consensus — valid arguments lose when other agents confidently assert the wrong answer.26 Tool-MAD improves this by giving each agent heterogeneous tool access and using Faithfulness/Relevance scores in the judge stage. If you’re building debate-style orchestration, invest in (a) tool heterogeneity per agent and (b) quantitative judge scoring rather than assuming more agents = better answers.

Managed Multiagent Orchestration and Outcomes (Public Beta)

If you don’t want to build the deliberation infrastructure described below, Multiagent Orchestration entered Public Beta in Claude Managed Agents on May 6, 2026.35 Per Anthropic: “When there is too much work for a single agent to do well, multiagent orchestration lets a lead agent break the job into pieces and delegate each one to a specialist with its own model, prompt, and tools.”35 Specialists “work in parallel on a shared filesystem and contribute to the lead agent’s overall context.”35

Tracing comes in the box. Per Anthropic: “you can also trace every step in the Claude Console: which agent did what, in what order, and why, giving you full visibility into how your task was delegated and executed.”35

The companion Public Beta feature is Outcomes. Per Anthropic: “you write a rubric describing what success looks like and the agent works toward it. A separate grader evaluates the output against your criteria in its own context window, so it isn’t influenced by the agent’s reasoning.”35 This is the managed-service version of the two-gate validation pattern documented later in this section: the rubric replaces the hand-written gate, the separate grader replaces the consensus validator.

Self-Hosted Deliberation (this section) Managed Multiagent + Outcomes
Specialist routing You write the spawn logic Lead agent breaks the job into pieces
Validation Two-gate hooks + consensus scoring Rubric + grader in separate context
Tracing You instrument it Claude Console
Best for Patterns that need full control or specific tool composition Standard delegation patterns where the validation rubric is the contract
Pricing Token + harness cost only Standard tokens plus the Managed Agents session-hour rate (April 8 launch base; see 23)

Self-hosted deliberation remains the right answer when the validation needs to integrate with your own hook surface (PreToolUse blocking, exit-code semantics, custom dispatchers) or when the harness must run without external dependencies. Managed Multiagent is the right answer when standard delegation plus rubric grading is the contract you actually need.

Minimum Viable Deliberation

Start with 2 agents and 1 rule: agents must evaluate independently before seeing each other’s work.7

Decision arrives
  |
  v
Confidence check: is this risky, ambiguous, or irreversible?
  |
  +-- NO  -> Single agent decides (normal flow)
  |
  +-- YES -> Spawn 2 agents with different system prompts
             Agent A: "Argue FOR this approach"
             Agent B: "Argue AGAINST this approach"
             |
             v
             Compare findings
             |
             +-- Agreement with different reasoning -> Proceed
             +-- Genuine disagreement -> Investigate the conflict
             +-- Agreement with same reasoning -> Suspect herding

This pattern covers 80% of the value. Everything else adds incremental improvement.

The Confidence Trigger

Not every task needs deliberation. A confidence scoring module evaluates four dimensions:17

  1. Ambiguity - Does the query have multiple valid interpretations?
  2. Domain complexity - Does it require specialized knowledge?
  3. Stakes - Is the decision reversible?
  4. Context dependency - Does it require understanding the broader system?

The score maps to three levels:

Level Threshold Action
HIGH 0.85+ Proceed without deliberation
MEDIUM 0.70-0.84 Proceed with confidence note logged
LOW Below 0.70 Trigger full multi-agent deliberation

The threshold adapts by task type. Security decisions require 0.85 consensus. Documentation changes need only 0.50. This prevents over-engineering simple tasks while ensuring risky decisions get scrutiny.7

The State Machine

Seven phases, each gated by the previous:7

IDLE -> RESEARCH -> DELIBERATION -> RANKING -> PRD_GENERATION -> COMPLETE
                                                                    |
                                                              (or FAILED)

RESEARCH: Independent agents investigate the topic. Each agent gets a different persona (Technical Architect, Security Analyst, Performance Engineer, and others). Context isolation ensures agents cannot see each other’s findings during research.

DELIBERATION: Agents see all research findings and generate alternatives. The Debate agent identifies conflicts. The Synthesis agent combines non-contradictory findings.

RANKING: Each agent scores every proposed approach across 5 weighted dimensions:

Dimension Weight
Impact 0.25
Quality 0.25
Feasibility 0.20
Reusability 0.15
Risk 0.15

The Two-Gate Validation Architecture

Two validation gates catch problems at different stages:7

Gate 1: Consensus Validation (PostToolUse hook). Runs immediately after each deliberation agent completes: 1. Phase must have reached at least RANKING 2. Minimum 2 agents completed (configurable) 3. Consensus score meets the task-adaptive threshold 4. If any agent dissented, concerns must be documented

Gate 2: Pride Check (Stop hook). Runs before the session can close: 1. Diverse methods: multiple unique personas represented 2. Contradiction transparency: dissents have documented reasons 3. Complexity handling: at least 2 alternatives generated 4. Consensus confidence: classified as strong (above 0.85) or moderate (0.70-0.84) 5. Improvement evidence: final confidence exceeds initial confidence

Two hooks at different lifecycle points match how failures actually occur: some are instant (bad score) and some are gradual (low diversity, missing dissent documentation).7

Why Agreement Is Dangerous

Charlan Nemeth studied minority dissent from 1986 through her 2018 book In Defense of Troublemakers. Groups with dissenters make better decisions than groups that reach quick agreement. The dissenter does not need to be right. The act of disagreement forces the majority to examine assumptions they would otherwise skip.18

Wu et al. tested whether LLM agents can genuinely debate and found that without structural incentives for disagreement, agents converge toward the most confident-sounding initial response regardless of correctness.19 Liang et al. identified the root cause as “Degeneration-of-Thought”: once an LLM establishes confidence in a position, self-reflection cannot generate novel counterarguments, making multi-agent evaluation structurally necessary.20

Independence is the critical design constraint. Two agents evaluating the same deployment strategy with visibility into each other’s findings produced scores of 0.45 and 0.48. Same agents without visibility: 0.45 and 0.72. The gap between 0.48 and 0.72 is the cost of herding.7

Detecting Fake Agreement

A conformity detection module tracks patterns suggesting agents are agreeing without genuine evaluation:7

Score clustering: Every agent scoring within 0.3 points on a 10-point scale signals shared context contamination rather than independent assessment. When five agents evaluating an authentication refactor all scored security risk between 7.1 and 7.4, re-running with fresh context isolation spread the scores to 5.8-8.9.

Boilerplate dissent: Agents copying each other’s concern language rather than generating independent objections.

Absent minority perspectives: Unanimous approval from personas with conflicting priorities (a Security Analyst and a Performance Engineer rarely agree on everything).

The conformity detector catches the obvious cases (roughly 10-15% of deliberations where agents converge too quickly). For the remaining 85-90%, the consensus and pride check gates provide sufficient validation.

What Didn’t Work in Deliberation

Free-form debate rounds. Three rounds of back-and-forth text for a database indexing discussion produced 7,500 tokens of debate. Round 1: genuine disagreement. Round 2: restated positions. Round 3: identical arguments in different words. Structured dimension scoring replaced free-form debate, dropping cost by 60% while improving ranking quality.7

Single validation gate. The first implementation ran one validation hook at session end. An agent completed deliberation with a 0.52 consensus score (below threshold), then continued on unrelated tasks for 20 minutes before the session-end hook flagged the failure. Splitting into two gates (one at task completion, one at session end) caught the same problems at different lifecycle points.7

Cost of Deliberation

Each research agent processes roughly 5,000 tokens of context and generates 2,000-3,000 tokens of findings. With 3 agents, that is 15,000-24,000 additional tokens per decision. With 10 agents, roughly 50,000-80,000 tokens.7

At current Opus pricing, a 3-agent deliberation costs approximately $0.68-0.90. A 10-agent deliberation costs $2.25-3.00. The system triggers deliberation on roughly 10% of decisions, so the amortized cost across all decisions is $0.23-0.30 per session. Whether that is worth it depends on what a bad decision costs.

When to Deliberate

Deliberate Skip
Security architecture Documentation typos
Database schema design Variable renaming
API contract changes Log message updates
Deployment strategies Comment rewording
Dependency upgrades Test fixture updates

CLAUDE.md Design

CLAUDE.md is operational policy for an AI agent, not a README for humans.21 The agent does not need to understand why you use conventional commits. It needs to know the exact command to run and what “done” looks like.

The Precedence Hierarchy

Location Scope Shared Use Case
Enterprise managed settings Organization All users Company standards
./CLAUDE.md or ./.claude/CLAUDE.md Project Via git Team context
~/.claude/CLAUDE.md User All projects Personal preferences
./CLAUDE.local.md Project-local Never Personal project notes
.claude/rules/*.md Project rules Via git Categorized policies
~/.claude/rules/*.md User rules All projects Personal policies

Rules files load automatically and provide structured context without cluttering CLAUDE.md.6

What Gets Ignored

These patterns reliably produce no observable change in agent behavior:21

Prose paragraphs without commands. “We value clean, well-tested code” is documentation, not operations. The agent reads it and proceeds to write code without tests because there is no actionable instruction.

Ambiguous directives. “Be careful with database migrations” is not a constraint. “Run alembic check before applying migrations. Abort if downgrade path is missing.” is.

Contradictory priorities. “Move fast and ship quickly” plus “Ensure comprehensive test coverage” plus “Keep runtime under 5 minutes” plus “Run full integration tests before every commit.” The agent cannot satisfy all four simultaneously and defaults to skipping verification.21

Style guides without enforcement. “Follow the Google Python Style Guide” without ruff check --select D gives the agent no mechanism to verify compliance.

What Works

Command-first instructions:

## Build and Test Commands
- Install: `pip install -r requirements.txt`
- Lint: `ruff check . --fix`
- Format: `ruff format .`
- Test: `pytest -v --tb=short`
- Type check: `mypy app/ --strict`
- Full verify: `ruff check . && ruff format --check . && pytest -v`

Closure definitions:

## Definition of Done
A task is complete when ALL of the following pass:
1. `ruff check .` exits 0
2. `pytest -v` exits 0 with no failures
3. `mypy app/ --strict` exits 0
4. Changed files have been staged and committed
5. Commit message follows conventional format: `type(scope): description`

Task-organized sections:

## When Writing Code
- Run `ruff check .` after every file change
- Add type hints to all new functions

## When Reviewing Code
- Check for security issues: `bandit -r app/`
- Verify test coverage: `pytest --cov=app --cov-fail-under=80`

## When Releasing
- Update version in `pyproject.toml`
- Run full suite: `pytest -v && ruff check . && mypy app/`

Escalation rules:

## When Blocked
- If tests fail after 3 attempts: stop and report the failing test with full output
- If a dependency is missing: check `requirements.txt` first, then ask
- Never: delete files to resolve errors, force push, or skip tests

Writing Order

If starting from scratch, add sections in this priority order:21

  1. Build and test commands (the agent needs these before it can do anything useful)
  2. Definition of done (prevents false completions)
  3. Escalation rules (prevents destructive workarounds)
  4. Task-organized sections (reduces irrelevant instruction parsing)
  5. Directory scoping (monorepos: keeps service instructions isolated)

Skip style preferences until the first four are working.

The platform now audits your CLAUDE.md for you. As of the early-July 2026 releases (v2.1.203–v2.1.206), /doctor analyzes CLAUDE.md and proposes trimming content the model can derive from the codebase itself — restated directory layouts, framework conventions the code already exhibits, command lists that duplicate package scripts.68 This is first-party confirmation of the section’s thesis: instructions earn their tokens by encoding what the agent cannot infer (policies, thresholds, closure definitions), not what it can read from disk. Run /doctor after significant CLAUDE.md growth and treat its trim proposals as a starting point — but keep the operational rules it may flag as “derivable” if they are load-bearing constraints rather than descriptions.

File Imports

Reference other files within CLAUDE.md:

See @README.md for project overview
Coding standards: @docs/STYLE_GUIDE.md
API documentation: @docs/API.md
Personal preferences: @~/.claude/preferences.md

Import syntax: relative (@docs/file.md), absolute (@/absolute/path.md), or home directory (@~/.claude/file.md). Maximum depth: 5 levels of imports.6

Cross-Tool Instruction Compatibility

AGENTS.md is an open standard recognized by every major AI coding tool.21 If your team uses multiple tools, write AGENTS.md as the canonical source and mirror relevant sections to tool-specific files:

Tool Native File Reads AGENTS.md?
Codex CLI AGENTS.md Yes (native)
Cursor .cursor/rules Yes (native)
GitHub Copilot .github/copilot-instructions.md Yes (native)
Amp AGENTS.md Yes (native)
Windsurf .windsurfrules Yes (native)
Claude Code CLAUDE.md No (separate format)

The patterns in AGENTS.md (command-first, closure-defined, task-organized) work in any instruction file regardless of tool. Do not maintain parallel instruction sets that drift apart. Write one authoritative source and mirror.

Codex Parity Notes

Codex now has first-class equivalents for the major harness layers, but the migration is a pattern translation, not a file copy. Codex reads AGENTS.md before work begins, layering global guidance from ~/.codex with project and nested repository instructions.31 Codex skills use the same SKILL.md mental model with progressive disclosure: Codex starts with the skill name, description, and file path, then loads the full skill only when it decides to use it.32 Codex also has native hooks, plugin-bundled hooks, managed hooks, MCP support, and explicit subagent workflows.3334

Codex v0.138.0–v0.139.0 hardened that AGENTS.md discovery for non-trivial workspaces: loading now routes through the environment’s filesystem abstraction and preserves logical paths during the discovery walk, so the right file is selected even when the workspace is a remote filesystem or a symlinked tree.61 This matters whenever your canonical AGENTS.md is the authoritative source and the agent is operating over a mounted, container-materialized, or symlinked checkout — the cases where a naive path walk silently picks the wrong instruction file or none at all. If you mirror one authoritative AGENTS.md across services, treat this as the floor for trusting that the file the agent actually loaded is the one you wrote.

Codex v0.141.0 then hardened the remote-execution path itself: remote executors now connect over authenticated, end-to-end encrypted Noise-relay channels (the control plane and executor no longer trust the relay between them), cross-platform remote execution preserves the executor’s native working directory and shell, and TLS accepts P-521 certificate signatures for enterprise proxies.65 If your orchestration drives Codex executors across a network boundary, this is the difference between a trusted-relay assumption and an end-to-end-encrypted one — treat it as the baseline for any remote-executor topology.

The July 2026 line shows the two runtimes converging on the same primitives from opposite directions.72 Codex v0.143.0 makes MCP tools load via tool search by default — tool schemas are deferred and fetched on demand rather than front-loaded into context — the same deferred-tool-loading pattern Claude Code exposes through its ToolSearch surface, and the correct answer on both runtimes to context bloat at high MCP tool counts. Codex v0.144.0 adds a writes app-approval mode: read-only actions run without prompting while writes require approval — a genuinely new permission-mode primitive sitting between read-only and auto-approve that Claude Code’s mode list does not directly express (its closest analogue is plan mode, which blocks writes outright rather than prompting per write). The same release takes MCP interactive auth to GA. And v0.144.5 expands dangerous-command detection, mirroring the destructive-command guardrails Claude Code shipped in v2.1.183 and v2.1.208. For cross-runtime harness design, the convergence is the story: deferred tool loading, graded write approval, and intent-level dangerous-command blocking are becoming table stakes rather than vendor differentiators.

Codex v0.145.0 pushes the convergence further on two fronts.76 The opt-in multi-agent V2 surface stabilized: sub-agent models, reasoning levels, and concurrency are now configurable, and the previously removed agent roles are restored — Codex’s answer to per-subagent model and effort configuration in .claude/agents/ frontmatter. And /import grew into full cross-harness migration: beyond the Claude Code settings import that shipped in v0.140.0, it now migrates settings from Claude Code and Cursor — MCP servers, plugins, sessions, commands, and project-scoped memories included. For teams running both runtimes, the migration cost between them keeps dropping in one direction; the harness layers you build on Claude Code — servers, skills-as-commands, memory — are increasingly portable state rather than lock-in.

The practical mapping:

Claude Code harness layer Codex equivalent Migration rule
CLAUDE.md / .claude/rules/ AGENTS.md / nested AGENTS.override.md Keep commands and completion rules canonical; split only when directory scope genuinely differs
.claude/skills/<name>/SKILL.md .agents/skills/<name>/SKILL.md or plugin skill Port reusable workflows, but rewrite descriptions for Codex’s activation wording and budget
.claude/settings.json hooks Codex config.toml, plugin hooks, or managed requirements hooks Port deterministic gates first; test each hook with real tool events before enabling broadly
.claude/agents/*.md ~/.codex/agents/*.toml, .codex/agents/*.toml, or built-in worker / explorer Port only agents with repeated value; prefer explicit delegation because Codex subagents are explicit
Plugins Codex plugins Use plugins as the distribution unit after local hooks and skills are proven

The important difference: Claude subagents can be selected automatically from descriptions, while Codex currently documents subagent workflows as explicit. That makes skills and hooks the right default for always-on harness behavior in Codex; subagents are for deliberate parallel work, review, and exploration.

Testing Your Instructions

Verify the agent actually reads and follows your instructions:

# Check active instructions
claude --print "What instructions are you following for this project?"

# Verify specific rules are active
claude --print "What is your definition of done?"

The acid test: Ask the agent to explain your build commands. If it cannot reproduce them verbatim, the instructions are either too verbose (content pushed out of context), too vague (agent cannot extract actionable instructions), or not being discovered. GitHub’s analysis of 2,500 repositories found that vagueness causes most failures.21


Production Patterns

Opus 4.7 Long-Horizon Patterns (April 2026)

Claude Opus 4.7 (April 16, 2026) shipped with specific capabilities that change what a harness needs to defend against:29

  • Tool-failure resilience: Opus 4.7 continues through tool failures that halted Opus 4.6 sessions. You can reduce — but not eliminate — defensive retry wrappers in subagent code. Keep the hook-level guards; trim the in-prompt “if the tool fails, try again three times” scaffolding.
  • xhigh effort tier (Opus-4.7 only): Sits between high and max. Recommended default for coding and agentic workloads. On long-running subagents, xhigh meaningfully outperforms high with sub-proportional token cost. max remains the right choice for single-shot hard reasoning; xhigh is better for sustained tasks.
  • Token-budget ceiling: Configurable per agent run via output_config.task_budget (beta header task-budgets-2026-03-13). The model sees a running countdown and gracefully scopes work to the budget instead of running out unexpectedly. Use for agentic loops where you want predictable token spend without sacrificing quality on short prompts.
  • Implicit-need awareness: First Claude model to pass “implicit-need” tests — recognizing when the user’s literal request underspecifies what they actually need. This makes CLAUDE.md’s “clarifying rules” section less necessary. If your CLAUDE.md is 200 lines of “also consider X when the user asks for Y” guardrails, prune the ones that are now covered natively.

Worktree Base, Sandbox Paths, and Admin Settings (May 7, 2026)

Claude Code v2.1.133 adds four admin-tier settings worth knowing about for production harnesses:39

Setting Values What it does
worktree.baseRef fresh (default) | head New worktrees branch from origin/<default> again. Breaking-default revert from v2.1.128, which had used local HEAD. Set worktree.baseRef: "head" if your team relies on unpushed commits being available in new worktrees.
sandbox.bwrapPath absolute path Pin the Bubblewrap binary location on Linux/WSL hosts where it is not on $PATH or where you ship a vendored version.
sandbox.socatPath absolute path Same idea for the socat binary used by sandbox networking.
parentSettingsBehavior 'first-wins' (default) | 'merge' Admin-tier control over how SDK managedSettings compose with parent enterprise/team settings. 'merge' lets a child session inherit and extend; 'first-wins' keeps the parent authoritative.

The worktree.baseRef revert is the one to flag for users: agents that relied on the v2.1.128-v2.1.132 behavior (worktrees branching from local HEAD) lose access to unpushed work in fresh worktrees unless they opt back in.

OTel Feedback Survey for Enterprise Observability (May 8, 2026)

Claude Code v2.1.136 added CLAUDE_CODE_ENABLE_FEEDBACK_SURVEY_FOR_OTEL to re-enable the in-session quality survey for enterprises capturing the responses through OpenTelemetry.40 If your org sinks OTel events to a central observability stack, this env var puts the survey back into the data path so quality signal flows through the same pipeline as latency and error metrics. Treat it as opt-in: the default keeps the survey suppressed, which is correct for non-OTel deployments.

Corporate Launchers and MCP-Scale Performance (July 2026)

Two v2.1.207 changes matter for production deployments.68 CLAUDE_CODE_PROCESS_WRAPPER lets managed environments launch the Claude Code process through a corporate wrapper binary — the integration point for endpoint agents, launch-time policy checks, and environments where every process must run under a mandated supervisor. If your enterprise previously faked this with shell aliases or forked launcher scripts, this is the supported seam.

The same release cut runtime overhead where harnesses feel it most: up to 7× faster tool-use rounds in sessions with high MCP tool counts, and 79× smaller session transcripts.68 This softens — without reversing — the Cost as Architecture guidance: CLI-first still wins for stateless one-shot operations, but a harness carrying dozens of MCP tools no longer pays the per-round penalty it did in the spring, and transcript storage stops being a hidden cost of long autonomous runs.

The Quality Loop

A mandatory review process for all non-trivial changes:

  1. Implement - Write the code
  2. Review - Re-read every line. Catch typos, logic errors, unclear sections
  3. Evaluate - Run the evidence gate. Check patterns, edge cases, test coverage
  4. Refine - Fix every issue. Never defer to “later”
  5. Zoom Out - Check integration points, imports, adjacent code for regressions
  6. Repeat - If any evidence gate criterion fails, return to step 4
  7. Report - List what changed, how verified, cite specific evidence

The Evidence Gate

“I believe” and “it should” are not evidence. Cite file paths, test output, or specific code.

Criterion Required Evidence
Follows codebase patterns Name the pattern and file where it exists
Simplest working solution Explain what simpler alternatives were rejected and why
Edge cases handled List specific edge cases and how each is handled
Tests pass Paste test output showing 0 failures
No regressions Name the files/features checked
Solves the actual problem State user’s need and how this addresses it

If you cannot produce evidence for any row, return to Refine.22

Human Merge Authority

A May 2026 arXiv study of 29,585 AI-agent pull-request lifecycles separates operational agency from merge governance.47 The useful architecture lesson is simple: agents can start work, carry branches forward, open PRs, review work, and summarize risk, while merge authority remains a separate governance boundary.

Make that boundary explicit in the harness. Let agents prepare PRs and collect evidence; require human approval for merges, releases, and destructive repository operations unless the organization has a separately audited automation policy. Where automation executes a merge, preserve logs that distinguish the executor from the human or policy that authorized it.

Error Handling Patterns

Atomic file writes. Multiple agents writing to the same state file simultaneously corrupts JSON. Write to .tmp files, then mv atomically. The OS guarantees mv is atomic on the same filesystem.17

# Atomic state update
jq --argjson d "$new_depth" '.depth = $d' "$STATE_FILE" > "${STATE_FILE}.tmp"
mv "${STATE_FILE}.tmp" "$STATE_FILE"

State corruption recovery. If state gets corrupted, the recovery pattern recreates from safe defaults rather than crashing:16

if ! jq -e '.depth' "$RECURSION_STATE_FILE" &>/dev/null; then
    # Corrupted state file, recreate with safe defaults
    echo '{"depth": 0, "agent_id": "root", "parent_id": null}' > "$RECURSION_STATE_FILE"
    echo "- Recursion state recovered (was corrupted)"
fi

The ((VAR++)) bash trap. ((VAR++)) returns exit code 1 when VAR is 0 because 0++ evaluates to 0, which bash treats as false. With set -e enabled, this kills the script. Use VAR=$((VAR + 1)) instead.16

Blast Radius Classification

Classify every agent action by blast radius and gate accordingly:2

Classification Examples Gate
Local File writes, test runs, linting Auto-approve
Shared Git commits, branch creation Warn + proceed
External Git push, API calls, deployments Require human approval

Remote Control (connecting to local Claude Code from any browser or mobile app) turns the “External” gate from a blocking wait into an async notification. The agent keeps working on the next task while you review the previous one from your phone.2

Task Specification for Autonomous Runs

Effective autonomous tasks include three elements: objective, completion criteria, and context pointers:16

OBJECTIVE: Implement multi-agent deliberation with consensus validation.

COMPLETION CRITERIA:
- All tests in tests/test_deliberation_lib.py pass (81 tests)
- post-deliberation.sh validates consensus above 70% threshold
- recursion-guard.sh enforces spawn budget (max 12 agents)
- No Python type errors (mypy clean)

CONTEXT:
- Follow patterns in lib/deliberation/state_machine.py
- Consensus thresholds in configs/deliberation-config.json
- Spawn budget model: agents inherit budget, not increment depth

Criteria must be machine-verifiable: test pass/fail, linter output, HTTP status codes, file existence checks. An early task that asked the agent to “write tests that pass” produced assert True and assert 1 == 1. Technically correct. Practically worthless.16

Criteria Quality Example Outcome
Vague “Tests pass” Agent writes trivial tests
Measurable but incomplete “Tests pass AND coverage >80%” Tests cover lines but test nothing meaningful
Comprehensive “All tests pass AND coverage >80% AND no type errors AND linter clean AND each test class tests a distinct module” Production-quality output

Failure Modes to Watch For

Failure Mode Description Prevention
Shortcut Spiral Skipping quality loop steps to finish faster Evidence gate requires proof for each criterion
Confidence Mirage “I’m confident” without running verification Ban hedging language in completion reports
Phantom Verification Claiming tests pass without running them this session Stop hook runs tests independently
Deferred Debt TODO/FIXME/HACK in committed code PreToolUse hook on git commit scans diff
Filesystem Pollution Dead-end artifacts from abandoned iterations Cleanup step in completion criteria

A Concrete Session Trace

A session trace from an autonomous run processing a PRD with 5 stories:2

  1. SessionStart fires. Dispatcher injects: current date, project detection, philosophy constraints, cost tracking initialization. Five hooks, 180ms total.

  2. Agent reads the PRD, plans the first story. UserPromptSubmit fires. Dispatcher injects: active project context, session drift baseline.

  3. Agent calls Bash to run tests. PreToolUse:Bash fires. Credentials check, sandbox validation, project detection. 90ms. Tests run. PostToolUse:Bash fires: activity heartbeat logged, drift check.

  4. Agent calls Write to create a file. PreToolUse:Write fires: file scope check. PostToolUse:Write fires: lint check, commit tracking.

  5. Agent finishes the story. Stop fires. Quality gate checks: did the agent cite evidence? Hedging language? TODO comments in the diff? If any check fails, exit 2 and the agent continues.

  6. Independent verification: A fresh agent runs the test suite without trusting the previous agent’s self-report.

  7. Three code review agents spawn in parallel. Each reviews the diff independently. If any reviewer flags CRITICAL, the story goes back in the queue.

  8. Story passes. Next story loads. The cycle repeats for all 5 stories.

Total hooks fired across 5 stories: ~340. Total time in hooks: ~12 seconds. That overhead prevented three credential leaks, one destructive command, and two incomplete implementations in a single overnight run.

Case Study: Overnight PRD Processing

A production harness processed 12 PRDs (47 stories) across 8 overnight sessions. Metrics compare the first 4 PRDs (minimal harness: CLAUDE.md only) against the last 8 (full harness: hooks, skills, quality gates, multi-agent review).

Metric Minimal (4 PRDs) Full Harness (8 PRDs) Change
Credential leaks 2 leaked to git 7 blocked pre-commit Reactive to preventive
Destructive commands 1 force-push to main 4 blocked Exit 2 enforcement
False completion rate 35% failed tests 4% Evidence gate + Stop hook
Revision rounds/story 2.1 0.8 Skills + quality loop
Context degradation 6 incidents 1 incident Filesystem memory
Token overhead 0% ~3.2% Negligible
Hook time/story 0s ~2.4s Negligible

The two credential leaks required rotating API keys and auditing downstream services: roughly 4 hours of incident response. The harness overhead that prevented the equivalent was 2.4 seconds of bash per story. The false completion rate dropped from 35% to 4% because the Stop hook independently ran tests before allowing the agent to report done.


Security Considerations

The Five Principles of Trustworthy Agents (Anthropic, April 2026)

Anthropic published a formal framework for agent trustworthiness on April 9, 2026.27 The five principles parallel — and extend — the Evidence Gate thinking in this guide:

Principle What it means How this harness satisfies it
Human control Meaningful human override at every decision point Hooks gate tool calls; PreCompact blocking; Auto Mode classifier as check-layer
Value alignment Agent actions track user intent, not adjacent goals CLAUDE.md as explicit intent specification; skills as capability scoping
Security Resistance to adversarial inputs and prompt injection Sandbox + deny-rules + input validation at the hook layer
Transparency Auditable records of decisions and actions Hook logging; session transcripts; skill-invocation traces
Privacy Appropriate data handling and governance Credential env-var scrubbing; secret detection at hook layer

Anthropic also donated MCP to the Linux Foundation’s Agentic AI Foundation, joining AGENTS.md (now jointly stewarded with OpenAI, Google, Cursor, Factory, Sourcegraph). Agent interoperability standards are now vendor-neutral.27

MCP’s stateless turn and self-reported identity (July 2026). The MCP specification is mid-transition to a stateless core (SEP-2575), which drops the stateful initialize handshake that used to carry server identity. A draft-spec change merged July 16 (PR #3002) restores identity as an optional surface: servers may include an io.modelcontextprotocol/serverInfo object in response _meta, and clientInfo becomes optional on requests.71 The security-relevant part is what the spec says about trust: this identity is self-reported and unverified — display and logging only — and SHOULD NOT drive security decisions. If your harness keys allowlists, permission rules, or logging-based audit on an MCP server’s declared name, that name is a claim, not a credential; pin trust to the transport and configuration (which server you configured at which endpoint), never to what the server says it is. The finalized stateless spec revision is scheduled for July 28, 2026 — expect the protocol-level details in this section to firm up in the next update.

Skill sandbox tooling: For teams that treat skills as an attack surface, Permiso’s SandyClaw (launched April 2, 2026) runs skills in a dedicated sandbox and delivers evidence-backed verdicts from Sigma/YARA/Nova/Snort detection. First product in the skill-sandbox category.28

The Sandbox

Claude Code supports an optional sandbox mode (enabled via settings.json or the /sandbox command) that restricts network access and filesystem operations using OS-level isolation (seatbelt on macOS, bubblewrap on Linux). When enabled, the sandbox prevents the model from making arbitrary network requests or accessing files outside the project directory. Without sandboxing, Claude Code uses a permission-based model where you approve or deny individual tool calls.13

May 2026 security floor. Claude Code v2.1.149 fixed a PowerShell working-directory permission bypass, several PowerShell allow-rule and stale-variable permission-analysis gaps, and a git-worktree sandbox write-allowlist bug that covered the full main repository root instead of only shared git internals.53 If your harness allows PowerShell or worktree-isolated agents, treat v2.1.149+ as the floor and keep shell rules narrow. Broad PowerShell(*) and all-repo write exceptions are orchestration shortcuts, not safety boundaries.

OpenAI Agents SDK sandbox lockdown (v0.17.0, May 8, 2026). On the OpenAI side, openai-agents-python v0.17.0 tightened a parallel boundary: LocalFile.src and LocalDir.src are now constrained to within the materialization base_dir (the SDK process current working directory when the manifest is applied), unless the source is explicitly granted via Manifest.extra_path_grants with SandboxPathGrant.41 Relative local sources resolve from base_dir; absolute paths must already sit inside it or carry a grant. This closes a local artifact boundary issue: prior versions allowed manifests to pull arbitrary host paths into a sandbox workspace. Migration: declare trusted host roots at the manifest level with SandboxPathGrant(path=..., read_only=True) for read-only mounts. Treat extra_path_grants as trusted application configuration; never populate grants from model output or untrusted manifest input.

OpenAI Agents SDK follow-up floor (v0.17.3). The 0.17.1-0.17.3 line added more sandbox and session hardening: archive extraction limits, GitRepo subpath validation, clearer sandbox-provider errors, mountpoint credentials kept out of sandbox commands, rejection of relative sandbox workspace roots, and Vercel-sandbox terminal-state handling.54 If you are using OpenAI-hosted or provider-backed sandboxes rather than only Claude Code hooks, treat 0.17.3 as the current floor for the patterns in this section.

Three Containment Patterns Across Products (Anthropic, May 2026)

Anthropic’s engineering post “How we contain Claude across products” (May 25, 2026) is the vendor’s own articulation of the principles this section teaches piecemeal — the settings-level sandbox above, the worktree-isolation floor, the treat-everything-as-untrusted stance.81 Its core move is mapping containment strength to product surface, and the mapping is itself the lesson: there is no one correct isolation design, only isolation matched to who is watching and what can go wrong.

  • Ephemeral gVisor containers (claude.ai). Server-side execution runs in gVisor containers on isolated infrastructure with a per-session ephemeral filesystem. The threat model is infrastructure and tenant isolation — the user’s machine is never reachable, so nothing local needs defending.
  • Human-in-the-loop OS sandboxing (Claude Code). The pattern described in the sandbox paragraph above, stated as policy: Seatbelt on macOS and bubblewrap on Linux, with reads allowed, writes confined to the workspace, and network denied by default — the human approves what the boundary does not cover. Anthropic open-sourced the runtime (sandbox-runtime) so the boundary is auditable. The post is candid about the weak link: roughly 93% of permission prompts get approved, and the auto-mode classifier — catching roughly 83% of overeager behaviors before execution while cutting approval prompts by 84% — exists precisely because approval fatigue is a security property, not a UX complaint. That is the check-layer posture this guide has tracked since v2.1.193.
  • Sealed VMs (Claude Cowork). Full virtual machines on platform hypervisors — Apple Virtualization framework on macOS, HCS on Windows — with only the selected workspace and .claude folder mounted; nothing else on the host is visible. Credentials never enter the VM: they stay in the host keychain, and each session receives a scoped, independently revocable token. A defensive MITM proxy inside the VM enforces it, passing only requests that carry the VM’s own provisioned session token — an attacker-embedded key is rejected at the boundary, because only the VM knows provenance.

The design principles underneath the taxonomy are the transferable part. Contain at the environment layer first, steer at the model layer second: any probabilistic defense has a non-zero miss rate, so deterministic boundaries must catch what prompt-level steering misses — the hooks-guarantee-execution argument of this guide, restated by the vendor. Match isolation strength to the user’s capacity for oversight: a developer can evaluate a bash command before approving it; a knowledge worker cannot — which is why Code gets a permission dialog and Cowork gets a sealed VM. Prefer battle-tested primitives over custom isolation code: hypervisors, seccomp, and container runtimes survived adversarial scrutiny better than Anthropic’s own custom allowlist proxies and configuration parsers did. Treat project-local config and tool outputs as untrusted: the post’s instruction is to treat project-open and config-load like any inbound request from the internet, and tool output as an attack surface even when the tool is trusted — the same stance this guide applies to inter-agent messages, subagent-read content, and self-reported MCP identity. Keep credentials outside the sandbox: scoped, revocable, per-session tokens rather than ambient keys the agent could leak.

The settings surface is catching up to the first principle (v2.1.219). “Contain at the environment layer first” is easy to endorse and has been awkward to actually configure, because Claude Code’s sandbox resolved what its rules did not cover by asking — and a permission prompt is a probabilistic defense wearing a deterministic costume, as the 93%-approval figure above concedes. sandbox.network.strictAllowlist removes the question for egress: with it set, a sandboxed command’s request to a non-allowlisted host is denied outright instead of prompting.84 Pair it with v2.1.216’s sandbox.filesystem.disabled and the two settings compose into a posture rather than a pile of toggles — filesystem and network containment are independently selectable, and network containment can now be made deterministic. For an unattended harness this is the more important of the two, because egress is where an injected instruction becomes exfiltration, and the terminal case of approval fatigue is that there is nobody at the keyboard to be fatigued. The cost is the ordinary cost of a deterministic boundary: the allowlist has to be right, and a host you forgot fails as an opaque denial rather than a question. Enumerate the hosts your agents legitimately need, then take the prompt away.

None of this replaces the hook layer; it sits beneath it. The containment patterns are the deterministic floor, and the worktree-enforcement history in this guide is the same lesson in miniature: a boundary only counts if it holds against deliberate redirection, and the primitives most likely to hold are the ones that were not written for the occasion.

Permission Boundaries

The permission system gates operations at multiple levels:

Level Controls Example
Tool permissions Which tools can be used Restrict subagent to Read, Grep, Glob
File permissions Which files can be modified Block writes to .env, credentials.json
Command permissions Which bash commands can run Block rm -rf, git push --force
Network permissions Which domains can be accessed Allowlist for MCP server connections

Parameter-Level Permission Rules (June 2026)

Claude Code v2.1.178 extended permission rules from the tool level down to the parameter level: Tool(param:value) matches against a tool’s input parameters, with * as a wildcard. The canonical example is Agent(model:opus) — a rule that blocks subagents from being spawned on a specific model tier.63 Architecturally, this closes a gap the four-level table above could not express: previously you allowed or denied a tool wholesale, but could not constrain how it was called. A governance policy can now say “subagents may spawn, but not on the Fable 5 tier” or “Bash is allowed, but not with this flag” as a deterministic rule rather than a prompt-level request.

A companion managed setting, enforceAvailableModels (v2.1.175), constrains model selection from the top down: it pins the Default model and prevents user- or project-scoped settings from widening the managed availableModels allowlist.63 The two compose — the allowlist defines which tiers exist for the session at all, and parameter-level rules constrain how subagents draw from it. As of v2.1.196, administrators can also set an organization-wide default model from the org console, surfaced as “Org default” in /model, so a fleet inherits a governed default without each operator pinning one — a floor to complement the allowlist’s ceiling.

Path-Scoped Allow Rules Anchor to the Working Directory (July 2026)

Claude Code v2.1.214 closed a quiet over-match in path-scoped permission rules: an allow rule with a single-segment dir/** pattern — Edit(src/**), say — was auto-approving edits to any directory named src at any depth, including vendor/some-package/src/ and every other nested src/ the rule’s author never meant to bless. Such rules now anchor to <cwd>/dir only; if you genuinely want any-depth matching, declare it with **/dir/**.74 Deny and ask rules deliberately keep the old any-depth matching. That asymmetry is the correct fail-safe design: an allow rule that matches too narrowly fails safe (you get a prompt), while a deny rule that matches too narrowly fails open (a blocked path slips through) — so allows got stricter and denies stayed broad. If your settings rely on single-segment allow patterns to cover nested paths, they silently stopped doing so at v2.1.214; that is the fix working as intended, but it is worth a pass over your allowlists to re-declare the breadth you actually want.

Auto-Mode Destructive-Command Guardrails (June 2026)

Claude Code v2.1.183 narrowed auto mode’s blast radius for the operations that silently lose work or tear down environments. Auto mode now hard-blocks, unless you explicitly asked for them in the session: destructive git operations (git reset --hard, git checkout -- ., git clean -fd, git stash drop); git commit --amend when the commit wasn’t made by the agent this session; and infrastructure teardown (terraform destroy, pulumi destroy, cdk destroy) unless you named the specific stack.65 Architecturally, this is the complement to the spawn-vetting and parameter-level rules above: rather than gating which tool or how it’s spawned, it gates a small set of specific irreversible commands by intent — the agent can still run them, but only on explicit instruction, not on its own initiative. For an autonomous harness, encode the same principle in your own PreToolUse hooks: the commands that destroy state deserve a deny-by-default rule that only an explicit operator signal lifts.

July 2026: auto mode goes enterprise, and one prompt becomes unwaivable. Auto mode reached GA on Amazon Bedrock, Google Vertex AI, and Microsoft Foundry in v2.1.207, with a disableAutoMode managed setting as the enterprise opt-out — the classifier-as-check-layer posture is now available on every first-party enterprise platform, and disabling it is an explicit governance decision rather than a platform gap.68 v2.1.208 then made the catastrophic-removal guard absolute: confirmation prompts for catastrophic removals now pierce both --dangerously-skip-permissions and auto mode.68 That is a notable precedent — the first confirmation in Claude Code that no permission posture, including the explicit bypass flag, can waive. Autonomous-harness designs that assumed --dangerously-skip-permissions meant literally zero prompts should account for this one exception; it fires exactly where an unattended loop can do the most unrecoverable damage.

Anti-Fabrication Guardrails (July 2026)

The v2.1.203–v2.1.206 releases closed two paths by which an agent could fabricate its own audit trail.68 First, an auto-mode rule now blocks tampering with transcript files — the session record is no longer something the session’s own tool calls can rewrite. Second, background-task notifications now explicitly state that no human input occurred while the task ran. That second one targets a subtle failure: a model summarizing a background task could previously present (or invent) an in-transcript “approval” that never happened, and nothing in the notification contradicted it. Now the notification itself is the counter-evidence.

The architecture lesson generalizes to the Evidence Gate: transcripts, notifications, and logs are audit surfaces, and audit surfaces must not be writable by the thing they audit. The platform now enforces this for its own transcript; apply the same rule to your harness — evidence reports, test outputs, and deliberation records belong outside the model’s writable path.

Prompt Injection Defense

Skills and hooks provide defense-in-depth against prompt injection:

Skills with tool restrictions prevent a compromised prompt from gaining write access:

allowed-tools: Read, Grep, Glob

PreToolUse hooks validate every tool call regardless of how the model was prompted:

# Block credential file access regardless of prompt
if echo "$FILE_PATH" | grep -qE "\.(env|pem|key|credentials)$"; then
    echo "BLOCKED: Sensitive file access" >&2
    exit 2
fi

Subagent isolation limits blast radius. A subagent with permissionMode: plan cannot make changes even if its prompt is compromised.

The platform floor rose in July 2026. Claude Code v2.1.210 hardened the Agent tool against indirect prompt injection carried in content a subagent read — a poisoned file, web page, or tool result pulled in by a subagent has less ability to steer the delegation surface itself.69 And v2.1.211 hardened the human link in the chain: permission previews now neutralize bidirectional-override, zero-width, and look-alike Unicode characters, so a command can no longer be crafted to display as innocuous in the approval dialog while executing something else.69 The second fix matters most for harnesses where a human approves rendered previews under time pressure — the display was an injection surface too. Neither change replaces the hook-level defenses above; they raise the floor beneath them.

Agent Logs and Guardrails Are Security Surfaces

Two May 2026 advisories reinforce a pattern: agent infrastructure creates new places for sensitive content and executable policy to leak or escape. GitHub Advisory GHSA-f3jg-756w-gm35 covers a Gryph Agents payload-filter issue where sensitive tool-payload content could remain in local SQLite logs under default logging behavior.45 OSV GHSA-wxxx-gvqv-xp7p covers a LiteLLM custom-code guardrail sandbox escape in an admin-protected proxy endpoint.46

The production rule: treat agent transcripts, tool payloads, SQLite logs, and guardrail execution as sensitive infrastructure. Redact before persistence, apply retention limits, and keep custom guardrail code sandboxed and reviewable. A prompt-level “do not log secrets” rule is not enough; the logging and guardrail path needs deterministic tests.

Hook Security

HTTP hooks that interpolate environment variables into headers require an explicit allowedEnvVars list to prevent arbitrary environment variable exfiltration:13

{
  "type": "http",
  "url": "https://api.example.com/notify",
  "headers": {
    "Authorization": "Bearer $MY_TOKEN"
  },
  "allowedEnvVars": ["MY_TOKEN"]
}

The Human-Agent Division of Responsibility

Security in agent architectures requires a clear division between human and agent responsibilities:17

Human Responsibility Agent Responsibility
Problem definition Pipeline execution
Confidence thresholds Execution within thresholds
Consensus requirements Consensus computation
Quality gate criteria Quality gate enforcement
Error analysis Error detection
Architecture decisions Architecture options
Domain context injection Documentation generation

The pattern: humans own decisions that require organizational context, ethical judgment, or strategic direction. Agents own decisions that require computational search across large possibility spaces. Hooks enforce the boundary.

Recursive Hook Enforcement

Hooks fire for subagent actions too.13 If Claude spawns a subagent via the Agent tool, your PreToolUse and PostToolUse hooks execute for every tool the subagent uses. Without recursive hook enforcement, a subagent could bypass your safety gates. The SubagentStop event lets you run cleanup or validation when a subagent completes.

This is not optional. An agent that spawns a subagent without your security hooks is an agent that can force-push to main, read credential files, or run destructive commands while your gates watch the main conversation do nothing.

Cost as Architecture

Cost is an architectural decision, not an operational afterthought.2 Three levels:

Token level. System prompt compression. Remove tutorial code examples (the model knows the APIs), collapse duplicate rules across files, and replace explanations with constraints. “Reject tool calls matching sensitive paths” does the same work as a 15-line explanation of why credentials should not be read.

Agent level. Fresh spawns over long conversations. Each story in an autonomous run gets a new agent with a clean context. The context never balloons because each agent starts fresh. Briefing instead of memory: models execute a clear briefing better than they navigate 30 steps of accumulated context.

Architecture level. CLI-first over MCP when the operation is stateless. A claude --print call for a one-shot evaluation costs less and adds no connection overhead. MCP makes sense when the tool needs persistent state or streaming.


Decision Framework

When to use each mechanism:

Problem Use Why
Format code after every edit PostToolUse hook Must happen every time, deterministically
Block dangerous bash commands PreToolUse hook Must block before execution, exit code 2
Apply security review patterns Skill Domain expertise that auto-activates on context
Explore codebase without polluting context Explore subagent Isolated context, returns summary only
Run experimental refactoring safely Worktree-isolated subagent Changes can be discarded if they fail
Review code from multiple perspectives Parallel subagents or Agent Team Independent evaluation prevents blind spots
Decide on irreversible architecture Multi-agent deliberation Confidence trigger + consensus validation
Persist decisions across sessions MEMORY.md Filesystem survives context boundaries
Share team standards Project CLAUDE.md + .claude/rules/ Git-distributed, loads automatically
Define project build/test commands CLAUDE.md Command-first instructions the agent can verify
Run long autonomous development Ralph loop (fresh-context iteration) Full context budget per iteration, filesystem state
Notify Slack when session ends Async Stop hook Non-blocking, does not slow the session
Validate quality before commit PreToolUse hook on git commit Block the commit if lint/tests fail
Enforce completion criteria Stop hook Prevent agent from stopping before task is done

Skills vs Hooks vs Subagents

Dimension Skills Hooks Subagents
Invocation Automatic (LLM reasoning) Deterministic (event-driven) Explicit or auto-delegated
Guarantee Probabilistic (model decides) Deterministic (always fires) Deterministic (isolated context)
Context cost Injected into main context Zero (runs outside LLM) Separate context window
Token cost Description budget (1% of window, fallback 8,000 characters) Zero Full context per subagent
Best for Domain expertise Policy enforcement Focused work, exploration

FAQ

How many hooks is too many?

Performance, not count, is the constraint. Each hook runs synchronously, so total hook execution time adds to every matched tool call. 95 hooks across user-level and project-level settings run without noticeable latency when each hook completes in under 200ms. The threshold to watch: if a PostToolUse hook adds more than 500ms to every file edit, the session feels sluggish. Profile your hooks with time before deploying them.14

Can hooks block Claude Code from running a command?

Yes. PreToolUse hooks block any tool action by exiting with code 2. Claude Code cancels the pending action and shows the hook’s stderr output to the model. Claude sees the rejection reason and suggests a safer alternative. Exit 1 is a non-blocking warning where the action still proceeds.3

Where should I put hook configuration files?

Hook configurations go in .claude/settings.json for project-level hooks (committed to your repository, shared with your team) or ~/.claude/settings.json for user-level hooks (personal, applied to every project). Project-level hooks take precedence when both exist. Use absolute paths for script files to avoid working-directory issues.14

Does every decision need deliberation?

No. The confidence module scores decisions across four dimensions (ambiguity, complexity, stakes, context dependency). Only decisions scoring below 0.70 overall confidence trigger deliberation, roughly 10% of total decisions. Documentation fixes, variable renames, and routine edits skip deliberation entirely. Security architecture, database schema changes, and irreversible deployments trigger it consistently.7

How do I test a system designed to produce disagreement?

Test both success paths and failure paths. Success: agents disagree productively and reach consensus. Failure: agents converge too quickly, never converge, or exceed spawn budgets. End-to-end tests simulate each scenario with deterministic agent responses, verifying that both validation gates catch every documented failure mode. A production deliberation system runs 141 tests across three layers: 48 bash integration tests, 81 Python unit tests, and 12 end-to-end pipeline simulations.7

What is the latency impact of deliberation?

A 3-agent deliberation adds 30-60 seconds of wall-clock time (agents run sequentially through the Agent tool). A 10-agent deliberation adds 2-4 minutes. The consensus and pride check hooks each run in under 200ms. The primary bottleneck is LLM inference time per agent, not orchestration overhead.7

How long should a CLAUDE.md file be?

Keep each section under 50 lines and the total file under 150 lines. Long files get truncated by context windows, so front-load the most critical instructions: commands and closure definitions before style preferences.21

Can this work with tools other than Claude Code?

The architectural principles (hooks as deterministic gates, skills as domain expertise, subagents as isolated contexts, filesystem as memory) apply conceptually to any agentic system. The specific implementation uses Claude Code’s lifecycle events, matcher patterns, and Agent tool. AGENTS.md carries the same patterns to Codex, Cursor, Copilot, Amp, and Windsurf.21 The harness pattern is tool-agnostic even if the implementation details are tool-specific.


Quick Reference Card

Hook Configuration

{
  "hooks": {
    "PreToolUse": [{"matcher": "Bash", "hooks": [{"type": "command", "command": "script.sh"}]}],
    "PostToolUse": [{"matcher": "Write|Edit", "hooks": [{"type": "command", "command": "format.sh"}]}],
    "Stop": [{"matcher": "", "hooks": [{"type": "agent", "prompt": "Verify tests pass. $ARGUMENTS"}]}],
    "SessionStart": [{"matcher": "", "hooks": [{"type": "command", "command": "setup.sh"}]}]
  }
}

Skill Frontmatter

---
name: my-skill
description: What it does and when to use it. Include trigger phrases.
allowed-tools: Read, Grep, Glob
---

Subagent Definition

---
name: my-agent
description: When to invoke. Include PROACTIVELY for auto-delegation.
tools: Read, Grep, Glob, Bash
model: opus
permissionMode: plan
---

Instructions for the subagent.

Exit Codes

Code Meaning Use For
0 Success Allow the operation
2 Block Security gates, quality gates
1 Non-blocking warning Logging, advisory messages

Key Commands

Command Purpose
/compact Compress context, preserve decisions
/context View context allocation and active skills
edit .claude/agents/ Manage subagents — the /agents wizard was removed in v2.1.198; create or edit definitions directly, or ask Claude to
/goal <condition> Keep Claude working toward a completion condition
claude agents Open Agent View for running, blocked, and completed sessions
CLAUDE_CODE_WORKFLOWS=1 Enable the Workflow tool for deterministic multi-agent orchestration
claude -c Continue most recent session
claude --print One-shot CLI invocation (no conversation)
# <note> Add note to memory file
/memory View and manage auto-memory

File Locations

Path Purpose
~/.claude/CLAUDE.md Personal global instructions
.claude/CLAUDE.md Project instructions (git-shared)
.claude/settings.json Project hooks and permissions
~/.claude/settings.json User hooks and permissions
~/.claude/skills/<name>/SKILL.md Personal skills
.claude/skills/<name>/SKILL.md Project skills (git-shared)
~/.claude/agents/<name>.md Personal subagent definitions
.claude/agents/<name>.md Project subagent definitions
.claude/rules/*.md Project rule files
~/.claude/rules/*.md User rule files
~/.claude/projects/{path}/memory/MEMORY.md Auto-memory

Changelog

Date Change Source
2026-08-01 Staleness fix: an “as of July 2026” version claim that the rest of the guide had already outgrown. The Python SDK paragraph asserted the package had “advanced to v0.2.111 on PyPI (bundling Claude CLI v2.1.202), and the TypeScript SDK to v0.3.203” — 17 releases behind on both lines, while other sections of this same guide correctly documented 0.2.128 and 0.3.220. Now reads v0.2.128 (bundled CLI v2.1.220, mcp floor raised to >=1.23.0) and v0.3.220, dated to a verified check rather than an open-ended month. New 86 cites PyPI, npm, and the Python SDK changelog. No upstream releases in this window: Claude Code v2.1.220, Codex v0.146.0 stable (v0.147.0 alphas only), FastAPI 0.141.1, XcodeBuildMCP 2.7.0, MCPVault 0.12.4, hermes-agent 0.19.0, Midjourney Version 8.2, Suno V5.5, Apple 26.6 stable all unchanged. 86
2026-07-29 Completeness fix: three TS SDK v0.3.216 fields that the July 21 entry omitted. Re-scanning the claude-agent-sdk-typescript changelog against this guide found the v0.3.216 field list short by three: rewindFiles responses carry an optional skippedLinks count for paths the rewind safety guards refused to restore or delete, and the success result message carries optional user_message_uuid and request_sent_wall_ms for cross-host request-latency correlation. Added to both the body list and 75; no new footnote. Everything else in the v0.3.215-v0.3.220 range was already covered, including the subagent nesting-depth history (shipped 5, cut to 1 in v2.1.217, settled at 3 in v2.1.219) and the concurrency cap of 20 — the SDK changelog’s “depth cap lowered from 5 to 1” line is a stale snapshot of a value this guide already tracks past. Agent SDK npm latest confirmed 0.3.220 (July 24) and PyPI 0.2.128; no newer release in the window. 75
2026-07-27 Rendering fix, no content change. This changelog’s header declared two columns while its rows supplied three, so python-markdown truncated every row to Date and Change and silently dropped the Source cell — taking nine footnote citations with it ([^83], [^84], [^85], [^103], [^105], [^107], [^108], [^110], [^111]). Because those nine were cited nowhere else, each rendered as a reference-list entry whose back-arrow pointed at an anchor that did not exist in the page. The header is now Date \| Change \| Source, which restores all nine. Verified by rendering the guide through the site’s own markdown configuration and diffing id="fn:N" against id="fnref:N": 77 live references before, 86 after, zero orphans. The same defect was found and fixed in the FastAPI + HTMX and Obsidian guides in this pass; ios-agent-development carries a different, unfixed citation gap noted in its own report.
2026-07-25 Guide v1.27: Nesting-depth default corrected (3, not 1), Claude Opus 5, and a fourth guardrail axis. Correction — subagent spawn depth is back to 3 (v2.1.219): “Subagents can now spawn nested subagents up to depth 3 by default (was 1); set CLAUDE_CODE_MAX_SUBAGENT_SPAWN_DEPTH=1 to disable nesting.” The default shipped at 5 (v2.1.172), was cut to 1 (v2.1.217), and settled at 3 (v2.1.219) — the last two moves inside three days. The Recursion Guard subsection no longer presents any default as settled; it now argues that depth is an unstable platform parameter and should be pinned explicitly via CLAUDE_CODE_MAX_SUBAGENT_SPAWN_DEPTH rather than inherited. Companion fix: --forward-subagent-text now forwards depth-2+ subagents too, keyed by their spawning Agent tool_use id — group forwarded text by that id instead of assuming every line comes from a direct child. DirectoryAdded hook (CC v2.1.219 + TS SDK v0.3.219): the first new lifecycle event since MessageDisplay (v2.1.152), fired after /add-dir or the SDK register_repo_root control request registers a working directory mid-session — startup workspace assertions (trust checks, secret scans, path-scoped rules, per-repo policy) must re-run on it; event table now 30. sandbox.network.strictAllowlist (v2.1.219): denies non-allowlisted hosts for sandboxed commands without prompting — deterministic egress denial, composing with v2.1.216’s sandbox.filesystem.disabled; added to the containment-patterns subsection as the settings surface catching up to “contain at the environment layer first.” Orchestration width is a fourth guardrail axis (v2.1.219): dynamic workflows default to a medium size guideline (“aim for fewer than 15 agents”), settable from any settings file via the new workflowSizeGuideline key (also in TS SDK settings types) and shown in the running-workflow status line — the three-axes framing (spawn count, depth, concurrency) is now four, and 15 is finally the same order of magnitude as this guide’s 12-agent deliberation budget rather than a runaway fuse. Claude Opus 5 (claude-opus-5, July 24): the new default Opus — 1M context, $5/$25 per MTok (same price as Opus 4.8), fast mode $10/$50 at roughly 2.5× speed; more than doubles Opus 4.8 on Frontier-Bench v0.1 and lands within 0.5% of Fable 5’s CursorBench 3.2 score at half the cost. This guide’s recommended agentic default moves from Opus 4.8 to Opus 5; Opus 4.7 is out of fast mode (/fast now applies to Opus 5 and Opus 4.8), and the auto-mode classifier’s Fable-5 fallback resolves to Opus 5. Changelog-only: Py SDK v0.2.127 — background tasks silently bypassed PreToolUse hooks: query() closed stdin on the first result frame while background subagents were still running, so their SDK-MCP tool calls failed with "Stream closed" and skipped the hook (#1103). Second hook-enforcement bypass in a month after TS v0.3.208’s abort→hook-success; the pattern is now named in the SDK hook-streaming caveat — SDK-side enforcement fails open at lifecycle edges, and silently, because a bypassed hook looks like an approving one. TS SDK v0.3.219: opt-in cancel_queued on the interrupt control request (capability interrupt_cancel_queued_v1); fast_mode_disabled_reason on result and init; the init response no longer reports fast_mode_state from the spawn-time model after a switch. CC v2.1.219 MCP diagnostics: mcp_server_errors in the headless stream-json init event; HTTP status and error text in claude mcp list / /mcp on connect failure; hidden-whitespace warning for MCP config values. Managed-settings scoping: managed MCP allowlist/denylist ${VAR} entries now resolve from the startup environment and managed-settings env instead of settings-file env — a governance-relevant resolution-order change. Misc: claude -p no longer drops already-produced text when a turn dies mid-stream; CLAUDE_CODE_GIT_BASH_PATH is ignored with a warning when it is not a bash/sh binary; the bundled claude-api skill defaults to Opus 5. CC v2.1.220 / TS v0.3.220 / Py v0.2.128 (July 25): bug fixes and parity bumps only. MCP: no normative merges; the stateless spec still lands 2026-07-28. 84 85 87
2026-07-24 Guide v1.26: Anthropic’s containment-patterns post absorbed + Claude Code v2.1.218. Added the “Three Containment Patterns Across Products” subsection to Security Considerations, from Anthropic’s engineering post “How we contain Claude across products” (May 25, 2026): ephemeral gVisor containers server-side (claude.ai), human-in-the-loop OS sandboxing (Claude Code: Seatbelt/bubblewrap, the open-sourced sandbox-runtime), and sealed VMs on platform hypervisors (Claude Cowork: Apple Virtualization framework / Windows HCS, credentials in the host keychain with scoped revocable session tokens enforced by an in-VM defensive MITM proxy) — plus the harness-design principles the post articulates: environment-layer containment first, isolation matched to user oversight capacity, battle-tested primitives over custom isolation code, project-local config and tool outputs as untrusted input, credentials outside the sandbox. Changelog-only: CC v2.1.218 (Jul 22) — auto-mode classifier adjudicates the dangerous-rm, background-&, and suspicious-Windows-path checks instead of opening permission dialogs; plan mode with auto routes Bash the static analyzer can’t prove read-only to the classifier; agent frontmatter hooks require the agent file’s own folder to have accepted workspace trust; context: fork skills run in the background by default (background: false opts out); /code-review runs as a background subagent; /deep-research no longer self-invokes; fork-session lineage preserved after compaction in headless/SDK sessions; Ctrl+B backgrounding honors background-shell caps. TS SDK v0.3.218 (Jul 22): SkillToolOutput.background flag; api_error_status reports 429/529 mid-stream; canonicalModel + provider on modelUsage. Py SDK v0.2.126 (Jul 22): ResultMessage.terminal_reason; typed model_usage with canonicalModel/provider; bundles CLI v2.1.218. MCP: no normative merges; stateless spec still lands 2026-07-28. 81 82 83
2026-07-22 Guide v1.25: Claude Code v2.1.217 — recursive-subagent walk-back + concurrency cap. Nested spawning off by default: subagents no longer spawn their own subagents — the v2.1.172 five-level recursion default lasted through v2.1.216; deeper nesting is now opt-in via CLAUDE_CODE_MAX_SUBAGENT_SPAWN_DEPTH (Recursion Guard subsection rewritten). Concurrency cap: concurrently-running subagents capped at 20 by default (CLAUDE_CODE_MAX_CONCURRENT_SUBAGENTS) so one message can’t fan out unbounded background agents. The first-party guardrail set now covers all three axes the userland spawn-budget guard tracks: total spawns per session (v2.1.212, cap 200), nesting depth (v2.1.217, default one level), and concurrent width (v2.1.217, default 20). Changelog-only: CC v2.1.217 --max-budget-usd now actually stops background subagents (once the cap is reached, new spawns are denied and running background agents are halted); background-session isolation canonicalizes symlinked working directories. Py SDK v0.2.125 bundles CLI v2.1.217 with no SDK-surface changes; TS SDK v0.3.217 ships alongside. MCP PR #3092 (merged Jul 21): normative correction aligning SEP-2575 error codes with the renumbered draft schema and conformance suite — July-28 release prep continues. 78 79 80
2026-07-21 Guide v1.24: Claude Code v2.1.214–v2.1.216 path-scoping + worktree-enforcement hardening, Codex v0.145.0 multi-agent V2 + cross-harness import. Path-scoped rules anchor to cwd (v2.1.214): single-segment dir/** allow rules (e.g. Edit(src/**)) were auto-approving writes to any nested dir/ anywhere in the tree — now anchored to <cwd>/dir only; hook if: conditions with single-segment dir/** likewise now cwd-only (write **/dir/** for any-depth); deny/ask rules deliberately keep any-depth matching (asymmetric fail-safe: allows fail safe as a prompt, denies must not fail open). Worktree isolation is enforcement-grade (v2.1.216): worktree subagents could redirect git into the shared checkout via git -C, --git-dir, or GIT_DIR/GIT_WORK_TREE — closed; worktree sessions no longer land in another project’s leftover worktree; workflow/scheduled-task writes no longer follow a symlink planted at .claude; /rewind refuses symlinks/hard links. Skills auto-activation walk-back (v2.1.215): Claude no longer self-invokes the bundled /verify and /code-review skills — explicit invocation only. Codex v0.145.0: opt-in multi-agent V2 stabilized (configurable sub-agent models, reasoning levels, concurrency, restored roles); /import now migrates Claude Code and Cursor settings, MCP servers, plugins, sessions, commands, and project-scoped memories — full cross-harness migration extending v0.140.0. Changelog-only: CC v2.1.214 EndConversation tool; fail-closed Bash/PowerShell hardening batch (fd-redirects fail closed, >10,000-char commands always prompt, zsh subscripts prompt, help/man auto-allow closed, docker/Podman daemon-redirect flags prompt, file -m/-f requires permission, PowerShell 5.1 bypass fix); hook exit-2 blocks even when stdout JSON fails schema validation; memory frontmatter gains ISO modified timestamp with no silent truncation at inline #; OTel message.uuid/client_request_id/tool_source + CLAUDE_CODE_OTEL_CONTENT_MAX_LENGTH. CC v2.1.216 sandbox.filesystem.disabled (network egress control without FS isolation); resumed background agent sessions restore the agent’s prompt/tool restrictions; mid-session skill/command changes appear in the slash menu without restart. TS SDK v0.3.214/v0.3.216: set_permission_mode rejects unknown modes; aborted: true on interrupt-truncated messages; tool_progress subagent_type/subagent_retry; task-notification subkind scheduled-trigger; SessionStart source "fork"; tool_result_meta sidecar (non_execution_kind, user_feedback); rewindFiles reports skippedLinks for paths the rewind safety guards refused to restore or delete; success results carry user_message_uuid and request_sent_wall_ms for cross-host request-latency correlation. Py SDK v0.2.124: Windows BatBadBut-class fix (refuses .bat/.cmd spawn; cmd.exe metacharacters in resume/session_id raise ValueError; dash-leading extra_args bound as --flag=value). Codex v0.145.0 hardening: MCP startup timeouts, serialized OAuth refreshes, non-blocking OAuth discovery, stronger forced-rm detection, preserved rejection reasons, experimental paginated thread history. MCP 2026-07-28 release prep (docs PRs #3064/#3066/#3098, merged Jul 21): finalized spec to present Tasks as an optional io.modelcontextprotocol/tasks extension; HTTP+SSE deprecated in favor of Streamable HTTP. 74 75 76 77
2026-07-17 Guide v1.23: Claude Code v2.1.203–v2.1.212 runaway-loop guardrails + injection hardening, TS SDK protocol surfaces, MCP stateless-identity draft, Codex/OpenAI parity. First-party runaway-loop guardrails (v2.1.212): per-session subagent spawn cap (default 200, CLAUDE_CODE_MAX_SUBAGENTS_PER_SESSION, /clear resets) and WebSearch cap (200, CLAUDE_CODE_MAX_WEB_SEARCHES_PER_SESSION) — the userland spawn-budget pattern now has a native backstop; Task tool mode param deprecated (subagents inherit the parent session’s permission mode); /fork now creates a new background session (in-session variant renamed /subtask); MCP calls >2 min auto-background (CLAUDE_CODE_MCP_AUTO_BACKGROUND_MS). Hook-vs-auto-mode precedence (v2.1.211): PreToolUse ask floors the decision at a prompt (auto mode cannot override for unsandboxed Bash); --forward-subagent-text / CLAUDE_CODE_FORWARD_SUBAGENT_TEXT for stream-json; “always allow” rules persist at the repo root across worktrees; permission previews neutralize bidi/zero-width/look-alike spoofing. v2.1.210: worktree-isolation subagents mutating the main checkout fixed; Agent tool hardened against indirect injection from subagent-read content; auto-mode classifier defaults to Sonnet 5 pinned per session; MEMORY.md over-limit writes error instead of silently truncating. v2.1.207/v2.1.208: auto mode GA on Bedrock/Vertex/Foundry (disableAutoMode opt-out); catastrophic-removal prompts pierce --dangerously-skip-permissions and auto mode; CLAUDE_CODE_PROCESS_WRAPPER corporate launcher; up to 7× faster tool rounds at high MCP tool counts, 79× smaller transcripts. v2.1.203–v2.1.206: anti-fabrication (transcript-file tampering blocked; background-task notifications explicitly state no human input occurred); MCP roots/list includes additional working directories with roots/list_changed; /doctor proposes trimming CLAUDE.md content derivable from the codebase. TS SDK v0.3.205–v0.3.208: typed interrupt receipts (still_queued, interrupt_receipt_v1), command_lifecycle frames, AgentToolCompletedOutput, canUseTool {behavior:'allow'} without updatedInput; v0.3.208 security fix — caller abort during a pending hook was converted to hook success, letting PreToolUse-gated tools execute after abort. MCP draft spec (PR #3002, merged Jul 16): optional self-reported io.modelcontextprotocol/serverInfo response _meta + optional clientInfo — display/logging only, SHOULD NOT drive security decisions; final stateless spec ships 2026-07-28. Codex: v0.143.0 MCP tools via tool search by default (deferred tool loading); v0.144.0 writes app-approval mode + MCP interactive auth GA; v0.144.5 expanded dangerous-command detection. OpenAI hosted multi-agent beta: openai-agents-python v0.18.2 (Jul 11) + openai-agents-js v0.13.2 (Jul 10). Changelog-only: SDK argv flag-injection fixes (TS 0.3.212 / Py 0.2.121 — dash-leading resume/session_id values now passed in equals form); BashToolOutput.timedOutAfterMs; SDKAssistantMessage.timestamp; CC v2.1.204 headless SessionStart streaming fix; openai-agents GPT-5.6 defaults; MCP Mcp-Param-* rejection-retry guidance. 68 69 70 71 72 73
2026-07-07 Guide v1.22: Claude Code v2.1.196–v2.1.202. Sonnet 5 is the shipped default model (v2.1.197) — reframed the model-tier note (this guide still recommends Opus 4.8 as the agentic default for autonomous harnesses). Subagents run in the background by default (v2.1.198): the background field now pins the behavior rather than opting in; the Explore agent inherits the session model (capped at Opus); subagents and compaction inherit extended-thinking config; background claude agents sessions auto-commit/push/open a draft PR and fire the Notification hook with agent_needs_input/agent_completed; the /agents wizard was removed (edit .claude/agents/ directly). v2.1.199: SessionStart/Setup/SubagentStart hooks surface stderr on exit code 2; SendMessage reused-name misrouting detection added to the cross-session authority note; stacked slash-skills load up to 5. v2.1.200: the default permission mode is labeled “Manual” (manual alias) in the subagent permissionMode list. v2.1.196: organization-wide default models noted in the governance section; MCP self-approval closed. SDK currency: claude-agent-sdk v0.2.111 (Python, bundles CLI v2.1.202) / @anthropic-ai/claude-agent-sdk v0.3.203 (TS), incremental over the documented 0.1.x surface. 67
2026-07-02 Guide v1.21: hook-matcher + classifier governance updates. Claude Code v2.1.195: hyphenated-identifier matchers exact-match instead of substring-matching (see Hook Architecture — matcher semantics). Claude Code v2.1.193: autoMode.classifyAllShell routes all shell through the auto-mode classifier, with denial reasons surfaced in transcript/toast//permissions (see Security Considerations). Codex v0.142.2: PowerShell with uninspectable AST regions now requires approval. All items verified against the canonical changelogs during this update cycle. 66
2026-06-20 Guide v1.20: Claude Code v2.1.183 + Codex v0.141.0 — governance and remote-execution security. Added auto-mode destructive-command guardrails (CC v2.1.183 hard-blocks git reset --hard/checkout -- ./clean -fd/stash drop, git commit --amend on non-agent commits, and terraform/pulumi/cdk destroy without a named stack unless you asked) to Security Considerations, framed as the intent-level complement to parameter-level rules and spawn-vetting; and encrypted Noise-relay remote executors (Codex v0.141.0: end-to-end encrypted executor channels, cross-platform cwd/shell preservation, P-521 TLS) to the Codex Parity Notes. 65
2026-06-16 Guide v1.19: Claude Code v2.1.173–v2.1.179 governance + scoping primitives, plus Codex v0.140.0 cross-tool import. Wove the v2.1.178 release into the body: parameter-level permission rules Tool(param:value) with * wildcard (e.g. Agent(model:opus) to block a model tier) plus the enforceAvailableModels managed setting (v2.1.175), both in Security → Permission Boundaries; auto mode now vets subagent spawns before launch, closing the spawn-as-bypass gap (Subagent Patterns); nested .claude/skills loading + closest-wins resolution for skills/agents/workflows/output-styles in nested .claude/ trees (Skills System); and the disallowedTools MCP server-spec matching fix (Subagent Configuration Fields). Added Codex /import cross-tool portability + permanent session deletion (v0.140.0) to the Codex parity note. 63 64
2026-06-10 Guide v1.18: Recursive sub-agents (Claude Code v2.1.172). Added a note to the Recursion Guard subsection: Claude Code sub-agents can now spawn their own sub-agents, nesting up to 5 levels deep — where delegation was previously effectively one level (v2.1.172, June 10). Reframed the userland spawn-budget/depth-cap pattern as the control that keeps a 5-level tree from fanning out, with 5 levels treated as a platform ceiling rather than a default. 62
2026-06-09 Guide v1.17: Claude Code v2.1.169–v2.1.170 + Codex v0.138.0–v0.139.0 governance and multi-agent-v2 hardening. Wove five verified harness-architecture changes into the body. Skills System gained a “Hiding the Bundled Surface as Governance” subsection: the disableBundledSkills setting (and CLAUDE_CODE_DISABLE_BUNDLED_SKILLS env var) hides bundled skills, workflows, and built-in slash commands from the model as a deliberate attack-surface reduction (v2.1.169). The June Hook-Architecture subsection added the --safe-mode flag (and CLAUDE_CODE_SAFE_MODE), which starts a session with all customizations disabled — CLAUDE.md, plugins, skills, hooks, MCP — for clean-room troubleshooting and governance (v2.1.169), plus a model-tier note: Anthropic’s Claude Fable 5 (claude-fable-5) launched June 9 as a Mythos-class tier above Opus, selectable via /model claude-fable-5 in v2.1.170, with Opus 4.8 remaining Claude Code’s agentic default. Memory and Context added the /cd command (v2.1.169), which moves a session to a new working directory without breaking the mid-session prompt cache. Multi-Agent Orchestration / Codex Parity hardened for production: close_agent renamed interrupt_agent (v0.139.0), encrypted inter-agent message payloads, a v2 agent config catalog, agent-residency LRU, and concurrency counted by active execution (v0.138.0), AGENTS.md discovery routed through environment filesystems with preserved logical paths for correct file selection on remote/symlinked workspaces (v0.138.0/v0.139.0), and subagent MCP-startup warnings scoped to the owning thread instead of duplicating into the parent (v0.139.0). 60 61
2026-06-08 Guide v1.16: June agent-architecture patterns from Claude Code v2.1.162–v2.1.166 + Codex v0.137.0. Added the “Stop-hook steering, cross-session authority, and multi-agent v2” subsection covering four harness-relevant changes: (1) Stop/SubagentStop hooks can return hookSpecificOutput.additionalContext to inject “not done yet, here is why” feedback and continue the turn without a hook-error block (v2.1.163); (2) cross-session messaging hardened so SendMessage-relayed messages from another session no longer carry the originating user’s authority — treat inbound inter-agent messages as untrusted data (v2.1.166); (3) the fallbackModel setting chains up to three backup models with a one-shot fallback retry on non-retryable API errors, and claude agents --json adds a waitingFor field for fleet observability (v2.1.162/166); (4) Codex multi-agent v2 (v0.137.0) keeps the runtime with each thread, defaults hide_spawn_agent_metadata to true, propagates parent events to child listeners, and adds a v1 skills extension with per-turn catalog resolution and thread-start/turn-error lifecycle contributor events. No spec change to AGENTS.md (still Agentic-AI-Foundation-stewarded, no versioned changelog). 59
2026-05-31 Guide v1.15: Claude Code v2.1.157 + Hermes v0.15.1/v0.15.2 patches. Added the “Plugin and Skill Convergence in .claude/skills/ subsection: Claude Code v2.1.157 makes any folder in a project’s .claude/skills/ directory auto-load as a plugin without marketplace registration, and claude plugin init <name> scaffolds a fresh plugin with manifest + SKILL.md there. The harness implication is real — small-scope project tooling no longer pays the manifest tax to live in version control; plugins still own the bundled-installable ZIP shape. Same release ships EnterWorktree mid-session switching between Claude-managed worktrees and leaves background worktrees unlocked after the agent finishes so git worktree remove/prune work cleanly. Hermes Agent v0.15.1 (May 29) is the same-day Velocity hotfix: dashboard 401 reload-loop fix on loopback mode, Docker now requires explicit HERMES_DASHBOARD_INSECURE=1, MCP bare commands (npx, npm, node) resolve in Docker, Skills page restored, Kanban workers respond to SIGTERM cleanly, Skills.sh catalog grew 858 → 19,932 entries via sitemap. Hermes v0.15.2 (May 29) is a packaging-only hotfix that bundles plugin.yaml manifests in wheel and sdist distributions. 58
2026-05-28 Guide v1.14: Claude Code v2.1.152-v2.1.154 + Codex v0.134.0-v0.135.0 + Hermes v0.15.0 architecture-pattern pass. Claude Code shifted defaults and added orchestration primitives: Opus 4.8 is now the default with high effort by default and a new /effort xhigh; dynamic workflows orchestrate tens to hundreds of agents in the background via /workflows; lean system prompt is now default for all models except Haiku/Sonnet/Opus 4.7-and-earlier; the new MessageDisplay hook event lets hooks transform or hide assistant text as it is displayed; disallowed-tools in skill/command frontmatter removes tools while the skill is active; /reload-skills re-scans skill directories without restart; SessionStart hooks can return reloadSkills: true and set hookSpecificOutput.sessionTitle; --fallback-model switches mid-session when the primary is missing; auto mode no longer requires opt-in consent; pluginSuggestionMarketplaces managed setting allowlists org marketplaces for context-aware suggestions; claude agents accepts ! <command> background-shell sessions; plugins can declare defaultEnabled: false; stdio MCP subprocess env now includes CLAUDE_CODE_SESSION_ID and CLAUDECODE=1. Codex v0.134.0 made --profile the primary profile selector across CLI, TUI permissions, and sandbox flows (legacy configs rejected with migration guidance), added local conversation-history search, improved MCP setup with per-server environment targeting and OAuth for streamable HTTP servers, and let read-only MCP tools run concurrently when they advertise readOnlyHint; v0.135.0 added richer codex doctor diagnostics, /status remote details, vim text-object editing, named permission profiles in /permissions, and Sandbox presets in the Python SDK. Hermes Agent v0.15.0 (May 28) ships the Velocity release: run_agent.py refactored 76% across 14 modules, multi-agent Kanban v2 with auto-decomposition and swarm topology, Bitwarden Secrets Manager replacing per-provider keys with one bootstrap token, Promptware defense against Brainworm-class prompt injection at three security chokepoints, skill bundles, a TUI session orchestrator for multi-session management in one terminal, and a 4,500× faster session_search with the LLM dependency removed. Harness-architecture implications: the named-profile pattern (Codex --profile, Claude Code pluginSuggestionMarketplaces) is becoming the standard configuration primitive for multi-tenant agent runtimes; concurrent read-only MCP tools (Codex readOnlyHint) are the right pattern to fan out non-mutating context fetches; the MessageDisplay hook gives operators a first-class transformation surface that wasn’t reachable from PostToolUse or Stop; and the lean-system-prompt default removes the long-standing trade-off between operator-defined context and provider scaffolding. 55 56 57
2026-05-24 Guide v1.13: Claude Code v2.1.150 + OpenAI Agents SDK v0.17.3 security/currentness pass. Local claude --version returned 2.1.144 (Claude Code) while npm latest for @anthropic-ai/claude-code returned 2.1.150 and GitHub latest release returned v2.1.150. Added v2.1.149 harness guidance for PowerShell permission-bypass fixes, PowerShell allow-rule/stale-variable permission-analysis fixes, and the git-worktree sandbox write-allowlist fix; noted that v2.1.150 is internal infrastructure only with no announced user-facing changes. PyPI latest for openai-agents returned 0.17.3, so the OpenAI sandbox section now notes 0.17.1-0.17.3 follow-up hardening for archive extraction, GitRepo subpaths, sandbox credentials, relative workspace roots, and provider terminal-state handling.5354
2026-05-21 Guide v1.12: Claude Code v2.1.147 Workflow pass. Local claude --version returned 2.1.144 (Claude Code) while npm latest for @anthropic-ai/claude-code returned 2.1.147. Added the off-by-default Workflow tool as a first-party deterministic multi-agent orchestration primitive and clarified that hooks, tests, review gates, spawn budgets, and evidence reports remain the correctness boundary.52
2026-05-15 Guide v1.11: Claude Code v2.1.142 background-session and plugin reliability pass. Local claude --version returned 2.1.141 (Claude Code) while npm latest for @anthropic-ai/claude-code returned 2.1.142. Added operator guidance for new claude agents dispatch flags, Opus 4.7 Fast-mode default, root-level plugin SKILL.md discovery, plugin LSP visibility, MCP_TOOL_TIMEOUT remote HTTP/SSE behavior, and background-session / daemon / plugin-cache reliability fixes.51
2026-05-14 Guide v1.10: Claude Code v2.1.141 operator-signaling and scoping pass. Local claude --version returned 2.1.141 (Claude Code) and npm latest for @anthropic-ai/claude-code returned 2.1.141. Added hook guidance for terminalSequence as operator signaling rather than enforcement, noted claude agents --cwd <path> for directory-scoped Agent View, and documented the architecture impact of CLAUDE_CODE_PLUGIN_PREFER_HTTPS plus ANTHROPIC_WORKSPACE_ID for plugin installation and workload-identity federation scoping.50
2026-05-13 Guide v1.9: Claude Code v2.1.140 reliability pass. Local claude --version returned 2.1.140 (Claude Code). Added subagent_type to agent-hook guidance and updated the hook governance section for v2.1.140 fixes to ConfigChange, disableAllHooks, allowManagedHooksOnly, permission-dialog env-var display, custom style reset after settings sync, Windows Git Bash native-package fallback, and /scroll-speed behavior.49
2026-05-11 Guide v1.8: Claude Code v2.1.139 currentness pass + focused agent-security/memory scan. Verified local claude --version as 2.1.139 and added v2.1.139 operational changes: Agent View via claude agents, /goal completion loops, command-hook args, PostToolUse continueOnBlock, MCP CLAUDE_PROJECT_DIR, and OpenTelemetry active-time fix.424344 Added memory-curation warning from “The Memory Curse” arXiv preprint, human merge-authority guidance from the PR-lifecycle arXiv preprint, and agent-log/guardrail security guidance from the Gryph Agents and LiteLLM advisories.45464748 Fixed stale Skills vs Hooks vs Subagents token-budget row from 2% to the current 1% / 8,000-character skill-description budget.
2026-05-09 Guide v1.7: Day-3 follow-up on Claude Code v2.1.136 + openai-agents-python v0.17.0. Added autoMode.hard_deny and v2.1.136 hook/plugin fixes subsection to Hook Architecture covering the new unconditional-block tier, MCP-disappears-after-/clear fix across VS Code/JetBrains/Agent SDK, MCP OAuth refresh-token loss on concurrent refresh, plan-mode write-block fix when Edit(...) allow rule matched, plugin Stop/UserPromptSubmit cache-cleanup race, skills entry hiding default skills/ dir, and CLAUDE_ENV_FILE SessionStart-hook env vars going stale after /resume//clear.40 Added OTel Feedback Survey subsection to Production Patterns covering CLAUDE_CODE_ENABLE_FEEDBACK_SURVEY_FOR_OTEL.40 Extended The Sandbox subsection with openai-agents-python v0.17.0 lockdown: LocalFile.src / LocalDir.src constrained to within base_dir unless granted via Manifest.extra_path_grants with SandboxPathGrant.41 Added RealtimeAgent default-model note (gpt-realtime-2) to Managed vs. Self-Hosted Harnesses.41 Changelog-only: Claude Code v2.1.137 (Win VSCode activation fix), v2.1.138 (internal fixes); claude-agent-sdk-python v0.1.78 (CLI v2.1.136 bundle), v0.1.79 (CLI v2.1.137 bundle), v0.1.80 (CLI v2.1.138 bundle).
2026-05-08 Guide v1.6: Day-2 follow-up on Claude Code v2.1.132/v2.1.133 + SDK v0.1.77. Added SDK Skill Surface subsection to Skills System covering the skills option on ClaudeAgentOptions and the deprecation of "Skill" in allowed_tools.37 Added Effort and Session Provenance subsection to Hook Architecture covering the new effort.level JSON field + $CLAUDE_EFFORT env var on hook input, and the CLAUDE_CODE_SESSION_ID env var on Bash subprocesses.3839 Added Subagent skill discovery fix to the Subagent Configuration Fields table (subagents now discover project, user, and plugin skills via the Skill tool, silently dropped before v2.1.133).39 Added Worktree Base, Sandbox Paths, and Admin Settings subsection to Production Patterns covering worktree.baseRef (breaking-default revert back to origin/<default> from local HEAD), sandbox.bwrapPath, sandbox.socatPath, and parentSettingsBehavior.39
2026-05-07 Guide v1.5: Claude Managed Agents, May 6 SF expansion. Added Strategy 5 (Managed Memory Curation: Dreaming, Research Preview) to Memory and Context with table contrasting filesystem-as-memory vs. Dreaming.35 Added Managed Multiagent Orchestration (Public Beta) and Outcomes (Public Beta) at the top of Multi-Agent Orchestration with verbatim Anthropic quotes on shared-filesystem specialists and Claude Console tracing, plus a comparison table vs. self-hosted deliberation. Added SDK-side hook event streaming subsection covering claude-agent-sdk-python v0.1.74’s include_hook_events and HookEventMessage.36 Changelog-only: Claude Code v2.1.124-v2.1.131 (claude project purge, --dangerously-skip-permissions for project dirs, skill_activated invocation_trigger, PostToolUse format-on-save fix, PreToolUse JSON+exit-2 blocking fix, skillOverrides settings); claude-agent-sdk-python v0.1.72 (CLI 2.1.126), v0.1.73 (session_store_flush), v0.1.75 (CLI 2.1.131), v0.1.76 (api_error_status); openai-agents-python v0.15.0-v0.16.1 with v0.16.0 (May 7) defaulting to gpt-5.4-mini, removing the implicit max_turns ceiling, and adding SDK-side tool execution concurrency.
2026-05-07 Guide v1.4: Refreshed Claude Code hook and skill mechanics against current official docs and local runtime evidence (claude --version 2.1.132, codex --version returned codex-cli 0.128.0). Updated the hook surface from 22/26+ to 29 documented events, fixed skill-description budget from 2%/16,000 to 1%/8,000, changed hook-type count from four to five with mcp_tool, removed the unsupported fixed “10 parallel subagents” claim, and added a public-safe Codex parity section covering AGENTS.md, skills, hooks, plugins, and explicit subagent workflows.
2026-04-29 Guide v1.3: Expanded the OpenAI Agents SDK coverage in the Managed vs. Self-Hosted Harnesses section with the named SDK surface from openai-agents Python v0.14.0 (April 15) — SandboxAgent, Manifest, SandboxRunConfig, sandbox memory with progressive disclosure, workspace mounts (S3/R2/GCS/Azure), portable snapshots, and the local/Docker/hosted client backends (Blaxel, Cloudflare, Daytona, E2B, Modal, Runloop, Vercel). Replaced the secondary Help Net Security citation with the primary v0.14.0 release-notes citation. Added a short note on claude-agent-sdk-python v0.1.69-v0.1.71 (April 28-29) as the third self-hosted option (embed Claude Code runtime as a Python library): bundled Claude CLI bumped to v2.1.123, raised mcp dependency floor to >=1.19.0 (older versions silently dropped CallToolResult from in-process MCP tools), Trio nursery cancellation fix, and SandboxNetworkConfig allowlist-field parity with TS SDK. v0.14.7-v0.14.8 SDK refinements documented in [^58].
2026-04-25 Guide v1.2: Google Cloud Next 2026 (April 22-24) — Vertex AI rebranded to Gemini Enterprise Agent Platform; Agentspace absorbed into unified Gemini Enterprise; Workspace Studio (no-code agent builder); 200+ models in Model Garden including Anthropic Claude; partner agents from Box, Workday, Salesforce, ServiceNow; ADK v1.0 stable across four languages; Project Mariner (web-browsing agent); managed MCP servers with Apigee as API-to-agent bridge; A2A protocol v1.0 in production at 150 organizations. Microsoft Agent Framework 1.0 (April 2026): stable APIs, LTS commitment, full MCP support, .NET + Python. The browser-based DevUI that visualizes agent execution and tool calls in real time ships as a preview alongside the 1.0 stable surface. Salesforce Headless 360 (April 15, TDX): every Salesforce capability (CRM, service, marketing, ecommerce) exposed as API/MCP tool/CLI command so agents like Claude Code, Cursor, and Codex can build on the platform without a browser. (TDX 2026 ran April 15-16; the Headless 360 announcement is dated April 15.) MetaComp StableX KYA (April 21): Know Your Agent governance framework for regulated financial services (payments, compliance, wealth) — first of its kind from a licensed financial institution; available across Claude, Claude Code, OpenClaw, and other compatible AI platforms. Claude Managed Agents pricing: $0.08 per session-hour while a session is running, with no runtime charge while idle — on top of normal Claude model token rates. (Per Anthropic’s Claude pricing page; the public-beta launch was April 8, 2026.) Memory for Managed Agents entered public beta on April 23, 2026 under the managed-agents-2026-04-01 beta header. All Managed Agents endpoints now require this beta header.
2026-04-16 Guide v1.1: Added Managed vs. Self-Hosted Harnesses section covering Claude Managed Agents (April 8 beta) and OpenAI Agents SDK harness/compute separation (April 16). Added Scion cross-tool multi-agent hypervisor (April 7, Google). Documented M3MAD-Bench debate plateau finding. Added The Five Principles of Trustworthy Agents (Anthropic, April 9) + MCP/AGENTS.md Linux Foundation governance. Permiso SandyClaw skill-sandbox reference. New Opus 4.7 Long-Horizon Patterns: tool-failure resilience, xhigh effort tier, token-budget ceiling (task_budget beta), implicit-need awareness reducing CLAUDE.md scaffolding.
2026-03-24 Initial publication

References


  1. Andrej Karpathy on “claws” as a new layer on top of LLM agents. HN discussion (406 points, 917 comments). 

  2. Author’s implementation. 84 hooks, 48 skills, 19 agents, ~15,000 lines of orchestration. Documented in Claude Code as Infrastructure

  3. Anthropic, “Claude Code Hooks: Exit Codes.” code.claude.com/docs/en/hooks. Exit 0 allows, exit 2 blocks, exit 1 warns for most events; WorktreeCreate is stricter. 

  4. Anthropic, “Extend Claude with Skills.” code.claude.com/docs/en/skills. Skill structure, frontmatter fields, LLM-based matching, and 1% / 8,000-character description budget. 

  5. Anthropic, “Claude Code Sub-agents.” code.claude.com/docs/en/sub-agents. Isolated context, worktree support, agent teams. 

  6. Anthropic, “Claude Code Documentation.” docs.anthropic.com/en/docs/claude-code. Memory files, CLAUDE.md, auto-memory. 

  7. Author’s multi-agent deliberation system. 10 research personas, 7-phase state machine, 141 tests. Documented in Multi-Agent Deliberation

  8. Simon Willison, “Writing code is cheap now.” Agentic Engineering Patterns

  9. Laban, Philippe, et al., “LLMs Get Lost In Multi-Turn Conversation,” arXiv:2505.06120, May 2025. Microsoft Research and Salesforce. 15 LLMs, 200,000+ conversations, 39% average performance drop. 

  10. Mikhail Shilkov, “Inside Claude Code Skills: Structure, Prompts, Invocation.” mikhail.io. Independent analysis of skill discovery, context injection, and available_skills prompt section. 

  11. Claude Code Source, SLASH_COMMAND_TOOL_CHAR_BUDGET. github.com/anthropics/claude-code

  12. Anthropic, “Skill Authoring Best Practices.” platform.claude.com. 500-line limit, supporting files, naming conventions. 

  13. Anthropic, “Claude Code Hooks: Lifecycle Events.” code.claude.com/docs/en/hooks. 30 documented lifecycle events, hook types, matcher behavior, async hooks, HTTP hooks, prompt hooks, agent hooks, and MCP tool hooks. 

  14. Author’s Claude Code hooks tutorial. 5 production hooks from scratch. Documented in Claude Code Hooks Tutorial

  15. Author’s context window management across 50 sessions. Documented in Context Window Management

  16. Author’s Ralph Loop implementation. Fresh-context iteration with filesystem state, spawn budgets. Documented in The Ralph Loop

  17. Author’s deliberation system architecture. 3,500 lines of Python, 12 modules, confidence trigger, consensus validation. Documented in Building AI Systems: From RAG to Agents

  18. Nemeth, Charlan, In Defense of Troublemakers: The Power of Dissent in Life and Business, Basic Books, 2018. 

  19. Wu, H., Li, Z., and Li, L., “Can LLM Agents Really Debate?” arXiv:2511.07784, 2025. 

  20. Liang, T. et al., “Encouraging Divergent Thinking in Large Language Models through Multi-Agent Debate,” EMNLP 2024

  21. Author’s AGENTS.md analysis across real-world repositories. Documented in AGENTS.md Patterns. See also: GitHub Blog, “How to Write a Great agents.md: Lessons from Over 2,500 Repositories.” 

  22. Author’s quality loop and evidence gate methodology. Part of the Jiro Craftsmanship system. 

  23. Anthropic, “Claude Managed Agents Overview”. Public beta launched April 8, 2026. Harness-as-a-service with session checkpointing, bundled sandbox, REST API. Pricing: standard tokens + $0.08/session-hour. Beta header managed-agents-2026-04-01

  24. OpenAI, “openai-agents Python v0.14.0 release notes”. Released April 15, 2026; announcement covered April 16. Introduces the Sandbox Agents SDK surface as a beta layer over the existing Agent / Runner flow: SandboxAgent, Manifest (workspace contract), SandboxRunConfig, capabilities (shell, filesystem editing, image inspection, skills, sandbox memory, compaction), workspace mounts (local, Git, remote: S3, R2, GCS, Azure Blob, S3 Files), portable snapshots with path normalization and symlink preservation, and run-state serialization for resume. Backends: UnixLocalSandboxClient, DockerSandboxClient, and hosted clients for Blaxel, Cloudflare, Daytona, E2B, Modal, Runloop, Vercel via optional extras. The April 16 announcement summarized at Help Net Security

  25. Google Cloud, “Scion: Multi-Agent Hypervisor”. Open-sourced April 7, 2026. Orchestrates Claude Code, Gemini CLI, and other deep agents as isolated processes with per-agent container, git worktree, and credentials. Local/hub/Kubernetes deployment modes. InfoQ coverage

  26. Multi-agent debate research cluster, Q1–Q2 2026. Wu et al., “Can LLM Agents Really Debate?” (arXiv 2511.07784); M3MAD-Bench — multi-model multi-agent debate benchmark showing performance plateaus and susceptibility to misleading consensus; Tool-MAD — heterogeneous tool assignment per agent + Faithfulness/Relevance judge scores. 

  27. Anthropic, “Our framework for developing safe and trustworthy agents”. April 9, 2026. Five principles: human control, value alignment, security, transparency, privacy. MCP donation to Linux Foundation’s Agentic AI Foundation. 

  28. Permiso Security, “SandyClaw: First Dynamic Sandbox for AI Agent Skills”. April 2, 2026. Skill execution sandbox with Sigma/YARA/Nova/Snort detection and evidence-backed verdicts. 

  29. Anthropic, “Introducing Claude Opus 4.7”. April 16, 2026. Long-horizon agent improvements: 3× SWE-Bench production task resolution vs Opus 4.6, tool-failure resilience, xhigh effort tier, task budgets (beta), implicit-need awareness. See also What’s new in Opus 4.7 for Messages API breaking changes. 

  30. Composite reference — OpenAI openai-agents-python v0.14.7 (April 28, 2026) and v0.14.8 (April 29, 2026); Anthropic claude-agent-sdk-python v0.1.69 (April 28), v0.1.70 (April 28), and v0.1.71 (April 29). v0.14.7 highlights: tool_name/call_id convenience properties on tool items, raised Phase 2 memory consolidation turn limit, GPT-5.5 aliases for sandbox compaction, tar/zip member validation tightening, symlink rejection on LocalFile sources, removal of unset fields from Responses API calls. v0.14.8 highlights: preserve MCP re-export import errors, delimit sandbox prompt-instruction sections. claude-agent-sdk-python v0.1.69 added docstrings to ClaudeAgentOptions fields and bumped the bundled CLI to v2.1.121; v0.1.70 raised the mcp dependency floor to >=1.19.0 (older versions silently dropped CallToolResult returns from in-process MCP tool handlers), fixed Trio nursery corruption on early cancellation when iterating query() with options.stderr set (spawn_detached() now used for the stderr reader), and bumped the bundled CLI to v2.1.122; v0.1.71 added domain-allowlist fields (allowedDomains, deniedDomains, allowManagedDomainsOnly, allowMachLookup) to SandboxNetworkConfig for parity with the TypeScript schema, and bumped the bundled CLI to v2.1.123. 

  31. OpenAI, “Custom instructions with AGENTS.md”. Codex reads global and project AGENTS.md / AGENTS.override.md files before work, merges root-to-current-directory guidance, and caps project docs by project_doc_max_bytes

  32. OpenAI, “Agent Skills”. Codex skills use SKILL.md, progressive disclosure, explicit $skill invocation, and implicit activation from descriptions. 

  33. OpenAI, “Codex Hooks”. Codex hooks support command hooks in config, plugin hooks, managed hooks, matchers for supported events, stdin JSON input, and JSON output fields. 

  34. OpenAI, “Codex Subagents” and “Codex CLI 0.128.0 changelog”. Codex supports explicit parallel subagent workflows, built-in default, worker, and explorer agents, custom TOML agents, inherited sandbox policy, plugin-bundled hooks, hook enablement state, and persisted /goal workflows in 0.128.0. 

  35. Anthropic, “New in Claude Managed Agents”. May 6, 2026. Dreaming (Research Preview): scheduled background process that reviews agent sessions and memory stores, extracts patterns, and curates memories. Outcomes (Public Beta): rubric-based evaluation in which a separate grader scores output against the rubric in its own context window so it is not influenced by the agent’s reasoning. Multiagent Orchestration (Public Beta): lead agent delegates pieces of a job to specialists, each with its own model, prompt, and tools; specialists work in parallel on a shared filesystem and contribute to the lead agent’s overall context, with full per-step tracing in the Claude Console. 

  36. Anthropic, claude-agent-sdk-python v0.1.74. May 6, 2026. Adds include_hook_events to ClaudeAgentOptions; when set, hook events (PreToolUse, PostToolUse, Stop, others) are emitted by the CLI and yielded from the message stream as HookEventMessage, mirroring the TypeScript SDK’s includeHookEvents. Bundled Claude CLI bumped to v2.1.129. 

  37. Anthropic, claude-agent-sdk-python v0.1.77. May 8, 2026. Deprecates the "Skill" value in allowed_tools in favor of a dedicated skills option on ClaudeAgentOptions, gives Claude Code more structured signal about available skills, improves error messages on Command failed exceptions, and bundles Claude CLI v2.1.133. 

  38. Anthropic, Claude Code v2.1.132. May 6, 2026. Adds CLAUDE_CODE_SESSION_ID env var on Bash tool subprocesses (matches the session_id hooks already see), CLAUDE_CODE_DISABLE_ALTERNATE_SCREEN to keep conversation in native scrollback, refreshed /tui fullscreen startup banner (lower memory, mouse support, auto-copy on selection), and roughly twenty bug fixes spanning SIGINT graceful shutdown, surrogate emoji --resume corruption, plan-mode --permission-mode flag, Indic and ZWJ cursor handling, NFD vim ops, paste-starts-with-/ swallow, MCP unbounded memory, MCP tools/list retry, Bedrock + Vertex ENABLE_PROMPT_CACHING_1H 400, and statusline context_window showing cumulative tokens. 

  39. Anthropic, Claude Code v2.1.133. May 7, 2026. Hooks now receive effort.level JSON input + $CLAUDE_EFFORT env var (also readable from Bash commands). Subagents discover project, user, and plugin skills via the Skill tool (regression fix). New admin settings: worktree.baseRef (fresh | head) reverts the worktree base back to origin/<default> after v2.1.128’s switch to local HEAD; sandbox.bwrapPath and sandbox.socatPath pin sandbox binaries on Linux/WSL; parentSettingsBehavior ('first-wins' | 'merge') controls how SDK managedSettings compose with parent settings. Other fixes: parallel-session 401-after-refresh-token-race, drive-root allow-rule scoping, MCP OAuth proxy/mTLS support, Remote Control stop/interrupt completing cancel, cross-session /effort leakage, --remote-control listed in --help

  40. Anthropic, Claude Code v2.1.136. May 8, 2026. Adds settings.autoMode.hard_deny for auto-mode classifier rules that block unconditionally regardless of user intent or allow exceptions, and CLAUDE_CODE_ENABLE_FEEDBACK_SURVEY_FOR_OTEL to re-enable the in-session quality survey for enterprises capturing responses through OpenTelemetry. Operator-impact fixes: MCP servers from .mcp.json, plugins, and claude.ai connectors silently disappearing after /clear in VS Code, JetBrains, and Agent SDK; MCP OAuth refresh tokens being lost on concurrent refresh; plan mode not blocking file writes when a matching Edit(...) allow rule existed; plugin Stop/UserPromptSubmit hooks failing when cache cleanup deleted a still-running version; skills entry in plugin.json hiding the plugin’s default skills/ directory; CLAUDE_ENV_FILE SessionStart-hook env vars going stale after /resume or /clear. Plus roughly thirty additional polish and reliability fixes spanning the TUI, autocomplete, and terminal rendering. Companion releases: v2.1.137 (May 9, VSCode extension Windows activation fix), v2.1.138 (May 9, internal fixes); claude-agent-sdk-python v0.1.78, v0.1.79, and v0.1.80 bumped the bundled Claude CLI to v2.1.136, v2.1.137, and v2.1.138 respectively. 

  41. OpenAI, openai-agents-python v0.17.0. May 8, 2026. RealtimeAgent defaults to gpt-realtime-2. Sandbox local-source materialization now constrains LocalFile.src and LocalDir.src to within the manifest base_dir (the SDK process current working directory when the manifest is applied) unless the source is explicitly granted via Manifest.extra_path_grants with SandboxPathGrant. Relative local sources resolve from base_dir; absolute sources must already be inside it or under an explicit grant. Migration: declare trusted host roots at the manifest level, preferably read-only. Treat extra_path_grants as trusted application configuration; do not populate from model output or untrusted manifest input. Also includes a Responses context-management extra_args collision fix. 

  42. Anthropic, Claude Code v2.1.139. May 2026. Current-session local evidence on May 11, 2026: claude --version returned 2.1.139 (Claude Code). Release notes add Agent View (claude agents), /goal, hook args: string[], continueOnBlock for PostToolUse, CLAUDE_PROJECT_DIR for MCP stdio servers, plugin command interpolation for ${CLAUDE_PROJECT_DIR}, and fixes including claude_code.active_time.total OpenTelemetry emission in --print mode. 

  43. Anthropic, “Manage multiple agents with agent view”. Agent View docs describe dispatching and managing many Claude Code sessions from one screen, seeing what each session is doing, and identifying sessions that need operator input. The page identifies Agent View as Research Preview and documents local session limitations. 

  44. Anthropic, “Claude Code Hooks”. Hook docs covering command-hook fields, PreToolUse, PostToolUse, exit-code behavior, hook input/output, and direct slash-command expansion paths. 

  45. GitHub Advisory Database, GHSA-f3jg-756w-gm35 / CVE-2026-45046. “Gryph Agents Payload Filter Fails to Strip Tool Payload for Sensitive Content.” Published May 2026; describes sensitive file-write payload content remaining in local SQLite logs under default logging behavior and fixed in Gryph v0.7.0. 

  46. OSV, GHSA-wxxx-gvqv-xp7p / CVE-2026-40217. “LiteLLM has a sandbox escape in custom-code guardrail.” Published May 11, 2026; describes an admin-protected POST /guardrails/test_custom_code endpoint running user-supplied Python in a hand-rolled sandbox and recommends upgrading or blocking the endpoint if unable to upgrade. 

  47. Young Jo (seph) Chung and Safwat Hassan, “Collaborator or Assistnat? How AI Coding Agents Partition Work Across Pull Request Lifecycles”, arXiv:2605.08017v1, May 2026. The abstract reports analysis of 29,585 PR lifecycles across OpenAI, Copilot, Devin, Cursor, and Claude Code, distinguishing operational agency from merge governance. 

  48. Jiayuan Liu et al., “The Memory Curse: How Expanded Recall Erodes Cooperative Intent in LLM Agents”, arXiv:2605.08060v1, May 2026. The abstract reports experiments across 7 LLMs and 4 games over 500 rounds where expanded accessible history degraded cooperation in 18 of 28 model-game settings. 

  49. Anthropic, Claude Code v2.1.140. May 12, 2026. Adds subagent_type to agent hook input and fixes ConfigChange hooks, disableAllHooks, allowManagedHooksOnly, permission-dialog env-var display from hook results, custom style resets after settings updates, native package resolution fallback on Windows Git Bash, and /scroll-speed

  50. Anthropic, Claude Code v2.1.141. May 13, 2026. Adds terminalSequence to hook JSON output for desktop notifications, window titles, and bells; CLAUDE_CODE_PLUGIN_PREFER_HTTPS for HTTPS plugin-source cloning; ANTHROPIC_WORKSPACE_ID for workload identity federation workspace scoping; claude agents --cwd <path> for Agent View directory filtering; /feedback session attachment options for the last 24 hours or 7 days; and related agent, background-job, hook, MCP, Remote Control, permission-dialog, and terminal-rendering fixes. Current-session verification on May 14, 2026: claude --version returned 2.1.141 (Claude Code) and npm view @anthropic-ai/claude-code version dist-tags.latest time.modified --json returned latest 2.1.141

  51. Anthropic, Claude Code v2.1.142. May 14, 2026. Adds claude agents dispatch flags for background sessions (--add-dir, --settings, --mcp-config, --plugin-dir, --permission-mode, --model, --effort, --dangerously-skip-permissions), changes Fast mode to Opus 4.7 by default with CLAUDE_CODE_OPUS_4_6_FAST_MODE_OVERRIDE=1 as the pinning override, surfaces root-level plugin SKILL.md files as skills when no skills/ directory exists, shows plugin-provided LSP servers in plugin details, warns before replacing an existing GitHub App connection, and fixes MCP_TOOL_TIMEOUT, background-session worktree, daemon sleep/wake, post-upgrade daemon cleanup, plugin cache, and Agent View reliability issues. Current-session verification on May 15, 2026: claude --version returned 2.1.141 (Claude Code) and npm latest returned 2.1.142

  52. Anthropic, Claude Code v2.1.147. May 21, 2026. Adds the off-by-default Workflow tool for deterministic multi-agent orchestration (CLAUDE_CODE_WORKFLOWS=1), pinned background sessions, /code-review [effort] --comment replacing /simplify, REPL and Workflow sandbox hardening, auto-updater diagnostics, large-diff rendering improvements, prompt-history deduplication, and fixes for enterprise login restrictions, PowerShell behavior, MCP pagination, Agent View, plugins, hook conditions, pasted text, and stripped-image loops. Current-session verification on May 21, 2026: claude --version returned 2.1.144 (Claude Code) and npm view @anthropic-ai/claude-code version dist-tags.latest time.modified --json returned latest 2.1.147 with time.modified 2026-05-21T20:38:35.053Z

  53. Anthropic, Claude Code v2.1.148, v2.1.149, v2.1.150, and Claude Code CHANGELOG. v2.1.148 fixes a Bash exit-code regression from v2.1.147. v2.1.149 adds /usage per-category limits usage, /diff keyboard scrolling, GFM task-list rendering, and Enterprise allowAllClaudeAiMcps; harness-relevant fixes include PowerShell cd permission bypasses, PowerShell prefix/wildcard and stale-variable permission analysis, git-worktree sandbox write-allowlist scope, Bash find vnode exhaustion on macOS, managed-settings approval freezes, otelHeadersHelper path-space diagnostics, and Remote Control session rename sync. v2.1.150 is internal infrastructure only. Current-session verification on May 24, 2026: local claude --version returned 2.1.144 (Claude Code) while npm latest returned 2.1.150 with time.modified 2026-05-23T04:03:10.243Z; GitHub latest release returned v2.1.150 published 2026-05-23T04:03:51Z

  54. OpenAI, openai-agents-python v0.17.1, v0.17.2, and v0.17.3. v0.17.1 adds sandbox-provider error details, archive extraction limits, GitRepo subpath validation, and tracing/session/realtime fixes. v0.17.2 fixes Conversations reasoning persistence, local approval rejection reasons, AsyncSQLiteSession settings, and realtime unknown-tool behavior. v0.17.3 keeps mountpoint credentials out of sandbox commands, rejects relative sandbox workspace roots, handles terminal Vercel sandbox states, and fixes output-schema, guardrail, runtime, and memory import edge cases. Current-session verification on May 24, 2026: python3 -m pip index versions openai-agents returned latest 0.17.3; GitHub latest release returned v0.17.3 published 2026-05-19T01:27:36Z

  55. Claude Code Changelog (canonical), v2.1.152 release notes, v2.1.153 release notes, v2.1.154 release notes. v2.1.152 (May 27) adds the MessageDisplay hook event, disallowed-tools in skill/command frontmatter, /reload-skills, SessionStart hook reloadSkills and sessionTitle outputs, /code-review --fix apply-to-working-tree, pluginSuggestionMarketplaces managed setting, removal of auto-mode opt-in, and --fallback-model mid-session switching. v2.1.153 (May 28) makes /model save as the new-session default with s for session-only, adds skipLfs to plugin marketplaces, surfaces COLUMNS/LINES in status-line env, and persists macOS background-agent Privacy & Security grants. v2.1.154 (May 28) makes Opus 4.8 the default with high effort by default and a new /effort xhigh, introduces dynamic workflows via /workflows, makes Fast mode on Opus 4.8 available at 2× rate for 2.5× speed, defaults the lean system prompt for all models except Haiku/Sonnet/Opus 4.7-and-earlier, lets claude agents accept ! <command> for background-shell sessions, lets plugins declare defaultEnabled: false, passes CLAUDE_CODE_SESSION_ID and CLAUDECODE=1 to stdio MCP subprocess env, and deprecates CLAUDE_CODE_OPUS_4_6_FAST_MODE_OVERRIDE (removed June 1). 

  56. Codex Changelog (OpenAI Developers) and openai/codex releases. Codex CLI 0.134.0 (May 26, 2026) added local conversation-history search, made --profile the primary profile selector across CLI/TUI/sandbox flows with legacy-config migration, improved MCP setup with per-server environment targeting plus OAuth for streamable HTTP servers, made connector tool schemas more reliable by preserving local $ref/$defs and compacting oversized schemas before exposure, and enabled concurrent execution of read-only MCP tools advertising readOnlyHint. Codex CLI 0.135.0 (May 28, 2026) added richer codex doctor diagnostics, surfaced remote connection details and server version in /status, added vim text-object editing with improved word/line-end behavior and configurable interrupt-turn, made /permissions understand named permission profiles, packaged a bundled patched zsh helper across supported macOS and Linux, and added friendly Sandbox presets to the Python SDK for thread and turn APIs. 

  57. Hermes Agent v0.15.0 release notes. “The Velocity release.” 1,302 commits, 747 merged PRs, 321 community contributors. run_agent.py refactored 76% (16,083 → 3,821 lines across 14 modules). Multi-agent Kanban platform with auto-decomposition, swarm topology, per-task model overrides, scheduled tasks, and worktree management. session_search redesigned 4,500× faster with the LLM dependency removed. Promptware defense against Brainworm-class prompt injection at three security chokepoints. Bitwarden Secrets Manager integration replacing per-provider keys with a single bootstrap token. Skill bundles for loading multiple skills with one slash command. TUI session orchestrator for multi-session management in one terminal. Krea 2 and FAL image-generation providers; xAI integration round (web-search plugin, OAuth upstream, retired-model detection, natural TTS pauses). 

  58. Claude Code v2.1.157 release notes and the Claude Code Changelog (canonical). May 29, 2026. Plugins placed in a project’s .claude/skills/ directory now load automatically without requiring a marketplace; claude plugin init <name> scaffolds a fresh plugin in that directory; /plugin gained argument autocomplete. Also: EnterWorktree can switch between Claude-managed worktrees mid-session, background worktrees are left unlocked after the agent finishes so git worktree remove/prune work cleanly, and tool_decision telemetry events include tool_parameters when OTEL_LOG_TOOL_DETAILS=1. Also includes bug fixes for unprocessable images (now degrade to text placeholders), sandbox network permission prompts in auto/bypass mode, background-session retire-on-park, and terminal rendering across tmux / VS Code / Cursor / Windsurf. 

  59. Claude Code Changelog (canonical) and Codex CLI v0.137.0 release notes, June 2026. Claude Code v2.1.162 (June 3) added waitingFor to claude agents --json; v2.1.163 (June 4) added hookSpecificOutput.additionalContext for Stop/SubagentStop non-error feedback; v2.1.166 (June 6) hardened cross-session SendMessage authority (relayed messages no longer carry user authority) and added the fallbackModel setting (up to three fallbacks, one-shot retry on non-retryable errors). Codex CLI v0.137.0 (June 4) shipped multi-agent v2 (runtime-with-thread, hide_spawn_agent_metadata default true, parent→child event propagation), a v1 skills extension with per-turn catalog resolution, and thread-start/turn-error lifecycle contributor events; the Codex subagents docs confirm default/worker/explorer agent types and agents.max_threads/max_depth concurrency controls. AGENTS.md (agents.md) publishes no versioned spec change. Current-session verification June 8, 2026. 

  60. Anthropic, Claude Code v2.1.169 release notes and v2.1.170 release notes, June 8–9, 2026. v2.1.169 adds the disableBundledSkills setting plus CLAUDE_CODE_DISABLE_BUNDLED_SKILLS (hides bundled skills, workflows, and built-in slash commands from the model); the --safe-mode flag plus CLAUDE_CODE_SAFE_MODE (starts a session with all customizations disabled: CLAUDE.md, plugins, skills, hooks, and MCP servers); and the /cd command (moves a session to a new working directory without breaking the prompt cache). v2.1.170 makes Claude Fable 5 (claude-fable-5) selectable via /model claude-fable-5, with Opus 4.8 remaining Claude Code’s agentic default. Model-tier launch: Anthropic, “Claude Fable 5”, June 9, 2026 — a “Mythos-class” tier above Opus, described as Anthropic’s most powerful model made safe for general use. 

  61. OpenAI, Codex CLI rust-v0.138.0 release notes (June 8, 2026) and rust-v0.139.0 release notes (June 9, 2026). v0.138.0 hardens multi-agent v2 with encrypted inter-agent message payloads, a v2 agent config catalog, an agent-residency LRU, and concurrency counted by active execution rather than spawned threads. v0.139.0 renames the close_agent lifecycle API to interrupt_agent, and scopes subagent MCP startup warnings to the owning thread so they no longer duplicate into the parent. AGENTS.md discovery is hardened across both releases: loading routes through environment filesystems and preserves logical paths during discovery, ensuring correct file selection for remote and symlinked workspaces. 

  62. Anthropic, Claude Code v2.1.172 release notes (June 10, 2026). Sub-agents can now spawn their own sub-agents, with recursive delegation supported up to 5 levels deep; previously delegation was effectively one level. 

  63. Anthropic, Claude Code v2.1.175 release notes and v2.1.178 release notes, June 12–15, 2026. v2.1.175 adds the enforceAvailableModels managed setting (pins the Default model and prevents user/project settings from widening the managed availableModels allowlist). v2.1.178 adds Tool(param:value) permission-rule syntax matching a tool’s input parameters with a * wildcard (e.g. Agent(model:opus)); loads skills from nested .claude/skills directories with <dir>:<name> disambiguation on name clash; resolves nested .claude/ agents, workflows, and output-styles closest-to-cwd on collision (project-scope workflow saves target the closest existing .claude/workflows/); evaluates subagent spawns with the auto-mode classifier before launch; and fixes MCP server-level specs (mcp__server, mcp__server__*, mcp__*) in subagent disallowedTools being silently ignored. 

  64. OpenAI, Codex CLI rust-v0.140.0 release notes, June 15, 2026 (promoted to stable from the v0.140.0-alpha line). Adds /import to selectively import setup, project config, and recent chats from Claude Code; permanent session deletion via codex delete, /delete, and app-server thread/delete with confirmation safeguards; a unified @ mentions menu for files, plugins, and skills; and /usage token-activity views. 

  65. Anthropic, Claude Code v2.1.183 release notes, June 19, 2026 — auto mode blocks destructive git commands (git reset --hard, git checkout -- ., git clean -fd, git stash drop) when you didn’t ask to discard work, git commit --amend on commits not made by the agent this session, and terraform destroy/pulumi destroy/cdk destroy unless you asked for the specific stack. OpenAI, Codex CLI rust-v0.141.0 release notes, June 18, 2026 (promoted to stable from the v0.141.0-alpha line) — remote executors use authenticated, end-to-end encrypted Noise-relay channels; cross-platform remote execution preserves executor-native working directories and shells; TLS supports P-521 certificate signatures for enterprise proxies. 

  66. Claude Code Changelog (canonical) — v2.1.193 (June 25, 2026): autoMode.classifyAllShell setting; auto-mode denial reasons in transcript, toast, and /permissions. v2.1.195 (June 26, 2026): hook matchers with hyphenated identifiers (e.g. code-reviewer, mcp__brave-search) exact-match instead of substring-matching; use mcp__brave-search__.* to match all tools from a hyphenated MCP server. Codex CLI v0.142.2 release notes (June 25, 2026): PowerShell commands containing executable AST regions the safety classifier cannot inspect now require approval. Verified against both canonical sources July 1–2, 2026 (PST). 

  67. Claude Code Changelog (canonical) and GitHub releases. v2.1.196 (June 29, 2026): organization-wide default models (admin-set, shown as “Org default” in /model); claude mcp list/get no longer spawn repo-self-approved .mcp.json servers in untrusted workspaces. v2.1.197 (June 30): Claude Sonnet 5 becomes the shipped default model (native 1M context, $2/$10 promotional pricing through Aug 31). v2.1.198 (July 1): subagents run in the background by default; the built-in Explore agent inherits the session model (capped at Opus); subagents and compaction inherit the session’s extended-thinking configuration; background claude agents sessions commit, push, and open a draft PR after worktree code work and fire the Notification hook with agent_needs_input/agent_completed; the /agents wizard was removed (edit .claude/agents/ directly or ask Claude). v2.1.199 (July 2): stacked slash-skill invocations load up to 5 leading skills; SendMessage reused-agent-name misrouting is detected; SessionStart/Setup/SubagentStart hooks surface stderr on exit code 2. v2.1.200 (July 3): the default permission mode is labeled “Manual” across the CLI, --help, VS Code, and JetBrains, with manual accepted alongside the unchanged config value; AskUserQuestion dialogs no longer auto-continue by default. v2.1.202 (July 6): a “Dynamic workflow size” /config control; /review <pr> reverts to a single-pass review while /code-review <level> <pr#> runs the multi-agent pass. Anthropic claude-agent-sdk is at v0.2.111 (July 6, 2026; bundles Claude CLI v2.1.202) and the TypeScript @anthropic-ai/claude-agent-sdk at v0.3.203; the 0.2.x / 0.3.x lines are incremental over the documented 0.1.x surface (recent work is subprocess-cleanup and NDJSON-stream reliability). Current-session verification July 7, 2026 (PST). 

  68. Claude Code Changelog (canonical), GitHub releases v2.1.207 and v2.1.208, and What’s new in Claude Code. July 2026. v2.1.203–v2.1.206 (early July): auto-mode rule blocks transcript-file tampering; background-task notifications explicitly state that no human input occurred while the task ran; MCP roots/list includes the session’s additional working directories with roots/list_changed notifications; /doctor proposes trimming CLAUDE.md content derivable from the codebase; v2.1.204 also fixed headless SessionStart streaming. v2.1.207: auto mode GA on Amazon Bedrock, Google Vertex AI, and Microsoft Foundry with the disableAutoMode managed setting as opt-out; CLAUDE_CODE_PROCESS_WRAPPER for corporate process launchers; up to 7× faster tool-use rounds at high MCP tool counts and 79× smaller session transcripts. v2.1.208: catastrophic-removal confirmation prompts pierce --dangerously-skip-permissions and auto mode. 

  69. Claude Code Changelog (canonical) and GitHub releases v2.1.210, v2.1.211, and v2.1.212. July 2026. v2.1.210: worktree-isolation subagents can no longer mutate the main checkout; Agent tool hardened against indirect prompt injection from content a subagent read; auto-mode classifier defaults to Sonnet 5, pinned per session; MEMORY.md writes exceeding the size limit error instead of silently truncating. v2.1.211: PreToolUse hook ask decisions floor the permission outcome at a prompt — auto mode cannot override to allow for unsandboxed Bash; --forward-subagent-text / CLAUDE_CODE_FORWARD_SUBAGENT_TEXT forwards subagent text into stream-json output; “always allow” rules persist at the repository root across worktrees; permission previews neutralize bidirectional-override, zero-width, and look-alike characters. v2.1.212: per-session subagent spawn cap (default 200, CLAUDE_CODE_MAX_SUBAGENTS_PER_SESSION, reset by /clear); per-session WebSearch cap (200, CLAUDE_CODE_MAX_WEB_SEARCHES_PER_SESSION); Task tool mode parameter deprecated in favor of inheriting the parent session’s permission mode; /fork creates a new background session with the in-session variant renamed /subtask; MCP calls exceeding two minutes auto-background (CLAUDE_CODE_MCP_AUTO_BACKGROUND_MS). 

  70. Anthropic, @anthropic-ai/claude-agent-sdk TypeScript releases v0.3.205–v0.3.208. July 2026. Typed interrupt receipts (still_queued UUIDs; interrupt_receipt_v1 capability advertised in system/init); command_lifecycle frames reporting queued/started/completed/cancelled/discarded per message; AgentToolCompletedOutput type; canUseTool may return {behavior: 'allow'} without updatedInput. Security fix in v0.3.208: a caller abort arriving during a pending hook was converted into hook success, so tools gated by a PreToolUse hook could execute after the caller aborted. 

  71. Model Context Protocol, PR #3002. Merged July 16, 2026 into the draft specification. Adds an optional io.modelcontextprotocol/serverInfo object in response _meta and makes clientInfo optional on requests, restoring server identity after SEP-2575’s stateless core removed the stateful initialize handshake. The identity is self-reported and unverified: intended for display and logging only, and SHOULD NOT drive security decisions. The finalized stateless spec revision is scheduled for July 28, 2026. 

  72. OpenAI, Codex CLI releases rust-v0.143.0, rust-v0.144.0, and rust-v0.144.5. July 2026. v0.143.0: MCP tools load via tool search by default (deferred tool loading rather than front-loaded schemas). v0.144.0: new writes app-approval mode — read-only actions run without prompting, writes require approval — and MCP interactive auth GA. v0.144.5: expanded dangerous-command detection. 

  73. OpenAI, openai-agents-python v0.18.2 (July 11, 2026) and openai-agents-js v0.13.2 (July 10, 2026). Both releases add hosted multi-agent support in beta — OpenAI-managed orchestration of multiple agents as a hosted service, the counterpart to Anthropic’s Managed Multiagent Orchestration public beta. 

  74. Claude Code Changelog (canonical), v2.1.214–v2.1.216, July 2026. v2.1.214: permission rules and hook if: conditions with single-segment dir/** path patterns now anchor to <cwd>/dir (write **/dir/** for any-depth); the previous behavior auto-approved allow rules like Edit(src/**) against any nested dir/ in the tree; deny and ask rules keep any-depth matching. Also: EndConversation tool; a fail-closed Bash/PowerShell permission-hardening batch; hook exit code 2 blocks even when stdout JSON fails schema validation; memory frontmatter ISO modified timestamps without silent truncation; OTel message.uuid, client_request_id, tool_source, and CLAUDE_CODE_OTEL_CONTENT_MAX_LENGTH. v2.1.215: the bundled /verify and /code-review skills are no longer self-invoked — explicit invocation only. v2.1.216: worktree-isolated subagents can no longer redirect git into the shared checkout via git -C, --git-dir, or GIT_DIR/GIT_WORK_TREE; worktree sessions no longer resolve into another project’s leftover worktree; workflow and scheduled-task writes refuse a symlinked .claude pointing outside the project; /rewind no longer traverses symlinks or hard links; sandbox.filesystem.disabled allows network-egress-only sandboxing; resumed background agent sessions restore the agent’s prompt and tool restrictions; mid-session skill/command changes appear in the slash menu without restart. Verified against the canonical changelog July 21, 2026 (PST). 

  75. Anthropic, @anthropic-ai/claude-agent-sdk TypeScript releases v0.3.214–v0.3.216 and claude-agent-sdk Python v0.2.124. July 2026. TypeScript: set_permission_mode rejects unknown modes; aborted: true on interrupt-truncated messages; tool_progress carries subagent_type and subagent_retry; task-notification subkind scheduled-trigger; SessionStart source "fork"; tool_result_meta sidecar with non_execution_kind and user_feedback; optional skippedLinks count on rewindFiles responses; optional user_message_uuid and request_sent_wall_ms on the success result message. Python v0.2.124 (Windows, BatBadBut-class): refuses to spawn .bat/.cmd files; cmd.exe metacharacters in resume/session_id values raise ValueError; dash-leading extra_args values are bound as --flag=value

  76. OpenAI, Codex CLI rust-v0.145.0 release notes, July 2026. Stabilizes the opt-in multi-agent V2 surface (configurable sub-agent models, reasoning levels, concurrency; restored agent roles); expands /import to migrate settings, MCP servers, plugins, sessions, commands, and project-scoped memories from Claude Code and Cursor. Hardening: MCP startup timeouts, serialized OAuth refreshes, non-blocking OAuth discovery, stronger forced-rm detection, preserved rejection reasons, experimental paginated thread history. 

  77. Model Context Protocol, spec-release documentation PRs #3064, #3066, and #3098, merged July 21, 2026 ahead of the July 28 spec release. The finalized revision will present Tasks as an optional io.modelcontextprotocol/tasks extension rather than a core feature, and deprecates the HTTP+SSE transport in favor of Streamable HTTP. 

  78. Claude Code Changelog (canonical), v2.1.217, July 21, 2026. Subagents no longer spawn nested subagents by default — set CLAUDE_CODE_MAX_SUBAGENT_SPAWN_DEPTH to allow deeper nesting; new cap on concurrently-running subagents (default 20, CLAUDE_CODE_MAX_CONCURRENT_SUBAGENTS) so one message cannot fan out unbounded background agents; --max-budget-usd now actually stops background subagents — once the cap is reached, new spawns are denied and running background agents are halted; background-session isolation canonicalizes symlinked working directories, closing a workspace-folder escape. Verified against the canonical changelog July 22, 2026 (PST). 

  79. Anthropic, claude-agent-sdk Python v0.2.125 and @anthropic-ai/claude-agent-sdk TypeScript v0.3.217, July 21, 2026. Python v0.2.125 bundles CLI v2.1.217 with no SDK-surface changes; TS v0.3.217 ships alongside. Both inherit the CLI’s new subagent nesting and concurrency defaults. 

  80. Model Context Protocol, PR #3092, merged July 21, 2026. Normative correction aligning SEP-2575 error codes with the renumbered draft schema and the conformance suite, part of the preparation for the July 28, 2026 spec release. 

  81. Anthropic Engineering, “How we contain Claude across products”, May 25, 2026. Three containment patterns matched to product surfaces: ephemeral gVisor containers with per-session filesystems server-side (claude.ai); human-in-the-loop OS sandboxing (Claude Code: Seatbelt on macOS, bubblewrap on Linux, the open-sourced sandbox-runtime); sealed VMs on platform hypervisors (Claude Cowork: Apple Virtualization framework on macOS, HCS on Windows, workspace and .claude mounted and nothing else). Design principles: contain at the environment layer first and steer at the model layer second; match isolation strength to the user’s capacity for oversight; prefer battle-tested primitives (hypervisors, seccomp, container runtimes) over custom isolation code; treat project-local configuration and tool outputs as untrusted; keep credentials outside the sandbox via scoped, independently revocable per-session tokens, enforced in Cowork by a defensive MITM proxy inside the VM that rejects requests not carrying the VM’s own provisioned token. 

  82. Claude Code Changelog (canonical), v2.1.218, July 22, 2026. The dangerous-rm, background-&, and suspicious-Windows-path checks no longer open permission dialogs — the auto-mode classifier adjudicates them; plan mode with auto no longer prompts for Bash commands the static analyzer cannot prove read-only — the classifier judges them; agent frontmatter hooks require the agent file’s own folder to have accepted workspace trust; skills with context: fork run in the background by default (background: false opts out per skill); /code-review runs as a background subagent; /deep-research starts only when invoked manually; fork-session lineage preserved after compaction in headless and SDK sessions; Ctrl+B backgrounding applies the same background-shell caps as other paths. Verified against the canonical changelog July 24, 2026 (PST). 

  83. Anthropic, @anthropic-ai/claude-agent-sdk TypeScript v0.3.218 and claude-agent-sdk Python v0.2.126, July 22, 2026. TypeScript: SkillToolOutput.background flag; api_error_status reports mid-stream 429/529 errors; canonicalModel and provider on modelUsage. Python: ResultMessage.terminal_reason; typed model_usage entries with canonicalModel/provider; bundles CLI v2.1.218. 

  84. Claude Code Changelog (canonical), v2.1.219 (July 24, 2026) and v2.1.220 (July 25, 2026). v2.1.219: “Subagents can now spawn nested subagents up to depth 3 by default (was 1); set CLAUDE_CODE_MAX_SUBAGENT_SPAWN_DEPTH=1 to disable nesting”; Claude Opus 5 (claude-opus-5) added as the default Opus model — 1M context, fast mode at $10/$50 per MTok; sandbox.network.strictAllowlist denies non-allowlisted hosts for sandboxed commands without prompting; new DirectoryAdded hook fired after /add-dir or the SDK register_repo_root control request registers a working directory mid-session; dynamic workflows default to a medium size guideline (“aim for fewer than 15 agents”), settable from any settings file via workflowSizeGuideline (the /config row hides while one does) and shown in the running-workflow status line; nested subagent forwarding in stream-json — depth-2+ subagents appear under --forward-subagent-text, keyed by their spawning Agent tool_use id; mcp_server_errors in the headless stream-json init event listing --mcp-config entries skipped by config validation, with a startup warning in terminal runs; HTTP status and error text in claude mcp list and /mcp on connect failure, plus a warning for MCP config values with hidden leading/trailing whitespace; managed MCP allowlist/denylist ${VAR} entries resolve from the startup environment and managed-settings env instead of settings-file env; claude -p no longer drops text already produced when a turn dies on a mid-stream API error; CLAUDE_CODE_GIT_BASH_PATH ignored with a warning when the path is not a bash/sh binary; Opus 4.7 removed from fast mode (/fast now applies to Opus 5 and Opus 4.8); the bundled claude-api skill defaults to Opus 5 with a migration path from Opus 4.8. v2.1.220: bug fixes and reliability improvements only. The auto-mode Fable-5 fallback to “the best available Opus model” dates to v2.1.176 and now resolves to Opus 5. Verified against the canonical changelog July 25, 2026. 

  85. Anthropic, @anthropic-ai/claude-agent-sdk TypeScript v0.3.219 and v0.3.220; claude-agent-sdk Python v0.2.127 and v0.2.128. July 24–25, 2026. TypeScript v0.3.219: DirectoryAdded lifecycle hook event added to the control protocol; opt-in cancel_queued on the interrupt control request (capability interrupt_cancel_queued_v1) cancels queued and pending-dispatch messages alongside the abort; fast_mode_disabled_reason on result and init messages; the initialize response no longer reports fast_mode_state from the spawn-time model after a model switch; sandbox.network.strictAllowlist and workflowSizeGuideline added to SDK settings types. Python v0.2.127: fixed premature stdin closure with background tasks in flight — query() closed stdin on the first result frame while background subagents were still running, causing their SDK-MCP tool calls to fail with "Stream closed" and silently bypass PreToolUse hooks; stdin now stays open until all in-flight tasks complete and the final result frame arrives (#1103). v0.3.220 / v0.2.128: parity bumps to CLI v2.1.220. 

  86. claude-agent-sdk on PyPI and its CHANGELOG; @anthropic-ai/claude-agent-sdk on npm. Verified 2026-08-01: Python 0.2.128 (changelog: “Updated bundled Claude CLI to version 2.1.220”; requires mcp<2.0.0,>=1.23.0), TypeScript 0.3.220 (published 2026-07-24, “parity with Claude Code v2.1.220”). The prior figures in this paragraph (Python v0.2.111 bundling CLI v2.1.202, TypeScript v0.3.203) were 17 releases stale on each line while the rest of this guide already tracked 0.2.128 and 0.3.220. 

  87. Anthropic, “Introducing Claude Opus 5”. July 24, 2026. claude-opus-5; “$5 per million input tokens and $25 per million output tokens”; fast mode runs “around 2.5 times the default speed” at “twice Opus 5’s base price” ($10/$50 per MTok per the Claude Code v2.1.219 changelog, which also states the 1M context window). Benchmarks: “On Frontier-Bench v0.1, Opus 5 surpasses all other models, and more than doubles Opus 4.8’s performance”; on CursorBench 3.2 it lands “within 0.5% of Fable 5’s peak score, but at half the cost”; “On ARC-AGI 3 … Opus 5’s score is three times as high as the next-best model”; on OSWorld 2.0 it surpasses “Fable 5’s best result at just over a third of the cost.” Characterized as “a thoughtful and proactive model” that is “much stronger at verifying its work and iterating carefully.” 

NORMAL agent-architecture.md EOF