agentleFS
kohojkohoj/skills/claude-code-dissect/SKILL.md

claude-code-dissect

Skill1 starsChanged 7 months agoMITView on GitHub

Navigate and extract reusable design patterns from the Claude Code 2.1.88 source code for application in our project. It covers nine subsystems: startup/bootstrap, conversation engine, context compaction, tool system, permissions, hooks, multi-agent orchestration, memory, and extensions (MCP/plugins/skills/UI).

The file

We split this skill into the rules it gives an agent

5 rules. About 0 are common, 2 are distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Run the extraction script (see extract-sources.js in the repo) to restore source files

    line 27
  2. Very specific:

    Locate the source root: search the project for restored-src/src/Tool.ts using Glob.

    line 34
  3. Very specific:

    All file paths in the reference files are relative to this SOURCE_ROOT.

    line 36
  4. Distinctive:

    If the topic spans multiple areas, read the primary reference first, then follow its Neighbors section to related files.

    line 56
  5. Distinctive:

    If no topic matches, grep the source root for relevant keywords before giving up.

    line 58

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Claude Code Source Dissection

Setup

This skill requires the Claude Code source extracted from its sourcemap. To obtain it:

  1. npm pack @anthropic-ai/claude-code → get the tarball
  2. Extract cli.js.map from the tarball
  3. Run the extraction script (see extract-sources.js in the repo) to restore source files

The extracted source tree should live somewhere in your project. The skill will auto-discover it by searching for restored-src/src/Tool.ts (a unique marker file).

How to use this skill

  1. Locate the source root: search the project for restored-src/src/Tool.ts using Glob. The directory containing it (minus /Tool.ts) is SOURCE_ROOT. All file paths in the reference files are relative to this SOURCE_ROOT.
  2. Identify the topic from the user's request
  3. Read the matching reference file from references/ below
  4. Read the actual source files listed in the reference — prepend SOURCE_ROOT/ to each path
  5. Present your findings using the output format at the bottom

Routing Table

TopicReference FileCovers
Startup, init, bootstrap, state, session storage, gitreferences/bootstrap.mdBoot sequence, global state singleton, session JSONL, git worktree
Conversation loop, API call, streaming, retry, messagesreferences/engine.mdQuery loop, streaming generator, retry strategies, message normalization
System prompt, CLAUDE.md, compaction, prompt cache, tokensreferences/context.md5-level prompt assembly, summarizer agent, cache strategy, token budget
Tool definition, execution, schema, deferral, Bash parserreferences/tools.mdTool interface, lazy schema, execution pipeline, ToolSearch, Bash AST
Permission, allow/deny, classifier, safety, rulesreferences/permissions.md10-step pipeline, rule matching, YOLO classifier, filesystem guards
Hooks, PreToolUse, PostToolUse, lifecycle eventsreferences/hooks.mdHook definition, matching, execution, permission hooks
Agent, subagent, teammate, swarm, fork, multi-agentreferences/agents.md3 spawn modes, fork cache optimization, swarm backends, file mailbox
Memory, MEMORY.md, extraction, session memoryreferences/memory.md3-layer memory, auto extraction, session summary, team sync
MCP, plugin, skill, marketplace, IDE bridge, UI, Inkreferences/extensions.mdMCP client, plugin lifecycle, skill format, IDE bridge, Ink render engine

If the topic spans multiple areas, read the primary reference first, then follow its Neighbors section to related files.

If no topic matches, grep the source root for relevant keywords before giving up.

Output Format

Structure your response like this:

Pattern: one-line name Why it exists: 2-3 sentences on the problem it solves Data flow:

ASCII diagram showing runtime flow

Key code (from the source, simplified):

// The core abstraction, stripped to essentials

Files read: list with line numbers for critical sections How to adapt: what to keep, what to change for our project

Architecture Overview

For orientation, here's how the 9 subsystems connect:

User Input
    ↓
[bootstrap] → init, state singleton, session restore
    ↓
[engine] → query loop: message → API → stream → tool execution → continue/end
    ↓                                    ↓
[context] → prompt assembly        [tools] → validate → permission → hooks → call
    ↓           ↓                       ↓              ↓            ↓
[memory] ← compaction            [agents] ←──── [permissions] ← [hooks]
    ↑                               ↓
    └──── extraction ←────── [extensions] → MCP, plugins, skills, UI

Each reference file contains: architecture knowledge, key abstractions, reading order, file table with line counts, and neighbor cross-references.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

Reviews can't be read right now.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.