OR Key
drop another .md file to compare - side-by-side diff against claude-code-internals

claude-code-internals

Reference notes on how the assistant works under the hood.
personal 2 files

What it does for you

Reference notes on how the assistant works under the hood.

What it produces

A recent result, so you can see the kind of work it returns.

loading…

How to get it

These run inside the Snappy workspace. Want this working in your business? I set skills like this up with you, in one focused week.

Work with me
For developers how this skill is built, graded, and how it runs

at a glance- the short version

eval modeauto-shape
stages3

what's inside - the parts that make up a skill 2/4 present

A skill is just a few plain-text files. Only the main one is required. The rest are optional, added as the work needs them. This is what the skill is made of; how it runs is just below.

The skill
state/skills/claude-code-internals/SKILL.md present
the skill itself, in plain text
The main file. It says what the skill is and lays out the steps in plain English.
Code
state/lib/claude-code-internals.ts not present
code the skill can run
Optional. Many skills are just words and need no code at all.
Scripts
state/bin/claude-code-internals/ not present
helper scripts
Optional. Added when a skill has a few commands to run.
Loader
state/skills/claude-code-internals/AGENTS.md present
what the AI loads on the fly
Loaded automatically the moment this skill is needed. Kept short on purpose.

how it runs - the shared frame every skill uses 2/5 present

Every skill runs the same way. One part does the work, a separate part checks it, and a short loader hands the AI exactly what it needs for the job. Anything this skill doesn't use shows a one-line note saying why, on purpose, not by accident.

makes the work The worker
inferred
strings 10 from a command
No worker named, so the first command in the skill is treated as the worker.
checks the work The reviewer
inferred
shape gate an automatic check
The check is an automatic pass or fail on the shape of the result, run separately from the work itself.
frame
learns Self-correction
not present

This skill doesn't fix its own gaps yet.

tidies up Background fixes
present
queued for rewrite runs in the background
Bigger fixes that can't be made on the spot get queued and rewritten in the background later.
remembers Run history
present
state/log/evals.ndjson auto-shape runs
Every run is written down here, so the next time this skill is used it already knows how the last runs went.
Critical rules the things this skill must not get wrong
  1. Use dynamic paths. Never hardcode an installed Claude version.
  2. Grep string literals, descriptions, error messages, and telemetry names; Bun-mangled identifiers are not stable evidence.
  3. Prefer openclaw dist when source shape matters; use strings for private-bundle facts, feature flags, embedded prompts, and tool descriptions.
  4. SDK source is canonical for Anthropic message/tool block shapes. Do not guess MessageParam, ContentBlock, or tool_use envelopes.
  5. Extracted source and strings are reference-only. Do not commit generated/extracted Claude source.
  6. Strings are evidence for constants and architecture anchors, not a complete behavioral proof. Runtime changes still need live Snappy verification.
  7. +3 more in AGENTS.md →

what it has learned - fixes written back in over time sample

When a run hits something this skill didn't handle, the fix gets written back into the skill so it doesn't happen again. FIXED means it was corrected on the spot. LOGGED means it's queued for a bigger rewrite. Either way, the skill gets a little better and never makes the same mistake twice.

  1. Loading feedback rows…

how the work flows- step by step

