[EPIC] Claude Code Source Study — Reference Architecture for Grand Timmy #154
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What We Have
Anthropic open-sourced Claude Code. We have the full TypeScript source — 512K lines, 1,884 files — in
Timmy_Foundation/claude-code-src. This is not the plugin wrapper from GitHub. This is the runtime: tools, services, memory, compaction, agents, cost tracking, hooks, bridge.Why It Matters
Every major ticket in the Uniwizard backlog (#94) maps to something Claude Code has already built and shipped at production scale. We are building in Python what they built in TypeScript. Studying their source before building ours means:
Source Map
Hidden Feature Flags
Claude Code has unreleased capabilities behind feature gates:
PROACTIVEKAIROSAGENT_TRIGGERSAGENT_TRIGGERS_REMOTEMONITOR_TOOLCOORDINATOR_MODEWEB_BROWSER_TOOLWORKFLOW_SCRIPTSCONTEXT_COLLAPSEUDS_INBOXSeveral of these map directly to capabilities we're building.
Backlog Mapping
services/compact/services/extractMemories/tools/AgentTool/services/compact/+memdir/memdir/+services/SessionMemory/utils/model/tools/shared/services/api/coordinator/services/compact/Study Protocol
For each ticket, the assignee should:
Children
See linked issues below for per-component study tickets.
Architecture Analysis Complete — 2026-03-31
Full report at
/tmp/claude-code-analysis.md(26KB). Key findings:Top 5 Patterns to Adopt (priority order)
Concurrent tool execution — Read-only tools (file read, search, grep) run in parallel up to 10x. Source:
src/services/tools/toolOrchestration.ts. Our tools are 100% serial. This is the biggest perf win.Progressive compaction — 3-tier context shrinking: microcompact (summarize old tool results in-place, no API), autocompact (full compaction at token threshold), reactive compact (emergency on prompt_too_long). Source:
src/services/compact/. We do one-shot compression.Tool result budgets — Large outputs get persisted to disk with a preview replacing the content in context. Source:
src/utils/toolResultStorage.ts. Prevents context blowout from huge grep/find results.Permission wildcards — Rules like
Bash(git:*)auto-approve git commands. Per-tool, per-source (user/project/policy). Source:src/utils/permissions/. We have simple y/n.JSONL session storage — Append-only writes (crash-safe),
readHeadAndTail()for fast browsing. Source:src/utils/sessionStorage.ts. Our full JSON writes risk corruption on crash.Hidden Capabilities Behind Feature Flags
Security Observations
tengu_— internal codename for Claude Codeprocess.exit(1)if--inspectdetected on external buildsAnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHSOur Advantages
Backlog Alignment
Every study issue (#155-165) maps to a concrete Hermes improvement. Priority execution order: