What is the Most Minimal Agentic Coder You Can Write?
By Ben Houston, 2025-03-21
Agentic coding has recently gained traction as an innovative approach where autonomous software agents leverage advanced Large Language Models (LLMs) to perform tasks traditionally done by developers. These agents can autonomously write code, execute commands, and debug software, dramatically enhancing developer productivity. But what's the simplest way you can create a functional agentic coder?
I explored this challenge and built mycoder-mini, an extremely minimal agentic coder in just around 200 lines of TypeScript code. The entire codebase is available in this GitHub repository, specifically within the single TypeScript file here.
How Does mycoder-mini Work?
At its core, mycoder-mini leverages an LLM (specifically, Anthropic's Claude 3) to generate shell commands based on a user's prompt. Here's the essence of its functionality in code:
const runAgentLoop = async (initialPrompt: string) => { const tools = [shellCommandSchema, finishedSchema]; const systemPrompt = `You are an AI agent that can run shell ` + `commands to accomplish tasks. Use provided tools to ` + `complete the user's task. Call the finished tool ` + `when done.`; let messages = [{ role: 'user', content: initialPrompt }]; while (true) { const response = await anthropic.messages.create({ model: 'claude-3-7-sonnet-20250219', messages, systemPrompt, tools }); messages.push({ role: 'assistant', content: response.content }); for (const block of response.content) { if (block.type === 'tool_use') { if (block.name === 'shellCommand') { const result = await shellCommand(block.input.command); messages.push({ role: 'user', content: [ { type: 'tool_result', tool_use_id: block.id, content: JSON.stringify(result) } ] }); } else if (block.name === 'finished') { return; } } } } };
In this simplified loop, the agent:
- Receives an initial goal from the user.
- Queries Claude 3.7 for commands.
- Executes shell commands returned by the model.
- Continues this loop until the task is marked as completed.
Limitations of the Minimal Approach
Despite its simplicity and functionality, mycoder-mini comes with notable limitations:
- Synchronous Execution: Commands are executed synchronously, which means it can't handle asynchronous processes, long-running CLI tools, or interactive shell sessions.
- No Browser Integration: It lacks browser automation capabilities, preventing interactions with web pages or dynamic data retrieval through browsing.
- Limited Toolset: It relies exclusively on shell commands, limiting it to tasks achievable purely through CLI.
Even with these constraints, mycoder-mini demonstrates the foundational principles of agentic coding clearly and concisely.
Try It Yourself
The complete implementation is accessible on GitHub. Whether for learning, experimentation, or expanding into more sophisticated agentic systems, mycoder-mini is a compelling starting point.