1 stage
openclaw (already readable, no extraction step)
```bash
# All bundled JS:
what this step does
Openclaw's dist/ is bundled but not minified; you can grep for symbol names, class shapes, and event-type strings directly. When you need clean unminified source, prefer the bundled Anthropic SDK first; fall back to the Bun strings dump only when openclaw doesn't cover what you need.
2 stage
What's the Read tool's description and which too
```bash
grep -E 'Reads a file from the local filesystem' /tmp/claude-code-full-strings.txt | head -5
what this step does
Returns multiple variants: the standard form ("You can access any file directly...") plus a stripped form gated on a qY(H) feature check. The references to "the ${iq} tool" in the Write description show the tool-name indirection - iq is a runtime constant identifying the Read tool, mangled by Bun.
3 control
What openclaw bundles handle agent dispatch / ho
```bash
ls /opt/homebrew/lib/node_modules/openclaw/dist/ | grep -iE '^(agent|action|spawn|hook|task)'
what this step does
Returns ~30 named bundles including agent-runtime-*.js, agent-runner.runtime-*.js, action-agents-*.js, action-spawn-*.js, agent-command-*.js, agent-events-*.js, agent-paths-*.js, agent-scope-*.js. Each is a logically-named slice of the runtime - Bun's compiler kept the input filenames as bundle prefixes, so the file system itself indexes the surface area.

SKILL.md- the skill, written out in plain English

claude-code-internals - agent-runtime reference map

Purpose

There are hundreds of thousands of runtime strings and bundled agent-runtime source lines on this Mac mini that snappy-os couldn't see until now: the Claude Code Bun binary (string-extractable), Robert's private Claude 2.1.88 bundle, openclaw's readable fork, and the vendored Anthropic SDK source. Without this skill, every subagent answering "how does Claude wire X" guesses from the public docs or invents from training. With it, the answer is one grep away.

The skill is the map, not the source. Source stays on disk where it already lives; we DO NOT commit it (size + legal). The deliverable is correct guidance + a verified grep cookbook.

Evidence surfaces

SurfacePathSizeReadability
Installed Claude Code (Bun binary)$(realpath "$(which claude)")Version-dependentVariable names mangled by Bun; string literals, regexes, error messages, system-prompt fragments, tool descriptions are intact and grep-clean
Claude private 2.1.88 no-telemetry bundle/Users/robertboulos/projects/claude-private/claude-private-2.1.88.run; extracted binary /tmp/claude-2188.Z9mvvM/claude-notelemetry360,815 strings in current dumpBest source for token/deferred-tool/MCP dedupe/readiness, config/session/telemetry/provider truth, and per-segment token accounting because it is the exact private bundle Robert supplied
openclaw (clean fork)/opt/homebrew/lib/node_modules/openclaw/ (npm-global)~333 k LoC across dist/ + node_modules/Bundled but readable - biggest single bundle is dist/session-BfHaPMI3.js (96,757 lines). Other large dists: dist/extensions/diagnostics-otel/index.js (~51k), dist/pi-embedded-Vw-lS5ti.js (~34k), dist/channel.runtime-C_Zbkn3e.js (~34k)
Anthropic SDK source (real .ts)/opt/homebrew/lib/node_modules/openclaw/node_modules/@anthropic-ai/sdk/src/~tens of k LoCFirst-class TypeScript source, no minification - resources/beta/messages/messages.ts is the canonical message-shape reference

The Claude Code symlink resolves to a versioned dir: ~/.local/bin/claude~/.local/share/claude/versions/<v>. Do not hardcode the version - resolve with realpath $(which claude) so the skill keeps working after Claude Code auto-updates. The private 2.1.88 artifact is separate and must be referenced by its explicit path.

Extraction recipe

Claude Code (run once per Claude Code update; cache in /tmp)

strings -n 10 "$(realpath "$(which claude)")" > /tmp/claude-code-full-strings.txt
wc -l /tmp/claude-code-full-strings.txt
# 254232 (installed 2.1.175 on 2026-06-13)

strings -n 10 keeps strings ≥10 chars, which is the sweet spot - drops the mangled identifier noise but keeps every system-prompt fragment, tool description, error message, regex literal, env-var name, and embedded JSON shape. The output is a flat newline-delimited file; grep -E is the entire analysis toolkit.

Cache invalidation: Claude Code auto-updates. If /tmp/claude-code-full-strings.txt is older than 1 day, or the symlink target version differs from the path used to extract it, re-run strings. The Critical Rules section in AGENTS.md codifies this.

Claude private 2.1.88 bundle (when auditing token/tool architecture)

cd /Users/robertboulos/projects/claude-private
rm -rf /tmp/claude-2188.Z9mvvM
mkdir -p /tmp/claude-2188.Z9mvvM
sh claude-private-2.1.88.run --target /tmp/claude-2188.Z9mvvM --noexec
strings -n 10 /tmp/claude-2188.Z9mvvM/claude-notelemetry \
  > /tmp/claude-2188.Z9mvvM/strings.txt
wc -l /tmp/claude-2188.Z9mvvM/strings.txt
# 360815 (2026-06-13)

Read resources/claude-source-coverage-matrix.md, resources/private-2188-anchor-index.md, and resources/claude-private-2.1.88-runtime-map.md before making any claim about Snappy's tool routing, MCP duplicate suppression, MCP readiness, token/cache economy, per-segment token attribution, deferred schema disclosure, ToolSearch refresh, plugin/output-style ownership, streaming recovery, context-window/output-token handling, shell safety, scheduled work, tool-result pairing, interrupted turns, native device tools, files/media/clipboard evidence provenance, timezone/freshness, network/proxy reachability, typed recovery objects, workspace scope, test/oracle quality, or regex classifier parity.

openclaw (already readable, no extraction step)

# All bundled JS:
find /opt/homebrew/lib/node_modules/openclaw \
  -type f \( -name '*.js' -o -name '*.mjs' -o -name '*.cjs' \) | wc -l

# Real Anthropic SDK TypeScript:
ls /opt/homebrew/lib/node_modules/openclaw/node_modules/@anthropic-ai/sdk/src/

Openclaw's dist/ is bundled but not minified; you can grep for symbol names, class shapes, and event-type strings directly. When you need clean unminified source, prefer the bundled Anthropic SDK first; fall back to the Bun strings dump only when openclaw doesn't cover what you need.

Self-bootstrap

If either surface is missing on a fresh machine:

# Claude Code (the binary):
test -e "$HOME/.local/share/claude/versions" \
  || npm install -g @anthropic-ai/claude-code

# Openclaw (the fork):
test -e /opt/homebrew/lib/node_modules/openclaw \
  || npm install -g openclaw

# Installed Claude strings dump (re-run any time the Claude Code binary updates):
test -f /tmp/claude-code-full-strings.txt \
  || strings -n 10 "$(realpath "$(which claude)")" > /tmp/claude-code-full-strings.txt

# Private 2.1.88 bundle dump (only when that artifact is the evidence target):
if [ ! -f /tmp/claude-2188.Z9mvvM/strings.txt ]; then
  cd /Users/robertboulos/projects/claude-private
  rm -rf /tmp/claude-2188.Z9mvvM
  mkdir -p /tmp/claude-2188.Z9mvvM
  sh claude-private-2.1.88.run --target /tmp/claude-2188.Z9mvvM --noexec
  strings -n 10 /tmp/claude-2188.Z9mvvM/claude-notelemetry \
    > /tmp/claude-2188.Z9mvvM/strings.txt
fi

The frontmatter install_check points at the versioned binary directory, which the reachability lint can probe directly. Openclaw is a soft secondary checked inline above (the lint takes one path per skill).

Grep cookbook

Verified working as of 2026-04-28. Each entry: question → command → why this shape works.

What does Claude Code's Edit tool actually advertise?

grep -E 'Performs exact string replacements in files' /tmp/claude-code-full-strings.txt

Returns the literal description string used in Edit's tool definition (and a nearby variant gated on the tengu_edit_minimalanchor_jrn feature flag). The string is exactly what gets sent to Sonnet/Opus as the tool spec - this is truth, not docs.

What's the Read tool's description and which tool does it cross-reference?

grep -E 'Reads a file from the local filesystem' /tmp/claude-code-full-strings.txt | head -5

Returns multiple variants: the standard form ("You can access any file directly...") plus a stripped form gated on a qY(H) feature check. The references to "the ${iq} tool" in the Write description show the tool-name indirection - iq is a runtime constant identifying the Read tool, mangled by Bun.

Which native modules does the Bun binary embed?

grep -E '/\$bunfs/root/[a-z-]+\.node' /tmp/claude-code-full-strings.txt | sort -u

Returns: image-processor.node, computer-use-swift.node, computer-use-input.node, audio-capture.node, url-handler.node. That's the entire native-extension surface area - anything beyond this is JS.

What's the Claude Code version + build metadata?

grep -E 'PACKAGE_URL|VERSION|BUILD_TIME|FEEDBACK_CHANNEL' /tmp/claude-code-full-strings.txt | head

Returns build-time constants such as VERSION, PACKAGE_URL:"@anthropic-ai/claude-code", etc. Useful when you need to correlate a behavior change to a specific release without hardcoding the installed version.

What openclaw bundles handle agent dispatch / hooks?

ls /opt/homebrew/lib/node_modules/openclaw/dist/ | grep -iE '^(agent|action|spawn|hook|task)'

Returns ~30 named bundles including agent-runtime-*.js, agent-runner.runtime-*.js, action-agents-*.js, action-spawn-*.js, agent-command-*.js, agent-events-*.js, agent-paths-*.js, agent-scope-*.js. Each is a logically-named slice of the runtime - Bun's compiler kept the input filenames as bundle prefixes, so the file system itself indexes the surface area.

How is the Anthropic message shape actually defined?

sed -n '1,80p' /opt/homebrew/lib/node_modules/openclaw/node_modules/@anthropic-ai/sdk/src/resources/beta/messages/messages.ts

This is real .ts source - no extraction needed. Read it directly when you need authoritative MessageParam / ContentBlock / Tool / ToolUseBlock shapes. Everything you'd otherwise hallucinate.

Where does Claude Code declare its hook lifecycle events?

grep -E 'PostToolUse|PreToolUse|UserPromptSubmit|SessionStart' \
  /tmp/claude-code-full-strings.txt | head -10

Returns the hook event names as they appear in the Claude Code wire (these are the strings the hook framework matches against in ~/.claude/settings.json).

Where does openclaw house its hook plumbing?

ls /opt/homebrew/lib/node_modules/openclaw/dist/ | grep -iE 'hook'

Returns the named hook bundles: hook-runtime-*.js (event dispatch), hook-runner-global-*.js (registry), hooks-cli-*.js (CLI surface), hooks-policy-*.js, hooks-status-*.js, internal-hooks-*.js, message-hook-mappers-*.js, commands-reset-hooks-*.js. Pick the bundle that matches the layer you're inspecting; the file system itself indexes the hook surface area.

What feature flags / experiments is Claude Code carrying?

grep -E 'tengu_[a-z_]+' /tmp/claude-code-full-strings.txt | sort -u | head -20

Returns the internal experiment IDs (tengu_edit_minimalanchor_jrn, tengu_noreread_q7m_velvet, ...). Each one toggles a different prompt or heuristic; reading the surrounding context tells you what alternate behavior is gated.

Deep dives (the bible - nine grep-verified resource files)

Built collaboratively by 6 parallel subagents on 2026-05-04 against the 2.1.126 binary, then extended with Robert's private 2.1.88 bundle. Each file is exhaustively cited or anchored by grep line. Total: ~7,600 lines across the resource set. Read whichever one matches the question; do not paraphrase, copy citations.

Question shapeResource file
How is the system prompt assembled? Identity, role line, output styles, CLAUDE.md scopes, system-reminders, thinking budgetsresources/system-prompt-assembly.md (412 lines)
What tools does the model see? Schemas, descriptions, side effects, gatingresources/tool-catalog.md (2551 lines, 41 tools)
How do hooks fire? Which events, which payload keys, what the matcher doesresources/hooks-and-lifecycle.md (1004 lines, 30 events)
How does plan mode actually work? Permission modes, ExitPlanMode approval, subagent inheritanceresources/plan-mode-and-permissions.md (729 lines)
What's the streaming event taxonomy? tool_use lifecycle, thinking blocks, SDK typesresources/streaming-and-tool-use.md (1460 lines)
How does the Agent (Task) tool launch subagents? Worktree isolation, fork vs general-purpose, pre-promptsresources/subagent-and-task-model.md (881 lines)
Which exact private 2.1.88 line ranges are closure-grade anchors for token, MCP, schedules, Computer Use, API, plugins, and the regex failure?resources/private-2188-anchor-index.md
How does the private 2.1.88 bundle prove deferred tools, ToolSearch, MCP dedupe/readiness, token/cache economy, per-segment token attribution, config/settings state, session/resume identity, diagnostics/telemetry, provider/billing truth, streaming recovery, context-window/output-token handling, plugin/output-style ownership, native device capabilities, shell safety, schedules, files/media, typed tool results, interrupted-turn recovery, and why Snappy regex routing is the wrong layer?resources/claude-private-2.1.88-runtime-map.md
What exact Claude-source facet must an audit cover, what source proves it, what Snappy owner/gate follows, and when is the audit incomplete?resources/claude-source-coverage-matrix.md
Which Snappy app failures, page-by-page findings, token/regex/god-object issues, proof labels, and rebuild gates must every audit or handoff carry?resources/snappy-audit-finding-map.md
Which Claude 2.1.88 mechanisms should Snappy copy first? Idle microcompact, small-fast background query lane, care prose, summary schema, Bash teaching, overload fallback, AskUser previewsresources/cc-2188-bring-to-snappy.md

Findings that contradict public docs (load-bearing for snappy-os mirroring)

These surfaced during the bible build. Each is a corrective the binary made clear that public sources do not.

  • 30 hook events, not 9. The user-docs cover 9 (UserPromptSubmit, PreToolUse, PostToolUse, Notification, Stop, SubagentStop, PreCompact, SessionStart, SessionEnd). The binary's Zod schema layer registers 21 more: PostCompact, PostToolUseFailure, PostToolBatch, SubagentStart, Setup, PermissionRequest, PermissionDenied, UserPromptExpansion, FileChanged, ConfigChange, CwdChanged, Elicitation, ElicitationResult, InstructionsLoaded, TaskCompleted, TaskCreated, TeammateIdle, WorktreeCreate, WorktreeRemove, plus permissions. See hooks-and-lifecycle.md for the dispatch table that maps each to its payload-key matcher.
  • 5 CLAUDE.md scopes, not 4. lXH() returns User / Local / Project / Managed + AutoMem (feature-flagged via P4()).
  • permissionDecision has 4 values, not 3. The fourth is defer (print-mode + solo-call only; silently dropped in interactive mode or with sibling tool calls pending).
  • Identity routing is isNonInteractive/hasAppendSystemPrompt, NOT OAuth-vs-API-key. Both auth modes land in firstParty via tq(). Only Vertex gets a dedicated branch.
  • No hard-coded "block side-effect tools in plan mode" gate. Plan-mode side-effect blocking is three SOFT layers: per-turn system-reminder prose, the Bash mode-validator suggesting setMode acceptEdits, and ExitPlanMode being the only mode-changer the model has tool-surface access to. "model is actor, prose is contract, tool surface shapes compliance."
  • ExitPlanMode is NEVER auto-approved (outside the remote-planning subagent path). checkPermissions always returns {behavior:"ask", message:"Exit plan mode?"}. Continuous per-plan consent IS the safety property.
  • There is no Task tool in 2.1.126. Canonical name is Agent; Task is just an alias on the same registration. TaskCreate/TaskGet/TaskList/TaskUpdate are FOUR DIFFERENT tools (a more-powerful TodoWrite with status, ownership, dependency graph), gated by qf().
  • TaskOutput is self-deprecated. Background result delivery is via synthetic user-role <task-notification> messages. The Agent tool prompt actively forbids polling the transcript mid-flight: "Don't peek. Reading the transcript mid-flight pulls the fork's tool noise into your context."
  • Hidden fork subagent type (agentType:"fork", tools:["*"], permissionMode:"bubble", empty system prompt). Fork is the implicit default when subagent_type is omitted; it shares the parent's renderedSystemPrompt so it's structurally cheaper than general-purpose.
  • Tool-result pairing repair (tengu_tool_result_pairing_repaired, "inc-4977"). Claude Code defensively walks every outgoing message list and strips orphaned tool_use blocks whose tool_result got dropped before the API returns 400. The day snappy-os ships a direct-anthropic backend with native tool_use, this is P0 to mirror.
  • Stream watchdog with 5 telemetry events (tengu_streaming_idle_warning, _idle_timeout, _stall, _stall_summary, _no_events). Auto-falls-back to non-streaming on zero-event streams. snappy-chat ships zero of this; the "stuck on streaming" symptoms have no diagnostic surface today.
  • thinking.display: 'omitted' is a third option besides "render thinking" / "disable thinking" - runs full budget but ships only the signature. Solves the "operator-internal reasoning leaks during demo/screenshot" problem without sacrificing reasoning quality.
  • Thinking budget is per-model {default, upperLimit} tuples, not the 4-tier {minimal:1024, low:2048, medium:8192, high:16384} map cited in some external docs. Each model maps to a tuple ranging 4 KB (claude-3-opus) to 64 KB (claude-opus-4-7). Runtime sends upperLimit-1 clamped against max_tokens-1 when enabled. Adaptive thinking is gated to opus-4-{6,7} + sonnet-4-6 only; runtime kill-switch via CLAUDE_CODE_DISABLE_ADAPTIVE_THINKING.
  • Bash safety is parsed, not guessed. The private 2.1.88 bundle exposes

command normalization, read-only/destructive/concurrency-safe tool metadata, command-injection checks, and approval distinctions. Snappy scripts must inherit that shape instead of treating shell work as a raw text box.

  • Schedules are structured runtime rows. Cron, created/last-fired time,

recurring/permanent state, invalid-row handling, and wakeups are visible in the private bundle. Snappy Scheduled/Scripts/Projects must share that substrate.

  • Files and media are typed IO. Downloads have retry/status/path safety,

image/document blocks have cost and processing behavior, and generated artifacts need provenance rather than raw links or unowned screenshots.

  • Token economy is cache-aware. The private bundle tracks input/output,

cache creation, cache read, service tier, server tool use, per-model usage, fork-agent usage, and session totals. A Snappy token audit that ignores cache stability or provider-actual usage is not a Claude-shaped audit.

  • Streaming recovery is explicit. Context-window and output-token failures

have named handling, resume/retry language, and model fallback hooks. Partial streaming cannot be treated as a successful answer just because text exists.

  • ToolSearch/MCP refresh is live. Tool, prompt, and resource list-changed

notifications invalidate cached capability state. A static connector/CLI page cannot be the source of truth for a dynamic capability graph.

  • MCP duplicate suppression and readiness are explicit. The private bundle

carries lazy dedupe for duplicate claude.ai connector servers and can proceed while connector readiness continues in the background. Snappy must not expose duplicate Data/CLI/Loader surfaces as if that were an acceptable product model.

  • Plugins and output styles are registries. Plugin manifests, slash-command

ownership, allowed tools, and output styles shape the turn. Hidden settings pages that alter those without context disclosure are a product contract failure.

  • Settings/config state is layered and write-guarded. User/project/local,

flags, policy, MCP servers, allowed/disallowed tools, auth helpers, OAuth account identity, and additional directories are explicit runtime state. Snappy Settings cannot be hidden trap doors or duplicate pages with no source-of-truth registry.

  • Session identity is durable. Continue, resume, fork-session,

resume-at-message, session IDs, request IDs, message UUIDs, interruption state, cost, and permission denials are first-class. Snappy row clicks, artifact reopen, project threads, retries, and edit branches must round-trip through stable IDs.

  • Telemetry is named event truth. API success/failure, compaction failure,

model fallback, config parse/stale writes, OAuth token refresh, tool success, and tool failure have tengu_* owners. Snappy diagnostics cannot be green summary cards while recent typed failures exist.

  • Provider and billing identity are explicit. Selected model, initial main

loop model, fallback, auth source, first-party/Bedrock/Vertex route, cache reads/writes, web-search requests, and unknown-cost handling are separate facts. Snappy must not hide provider/billing truth behind one chip label.

  • Token attribution is per segment. Claude tracks system prompt,

CLAUDE.md, deferred built-ins, MCP tools, slash commands, skills, agents, tool calls, tool results, attachments, cache writes, and cache reads. Snappy token audits must name which segment caused the spend.

  • The regex-token failure is named. P002 (produce + shows + pull

requests) proved that a raw prompt classifier can deny the model the right tool surface and hard-fail the run before dispatch. Do not accept synonym patches; only constant core + deferred tools + ToolSearch + advisory real payload measurement is Claude-shaped.

  • Current Snappy god objects and regex remnants are audit targets. The

private-runtime map records the current line-count offenders and the remaining regex/classifier files. Future work must split owners and shrink the ratchet; do not accept "we already fixed that" without refreshing counts.

  • God-object enforcement currently has a failing broad gate. The real

cross-repo gate is snappy-chat/scripts/lint-god-objects.ts; it currently fails because web/src/dispatch-card.tsx grew from baseline 7213 to 7851. Treat any "god objects handled" claim as false until that command passes.

What this skill does NOT do

  • Do NOT commit extracted source to the repo. Size (215 MB binary, ~333k

LoC of bundled JS) and legal posture (Anthropic's redistribution rights are not your problem to reinterpret). Reference the path + the grep instead.

  • Do NOT try to reverse-engineer the Bun binary into runnable source.

Variable mangling defeats decompilation. The string literals + function shapes are the readable layer; anything deeper is a research project.

  • Do NOT trust string-matched function bodies as canonical behavior. Bun's

compiler can inline + reorder; what you see in the strings dump is a byproduct of compilation, not the input. For canonical behavior, prefer openclaw's clean dist/ or the Anthropic SDK source.

  • Do NOT use this skill for "how do I use the chat surface" questions.

That's crayon-sdk (production patterns) or openui-mcp (live API). This skill answers "how does Claude itself work under the hood."

  • Do NOT bypass crayon-sdk's gotcha catalog. When you're integrating

with the chat UI and hit a production failure mode, crayon-sdk/gotchas.md has 14 hard-won traps. Internals-grep is for new questions, not relitigating known answers.

  • **Do NOT claim Snappy is "Claude-like" while it is using raw-input regex

classifier fast paths as the dispatch architecture.** The private 2.1.88 source points to a small always-on tool surface, deferred schema disclosure, ToolSearch/MCP refresh, model-emitted tool_use, typed runtime tool_result, shell/file/media/native-device safety, schedule/subagent lifecycle, hook boundaries, interrupted-turn repair, streaming recovery, context-window/output-token handling, and loaded-tool/token-cache accounting.

When to prefer this over neighbors

Question shapeUse
"What does Claude Code's <Tool> tool look like in the wire?"claude-code-internals (strings dump)
"Which Bun native modules ship with Claude Code?"claude-code-internals
"Where does openclaw dispatch a subagent / fire a hook?"claude-code-internals (openclaw dist/agent-*)
"What's the canonical MessageParam / ContentBlock shape?"claude-code-internals (Anthropic SDK source)
"Why is my CrayonChat not remounting?"crayon-sdk (production gotcha)
"What's the <FullScreen> prop list in OpenUI?"openui-mcp (live API)
"How do I ship production-grade UI polish?"impeccable
"How do I scaffold a new snappy skill?"skill (the meta-skill)

Steps (when invoked as a snappy verb)

  1. Read this file's "Evidence surfaces" + "Grep cookbook" sections.
  2. Verify install_check: test -d "$HOME/.local/share/claude/versions". If missing, run the self-bootstrap install line.
  3. Verify openclaw: test -d /opt/homebrew/lib/node_modules/openclaw. If missing, npm install -g openclaw.
  4. If /tmp/claude-code-full-strings.txt is missing or older than 1 day OR the symlink target version differs, re-extract: strings -n 10 "$(realpath "$(which claude)")" > /tmp/claude-code-full-strings.txt.
  5. If the question is about Snappy's tool routing, MCP, ToolSearch, token/cache economy, prompt bloat, regex classifiers, generated surfaces, provider parity, page/workspace acceptance, settings/config state, session/resume identity, diagnostics/telemetry, provider/billing truth, streaming recovery, context-window/output-token handling, plugins/output styles, native device tools, shell safety, scheduled work, subagents, files/media, or interrupted turns, read resources/claude-source-coverage-matrix.md, resources/snappy-audit-finding-map.md, resources/private-2188-anchor-index.md, and resources/claude-private-2.1.88-runtime-map.md, then use /tmp/claude-2188.Z9mvvM/strings.txt.
  6. Run the relevant cookbook grep for the question at hand. If the cookbook doesn't cover it, derive a new grep from the patterns above and add a row to the cookbook (P-fix into AGENTS.md).
  7. Cite the file:line you grep'd from in your answer. Do NOT paste extracted source into a commit.
  8. Append an eval row to state/log/evals.ndjson with skill: "claude-code-internals", eval_mode: "shape".

Provenance

  • Sources:
  • Claude Code: Bun-compiled, distributed via @anthropic-ai/claude-code npm

package; resolves to ~/.local/share/claude/versions/<v>.

  • openclaw: open-source fork, distributed via the openclaw npm package;

today on this machine: version 2026.4.9 (commit 0512059).

  • Anthropic SDK: vendored under openclaw/node_modules/@anthropic-ai/sdk/src/.
  • Strings dump: /tmp/claude-code-full-strings.txt, 239,258 lines, regen

via the one-liner above.

  • Private 2.1.88 strings dump:

/tmp/claude-2188.Z9mvvM/strings.txt, 360,815 lines, generated from Robert's supplied bundle. Older /tmp/claude-private-2.1.88-notelemetry-strings.txt notes are retired scout paths, not current closure evidence.

  • Absorbed into snappy-os: 2026-04-28.

Eval

Eval mode is auto-shape (no lib, no sidecar). Auto-shape scoring checks:

  • frontmatter (name, description, eval) is valid
  • AGENTS.md sibling exists
  • install_check path ($HOME/.local/share/claude/versions) is reachable

AGENTS.md- what the AI loads when this skill comes up

claude-code-internals - loader

Full skill: state/skills/claude-code-internals/SKILL.md. Heavy evidence lives in state/skills/claude-code-internals/resources/; do not inject the whole cookbook into ordinary turns.

Source Map

  • Installed Claude Code binary: $(realpath "$(which claude)").
  • Installed strings cache: /tmp/claude-code-full-strings.txt; refresh if missing, older than 24h, or binary symlink changed.
  • Private no-telemetry bundle: /Users/robertboulos/projects/claude-private/claude-private-2.1.88.run; extracted audit cache: /tmp/claude-2188.Z9mvvM/strings.txt.
  • Openclaw source-shaped dist: /opt/homebrew/lib/node_modules/openclaw/dist/.
  • Anthropic SDK TypeScript source: /opt/homebrew/lib/node_modules/openclaw/node_modules/@anthropic-ai/sdk/src/.
  • Snappy implementation under audit: /Users/robertboulos/projects/snappy-os/state/lib/harness, state/bin/head-screen/dispatch-chat-handler.ts, and snappy-os UI/runtime files.

Required Reading Order For Snappy Audits

  1. resources/claude-source-coverage-matrix.md - facet coverage, Claude proof, Snappy obligation, gate.
  2. resources/snappy-audit-finding-map.md - Robert-observed failures, proof labels, no-out clauses.
  3. resources/private-2188-anchor-index.md - exact private-bundle anchor ranges before closing private claims.
  4. resources/claude-private-2.1.88-runtime-map.md - token/tool/MCP/deferred-runtime architecture.
  5. resources/cc-2188-bring-to-snappy.md - implementation ROI order.
  6. Facet files as needed: tool-catalog.md, system-prompt-assembly.md, streaming-and-tool-use.md, hooks-and-lifecycle.md, subagent-and-task-model.md, plan-mode-and-permissions.md.

Critical Rules

  • Use dynamic paths. Never hardcode an installed Claude version.
  • Grep string literals, descriptions, error messages, and telemetry names; Bun-mangled identifiers are not stable evidence.
  • Prefer openclaw dist when source shape matters; use strings for private-bundle facts, feature flags, embedded prompts, and tool descriptions.
  • SDK source is canonical for Anthropic message/tool block shapes. Do not guess MessageParam, ContentBlock, or tool_use envelopes.
  • Extracted source and strings are reference-only. Do not commit generated/extracted Claude source.
  • Strings are evidence for constants and architecture anchors, not a complete behavioral proof. Runtime changes still need live Snappy verification.
  • For Snappy parity, reject raw prompt regex, intent classifiers, or fake routes as "Claude-like". Claude-shaped means small resident core, deferred schema discovery, model-emitted tool_use, typed tool_result, token accounting by loaded surface, and repair/recovery around tool ledgers.
  • Token economy claims must separate system, project docs, memories, resident tools, deferred loaded tools, skills/agents, tool calls/results, attachments, cache creation/read, provider actuals, and estimates.
  • Product proof requires source, tests/lints, deploy truth, and installed behavior to agree.

Compact Command Index

questionfirst command or file
refresh installed stringsstrings -n 10 "$(realpath "$(which claude)")" > /tmp/claude-code-full-strings.txt
refresh private stringscd /Users/robertboulos/projects/claude-private && rm -rf /tmp/claude-2188.Z9mvvM && mkdir -p /tmp/claude-2188.Z9mvvM && sh claude-private-2.1.88.run --target /tmp/claude-2188.Z9mvvM --noexec && strings -n 10 /tmp/claude-2188.Z9mvvM/claude-notelemetry > /tmp/claude-2188.Z9mvvM/strings.txt
coverage auditsed -n '1,220p' state/skills/claude-code-internals/resources/claude-source-coverage-matrix.md
private anchorssed -n '1,240p' state/skills/claude-code-internals/resources/private-2188-anchor-index.md
deferred tools proof`rg -n -o 'ToolSearchavailable-deferred-toolsisDeferredTooldeferredBuiltinTokenstool_usetool_result' /tmp/claude-2188.Z9mvvM/strings.txt`
token/cache proof`rg -n -o 'input_tokensoutput_tokenscache_creation_input_tokenscache_read_input_tokensmodelUsagedeferredToolTokensskillTokensagentTokenstoolResultTokens' /tmp/claude-2188.Z9mvvM/strings.txt`
hooks proofsed -n '1,220p' state/skills/claude-code-internals/resources/hooks-and-lifecycle.md
tool catalogsed -n '1,220p' state/skills/claude-code-internals/resources/tool-catalog.md
Snappy token matrixnpx tsx state/bin/token-acceptance-matrix.ts --md
Snappy regex debtnpx tsx state/lint/no-regex-in-harness.ts && npx tsx state/lint/no-tool-gate-regex.ts
Snappy god-object gatesnpx tsx state/lint/server-line-ratchet.ts && npx tsx state/lint/loose-type-ratchet.ts

Snappy Harness Invariants To Enforce

  • Small resident core, deferred breadth. The model must know how to discover schemas without paying for every schema every turn.
  • One path: runtime exposes the capability surface; model emits tool intent; runtime executes and returns typed results.
  • MCP, connectors, CLIs, skills, components, artifacts, schedules, questions, and permissions are one capability substrate with stable IDs and provenance.
  • Tool ledger repair, interrupted turns, retries, output-token/context-window limits, stop/kill/resume, and orphan results are runtime state, not prose apologies.
  • Auth, network, proxy, stale mirror, connector reachability, and recovery states are typed and visible.
  • Plan/questions/tasks/schedules are tools with history and approval state, not page-local buttons.
  • Prompt cache stability and per-segment token attribution are product requirements.
  • Plugins/output styles/settings are registries with enablement, source, allowed tools, and context impact.
  • Session identity must join transcript, dispatch log, artifacts, row clicks, tool calls, and UI routes.
  • Regex cannot own token economy. The P002 class is a known failure: verb/data regex chose the wrong tool subset and exceeded budget before the model could choose tools.

Self-Test

An agent reading this should:

  1. [ ] Start Snappy audits from the coverage matrix and finding map.
  2. [ ] Use private anchors before closing private-bundle claims.
  3. [ ] Refresh strings when stale and use dynamic binary paths.
  4. [ ] Use SDK source for message/tool shapes.
  5. [ ] Reject regex/router parity claims unless deferred tools, tool_use/tool_result, token attribution, and ledger repair are present.
  6. [ ] Run Snappy token/regex/god-object gates before claiming harness parity.
  7. [ ] Never commit extracted Claude source.

Found a gap? Edit this file. <!-- footer-injection-point -->

api.ts- the code it can call

⚠ no api.ts - this skill has no typed action surface

scripts- helper scripts it can run

prose-only skill - 13 inline code blocks live in SKILL.md above (no state/bin/ sidecar yet).

how we check it- the checks, plus the last 10 runs

rubric auto-shape no rubric declared
recent no runs actor/auditor: unverifiable
deps none declared

no recent runs logged - the eval contract is declared but nothing has been graded yet