Skip to content

Instantly share code, notes, and snippets.

@taejs
Last active March 12, 2026 15:58
Show Gist options
  • Select an option

  • Save taejs/fcfd2ae3741f2bf4d55ad2eee10500e0 to your computer and use it in GitHub Desktop.

Select an option

Save taejs/fcfd2ae3741f2bf4d55ad2eee10500e0 to your computer and use it in GitHub Desktop.
Claude Code /claude-code-internals skill
name description
claude-code-internals
Reverse-engineer and explain Claude Code's internal architecture. Extract prompts, commands, data structures from the binary. Use when user asks about how Claude Code works internally, what prompts it uses, how features are implemented, or wants to extract/backup internal logic. Triggers: 'claude inside', 'how does claude code work', 'extract prompt', 'extract prompt', 'claude architecture', 'internals', 'binary'.

Claude Code Internals Explorer

Reverse-engineer Claude Code's architecture by extracting and analyzing its bundled JavaScript from the binary. Save findings to ~/obsidian-vault/reference/ for the user's review.

Principles

  1. Binary is the source of truth — Claude Code ships as a single binary with bundled JS. Use strings to extract.
  2. Cache findings — Always save extracted prompts/structures to ~/obsidian-vault/reference/ so they survive across sessions.
  3. Deobfuscate — The JS is minified. Variable names are mangled. Read the logic, not the names.
  4. Version-stamp — Always note the Claude Code version in extracted docs.

Binary Location & Version

CLAUDE_BIN=$(which claude)
CLAUDE_VERSION=$(claude --version 2>/dev/null || strings "$CLAUDE_BIN" | grep '"VERSION"' | head -1)

Extraction Techniques

1. Find a specific feature/prompt

# Search for keywords related to the feature
strings "$CLAUDE_BIN" | grep -i "keyword" | head -20

# Get surrounding context (the prompt text)
strings "$CLAUDE_BIN" | grep -B 5 -A 50 "exact phrase from feature"

# For longer extractions
strings "$CLAUDE_BIN" | grep -B 2 -A 200 "start of prompt text" | head -300

2. Find all slash commands

# Commands are registered with type:"prompt" and name:"commandname"
strings "$CLAUDE_BIN" | grep 'type:"prompt",name:"'
strings "$CLAUDE_BIN" | grep 'description:".*".*progressMessage'

3. Find system prompts

# Main system prompt function
strings "$CLAUDE_BIN" | grep -A 100 'You are an interactive CLI tool'

# Tool descriptions
strings "$CLAUDE_BIN" | grep -A 20 'description:.*tool'

4. Find configuration schemas

# Settings, hooks, permissions
strings "$CLAUDE_BIN" | grep -A 30 'settings.json'
strings "$CLAUDE_BIN" | grep -A 30 'hooks'

5. Find API interaction patterns

# How Claude Code talks to the API
strings "$CLAUDE_BIN" | grep -A 20 'anthropic.com'
strings "$CLAUDE_BIN" | grep -A 10 'model.*claude'

Known Internal Architecture

File Layout

Path Purpose
~/.claude/settings.json User settings (permissions, hooks, model preferences)
~/.claude/projects/{encoded-path}/ Per-project session data
~/.claude/projects/{path}/*.jsonl Session transcripts (JSONL format)
~/.claude/projects/{path}/{session-id}/ Session artifacts (tool results, subagent logs)
~/.claude/usage-data/facets/{session-id}.json AI-analyzed session facets (from /insights)
~/.claude/usage-data/session-meta/{session-id}.json Session metadata (duration, tools, tokens)
~/.claude/usage-data/report.html Generated insights HTML report
~/.claude/stats-cache.json Aggregate usage statistics
~/.claude/telemetry/ Telemetry data
~/.claude/history.jsonl Command history across all sessions
~/.claude/skills/ User-defined skills

Session JSONL Structure

Each line is a JSON object with a type field:

type: "user"                  — User message (content: string | array of content blocks)
type: "assistant"             — Claude response (content: array with text/tool_use/thinking blocks)
type: "file-history-snapshot"  — File state snapshot (has timestamp)
type: "progress"              — Progress indicator
type: "queue-operation"       — Internal queue management
type: "summary"               — Conversation summary (from context compression)

Facet Schema (from /insights)

{
  "underlying_goal": "string",
  "goal_categories": {"category": count},
  "outcome": "fully_achieved|mostly_achieved|partially_achieved|not_achieved",
  "user_satisfaction_counts": {"level": count},
  "claude_helpfulness": "unhelpful|slightly_helpful|moderately_helpful|very_helpful|essential",
  "session_type": "single_task|multi_task|iterative_refinement|exploration|quick_question",
  "friction_counts": {"type": count},
  "friction_detail": "string",
  "primary_success": "none|fast_accurate_search|correct_code_edits|...",
  "brief_summary": "string",
  "session_id": "uuid"
}

Known Built-in Commands

Command Description Source
/insights Session usage analysis + HTML report builtin
/help Help menu builtin
/clear Clear conversation builtin
/compact Compress context builtin
/config Open settings builtin
/cost Show token usage builtin
/doctor Diagnose issues builtin
/fast Toggle fast mode builtin
/init Initialize project CLAUDE.md builtin
/login Authenticate builtin
/logout Sign out builtin
/mcp MCP server management builtin
/memory Edit CLAUDE.md builtin
/model Switch model builtin
/permissions Manage tool permissions builtin
/pr-review Review a pull request builtin
/review Code review builtin
/status Show session info builtin
/terminal-setup Configure terminal integration builtin
/vim Toggle vim mode builtin

Output Format

Include:

  1. Version — Claude Code version at extraction time
  2. Raw extraction — The actual extracted text/code
  3. Deobfuscated explanation — What each part does in plain language
  4. Usage notes — How this knowledge can be applied

Common Questions to Explore

  • "How does context compression work?" → Search for summary, compact, compress
  • "What's the system prompt?" → Search for You are an interactive, SV8
  • "How do hooks work?" → Search for hooks, lifecycle, PreToolUse
  • "How does /review work?" → Search for pr-review, review, diff
  • "How are MCP tools loaded?" → Search for mcp, McpServer, tool_use
  • "What models are available?" → Search for claude-opus, claude-sonnet, model
  • "How does permission system work?" → Search for allowedTools, permission
  • "How does Task agent work?" → Search for subagent, Task, agent
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment