# "2025-12-22-RFKCzGlAU6Q-how-claude-code-works-promptlayer"
<!--
ref: @content/youtube/aie/2025-12-22-how-claude-code-works-promptlayer
triggers: [need for efficient agent design, context management issues, over-engineering concerns, tool integration challenges]
trigger_prompt: When exploring how to build effective AI agents without unnecessary complexity or when facing challenges with context management and tool usage.
version: 4
updated_at: 2026-10-31T19:12:16.540Z
-->

Claude Code (AI Engineer, 2025-12-22): Claude Code's breakthrough is "boring": a simple master while-loop plus well-designed tools, riding on progressively better models.

Jared, founder of PromptLayer (NYC-based AI engineering platform processing millions of LLM requests/day), delivers a closing conference workshop dissecting Claude Code's architecture and extracting lessons for agent builders.

## Core Thesis
Claude Code's breakthrough is "boring": a simple master while-loop plus well-designed tools, riding on progressively better models. The engineering instinct to over-scaffold with chained prompts, DAGs, classifiers, and RAG is the wrong move — trust the model, keep tools human-mimicking and rigorous, and treat context as the primary enemy.

## Key Insights

- **The winning architecture is ~4 lines**: while there are tool calls, run the tool, return results, repeat. Codex, AMP, and Cursor Composer converge on the same loop — "the real difference is the model."
- **Less scaffolding, more model**: Tool-calling is now native. Elaborate prompt chains and JSONformer-era workarounds are wasted effort because model flaws get fixed in the next release ("the AGI pill").
- **RAG is out, grep is in**: Claude Code skips embeddings/vector DBs entirely and uses grep as a tool call — mimicking what a human at a terminal actually does.
- **Context is the boogeyman**: "The longer the context, the stupider the agent gets." Sub-agents (via the `Task` tool), diff-based edits, offloading web fetches to cheaper models, and markdown-file sandboxes all exist to protect the main loop's context window.
- **Bash is the universal adapter**: Training data abundance makes shell tools dominant. Some argue for "one mega tool call" over hundreds of specialized ones.
- **To-do lists are prompt-based, not enforced**: The schema is almost trivial; works only because modern models follow instructions reliably. Benefits: forces planning, enables resume, UX signal, steerability.
- **H2A async buffer** decouples I/O from reasoning and smartly summarizes the middle of context while preserving the head.
- **Skills = extendable system prompt**: Solves CLAUDE.md bloat but discoverability is imperfect — users often invoke manually, suggesting a post-training gap.
- **Reasoning budget as a parameter**: "think" → "ultrathink" ladder exposes the token budget as a tunable knob.
- **Sandboxing is where the complexity lives**: Prompt injection via web fetch + shell is the real attack vector; containerization, URL blocklists, and bash-prefix gating dominate the codebase.
- **DAGs are obsolete for general-purpose agents** but still useful inside tool calls for deterministic output structure (e.g., travel itineraries, banking flows).
- **Evals beat benchmarks**: "Every model beats the benchmarks." Prefer back-tests on historical runs, point-in-time snapshots, and end-to-end headless runs. Watch "agent smell" — tool calls, retries, latency.
- **No global maximum in agent design** ("AI Therapist Problem"): Claude Code, Codex, Composer, Factory Droid, and Devon each win different use cases. Taste and architecture matter.
- **Handoff beats compact**: AMP's fresh-thread handoff pattern is "faster than reloading" vs. lossy summarization.
- **Higher-order agents are coming**: Headless Claude Code SDK as a pipeline component means developers stop calling model APIs directly and instead invoke agents in loops.

## Actionable Takeaways

1. **Adopt the one-hour rule**: If Claude Code can finish it in under an hour, just do it — don't ticket, don't prioritize.
2. **Build agents as a single while-loop + 5–10 bash-flavored tools**; delete scaffolding when iterating instead of adding it.
3. **Use unified diff edits** rather than file rewrites — shorter tokens, fewer mistakes.
4. **Offload to sub-agents** (`Task`) for long-running subprocesses, web fetches, and research to keep the main context lean.
5. **Give agents a sandbox** and instruct them to persist intermediate work as markdown files.
6. **Wrap genuine edge cases as rigorous, versioned, evaluable tool calls**; let the model explore everything else.
7. **Start evals with back-tests** on historical conversations — lowest lift, highest signal.
8. **Move bloat out of CLAUDE.md into skills**; expect to invoke them manually until training catches up.
9. **Keep humans in the loop** for merging auto-generated PRs (e.g., daily GitHub Action running Claude Code to update docs).
10. **Invest in spec/TDD workflows** for coding agents — tests compound agent effectiveness.
11. **Reserve DAGs for deterministic output structure**, not for research or exploration.
12. **Pick agents per task**: Claude Code for git/PR work, Codex for hard reasoning, Composer for speed.

## Notable Quotes

> "We literally rebuilt our engineering org around Claude Code."

> "Give it tools and then get out of the way. Less scaffolding, more model."

> "It's just one while loop with tool calls… this is basically four lines."

> "Bash is all you need."

> "The biggest enemy here is when your context is full, the model gets stupid for lack of better words."

> "Don't try to over-engineer around model flaws today because a lot of the things will just get better and you'll be wasting your time."

> "Now we have the coding agent prompting its own agents."

> "There isn't a global maximum… this is kind of my anti-AGI take."

> "Benchmarks have become marketing. Every model beats the benchmarks."

> "Trust in the model. When in doubt, rely on the model when you're building agents."

---

*You're reading a protocol on [protocol.supply](https://protocol.supply) — hosted, searchable knowledge for AI agents. Think Agent Skills, as an API: bootstrap once (`curl -sL https://api.protocol.supply/bootstrap`), search (`/search?q=…`), fetch (`/@repo/slug`).*

*Any skill can become a protocol, and any protocol installs as a local skill — tell your agent "install this as a skill" or see [`@protocol/protocol-to-skill`](https://api.protocol.supply/@protocol/protocol-to-skill).*