RPG-ZeroRepo: The AI Repo Generator That Plans the Code Before It Writes It
Microsoft Research’s framework turns a vague software request into a dependency-aware repository blueprint, then generates files in the order the structure demands.
- RPG-ZeroRepo’s core move is to insert a planning graph between a user request and generated code, so repository coherence becomes an explicit artifact instead of an accidental byproduct.
- The Repository Planning Graph gives the system a reasoned structure for features, folders, files, and dependencies, which makes generation feel closer to software architecture than autocomplete.
- Dependency labels like CONTAINS, IMPORTS, and INVOKES turn the plan into a build order, so foundational code gets written before the code that depends on it.
- The reverse-engineering path matters because the project is not only about creating repos from scratch, but also about compressing existing ones back into a machine-readable model.
Most AI coding tools are judged on what they can write. RPG-ZeroRepo is interesting because it cares just as much about what gets decided before writing starts. That shift sounds small. It is the difference between a model that improvises and a model that has an architecture to follow.
The missing layer between prompt and repo
The project’s basic bet is simple: single-file generation is not the hard part. The hard part is keeping a repository coherent when the app spans folders, modules, dependencies, and implementation order. RPG-ZeroRepo inserts a Repository Planning Graph between the prompt and the filesystem, so the model does not jump straight from intent to code.
That matters because software is full of hidden prerequisites. A utility has to exist before the feature that imports it. A shared interface has to settle before multiple implementations depend on it. RPG-ZeroRepo makes those relationships first-class, so the generation process has something stronger than a free-form prompt chain to follow.
We propose RPG, a Recurrent Prompt Generation framework for zero-shot software development. RPG decomposes the software development process into several stages, and for each stage, it recurrently generates prompts to guide the LLMs to complete the corresponding tasks.
The Repository Planning Graph is the product
The Repository Planning Graph, or RPG, is the central artifact. It is not a side table of metadata. It is the operating model. The graph organizes the repository from the root level down through functional areas and into implementation nodes, preserving the reason each file exists as it is planned.
That is the key conceptual shift. Instead of treating files as independent outputs, RPG-ZeroRepo treats them as nodes in a designed topology. A feature path carries intent. A node is not just something to generate. It is something to place inside a broader structure that already explains its role.
# Simplified shape of the idea
class RPGNode:
def __init__(self, name, node_type, path=None):
self.name = name
self.node_type = node_type
self.path = path
self.children = []
self.edges = []
class EdgeType:
CONTAINS = "contains"
IMPORTS = "imports"
INVOKES = "invokes"
# The point is not just to store files.
# The point is to preserve why a file exists
# and what must come before it.
Dependencies become the build order
The next move is where the framework becomes more than a planning notebook. RPG-ZeroRepo models dependencies explicitly with edge types such as CONTAINS, IMPORTS, and INVOKES. That lets the system infer which parts of the repo are prerequisites and which parts should wait.
In practice, this turns generation into a sequencing problem. Shared utilities appear before modules that import them. Lower-level implementation comes before higher-level orchestration. The result is less like asking a chatbot for files in a random order and more like walking a graph whose edges encode the correct order of work.
The skeleton turns the blueprint into files
The bridge from plan to disk is the repository skeleton. In the codebase, RepoSkeleton acts like a virtual filesystem that maps abstract nodes to physical paths. That sounds mundane until you realize what it solves: the system can walk the planned repository without losing the relationship between structure and implementation.
This is where path conflicts, directory layout, and file insertion stop being afterthoughts. The skeleton ensures that the graph is not just readable by the model. It is actionable on the filesystem. The abstraction survives the trip from blueprint to directories and files.
# Simplified mental model
skeleton.insert_file(
path="functionality/ai/pathfinding.py",
node=file_node,
)
# If the path already exists or conflicts,
# the skeleton resolves the mismatch so
# the generated tree stays aligned with the RPG.
Generation is a state machine, not a one-shot prompt
RPG-ZeroRepo’s execution flow reinforces the same thesis. Generation is split into phases, with support for checkpointing and resume. That makes the process feel like a pipeline, not a chat session. If a long project fails halfway through, the system can pick up from the last successful state instead of starting over.
That design choice matters more than it first appears. A state machine assumes that software generation has history, progress, and failure modes. A one-shot prompt assumes none of those things. RPG-ZeroRepo is built for the former.
RPG-ZeroRepo is the implementation of RPG, which can automatically generate the code and documentation for a software project starting from a zero repository (i.e., only a requirement document).
Why reverse engineering matters
One of the more revealing parts of the repo is rpg_encoder/. It points to a larger ambition than generation alone. The system can also compress an existing repository back into a graph, which means the same representation can serve both creation and understanding.
That is a stronger claim than most AI code tools make. If you can encode a repo into a planning graph, then the graph is not just a prompt trick. It becomes a compact model of repository structure that can support maintenance, inspection, and future regeneration.
What it is competing with
RPG-ZeroRepo lives in the same broad world as Devin, MetaGPT, and GPT-Pilot, but it is solving a narrower problem. Devin aims for broad autonomy. MetaGPT simulates a software team. GPT-Pilot focuses on developer-in-the-loop assistance. RPG-ZeroRepo is more research-specific: it tries to prove that a structured prompt graph can preserve coherence at repository scale.
| Project | Primary goal | Core approach | Planning model | Human involvement |
|---|---|---|---|---|
| RPG-ZeroRepo | Research on repo-scale coherence | Recurrent prompt generation with explicit repository graphs | Hierarchical planning graph plus dependency graph | Low after requirements are provided |
| Devin | Autonomous engineering | Integrated agent with tools and environment access | Task-level planning across live tools | Low, with oversight |
| MetaGPT | Simulated software team | Role-based multi-agent collaboration | Specialized agent roles and handoffs | Medium |
| GPT-Pilot | Interactive app generation | Step-by-step developer assistant | Guided generation inside the workflow | Medium to high |
That distinction is the whole story. RPG-ZeroRepo is not trying to be the broadest agent. It is isolating one hard problem, repository coherence, and attacking it with explicit structure.
The limits are also the signal
The repo reads like a research prototype because it is one. It is modular, ambitious, and clearly designed to test an idea rather than polish a product. That is a feature, not a bug. The codebase is useful precisely because it reveals the method in the open: plan first, then generate, then checkpoint, then resume.
That is the signal to take away. The project suggests that the next step for AI coding tools may not be better autocomplete. It may be a better repository model, one that makes global structure visible before the first file is written.





