Back to Vault
Claude Code Internals
Tier 1

claude-code-source-analysis (xiaonancs)

View on GitHub Fetched 2026-07-02 4 related flows

Summary

A systems-engineering reconstruction of the complete Claude Code agent harness from a reverse-engineered v2.1.88 snapshot (includes the extracted source zip plus appendix analyses). Part of a series that also covers OpenAI Codex CLI internals, giving a comparative harness view.

Key Takeaways

  • Reconstructs the full harness from an actual extracted v2.1.88 snapshot
  • Sister studies (Codex CLI) enable cross-harness comparison
  • Strong on context management and compaction mechanics

Reliability Note

Independent reverse-engineering effort - unofficial, verify against official Anthropic docs and behavior.

Flows informed by this source

4
Flows category icon
Memory & Context

Implement Context Compaction

Keep long agent sessions alive by compacting old conversation into structured summaries before the context window fills.

01Add token accounting
02Design the structured summary format
03Implement the compaction operation

+1 more steps to Done

Best forproduction-grade builds with strict verification

4 steps90-120 minutesAdvanced
Flows category icon
Memory & Context

Session Summaries That Survive Compaction

Write durable session summaries at the right moments so knowledge outlives compaction and process restarts.

01Define what deserves to survive
02Write at the moments that matter
03Load summaries into new sessions

+1 more steps to Done

Best forbuilders who have shipped a basic app before

4 steps60-90 minutesIntermediate
Flows category icon
Memory & Context

Prompt-Cache-Aware Conversation Design

Structure your agent's context for prefix caching: stable prefixes, append-only history, and cache-friendly dynamic content.

01Audit context stability
02Restructure for stable-first layout
03Verify cache hits and measure savings

Best forbuilders who have shipped a basic app before

3 steps45-75 minutesIntermediate
Flows category icon
MCP & Tooling

Tool Result Size Management

Stop tool outputs from flooding context: budgets per tool, smart truncation, pagination, and reference-based results.

01Budget every tool's output
02Truncate to preserve signal
03Paginate lists and reference artifacts

+1 more steps to Done

Best forbuilders who have shipped a basic app before

4 steps60-90 minutesIntermediate

Made with Emergent