LMPL specifications that reconstruct Claude Code's internal architecture from the public analyses of the March 2026 source map leak (cli.js.map shipped in @anthropic-ai/claude-code@2.1.88).
Each spec uses the @profile("agentic") / @intent("specify") LMPL profile and follows the same two-layer structure: an idealized skeleton, then a refined expansion grounded in source-level findings. No source code is reproduced — the pseudocode is an independent expression of the documented control flow.
| # | Spec | Captures | Lines |
|---|---|---|---|
| 01 | Core agentic loop | queryLoop(), State, Continue Site pattern, transition reasons, recovery branches |
467 |
| 02 | Tool catalog | Tool interface, registry, 6-stage lifecycle, concurrency partitioning, 5 canonical tools | 518 |
| 03 | Sub-agents & coordinator | spawn_subagent, 3 isolation levels, cache-alignment, coordinator as prompt contract |
402 |
| 04 | Guardrails & permissions | can_use_tool pipeline, 6 permission modes, yoloClassifier, bashSecurity 5-layer |
489 |
| 05 | MCP client | Transports, lifecycle, tools/resources/prompts, namespacing, trust model | 612 |
| 06 | Skills & slash-commands | Frontmatter contract, discovery, progressive disclosure, Skill meta-tool |
472 |
| 07 | Hooks | 9 events across 3 families, exit-code conventions, effect model, Guardrail integration | 492 |
| 08 | Plugin ecosystem | Manifest, components, marketplaces, activation lifecycle, version resolution, trust | 654 |
| 09 | Memory tiers | CLAUDE.md hierarchy, auto-memory (memdir/), JSONL sessions, filter pass |
558 |
| 10 | Context compaction | 4-tier pipeline, circuit breaker, PreCompact hook integration, recovery |
513 |
| 11 | Prompt cache | SYSTEM_PROMPT_DYNAMIC_BOUNDARY, 14 break vectors, sticky latches, fork-based sharing |
441 |
Read in any order — each spec stands alone — but specs with fewer dependencies are easier entry points.
01 Core loop
/ | | \
02 03 09 (02 Tool catalog, 03 Sub-agents, 09 Memory)
/ / \ |
04 / \ |
↑ 10 11 (10 Compaction uses 03; 11 Prompt cache uses 03+09)
| ↑
07 (07 Hooks extends 04 and integrates with 02/10)
↑
05 (05 MCP consumes 02, 04)
↑
06 (06 Skills consumes 02, 05)
↑
08 (08 Plugins packages 06/07/03/05)
Suggested reading orders:
- Quick tour — 01, 02, 04, 08 (loop → tools → guardrails → how it all gets packaged)
- Runtime-first — 01, 02, 03, 04, 10, 11 (loop + everything that runs per-turn)
- Extension-first — 01, 06, 07, 08, 05 (loop + every way to extend it)
Every spec carries:
- Scope & non-goals up front.
- Types section defining the vocabulary the spec uses.
- A refined expansion layer with source-grounded fidelity (behavioral scars, not just abstract intent).
- LMPL gaps — a running list of language-level features the specs need but don't have. Roughly 60 proposed extensions across the set; useful as an artifact for evolving the LMPL profile itself.
- Cross-spec references table and a References section citing the public analyses used as source grounding.
These specs reconstruct behavior documented in the public analyses of the 2026-03-31 leak. Representative sources (each spec cites its own):
- alejandrobalderas, claude-code-from-source — https://github.com/alejandrobalderas/claude-code-from-source
- 777genius, claude-code-working — https://github.com/777genius/claude-code-working
- cablate, claude-code-research — https://github.com/cablate/claude-code-research
- l3tchupkt, claude-code — https://github.com/l3tchupkt/claude-code
- bits-bytes-nn, "Claude Code Architecture Analysis" — https://bits-bytes-nn.github.io/insights/agentic-ai/2026/03/31/claude-code-architecture-analysis.html
- Blake Crosley, "What the Claude Code Source Leak Reveals" — https://blakecrosley.com/blog/claude-code-source-leak
- Siddhant Khare, "The plumbing behind Claude Code" — https://siddhantkhare.com/writing/the-plumbing-behind-claude-code
- Haseeb Qureshi, "Inside the Claude Code source" — https://gist.github.com/Haseeb-Qureshi/d0dc36844c19d26303ce09b42e7188c1
- Varonis Threat Labs, "A Look Inside Claude's Leaked AI Coding Agent" — https://www.varonis.com/blog/claude-code-leak
- Redreamality, "Claude Code Leak: A Deep Dive" — https://redreamality.com/blog/claude-code-source-leak-architecture-analysis/
No source code is reproduced in this repository. All pseudocode is independent LMPL expression of documented control flow.
The pseudocode uses the agentic profile defined in hiivmind-lmpl (spec/profiles/agentic.md). Key constructs used throughout:
agent_loop { observe / reason / act / update / until }— the canonical observe-reason-act skeleton@max_iterations,@requires_approval,@boundary— agent-level annotationsrequire/ensure/invariant— pre/post/invariant contractsconcurrently { ... } join— parallel fan-out (used for tool partitioning and swarm sub-agents)attempt / on failure— tool failure handling
Specs deliberately note where LMPL doesn't quite fit, rather than papering over the gap — these are the "LMPL gaps" sections.