Claude Code Workflow banner
omrylcn omrylcn

Claude Code Workflow

Productivity community

Description

Deep technical analysis of Claude Code CLI internals — how the agentic loop, tool execution, sub-agents, and 50+ tools work under the hood. Based on the publicly available source code.

Installation

This entry records only its repository, not the path inside it, so there is no exact command to give. Open the source below and copy the folder into ~/.claude/skills/, or the file into ~/.claude/agents/.

README

Claude Code Workflow — Deep Source Code Analysis

A comprehensive, line-by-line technical analysis of [nirholas/claude-code](https://github.com/nirholas/claude-code) — the publicly available source code of Anthropic's Claude Code CLI. From the moment you type `claude` in your terminal to the final response — every function call, every design decision, every architectural pattern documented.

sequenceDiagram
    participant U as User
    participant R as REPL
    participant QG as QueryGuard
    participant CTX as Context (memoized)
    participant Q as queryLoop()
    participant API as Anthropic API
    participant STE as StreamingToolExecutor
    participant T as Tool (Read/Edit/Bash)
    participant INK as Ink Terminal

    U->>R: Enter (sends message)
    R->>R: onSubmit() — slash command? empty?
    R->>R: processUserInput() — String → Message[]
    R->>QG: tryStart()
    
    alt Busy
        QG-->>R: null → enqueue
    else Available
        QG-->>R: generation (OK)
    end

    R->>CTX: Promise.all([systemPrompt, userContext, systemContext])
    CTX-->>R: Memoized results (computed on first query)

    rect rgb(66, 133, 244)
        Note over Q,API: while(true) — Agentic Loop

        R->>Q: query({ messages, systemPrompt, tools })
        Q->>Q: Compaction: snip → micro → collapse → auto
        Q->>API: HTTP POST (stream: true, 50+ tool, thinking)
    end

    rect rgb(52, 168, 83)
        Note over API,INK: Streaming — Tokens flow

        loop Token stream
            API-->>Q: thinking/text/tool_use chunk
            Q-->>R: yield event
            R-->>INK: setMessages → re-render
            INK-->>U: Terminal updates
        end
    end

    rect rgb(234, 67, 53)
        Note over STE,T: Tool Execution — Starts while model is writing

        opt If model sent tool_use
            Q->>STE: addTool(block) — start immediately
            STE->>STE: canUseTool() — permission check
            STE->>T: tool.call(input)
            T-->>STE: