Skip to content

Diagrams

The Agent Loop

Agent Loop

Gather context Read files, search code, check state Take action Call tools, edit files, run commands Verify results Run tests, check output, read logs repeat

Agent Turn Loop

Context System prompt, history, tool results, rules Model Produces response from context Response Text, tool calls, or both Runtime Executes tool calls, collects results if tool calls results become new context

Eslint Layer Boundaries

Diplomat Entry points — CLI, API Domain Infrastructure Controllers Orchestration Adapters I/O implementations Logic Business rules Wire External schemas Models Pure domain types Dependencies flow inward only — outer layers import inner, never the reverse

Hooks Lifecycle

Agent Decides to call a tool PreToolUse Annotate · Block · Validate block allow + context pass Blocked Wrong command denied Annotated Context injected Tool still runs Tool call Bash · Write · Read · MCP result PostToolUse Observe · Log · Update UI Side effect Update terminal · Log event

Instruction Sources Hierarchy

Five instruction sources feed into the context window: Managed Policy, User, and Project CLAUDE.md files load at launch; Subdirectory CLAUDE.md and .claude/rules/ path-scoped files load on demand. LOADED AT LAUNCH Managed Policy Org-wide, IT-deployed User ~/.claude/ CLAUDE.md Project ./CLAUDE.md Context Window all tokens, no special treatment LOADED ON DEMAND Subdirectory child CLAUDE.md .claude/rules/ path-scoped files

Instructions Context Flow

CLAUDE.md is read at SessionStart and added to the context window alongside conversation, tool results, and memory. The model output is conditioned on all tokens together. CLAUDE.md Instruction file read at SessionStart CONTEXT WINDOW Instructions CLAUDE.md Conversation Messages Tool Results Files, commands Memory Auto notes all tokens, conditioned together Model Output conditioned on full context

Intelligence Determinism Split

NON-DETERMINISTIC — shapes thinking Rules Passive knowledge — absorbed not called Skills Workflow brain — invoked orchestrates Agent Plans, decides, calls tools shape direct DETERMINISTIC — executes and enforces Hooks Structural enforcement — intercepts tool calls Tools Bash, Write, Read, MCP, ... calls intercept

Mcp Architecture

Claude Code (MCP client) enterprise-search search, read_document (MCP server) internal-api get_customer, create_order (MCP server) JSON-RPC JSON-RPC

Publishing Loop

Describe Tell Claude what you want Review /tech-writer flags claims /revise fixes structure Publish /publish builds, PRs, deploys repeat

Skill Orchestration

SKILL /pre-pr dispatch Lint CLI lint-fix + lint Unit tests CLI lein test Integration CLI lein integration Code review MCP search + read 4 sub-agents run in parallel — the skill narrates progress and synthesizes results