A 200-Line Agent That Builds React Apps Explains How Cursor Actually Works
Cursor, Copilot, and Devin all run on the same ReAct loop pattern. Seeing it implemented in under 200 lines strips away the magic and exposes the real engineering levers: tool design, context passing, and prompt guardrails. Developers who understand this can debug agent behavior, build custom coding agents, and evaluate tools by their loop architecture rather than by model brand.
A ReAct loop—LLM reasoning, tool execution, result feedback—drives an autonomous programming agent in fewer than 200 lines of Node.js. The agent creates a Vite React-TS project, writes a complete TodoList with localStorage persistence and styled UI, installs dependencies, and starts the dev server, all without human intervention. The loop itself is a simple for-loop that feeds tool results back into the message history; the LLM never plans globally, only decides the next step from the latest context.
Tool design turns out to be a conversation with the model, not an API contract. Three trade-offs shape reliability: auto-creating directories on write to tolerate the LLM’s coarse path generation, using spawn with stdio inherit for user-visible commands while sacrificing output capture, and tuning tool descriptions to disambiguate similar operations without burning context window.
Comparing the mini-agent to Cursor reveals the same ReAct skeleton, scaled up with hundreds of tools, context compression, diff-level edits, GUI interaction, and persistent memory. The core insight is that Cursor’s strength owes as much to toolchain and context engineering as to model quality.
The ReAct pattern shifts complexity from the model to the environment: the message history and tool results carry the state, so the model only needs to make one good local decision at a time.
Tool design for agents is closer to UX writing than to API design. You are anticipating where the LLM will hesitate and preemptively clarifying the path.
Cursor’s perceived intelligence is often misattributed to model quality; toolchain design and context management are equally decisive and more directly engineerable.
Writing explicit counter-examples in the system prompt—showing both wrong and right tool usage—is a cheap, high-leverage way to prevent known failure modes.