The argument in one line.
Claude Code's power comes from combining open-source infrastructure with the Claude API through a simple three-step orchestration loop—gather information, act on changes, verify results—that anyone can master by understanding its nine core architectural components: tools, cont.
Read if. Skip if.
- A developer or technical founder building AI agents who wants to understand Claude Code's architecture deeply enough to optimize token usage and design better workflows.
- An AI enthusiast with basic coding knowledge who's used Claude but never examined how its memory, context, and tool systems actually orchestrate together.
- A product builder considering Claude Code for a project and needs to know what's genuinely possible within its constraints before committing engineering time.
- You're looking for a quick tutorial on how to use Claude Code's UI — this is architectural deep-dive, not a getting-started guide.
- You have no interest in understanding the engineering layer and only want copy-paste prompts or workflows that work out of the box.
The full version, fast.
Claude Code operates on a gather-act-verify loop where it uses specialized tools — glob for file pattern matching, grep for content search, read for loading code, edit for surgical string replacements, and bash for running system commands — rather than reading entire codebases blindly. The context window is a fixed-size bucket that degrades in quality past 40-50% capacity, so managing it deliberately matters: PDFs can consume 98% of your window before a single prompt, but offloading to an external API like Gemini Flash via a skill reduces that to under 2%. CLAUDE.md acts as a persistent command center loaded at session start. Skills inject workflows on demand without polluting context. Sub-agents preserve fresh context windows for parallel tasks. Hooks attach automated behavior before or after any tool call.
Chat with this breakdown — free.
Sign in and you get 23 free chat messages on us — ask for the hook, quote a framework, find the exact transcript moment, generate a markdown action plan. Bring your own key when you want unlimited.
Create a free account →Where the time goes.

01 · Intro + cheat code
Hook, @claude-code-guide sub-agent trick as the research method, sets the 9-element agenda.

02 · TLDR architecture diagram
Four-layer overview: UI, Orchestration, Tool Execution, Security. Claude API is the intelligence; everything else is open-source scaffolding.

03 · Open-source foundations
React/Ink, TypeScript, Node.js, ripgrep — none invented by Anthropic. The magic is marrying them with the Claude API.

04 · Gather Act Verify loop
The single mental model governing every task. Gather = understand. Act = edit/create/bash. Verify = test and loop.

05 · Bug-fix walkthrough
Concrete login-bug example tracing all three phases. YOLO/bypass-permissions mode and agent browser verification.

06 · Permission modes intro
Default ask mode vs YOLO mode. settings.json breadcrumbs permissions over time.

07 · Claude toolkit overview
Six tool categories: file, search, execution, web, orchestration, extensions. How Claude decides which tool to use.

08 · File tools deep-dive
Read, Write, Edit (surgical string-replace), Glob (wildcard file finder). PDF token-cost warning.

09 · Grep and ripgrep
Three search modes: files_with_matches, content, count. ripgrep runs in parallel. Full search-to-read workflow.

10 · Bash explained
What bash means for non-developers. Short commands queue; long commands background. Git crash course.

11 · GitHub crash course
Branches, commits, main branch, sandbox environments. Lovable/Bolt vs Git discipline.

12 · Context window the bucket
CLAUDE.md + system prompt pre-fill 20-80%. /context demo. PDF nukes the window. Quality degrades past 40-50%.

13 · Compaction strategy
What compaction produces (sparse summary). Write your own summary first, then /compact so Claude weights it higher.

14 · Session management
Stateless sessions. What persists: files, CLAUDE.md, Git commits, installed packages, stored conversations.

15 · File snapshots
Before-edit snapshot saved in memory enables rollback. 5-step flow shown on screen.

16 · 5 ways to extend Claude Code
CLAUDE.md, Skills (just-in-time), MCP (cap at 1-3), Hooks (before/after events), Sub-agents (parallel workers).

17 · CLAUDE.md best practices
Routing source not instruction dump. Trigger words for freestyle commands. Dangers of global CLAUDE.md.

18 · Skills vs MCPs
MCPs auto-inject context; skills are on-demand. Convert rarely-used MCPs to skills.

19 · Permissions hierarchy
Org > User > Project. Most restrictive wins. Allow/block/ask states with concrete examples.

