Claude Code: Visual Reference
Last updated:
All diagrams in one place. Quick visual overview of Claude Codeβs key concepts. For detailed docs β Ultimate Guide | Cheatsheet
Interactive Mermaid diagrams available: For 40 interactive diagrams covering model selection, agent lifecycle, memory hierarchy, multi-agent patterns, security threats, and more, see guide/diagrams/. This file contains ASCII versions of key concepts.
20 diagrams: 8 new (this file) + 12 from existing guides, all consolidated here.
Harness Map Reading Guide
Section titled βHarness Map Reading GuideβThese ASCII diagrams cover selected Claude Code concepts. For the harness taxonomy, use the three figures on the Agent Harness Map: strict and broad scope, the four layers, and the selection funnel. Agent Harness Engineering explains the model, runtime harness, repository harness, and orchestrator. Agent Tools: Beyond Claude Code covers frameworks and control planes. Use Agent Evaluation, Session Observability, and Security Hardening to test, inspect, and constrain the chosen design. Definitions are in the glossary.
Table of Contents
Section titled βTable of ContentsβNew diagrams:
Architecture & Internals: 5. Master Loop 6. Hook Event Flow 7. Data Privacy Flow
Security: 8. MCP Rug Pull Attack 9. Docker Sandbox Architecture
Decision Trees: 10. Search Tool Selection 11. Trust Calibration Flow 12. Adoption Decision Tree 13. Methodology Selection
Workflows: 14. Research β Spec β Code 15. Review Auto-Correction Loop 16. PDF Pipeline Stack
Development & Learning: 17. TDD Red-Green-Refactor Cycle 18. UVAL Protocol Flow
Security (extended): 19. Security 3-Layer Defense 20. Secret Exposure Timeline
1. Context Management Zones
Section titled β1. Context Management ZonesβHow to react based on context window usage (check with /status):
Context Usage0% 50% 70% 90% 100%βββββββββββββΌββββββββββββΌββββββββββββΌβββββββββββ€β GREEN β YELLOW β ORANGE β RED ββ work β selective β /compact β /clear ββ freely β with care β NOW β required ββββββββββββββ΄ββββββββββββ΄ββββββββββββ΄βββββββββββ β² β² β β Be selective Risk: forgetting about reads instructions, and tool use hallucinationsActions by zone:
- Green (0-50%): Full speed. Read files, explore freely.
- Yellow (50-70%): Be selective. Avoid unnecessary file reads.
- Orange (70-90%): Run
/compactimmediately. Context is degrading. - Red (90%+): Run
/clearand restart. Responses are unreliable.
β Source: ultimate-guide.md:1335
2. Permission Modes Cycle
Section titled β2. Permission Modes CycleβCycle through modes with Shift+Tab:
Shift+Tab Shift+Tab ββββββββββββ βββββββββββββ βββββββββββββββββ βββββββββββββ βββββββββββββ β DEFAULT β β AUTO-ACCEPT β β PLAN MODE β β β β β β β β edit=ask β β edit=auto β β edit=no β β exec=ask β β exec=ask β β exec=no β ββββββββββββ βββββββββββββ βββββββββββββββββ βββββββββββββ βββββββββββββ Shift+Tab Shift+TabWhen to use each mode:
| Mode | Use when⦠| Risk level |
|---|---|---|
| Default | Normal development: review each change | Low |
| Auto-accept | Trusted tasks (formatting, refactoring) | Medium |
| Plan mode | Complex/risky operations: explore safely first | None |
Shortcuts:
Shift+Tab: Cycle to next modeShift+Tab Γ 2: Jump to plan mode from default/plan: Enter plan mode directly- Exit plan mode: approve the plan Claude presents, or press
Shift+Tab(there is no/executecommand)
β Source: ultimate-guide.md:760
3. Workflow Pipeline (9 Steps)
Section titled β3. Workflow Pipeline (9 Steps)βThe recommended workflow for every task:
βββββββββββ ββββββββββββ ββββββββββββββ βββββββββββββββ β 1.START ββββββ 2./statusββββββ 3. plan? ββββββ 4. describe β β claude β β check ctxβ β Shift+TabΓ2β β WHAT/WHERE β βββββββββββ ββββββββββββ β (if risky) β β HOW/VERIFY β ββββββββββββββ ββββββββ¬βββββββ β βββββββββββββββββββββββββββββββββββββββββββββββββββββ β βΌ ββββββββββββ ββββββββββββ ββββββββββββ ββββββββββββ ββββββββββββ β 5.review ββββββ 6. y/n ββββββ 7. test ββββββ 8.commit ββββββ9./compactβ β diff β β accept? β β run β β when doneβ β when >70%β ββββββββββββ ββββββββββββ ββββββββββββ ββββββββββββ ββββββββββββKey principles:
- Step 2: Always check context before starting. If >70%,
/compactfirst. - Step 3: Use plan mode for anything risky, complex, or multi-file.
- Step 4: Be specific. Vague prompts produce vague results.
- Step 5: Read every diff. Never blindly accept.
- Step 9: Compact after each task to stay in the green zone.
β Source: ultimate-guide.md:277
4. Quick Decision Tree
Section titled β4. Quick Decision TreeβWhat to do based on your situation:
What do you need?βββ Simple task ββββββββββββββββββ Just ask Claudeβββ Complex taskβ ββ Single session ββββββββββββ /plan + Tasks APIβ ββ Multi-session βββββββββββββ Tasks API + CLAUDE_CODE_TASK_LIST_IDβββ Repeating task βββββββββββββββ Create agent or commandβββ Context >70% βββββββββββββββββ /compactβββ Context >90% βββββββββββββββββ /clear (restart conversation)βββ Need library docs ββββββββββββ Context7 MCPβββ Deep debugging βββββββββββββββ Opus model + Alt+T (thinking)βββ UI from design βββββββββββββββ Figma MCP or screenshot inputβββ Team rollout βββββββββββββββββ Read adoption-approaches.mdβ Source: reference.yaml (decide section)
5. Master Loop
Section titled β5. Master LoopβThe entire architecture is a simple while loop: no DAG, no classifier, no RAG.
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ CLAUDE CODE MASTER LOOP ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€β ββ ββββββββββββββββ ββ β Your Prompt β ββ ββββββββ¬ββββββββ ββ β ββ βΌ ββ ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ ββ β β ββ β CLAUDE REASONS β ββ β (No classifier, no routing layer) β ββ β β ββ ββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββ ββ β ββ βΌ ββ ββββββββββββββββββ ββ β Tool Call? β ββ βββββββββ¬βββββββββ ββ β ββ YES β NO ββ βββββββββββββββββββ΄ββββββββββββββββββ ββ β β ββ βΌ βΌ ββ ββββββββββββββ ββββββββββββββ ββ β Execute β β Text β ββ β Tool β β Response β ββ β β β (DONE) β ββ βββββββ¬βββββββ ββββββββββββββ ββ β ββ βΌ ββ βββββββββββββββ ββ β Feed Result β ββ β to Claude ββββββββββββββββββββ ββ βββββββββββββββ β ββ β ββ βΌ ββ ββββββββββββββββββ ββ β LOOP BACK β ββ β (Next turn) β ββ ββββββββββββββββββ ββ βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ Source: architecture.md:84
6. Hook Event Flow
Section titled β6. Hook Event FlowβHow hooks intercept Claude Codeβs execution pipeline:
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ EVENT FLOW ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€β ββ User types message ββ β ββ βΌ ββ ββββββββββββββββββββββ ββ β UserPromptSubmit β β Add context (git status) ββ ββββββββββββββββββββββ ββ β ββ βΌ ββ Claude decides to run tool (e.g., Edit) ββ β ββ βΌ ββ ββββββββββββββββββββββ ββ β PreToolUse β β Security check ββ ββββββββββββββββββββββ ββ β ββ βΌ (if allowed) ββ Tool executes ββ β ββ βΌ ββ ββββββββββββββββββββββ ββ β PostToolUse β β Auto-format ββ ββββββββββββββββββββββ ββ βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ Source: ultimate-guide.md:6327
7. Data Privacy Flow
Section titled β7. Data Privacy FlowβWhat data leaves your machine when using Claude Code:
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ YOUR LOCAL MACHINE ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€β β’ Prompts you type ββ β’ Files Claude reads (including .env if not excluded!) ββ β’ MCP server results (SQL queries, API responses) ββ β’ Bash command outputs ββ β’ Error messages and stack traces ββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββ β βΌ HTTPSββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ ANTHROPIC API ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€β β’ Processes your request ββ β’ Stores conversation based on retention policy ββ β’ May use data for model training (if not opted out) βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ Source: data-privacy.md:24
8. MCP Rug Pull Attack
Section titled β8. MCP Rug Pull AttackβHow a malicious MCP server can exploit the one-time approval model:
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ 1. Attacker publishes benign MCP "code-formatter" ββ β ββ 2. User adds to ~/.claude.json, approves once ββ β ββ 3. MCP works normally for 2 weeks (builds trust) ββ β ββ 4. Attacker pushes malicious update (no re-approval!) ββ β ββ 5. MCP exfiltrates ~/.ssh/*, .env, credentials ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββMITIGATION: Version pinning + hash verification + monitoringβ Source: security-hardening.md:33
9. Docker Sandbox Architecture
Section titled β9. Docker Sandbox ArchitectureβFull isolation for autonomous Claude Code sessions:
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ HOST MACHINE ββ ββ ββββββββββββββββββββββββββββββββββββββββββββββββββββββ ββ β DOCKER SANDBOX (microVM) β ββ β β ββ β ββββββββββββββββ βββββββββββββββββββββββββββββ β ββ β β Claude Code β β Private Docker daemon β β ββ β β (--dsp mode) β β (isolated from host) β β ββ β ββββββββββββββββ βββββββββββββββββββββββββββββ β ββ β β ββ β ββββββββββββββββββββββββββββββββββββββββββββββββ β ββ β β Workspace: ~/my-project (synced with host) β β ββ β β Same absolute path as host β β ββ β ββββββββββββββββββββββββββββββββββββββββββββββββ β ββ β β ββ β Base: Ubuntu, Node.js, Python 3, Go, Git, β ββ β Docker CLI, GitHub CLI, ripgrep, jq β ββ β User: non-root 'agent' with sudo β ββ ββββββββββββββββββββββββββββββββββββββββββββββββββββββ ββ ββ Host Docker daemon: NOT accessible from sandbox ββ Host filesystem: NOT accessible (except workspace) ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ Source: sandbox-isolation.md:87
10. Search Tool Selection
Section titled β10. Search Tool Selectionβ3-level decision tree for choosing the right search tool:
Level 1: What Do You Know?
Do you know the EXACT text/pattern?βββ YES β Use rg (ripgrep)β ββ Known function name: rg "createSession"β ββ Known import: rg "import.*React"β ββ Known pattern: rg "async function"βββ NO β Go to Level 2Level 2: What Are You Looking For?
What's your search intent?βββ "Find by MEANING/CONCEPT"β β Use grepaiβ ββ Example: grepai search "payment validation logic"βββ "Find FUNCTION/CLASS definition"β β Use Serenaβ ββ Example: serena find_symbol --name "UserController"βββ "Find by CODE STRUCTURE"β β Use ast-grepβ ββ Example: async without error handlingβββ "Understand DEPENDENCIES" β Use grepai trace ββ Example: grepai trace callers "validatePayment"Level 3: Optimization
Found too many results?βββ rg β Add --type filter or narrow pathββ grepai β Add --path filter or use traceββ Serena β Filter by symbol type (function/class)ββ ast-grep β Add constraints to patternβ Source: search-tools-mastery.md:75
11. Trust Calibration Flow
Section titled β11. Trust Calibration FlowβHow much to review AI-generated code based on risk level:
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ TRUST CALIBRATION FLOW ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€β ββ AI generates code ββ β ββ βΌ ββ ββββββββββββββββ ββ β What type? β ββ ββββββββββββββββ ββ β β β ββ βΌ βΌ βΌ ββ Boiler Business Security ββ -plate logic critical ββ β β β ββ βΌ βΌ βΌ ββ Skim Test + Full review ββ only review + tools ββ β β β ββ ββββββββ΄βββββββββ ββ β ββ βΌ ββ Tests pass? ββNoβββΊ Debug & fix ββ β ββ Yes ββ β ββ βΌ ββ Ship it ββ βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ Source: ultimate-guide.md:1182
12. Adoption Decision Tree
Section titled β12. Adoption Decision TreeβHow to choose your Claude Code adoption strategy:
Starting Claude Code?βββ Need to ship today?β ββ YES β Turnkey Quickstartβ ββ NO ββββ Team needs shared conventions?β ββ YES β Turnkey + document what matters to youβ ββ NO ββββ Want to understand before configuring?β ββ YES β Autonomous Learning Pathβ ββ NO β Turnkey, adjust as you goβ Source: adoption-approaches.md:51
13. Methodology Selection
Section titled β13. Methodology SelectionβWhich development methodology to use:
ββ "I want quality code" βββββββββββββ workflows/tdd-with-claude.mdβββ "I want to spec before code" ββββββ workflows/spec-first.mdβββ "I need to plan architecture" βββββ workflows/plan-driven.mdβββ "I'm iterating on something" ββββββ workflows/iterative-refinement.mdβββ "I need methodology theory" βββββββ methodologies.mdβ Source: methodologies.md:24
14. Research β Spec β Code
Section titled β14. Research β Spec β CodeβUsing Perplexity for research, then Claude Code for implementation:
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ 1. PERPLEXITY (Deep Research) ββ "Research best practices for JWT refresh tokens ββ in Next.js 15. Include security considerations, ββ common pitfalls, and library recommendations." ββ ββ β Output: 2000-word spec with sources ββββββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββ β Export as spec.mdββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ 2. CLAUDE CODE ββ > claude ββ "Implement JWT refresh tokens following spec.md. ββ Use the jose library as recommended." ββ ββ β Output: Working implementation with tests βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ Source: ai-ecosystem.md:155
15. Review Auto-Correction Loop
Section titled β15. Review Auto-Correction LoopβIterative code review pattern where Claude reviews, fixes, and re-reviews:
ββββββββββββββββββββββββββββββββββββββββββββ Review Auto-Correction Loop ββ ββ Review (identify issues) ββ β ββ Fix (apply corrections) ββ β ββ Re-Review (verify fixes) ββ β ββ Converge (minimal changes) β Done ββ β ββ βββββ Repeat (max iterations) βββββββββββββββββββββββββββββββββββββββββββββ Source: iterative-refinement.md:354
16. PDF Pipeline Stack
Section titled β16. PDF Pipeline StackβQuarto + Typst stack for generating professional PDFs:
ββββββββββββββββββββββββββββββββββββββββββββββββββββ Your .qmd File ββ (Markdown + YAML frontmatter) ββββββββββββββββββββββββββββββββββββββββββββββββββββ β βΌββββββββββββββββββββββββββββββββββββββββββββββββββββ Quarto ββ (Document rendering engine) ββ β’ Processes YAML metadata ββ β’ Handles extensions ββ β’ Manages output formats ββββββββββββββββββββββββββββββββββββββββββββββββββββ β βββββββββββββββ΄ββββββββββββββ βΌ βΌβββββββββββββββββββββββ ββββββββββββββββββββββββ Pandoc β β Typst ββ (MD β AST β ?) β β (Typography/PDF) ββ β’ Markdown parser β β β’ Modern engine ββ β’ AST transforms β β β’ Fast compilation ββ β’ Format bridges β β β’ No LaTeX needed ββββββββββββββββββββββββ βββββββββββββββββββββββ β βΌββββββββββββββββββββββββββββββββββββββββββββββββββββ document.pdf ββ (Professional typography output) βββββββββββββββββββββββββββββββββββββββββββββββββββββ Source: pdf-generation.md:58
17. TDD Red-Green-Refactor Cycle
Section titled β17. TDD Red-Green-Refactor CycleβThe iterative loop at the heart of Test-Driven Development:
ββββββββββββββββββββββββββββ β β βΌ β ββββββββββββββββ β β π΄ RED β β β β β β Write a β β β failing β β β test β β ββββββββ¬ββββββββ β β β β Tests FAIL β β (expected) β βΌ β ββββββββββββββββ β β π’ GREEN β β β β β β Write β β β minimal β β β code to β β β pass β β ββββββββ¬ββββββββ β β β β Tests PASS β β (minimal) β βΌ β ββββββββββββββββ β β π΅ REFACTORβ β β β β β Clean up β β β while tests β β β stay green β β ββββββββ¬ββββββββ β β β β Next feature β βββββββββββββββββββββββββββββ
Key rules: RED β Test must FAIL before writing implementation GREEN β Write ONLY enough code to pass (no more) REFACTOR β Improve structure, tests must stay green REPEAT β One feature at a time, always in this orderSource: workflows/tdd-with-claude.md:78
18. UVAL Protocol Flow
Section titled β18. UVAL Protocol FlowβSystematic framework for learning with AI without losing your edge:
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β UVAL PROTOCOL β β (Use AI without losing your edge) β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
ββββββββββββ ββββββββββββ ββββββββββββ ββββββββββββ β U β β V β β A β β L β βUNDERSTANDβββββββ VERIFY βββββββ APPLY βββββββ LEARN β β β β β β β β β β 15-min β β Can you β β Modify β β Capture β β rule: β β explain β β the code β β insights β β β β it back? β β yourself β β for long β β 1.State β β β β β β term β β problemβ β Test: β β Tasks: β β β β 2.Brain- β β explain β β β’ Extend β β Methods: β β storm β β to a β β β’ Modify β β β’ Notes β β 3.Find β β colleagueβ β β’ Debug β β β’ Teach β β gaps β β without β β β’ Adapt β β β’ Blog β β 4.Ask β β looking β β to new β β β’ Review β β smart β β at code β β contextβ β later β ββββββββββββ ββββββββββββ ββββββββββββ ββββββββββββ β β β βββ Repeat per concept βββΊ β βββββββββββββββββββββββββββββββββββββββββββββββββββββ
If VERIFY fails β go back to UNDERSTAND (you copied, didn't learn) If APPLY fails β go back to VERIFY (you memorized, didn't understand)Source: learning-with-ai.md:208
19. Security 3-Layer Defense
Section titled β19. Security 3-Layer DefenseβThe full security document (security-hardening.md) organized as 3 defense layers:
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β SECURITY 3-LAYER DEFENSE β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€ β β β TIME βββββββββββββββββββββββββββββββββββββββββββββββββββΊ β β Before During After β β β β βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββ β β β LAYER 1 β β LAYER 2 β β LAYER 3 β β β β PREVENTION β β DETECTION β β RESPONSE β β β β β β β β β β β β β’ MCP vetting β β β’ Prompt inject β β β’ Secret β β β β workflow β β detection β β rotation β β β β β’ Version β β β’ Output β β β’ MCP β β β β pinning β β scanning β β isolation β β β β β’ .claudeignore β β β’ Anomaly β β β’ History β β β β β’ Input hooks β β monitoring β β rewriting β β β β β’ Safe MCP list β β β’ Secret leak β β β’ Incident β β β β β’ Permissions β β detection β β reporting β β β β β’ Integrity β β β’ Unicode/ANSI β β β’ Post-mortem β β β β scanning β β filtering β β & rotation β β β β β β β β β β β β GOAL: Block β β GOAL: Catch β β GOAL: Limit β β β β threats at β β attacks in β β damage and β β β β entry points β β real-time β β recover fast β β β βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββ β β β β Adoption path: β β Solo dev β Layer 1 basics (output scanner) β β Team β Layer 1 + 2 (+ injection hooks) β β Enterprise β All 3 layers (+ ZDR + verification) β β β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββSource: security-hardening.md:24/205/345
20. Secret Exposure Timeline
Section titled β20. Secret Exposure TimelineβEmergency response when a secret (API key, token, password) is exposed:
SECRET EXPOSED β Emergency Response Timeline βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
0 min 15 min 1 hour 24 hours β β β β βΌ βΌ βΌ βΌ ββββββββββββββββββββ βββββββββββββββββββ ββββββββββββββββββ β β±οΈ FIRST 15 MIN β β β±οΈ FIRST HOUR β β β±οΈ FIRST 24H β β Stop the β β Assess damage β β Remediate β β bleeding β β β β β β β β 3. Audit git β β 6. Rotate ALL β β 1. REVOKE key β β history β β related β β immediately β β (rewrite if β β credentials β β (AWS/GH/ β β pushed) β β β β Stripe) β β β β 7. Notify team β β β β 4. Scan deps β β /compliance β β 2. Confirm β β for leaked β β (GDPR/SOC2) β β exposure β β keys β β β β scope β β β β 8. Document β β (local or β β 5. Check CI/CD β β incident β β pushed?) β β logs β β timeline β β β β β β β ββββββββββββββββββββ βββββββββββββββββββ ββββββββββββββββββ
SEVERITY GUIDE: βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β Local only (not pushed) β Revoke + rotate (steps 1-2) β β Pushed to remote β Full timeline (steps 1-8) β β Public repo exposure β Assume compromised, rotate β β EVERYTHING, check for abuse β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββSource: security-hardening.md:347
Back to Guide README | Cheatsheet | Main README