In the previous chapter, Compound Engineering Workflow, we learned what to do: Plan, Work, Review, and Compound.
Now, we need to look at how to build software that lets AI do those things. This concept is called Agent-Native Architecture.
Imagine you are building a library.
In traditional software, we build "stairs" (User Interfaces/GUIs). We make buttons, dropdowns, and forms.
Agent-Native Architecture means building a building with both stairs and wide ramps. It ensures that anything a human can do via the UI, an agent can do via a command (tool).
In this architecture, features aren't just scripts that run from top to bottom. Instead, the agent operates in a Loop.
To make this work, we don't give the agent big, complex machines. We give it Atomic Toolsβlike Lego bricks.
Imagine creating a tool called fix_bug_and_deploy.
Instead, we give the agent three separate tools:
read_filewrite_filerun_deploy
Now, the agent can compose these tools. If run_deploy fails, the agent can read the error, use write_file to fix the config, and try run_deploy again.
How does the system actually handle this? Let's look at the flow when a user asks the agent to "Clean up my temporary files."
In the Compound Engineering Plugin, tools are defined using a standard format (often called MCP). Here is how simple a tool definition looks.
Example: A tool to read a file.
// Define the tool name and description
tool("read_file", "Read the contents of a file",
// Define the inputs the tool needs (using Zod for validation)
{
path: z.string().describe("The file path to read")
},
// Define what happens when the tool runs
async ({ path }) => {
const content = await fs.readFile(path, 'utf-8');
return { content: [{ type: "text", text: content }] };
}
);
Explanation:
read_file. The agent sees this name.path.If the tool is just "Read File," where is the intelligence? Where is the "Feature"?
In Agent-Native Architecture, the feature is the Prompt.
Instead of writing code to "Analyze Logs," we give the agent the read_file tool and a System Prompt:
## Your Job
You are a Log Analyzer.
1. Use `read_file` to open log files.
2. Look for lines containing "ERROR".
3. Summarize the errors for the user.
If we want to change how the feature works (e.g., look for "WARNING" too), we don't change the code. We just update the prompt.
Let's look back at the Compound Engineering Workflow from Chapter 1. We had a command /workflows:compound.
How is that built? It is NOT a giant script. It is an Agent-Native solution.
list_filesread_filewrite_file/workflows:compound command sends this prompt to the agent:
> "Review the changes made in the last session. Identify the problem and the solution. Create a new markdown file in docs/solutions/ describing the fix."
Agent-Native Architecture is about equality.
read, write), not complex scripts.By building our plugin this way, we don't just build a "Bug Fixer." We build a system that can fix bugs, write docs, and refactor code, all using the same basic set of file-editing tools.
In the next chapter, we will discuss the "workers" that use these tools.
Generated by Code IQ