Claude Code Internals - xsyetopz/claudetto GitHub Wiki
This section describes how Claude Code works. Read it if you maintain claudetto, because it covers the facts that claudetto depends on. It does not replace the official docs of Claude Code. Where the docs and the binary differ, this section gives the binary, and it names the source.
- The section covers the request that Claude Code builds, the tools, the hook events, and the plugin loader. It also covers the settings, the subagents, the compaction, and the auto mode.
- It also lists the reads that the docs do not name.
- Each page states what the binary does. It gives the code path or the text id where it has one.
- Each page gives a bound by name, value, and file when a bound exists.
- The section does not describe the Claude Code user interface, except where a setting changes it.
- The facts of this section were extracted from Claude Code
2.1.296, unless a page names another version. A page that gives a later version names it in the text. - The minimum Claude Code for claudetto is
2.1.302. The constantMIN_CLAUDE_CODE_VERSIONintools/limits.tsholds it. - Two checks follow the constant:
- The CI job in
.github/workflows/ci.ymlinstalls the same version. - The test
tests/tools/claude-code-release.test.tspins that job to the constant.
- The CI job in
-
src/kernel/budget.tsnames2.1.302in comments, where a bound comes from the bundle of that version. A change of the minimum version therefore needs a check of those comments too.
- The native installer keeps each version at
~/.local/share/claude/versions/<version>, as Sandbox states. - The
claudetto-schemacommand reads the file thatclaudeonPATHresolves to. It reads another file when--bundle FILEnames one. See Lab.
The facts come from four kinds of source. The label of a fact names its kind, as the Home page explains.
-
binary: the text of the bundle. The bundle is the JavaScript that the installed binary holds. A text dump of its strings is the fileexternal/cc-<version>/strings.txt, such asexternal/cc-2.1.302/strings.txt. Thestringscommand made the dump. The repository has no recipe for that dump. To repeat it, runstringson the binary and write the output to a file in a folder of your own (inference). Search the dump withgrep -nand read a line range. Do not print the whole file, because it is about 60 MB. -
extract: the text of each part of the built-in prompt, cut from the bundle. The folderexternal/cc-2.1.299/cc-extract-2.1.299/holds the extract of2.1.299, with one subfolder for each kind:-
section/holds each section of the system prompt, as<id>.txt. Some ids also have a<id>.full.txtfile. -
tool/holds the description of each built-in tool, as<Tool>.txt. Some tools also have a<Tool>.full.txtfile. -
compaction/holds the compaction prompts:entire.txt,full.txt, andrecent.txt. -
style/holds the built-in output styles, such asConcise.txt. -
listing/holds the agent types, the skills, and the deferred tools, asagent_types.txt,skills.txt, anddeferred_tools.txt.
-
-
capture: the request body that Claude Code sent to a local listener. The commandjust capturestarts a logging proxy withbun plugins/claudetto-lab/bin/claudetto-capture. The proxy writes each request body to a folder in the temp folder. It never writes a header, because a header carries the credential. For the first request with tools, it also sizes each part with thecount_tokensendpoint. The commandjust sandboxruns Claude Code in a separate config, andjust sandbox-aloneruns one plugin in it. See Lab. -
measured: a count from a run or from a transcript on the maintainer's machine. The commandjust measuresizes the start of a session from a transcript.
The claudetto-schema command reads the settings schema out of the bundle.
Run just schema to write the schema files into schemas/.
The command never changes the bundle.
The decision is in Decisions Settings, under D10.
- Read the bundle for evidence.
- Never patch the Claude Code binary or its npm package, even though the bundle is readable JavaScript.
- A patch breaks Anthropic's terms of service, as
CLAUDE.mdstates. - Use only the documented extension points: settings, environment variables, hooks, and the plugin API.
The pages of this section use the labels of the Home page.
- A fact that comes from the bundle has the label
binary. - A fact from a request body has the label
capture. - A count from a run has the label
measured. - A conclusion from those facts has the label
inference, and the page says so. - A choice with no label is a maintainer decision. The page links it when a decision page exists.
- Request Build: the system prompt sections, the attachments, and the cache.
- Tools and Deferral: the built-in tools, and which of them Claude Code defers.
- Hook Events: the hook events, their payloads, and the map to the 14 claudetto events.
- Plugin Loader: how Claude Code finds and loads a plugin.
- Settings Resolution: how Claude Code merges the settings files and the env vars.
- Subagents: how Claude Code starts a subagent.
- Compaction and Context: the compaction prompts, the context window, and the blocking limit.
- Auto Mode: the classifier of the auto mode, and its defaults.
- Undocumented Reads: the settings and env vars that the binary reads and the docs do not name.