Paper · Essay · 50 min · April 2026
Inside Claude Code: Tamagotchi pets, hidden codenames & the full architecture
1,900 TypeScript files, 30+ tools, a dreaming agent, a stealth mode, and an obfuscated model family. A forensic reading. No source is reproduced.
Claude Code hides a Tamagotchi pet system with 18 species and a rarity system straight out of Pokémon. It has a dreaming agent that consolidates memories while you sleep. It runs an undercover stealth mode that scrubs every trace of AI from commits. Buried in the source, an obfuscated codename reveals an unreleased model family.
This article exposes all of it, plus the architecture behind Anthropic's AI coding agent. No code is reproduced. Only architecture, flows, and design decisions.
~1,900
TypeScript files · ~45 MB of source
30+
Built-in tools
~80
Slash commands
35+
Subsystems
01BUDDY: the Tamagotchi easter egg
Hidden in src/buddy/ is a complete virtual pet. Every user gets a unique companion, generated deterministically from their user ID. Designed as an April 1, 2026 easter egg. It is remarkably deep.
Eighteen species: duck, goose, blob, cat, dragon, octopus, owl, penguin, turtle, snail, ghost, axolotl, capybara, cactus, robot, rabbit, mushroom, chonk. Five-tier rarity: Common 60%, Uncommon 25%, Rare 10%, Epic 4%, Legendary 1%. Common pets get no hat. Five stats: debugging, patience, chaos, wisdom, snark.
Two-level data model. CompanionBones (species, rarity, eye, hat, shiny, stats) are recomputed from the user ID every session. Editing config cannot grant you a Legendary. CompanionSoul (name, personality, hatch date) is persisted, generated once. Sprites are ASCII, 5×12, with idle frames. Launch window: 1–7 April 2026 teaser, then /buddy is permanent. Anthropic employees have access regardless of date.
02KAIROS: the always-on dreaming agent
KAIROS turns Claude Code from a session tool into a persistent assistant. Daily logs. Continuous between sessions. And it dreams. During inactivity, AutoDream consolidates accumulated logs into structured topic files.
- 01Orient: scan the memory directory, read the index and existing topic files.
- 02Gather: collect signal from daily logs, detect drifted memories, grep transcripts.
- 03Consolidate: merge into topic files, convert relative dates to absolute, remove contradicted facts.
- 04Prune & Index: update MEMORY.md, 25KB cap.
The consolidation runs as a forked sub-agent with read-only Bash (ls, find, grep, cat, stat, wc, head, tail). Three gates before dreaming starts: 24 hours, 5 sessions, no other process holding the lock. Stale PID reclaimed after 1 hour.
03Undercover Mode
In a public or open-source repository, Undercover Mode activates silently. The model is told: You are operating UNDERCOVER in a PUBLIC/OPEN-SOURCE repository. Do not blow your cover.
- Internal model codenames (Capybara, Tengu…) stripped.
- Unreleased version numbers gone.
- No “Claude Code”, no Co-Authored-By, no attribution.
- Applies to commits, PRs, Bash prompts, the system prompt.
Auto-detect unless the remote matches an internal allowlist of ~20 Anthropic repos. There is no force-OFF, by design, to protect against codename leaks. CLAUDE_CODE_UNDERCOVER=1 forces the mode on, not off. External builds contain none of this logic.
04Capybara: the obfuscated model family
Scattered references to Capybara, an internal codename for a new model family. Protected by layers: build-time excluded-strings canary, hex encoding in source, maskModelCodename() at display (cap*-v2-fast), Undercover Mode on commits, feature flags. The name is treated as a leak surface, not a joke.
05Eight layers
User Interface (Ink/React) → Commands & Skills → Conversation Loop → Tool System → Services → Persistence & Memory → Bridge → Remote. Every user message flows down. Tool results flow up.
The runtime is Bun, not Node. Fast startup, native TypeScript, bun:bundle for compile-time flags and dead-code elimination. 87 compile-time flags; hundreds more at runtime via GrowthBook (tengu_*). Internal builds include everything. Public builds strip it.
The conversation loop is a while(true) with five phases: pre-process (auto-compact), API call (SSE), stream, execute tools, continue or exit. Tools: 30+, partitioned into concurrent reads and serial writes. Permissions: seven modes, six priority levels, fail-closed. Bash: Tree-sitter AST plus a legacy parser, 23 security checks. Sandbox: Seatbelt on macOS, bwrap on Linux.
06Memory, agents, the bridge
Three-tier compaction before the API call: microcompact (old tool results), session memory, full compact as fallback. Triple memory: Auto Memory across sessions (MEMORY.md), Session Memory inside a session, Extract Memories as a background forked agent.
Sub-agents in four modes: synchronous, asynchronous, teammate, parallel. MCP to external tool servers. Plugins and ~15 bundled skills. A bridge that unifies CLI, desktop, web, mobile. About 80 slash commands. Full Vim. Streaming voice.
What makes it unique
- 01Exhaustive Bash security: 23 checks, fail-closed.
- 02Multi-level compaction.
- 03Triple memory.
- 04A serious multi-agent system.
- 05One engine on every surface.
- 06Plugins, MCP, skills as an ecosystem.
- 07A terminal that is actually a product: Vim, voice, React.
This analysis is educational and does not reproduce source code. The codebase analysed is the property of Anthropic. What's described here is the architecture and the design decisions: the what and the why, not the how.