20 · Live demo and CTA
Builds read_large_doc skill live. Raw PDF = 1.8M tokens; markdown extraction = 22K (98% reduction). CTA to community.
Lines worth screenshotting.
- Claude Code's architectural core is a CLI built on React, TypeScript, and Node.js — all open-source infrastructure that existed before Anthropic — married to the Claude API to create the intelligence layer.
- Claude Code reads the CLAUDE.md file as the first action in every new terminal session — it is the command center that everything else inherits from.
- The three-step loop (gather → act → verify) is Claude Code's fundamental operating cycle for every task: read the prompt and CLAUDE.md, make changes, then run a test to confirm correctness.
- The @claude-code-guide sub-agent is a built-in expert that answers questions about the Claude Code CLI, the agent SDK, and the Claude API — query it directly by tagging it.
- Hallucination increases significantly around 40-50% context window usage — the practical implication is to clear or compact before the window is half full, not when quality degrades.
- YOLO mode (dangerously skip permissions) is legitimate for production workflows where constant approval prompts would break an automated pipeline.
- A PDF-offloading skill that reads long documents externally instead of injecting them into the context window can cut token usage by 98% on document-heavy tasks.
- Compaction is nondeterministic — Claude chooses what to prioritize when compressing, which is why sub-agents with fresh context windows produce more reliable output than a single long session.
- The open-source infrastructure layer (file traversal, code search, tool execution) is why OpenCode and other forks can replicate Claude Code's core mechanics — the differentiator is the Claude API.
- Claude Code is a combination of proven engineering standing on open-source shoulders plus the Claude model — removing either layer breaks the product.
- The permission layer is designed to keep Claude Code as a coding companion, not a fully autonomous agent — YOLO mode removes this constraint at the user's explicit choice.
- Building a PDF skill that offloads document reading to an external tool rather than context injection is the most impactful single optimization for document-heavy Claude Code workflows.
Every Claude Code Failure Traces Back to One of Nine Architectural Elements
Mark Kashef's 63-minute teardown reduces Claude Code to a single governing loop — Gather, Act, Verify — and shows that the nine elements (tools, context, compaction, sessions, skills, MCPs, hooks, sub-agents, permissions) are all just mechanisms that support or threaten that loop.
- Four-layer stack: UI, Orchestration, Tool Execution, Security — the Claude API is the intelligence; everything else is open-source scaffolding built around it
- Understanding the stack clarifies what Anthropic controls versus what the open-source community can modify
- Every task follows the same three phases: Gather (understand), Act (edit/create/run), Verify (test and loop)
- Mapping a failure to a specific phase is the fastest path to a correct diagnosis and fix
- Six tool categories: file, search, execution, web, orchestration, extensions — Claude selects the tool based on the task, not the user's instruction
- Understanding which tool category a task falls into predicts which failure modes to watch for
- Edit uses surgical string-replace, not full-file rewrites — it is faster and safer for targeted changes
- PDF token-cost warning: always extract to markdown before feeding a PDF to Claude Code
- CLAUDE.md and system prompt pre-fill 20-80% of available context before the task prompt arrives
- Quality degrades past 40-50% fill — monitor context usage the same way you monitor memory usage in a running process
- Auto-compaction produces a sparse summary — write your own summary of the current task state before /compact so Claude weights it higher
- Manual compaction outperforms automatic because you control what gets preserved
- Sessions are stateless — what persists is files on disk, CLAUDE.md, git commits, and installed packages
- Designing your workflow around what actually persists (files and git) is more reliable than relying on conversation memory
- CLAUDE.md, skills (just-in-time), MCPs (cap at 1-3), hooks (before/after events), sub-agents (parallel workers) — each extension type has a distinct cost and use case
- Skills and MCPs are the most commonly misused pair — skills are free until invoked, MCPs cost context every session
- MCPs auto-inject context; skills inject context only when explicitly invoked — the difference is who pays the context cost and when
- Convert any MCP you use fewer than three times per day into a skill — it preserves the capability without the persistent context tax
- Raw PDF at 1.8 million tokens versus markdown extraction at 22,000 tokens — a 98% reduction that makes previously impossible context budgets manageable
- The read_large_doc skill is built live in the demo — the pattern is extractable and reusable for any document-heavy workflow
Terms worth knowing.
- CLI (command-line interface)
- A text-based way to interact with a program by typing commands into a terminal instead of clicking buttons in a graphical interface.
- Sub-agent
- A specialized helper agent that runs inside a larger agent system with its own prompt, tools, and isolated context window, used to handle a focused task without polluting the main session.
- Agent SDK
- A software development kit that lets developers build their own custom AI agents using the same underlying components as a vendor's pre-built agent.
- ASCII art
- Pictures or diagrams drawn using only standard keyboard characters, often used in terminals where images can't be displayed.
- Permission layer
- The safety system that asks the user to approve actions like editing files, running commands, or installing packages before the agent executes them.
- YOLO mode / bypass permissions
- A setting that disables approval prompts and lets the agent take any action without asking, trading safety for speed.
- Orchestration layer
- The decision-making part of an agent system that picks which tools to use, in what order, based on the user's request.
- Opus 4.5
- The high-end Claude model variant tuned for complex reasoning and coding tasks, with a 200,000-token context window.
- Open source
- Software whose source code is publicly available so anyone can read, use, modify, or build on it for free.
- IDE (integrated development environment)
- An application like VS Code or Cursor that combines a code editor, file browser, terminal, and debugging tools into one workspace.
- CLAUDE.md
- A markdown file placed in a project that the agent reads first on every new session, used as a persistent instruction manual and command center for that project.
- Plan mode
- A mode where the agent explores the codebase and writes out an execution plan for the user to approve before any files are changed.
- Bash
- A scripting language and shell that lets programs run commands directly on the operating system, used here to give the agent control of the local computer.
- Package
- A pre-built bundle of code that adds ready-made functionality to a project, installed from a public library so developers don't write common features from scratch.
- Context window
- The total amount of text (measured in tokens) that a language model can hold in active memory at once during a single conversation.
- Token
- A chunk of text — roughly three-quarters of a word — that language models use as their basic unit when counting input and output limits.
- Read tool
- The built-in capability that lets the agent open and load the contents of a file into its working memory.
- Write tool
- The built-in capability that lets the agent create new files from scratch, such as code files, configs, or markdown documents.
- Edit tool
- The built-in capability that makes surgical changes to an existing file by finding an exact piece of text and replacing it, instead of rewriting the entire file.
- Glob
- A file-pattern search that uses wildcards like *.ts to find every file matching a naming pattern across a project.
Things they pointed at.
Lines you could clip.
“The actual engineering is unbelievably simple. It is just the way that everything comes together where you have this harmony of orchestration that makes these agentic workflows possible.”
“The goal is that you are a human in the loop. It was not designed to just go off on its own.”
“You can nuke your entire laptop, you can nuke different services if you let it run wild without understanding exactly what it is doing.”
“The raw PDF was showing 1,800,000 tokens. But proper extraction gives us only 22,000 tokens. So we went down by 98%.”
“You can think of this context as a bucket. And in the bucket, as you have a longer conversation, that bucket fills up until it gets to the very top.”
Word for word.
Don't just watch it. Burn it in.
See every word as it's spoken — crank it to 2× and still catch all of it. The same dual-channel trick behind Amazon's Kindle + Audible.
The bait, then the rug-pull.
Mark Kashef spent hours asking Claude Code to explain itself, then rebuilt the whole map from scratch. The promise is direct: watch this once and you will understand what is actually happening behind the terminal better than 99% of people. The class-marker hook in the title lands before the first sentence is done.
Named ideas worth stealing.
Gather Act Verify
- Gather (read/search/understand)
- Act (edit/create/bash)
- Verify (test/check/loop)
The atomic task loop. Every Claude Code session runs this until complete or context runs out.
The Context Bucket
200K-token window as a physical budget. CLAUDE.md + system prompt pre-spend it. PDFs are budget-killers. Quality degrades past 40-50%.
CLAUDE.md as routing source
One-line pointer to a playbook file rather than inlining all instructions. Use trigger words for behavior changes.
Skills vs MCPs
- MCPs: always-on, auto-inject, bloat context
- Skills: just-in-time, only loaded when invoked
Convert rarely-used MCPs to skills to reclaim context budget.
Permission tiers Org User Project
- Org: company-wide policy
- User: personal settings
- Project: project-specific rules
Most restrictive tier wins. settings.json global vs settings.local.json project-specific.
How they asked for the click.
“Check out the first link in the description below for my early AI adopters community. A beginner to intermediate course is coming out in the next couple weeks.”
Soft sell after demonstrating real value. Two-tier: free diagram download (second link) and paid community (first link). Well-earned by runtime.






























































