aradotso/trending-skills/how-claude-code-works
Claude Code and agent skill by aradotso/trending-skills
- community
Checking that the SKILL.md file is still in the repository.
Install
npx vskill@latest install aradotso/trending-skills/how-claude-code-worksSKILL.md
git clone https://github.com/Windy3f3f3f3f/how-claude-code-works cd how-claude-code-works
Open docs/ folder — plain Markdown, readable in any editor
User Input │ ▼ QueryEngine (session management) │ ▼ query() main loop ◄──────────────────────┐ │ │ ▼ │ Claude API (streaming) │ │ │ ├─► Text tokens → stream to terminal │ │ │ └─► Tool calls → ToolExecutionEngine │ │ │ ├─ ReadFile │ ├─ EditFile │ ├─ Shell │ ├─ Search │ └─ MCP Tools │ │ │ └─ results ────────┘
Context Engineering layer feeds:
- System prompt
- Git status
- CLAUDE.md files
- Compression pipeline
Level 1: TRUNCATE └─ Cut large tool outputs in older messages (fast, lossy for old data)
Level 2: DEDUPLICATE └─ Remove repeated content (near-zero cost)
Level 3: FOLD └─ Collapse inactive conversation segments (reversible, content intact)
Level 4: SUMMARIZE └─ Launch sub-agent to summarize entire conversation (last resort)
interface Tool { name: string; description: string; inputSchema: ZodSchema; execute(input: unknown, context: ToolContext): Promise<ToolResult>; readonly: boolean; // true = can run in parallel requiresPermission: boolean; }
Layer 1: Permission Mode └─ Trust level restricts available operation classes
Layer 2: Rule Matching └─ Command pattern whitelist/blacklist
Layer 3: Bash AST Analysis (tree-sitter) └─ 23 safety checks on parsed shell AST, not regex:
- Command injection detection
- Env variable leak detection
- Special character attacks
- Pipe chain analysis
Layer 4: User Confirmation └─ Dangerous ops require explicit confirm 200ms debounce prevents accidental keypress confirmation
Layer 5: Hook Validation └─ User-defined rules, can mutate tool inputs (e.g. auto-add --dry-run to rm commands)
{ "hooks": { "PreToolUse": [ { "matcher": "Bash", "hooks": [ { "type": "command", "command": "my-safety-checker --input-file $CLAUDE_TOOL_INPUT" } ] } ], "PostToolUse": [ { "matcher": "Write", "hooks": [ { "type": "command", "command": "prettier --write $CLAUDE_FILE_PATH" } ] } ] } }
Sub-Agent: Main Agent ──dispatch──► Sub Agent │ └─ executes task └─ returns result ──► Main Agent continues
Coordinator (pure orchestration): Coordinator ──task──► Agent A (reads files, writes code) Coordinator ──task──► Agent B (runs tests) Coordinator CANNOT read/write itself — enforces separation
Swarm (peer-to-peer): Agent "Alice" ◄──mailbox──► Agent "Bob" Agent "Bob" ◄──mailbox──► Agent "Carol" Each agent independent, 3 execution backends
Why search-and-replace: ✓ Smaller diffs → fewer tokens → lower cost ✓ Uniqueness constraint forces model to be precise ✓ Hallucination resistance (must match exact existing text) ✓ Preserves unchanged code exactly (no reformatting side effects)
Uniqueness constraint: The search string must appear EXACTLY ONCE in the file. If 0 matches → error, model must retry with more context. If 2+ matches → error, model must add surrounding lines.
Pre-edit read enforcement: Tool executor checks whether the file was read in current context. If not → forces a ReadFile call first, then allows edit.
// 1. Message loop async function agentLoop(userMessage: string) { messages.push({ role: 'user', content: userMessage });
while (true) { const response = await anthropic.messages.create({ model: 'claude-opus-4-5', messages, tools: toolDefinitions, stream: true, });
// 2. Stream handler for await (const chunk of response) { if (chunk.type === 'content_block_delta') { process.stdout.write(chunk.delta.text ?? ''); } }
// 3. Tool execution const toolUses = extractToolUses(response); if (toolUses.length === 0) break; // done
const results = await Promise.all( toolUses.map(t => executeTool(t.name, t.input)) );
// 4. Result injection messages.push({ role: 'assistant', content: response.content }); messages.push({ role: 'user', content: results.map(toToolResult) }); } }
// 5. Tool registry const tools = new Map<string, ToolHandler>(); tools.set('read_file', async ({ path }) => fs.readFile(path, 'utf8')); tools.set('write_file', async ({ path, content }) => fs.writeFile(path, content)); tools.set('bash', async ({ command }) => execSync(command, { encoding: 'utf8' }));
// 6. Context management (basic) function trimContext(messages: Message[], maxTokens: number) { // Estimate tokens, drop oldest non-system messages until within budget while (estimateTokens(messages) > maxTokens) { const firstNonSystem = messages.findIndex(m => m.role !== 'system'); if (firstNonSystem === -1) break; messages.splice(firstNonSystem, 1); } }
// 7. Permission check (minimal) async function checkPermission(tool: string, input: unknown): Promise<boolean> { const dangerous = ['bash', 'write_file', 'delete_file']; if (!dangerous.includes(tool)) return true; const answer = await prompt(Allow ${tool}? [y/N] ); return answer.toLowerCase() === 'y'; }
Phase 1-3 (parallel): Load config + Init MCP + Check git status Phase 4-6 (parallel): Load CLAUDE.md + Prefetch memory + Warm tool registry Phase 7-8 (parallel): Init renderer + Authenticate Phase 9 (sequential): Start agent loop
API chunk arrives │ ▼ (< 1ms) Token renderer (Ink + Yoga Flexbox) │ ▼ Terminal output │ ├─ Meanwhile: parse partial JSON for tool calls └─ Tool pre-execution starts before stream ends
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/how-claude-code-works/SKILL.md
Popularity
- Repository stars
- 42
- Repository forks
- 10
- 7-day trend score
- 19
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 17 Jun 2026, 4 months ago.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/aradotso/trending-skills/how-claude-code-works)