Table of Contents
Fetching ...

RPG: A Repository Planning Graph for Unified and Scalable Codebase Generation

Jane Luo, Xin Zhang, Steven Liu, Jie Wu, Jianfeng Liu, Yiming Huang, Yangyu Huang, Chengyu Yin, Ying Xin, Yuefeng Zhan, Hao Sun, Qi Chen, Scarlett Li, Mao Yang

TL;DR

RPG introduces a Repository Planning Graph to unify proposal and implementation planning for large-scale repository generation, using a graph to encode capabilities, file structures, data flows, and functions. ZeroRepo implements a three-stage pipeline: proposal-level planning, implementation-level construction, and graph-guided code generation with test validation. RepoCraft benchmark across six real-world Python repos (1052 tasks) shows ZeroRepo achieves 81.5% functional coverage and 69.7% test accuracy, generating repositories with ~36k LOC and 445k tokens, surpassing baselines by substantial margins. RPG supports near-linear scaling of functionality and code size, demonstrates complex data flow dependencies, and improves agent localization and understanding of repositories, enabling scalable, coherent, long-horizon code generation.

Abstract

Large language models excel at generating individual functions or single files of code, yet generating complete repositories from scratch remains a fundamental challenge. This capability is key to building coherent software systems from high-level specifications and realizing the full potential of automated code generation. The process requires planning at two levels: deciding what features and modules to build (proposal stage) and defining their implementation details (implementation stage). Current approaches rely on natural language planning, which often produces unclear specifications, misaligned components, and brittle designs due to its inherent ambiguity and lack of structure. To address these limitations, we introduce the Repository Planning Graph (RPG), a structured representation that encodes capabilities, file structures, data flows, and functions in a unified graph. By replacing free-form natural language with an explicit blueprint, RPG enables consistent long-horizon planning for repository generation. Building on RPG, we develop ZeroRepo, a graph-driven framework that operates in three stages: proposal-level planning, implementation-level construction, and graph-guided code generation with test validation. To evaluate, we construct RepoCraft, a benchmark of six real-world projects with 1,052 tasks. On RepoCraft, ZeroRepo produces nearly 36K Code Lines and 445K Code Tokens, on average 3.9$\times$ larger than the strongest baseline (Claude Code), and 68$\times$ larger than other baselines. It achieves 81.5% coverage and 69.7% test accuracy, improving over Claude Code by 27.3 and 35.8 points. Further analysis shows that RPG models complex dependencies, enables more sophisticated planning through near-linear scaling, and improves agent understanding of repositories, thus accelerating localization.

RPG: A Repository Planning Graph for Unified and Scalable Codebase Generation

TL;DR

RPG introduces a Repository Planning Graph to unify proposal and implementation planning for large-scale repository generation, using a graph to encode capabilities, file structures, data flows, and functions. ZeroRepo implements a three-stage pipeline: proposal-level planning, implementation-level construction, and graph-guided code generation with test validation. RepoCraft benchmark across six real-world Python repos (1052 tasks) shows ZeroRepo achieves 81.5% functional coverage and 69.7% test accuracy, generating repositories with ~36k LOC and 445k tokens, surpassing baselines by substantial margins. RPG supports near-linear scaling of functionality and code size, demonstrates complex data flow dependencies, and improves agent localization and understanding of repositories, enabling scalable, coherent, long-horizon code generation.

Abstract

Large language models excel at generating individual functions or single files of code, yet generating complete repositories from scratch remains a fundamental challenge. This capability is key to building coherent software systems from high-level specifications and realizing the full potential of automated code generation. The process requires planning at two levels: deciding what features and modules to build (proposal stage) and defining their implementation details (implementation stage). Current approaches rely on natural language planning, which often produces unclear specifications, misaligned components, and brittle designs due to its inherent ambiguity and lack of structure. To address these limitations, we introduce the Repository Planning Graph (RPG), a structured representation that encodes capabilities, file structures, data flows, and functions in a unified graph. By replacing free-form natural language with an explicit blueprint, RPG enables consistent long-horizon planning for repository generation. Building on RPG, we develop ZeroRepo, a graph-driven framework that operates in three stages: proposal-level planning, implementation-level construction, and graph-guided code generation with test validation. To evaluate, we construct RepoCraft, a benchmark of six real-world projects with 1,052 tasks. On RepoCraft, ZeroRepo produces nearly 36K Code Lines and 445K Code Tokens, on average 3.9 larger than the strongest baseline (Claude Code), and 68 larger than other baselines. It achieves 81.5% coverage and 69.7% test accuracy, improving over Claude Code by 27.3 and 35.8 points. Further analysis shows that RPG models complex dependencies, enables more sophisticated planning through near-linear scaling, and improves agent understanding of repositories, thus accelerating localization.

Paper Structure

This paper contains 96 sections, 2 equations, 15 figures, 15 tables, 4 algorithms.

Figures (15)

  • Figure 1: The ZeroRepo pipeline for repository generation. (A) Proposal-level construction translates specifications into a functionality graph. (B) Implementation-level construction refines it via (B1) file-structure encoding into a file-augmented graph and (B2) data-flow/function encoding into the final Repository Planning Graph (RPG). (C) Graph-guided code generation traverses RPG in topological order to produce a stable repository.
  • Figure 2: Example of a Repository Planning Graph: Solid lines show hierarchy, black arrows for inter-module flows, dashed gray arrows for intra-module order.
  • Figure 3: Pipeline for Evaluation Task Collection. It comprises test file filtering, hierarchical parsing into test trees, sampling and filtering, and final task generation.
  • Figure 3: Coverage and Novelty of the Constructed RPG over Iterations on MLKit-Py (o3-mini)
  • Figure 4: Illustration of dependencies in the repository generated by Qwen3-Coder on MLKit-Py, showing (1) the repository skeleton at the folder/file level, (2) inter-module data flows, and (3) class and function dependencies.
  • ...and 10 more figures