What’s The Secret Behind Claude Code? I Rebuilt it to find out…

Arseny ShatokhinAbout 4 min readSep 20, 2025Watch original
THE SUMMARYAI-generated

Key Concepts

  • AI Agents: Software entities with instructions, knowledge, and actions to perform tasks.
  • Multi-Agent Systems: Systems with multiple AI agents that communicate and collaborate.
  • Orchestration: The process of managing communication and task delegation between agents.
  • Orchestrator Worker Pattern: A pattern where a main agent distributes tasks to sub-agents.
  • Handoff Pattern: A pattern where one agent temporarily replaces another in the main thread.
  • System Reminders: Invisible system messages in chat history that reinforce key rules and to-do lists.
  • Agentic Retrieval: An approach where an agent retrieves information itself without pre-supplied knowledge.
  • Agency Starter Template: A template containing code and rules for building agents with the presenter's framework.
  • Communication Flows: Defined pathways for agents to interact and exchange information.
  • Hooks: Features that allow you to get certain events whenever your agents do certain things.

Cloud Code Reverse Engineering

1. Multi-Agent Orchestration

  • Orchestrator Worker Pattern: Cloud Code uses a main agent that sends tasks to sub-agents, which execute them in parallel and return results.
    • Limitation: Sub-agents do not retain chat history between tasks.
    • Limitation: Only one level of depth in sub-agent communication is allowed. Sub-agents cannot communicate with each other directly.
  • Planner Agent: Interacts directly with the user in the main thread, temporarily replacing the main agent until planning is complete (handoff pattern).
  • Framework Comparison: The presenter's framework allows sub-agents to maintain chat history and supports uniform communication flows with multiple levels of depth.

2. Instructions (Prompts)

  • Source: Prompts were extracted from Cloud Code API requests found on a GitHub gist.
  • Key Feature: System Reminders: Cloud Code repeats key rules using a special system reminder after every key step.
    • To-Do List Repetition: The current to-do list items are repeated in the system reminder to prevent the agent from forgetting the next steps.
  • Prompt Structure:
    1. Define the role.
    2. Provide safety and scope guardrails.
    3. Output style and preferences.
    4. Task examples.
    5. Usage guidelines and additional context.

3. Tools

  • Extensive Descriptions: Tool descriptions are detailed, explaining not only what the tool does but also how to use it.
  • Functionality: Basic tools for editing and writing files, web search, and a to-do list.
  • Bash Tool: Can run multiple terminals in parallel and check their statuses separately.
  • Limitation: Cloud Code is a closed source system, so the tool code itself cannot be analyzed.

4. Knowledge

  • Agentic Retrieval: Cloud Code uses a fully agentic retrieval approach, meaning it does not have any RAG (Retrieval-Augmented Generation) like in Cursor or Windsurf.
  • Context: No additional context is supplied in the prompt except for what Cloud Code decides to read itself with the read file tool.

Rebuilding Cloud Code

1. Using the Agency Starter Template

  • Template Contents: Contains template code and rules files for building agents quickly.
  • Process:
    1. Copy the template.
    2. Create a new repository.
    3. Open the repository in Cursor.
    4. Copy prompts and tool descriptions from the GitHub gist.
    5. Prompt Claude to rebuild the agent following the file, skipping web search, web fetch, and task tools.
  • Cursor Rules File: Contains the entire process for building reliable AI agents with the presenter's framework.

2. Implementation Details

  • Tool Implementation: Claude implements each tool and tests them accordingly.
  • Communication Flows: The task tool is implemented using the communication flows parameter in the presenter's framework.
  • Light LLM Model: Used to specify the anthropic API key and model.
  • System Reminder Hook: Implemented using the agents SDK hooks feature, which allows you to get certain events whenever your agents do certain things.

3. Testing and Customization

  • Testing: The rebuilt agent is tested by sending example tasks and verifying its functionality.
  • Customization:
    • Adjust instructions and prompts.
    • Create agents specific to your tech stack (e.g., Superbase, Firebase).
    • Add a project description in the shared instructions file (project overview.md).
    • Customize the web search tool for different models.

Side-by-Side Comparison

1. Multiplayer Pixel Artboard

  • Cloud Code:
    • Multiplayer functionality works.
    • Chat works.
    • Notifications work.
    • Download button does not work.
  • Agency Code:
    • Functionality works perfectly.
    • Download works.
    • Chat seems to be working as well.
    • UI is different and does not use component or styling libraries.

2. Agency Form PDF Chat App

  • Cloud Code:
    • Chat application works.
    • Messages are truncated due to a message component block.
  • Agency Code:
    • UI is similar.
    • Sample questions are on the right.
    • Complete response formatted using markdown.
    • PDF content can be viewed.

Conclusion

  • No Secret Sauce: Cloud Code's performance is primarily due to the underlying Claude model, not unique prompts, tools, or architecture.
  • User Interface Matters: The user experience and onboarding in Cloud Code's CLI are key factors in its popularity.
  • Rebuild and Open Source: The presenter encourages viewers to rebuild and open source other AI agents.
  • Framework Benefits: The presenter's framework offers features like sub-agent history retention and flexible communication flows.
  • Customization is Key: Tailoring agents to specific tech stacks and projects can significantly improve results.

AI summaries can miss context or contain errors. Check important details against the original video.

Go a little deeper.

Have a question about this video? Load its transcript to open the video chat.