Skip to content

microsoft/RPG-ZeroRepo

Repository files navigation

RPG-ZeroRepo

RPG-ZeroRepo turns Repository Planning Graphs into a control layer for long-horizon AI coding agents.

Paper 1: arXiv:2509.16198 Paper 2: arXiv:2602.02084 ICLR 2026 ICML 2026 Python 3.11+ License: MIT

🔥 New: RPG-Kit is now open source for Claude Code and GitHub Copilot.

Coding agents often lose repository-level context across long tasks: requirements drift, architecture decisions disappear, and edits miss hidden dependencies.

RPG-Kit gives agents a persistent RPG workspace so they can plan, generate, understand, and update repositories through a shared graph instead of transient chat history and file search.

The repository also includes the research code: ZeroRepo implements the forward pipeline (requirements → RPG → repository), and RPG-Encoder implements the reverse pipeline (repository → RPG).


News

  • [2026-05-15] 🔥 RPG-Kit is now open source for Claude Code and GitHub Copilot. It uses Repository Planning Graphs as a control layer for long-horizon coding agents, including planning, multi-file generation, repository understanding, and graph-aware updates.
  • [2026-05-01] 🎉 RPG-Encoder (Closing the Loop: Universal Repository Representation with RPG-Encoder) has been accepted to ICML 2026.
  • [2026-03-02] 🔥 We have open-sourced the EpiCoder Feature Tree at Hugging Face, providing structured knowledge for repository planning in ZeroRepo.
  • [2026-02-27] 🔥 We released the code for RPG-Encoder and RepoCraft.
  • [2026-01-26] 🔥 RPG-ZeroRepo was accepted as a poster at ICLR 2026.

Documentation


RPG-Kit

RPG-Kit turns Repository Planning Graphs into a control layer for long-horizon AI coding agents.

Good planning for coding agents should be grounded, executable, verifiable, and reusable. RPG-Kit makes the plan a graph, not a transient chat artifact.

RPG-Kit gives agents such as Claude Code and GitHub Copilot a persistent RPG workspace for planning, generation, repository understanding, and graph-aware editing.

Why RPG-Kit?

Coding agents are strong at local edits, but repository-level work requires durable context: requirements, architecture, implementation progress, and dependencies must stay aligned across many steps.

Without RPG-Kit With RPG-Kit
The agent relies on chat history and file search. The agent works against a structured RPG workspace.
Requirements and design decisions drift over long tasks. Requirements, features, architecture, and files stay connected in the graph.
Multi-file generation can become inconsistent. Generation follows an explicit planning graph.
Updates are often local edits without impact analysis. Edits are planned through affected RPG nodes and dependencies.
The repository map is rebuilt mentally every time. The RPG is searchable, explorable, and reusable across tasks.

What can I do with RPG-Kit?

Task Start from RPG-Kit workflow Benefit
Build a new repository A natural-language requirement Create an RPG plan, refine it into architecture/tasks, then generate code. A persistent plan for long-horizon multi-file generation.
Understand an existing repository An existing codebase Encode the repo into an RPG workspace, then search, explore, and explain through MCP tools (search_rpg, explore_rpg, get_node_detail). A structured repository map beyond chat history and file search.
Update an existing repository A codebase + change request Use the RPG to locate affected nodes, plan the edit, and update code and graph together (/rpgkit.rpg_edit "..."). Graph-aware edits that account for cross-file dependencies.

Quick Start

uv tool install rpgkit-cli \
  --from "git+https://github.com/microsoft/RPG-ZeroRepo.git#subdirectory=RPG-Kit"
rpgkit check

On an existing repository:

cd your-existing-repo
rpgkit init . --encode
# In Claude Code or GitHub Copilot:
# /rpgkit.rpg_edit  "Add rate limiting to all API endpoints"

Generate a new repository:

rpgkit init my-project
cd my-project
# In Claude Code or GitHub Copilot:
# /rpgkit.feature_spec  Build a CLI tool for managing Docker containers
# /rpgkit.feature_build → /rpgkit.feature_refactor → ... → /rpgkit.code_gen

See RPG-Kit/README.md for the full setup, slash commands, and MCP tools. Also available in 简体中文 · 日本語 · 한국어 · हिन्दी.

Overview

RPG-Kit gives Claude Code and GitHub Copilot a persistent RPG workspace for repository-level tasks. Instead of relying only on chat history, file search, and local context, the agent can carry repository-level planning state across long tasks.

RPG-Kit exposes the RPG workspace through three interfaces:

  • CLI setup — initialize RPG-Kit in a new or existing repository with rpgkit init.
  • Slash commands — run build, understand, and update workflows inside the coding agent (/rpgkit.feature_spec, /rpgkit.code_gen, /rpgkit.encode, /rpgkit.rpg_edit, and more).
  • MCP graph tools — let the agent search, inspect, and traverse RPG nodes during coding (search_rpg, explore_rpg, get_node_detail, list_rpg_tree).

RPG-Kit can keep the RPG in sync with code changes through a post-commit hook, so edits made by the agent or directly in code can be reflected back into the graph.

Supported agents: Claude Code (verified), GitHub Copilot (verified).

RPG-Kit in action

The graph below was produced by running /rpgkit.encode on this repository:

RPG visualization of this repository

This illustrates how RPG-Kit turns an existing repository into an RPG that agents can search, explore, and use for graph-aware edits.

See RPG-Kit/ for the full guide.


Standalone research code

ZeroRepo and RPG-Encoder are the standalone research pipelines for constructing RPGs:

requirements → RPG → repository      # ZeroRepo
repository → RPG                     # RPG-Encoder

RPG-Kit (above) is the agent-facing layer that uses RPGs from either direction. The components below run without an agent CLI — useful for paper reproduction and benchmarking.

Component Use it for
ZeroRepo Reproduce the RPG paper's forward pipeline.
RPG-Encoder Reproduce the RPG-Encoder paper's reverse pipeline.
RepoCraft Evaluate repository-level code generation.

ZeroRepo: requirements → RPG → repository

RPG: A Repository Planning Graph for Unified and Scalable Codebase GenerationarXiv:2509.16198, ICLR 2026

ZeroRepo is the forward generation framework. It turns a natural-language project requirement into an RPG, refines the graph into architecture and implementation tasks, and generates a complete repository in dependency-aware order.

Pipeline:

  1. Feature planning — decompose user requirements into a structured feature tree and component decomposition.
  2. Architecture design — map features to modules, files, classes, interfaces, and data flows. Build the full RPG.
  3. Graph-guided code generation — generate interdependent files in dependency order, using the RPG as the persistent execution state.

ZeroRepo three-phase pipeline

python main.py \
  --config configs/zerorepo_config.yaml \
  --checkpoint ../my_project/checkpoints \
  --repo ../my_project/workspace \
  --phase all \
  --resume

See docs/zerorepo-pipeline.md for phase details, checkpoint files, intermediate file reference, and configuration.

RPG-Encoder: repository → RPG

Closing the Loop: Universal Repository Representation with RPG-EncoderarXiv:2602.02084, ICML 2026

RPG-Encoder closes the loop by mapping existing codebases back into Repository Planning Graphs. The resulting RPG captures both semantic intent and structural dependencies.

This enables agents to:

  • understand what each part of the repository is for;
  • navigate from features to files/functions and back;
  • update RPGs incrementally after code changes;
  • use the graph as context for maintenance and editing tasks.

Three mechanisms

Mechanism Module Description
Encoding rpg_parsing/ Extracts RPG from raw codebases via semantic lifting, structure reorganization, and artifact grounding
Evolution rpg_parsing/rpg_evolution.py Incrementally maintains RPGs via commit-level diff parsing, avoiding full re-encoding after every change
Operation rpg_agent/ Provides a unified agentic interface (SearchNode, FetchNode, ExploreRPG) for structure-aware navigation

Quick start (standalone)

python parse_rpg.py parse \
    --repo-dir /path/to/repo \
    --repo-name myrepo \
    --save-dir ./output

# Incrementally update after code changes:
python parse_rpg.py update \
    --repo-dir /path/to/updated/repo \
    --last-repo-dir /path/to/old/repo \
    --load-path ./output/rpg_encoder.json \
    --save-dir ./output

See zerorepo/rpg_encoder/README.md for detailed documentation.

RepoCraft Benchmark

RepoCraft is the benchmark and evaluation suite for repository-level code generation. It evaluates whether a model can plan and generate repository-scale software artifacts rather than isolated functions.

It consists of 1,052 tasks across 6 real-world Python projects (scikit-learn, pandas, sympy, statsmodels, requests, django).

Metric Description
Coverage Proportion of reference feature categories covered
Accuracy Pass Rate (unit tests) and Voting Rate (semantic checks)
Code Statistics File count, Lines of Code (LOC), Token count

See repocraft/README.md for the full pipeline documentation.


Papers

  • RPG / ZeroRepo: Luo et al., RPG: A Repository Planning Graph for Unified and Scalable Codebase Generation, arXiv:2509.16198, ICLR 2026.
  • RPG-Encoder: Luo et al., Closing the Loop: Universal Repository Representation with RPG-Encoder, arXiv:2602.02084, ICML 2026.

Citation

@article{luo2025rpg,
  title={RPG: A Repository Planning Graph for Unified and Scalable Codebase Generation},
  author={Luo, Jane and Zhang, Xin and Liu, Steven and Wu, Jie and Liu, Jianfeng and Huang, Yiming and Huang, Yangyu and Yin, Chengyu and Xin, Ying and Zhan, Yuefeng and others},
  journal={arXiv preprint arXiv:2509.16198},
  year={2025}
}

@article{luo2026closing,
  title={Closing the Loop: Universal Repository Representation with RPG-Encoder},
  author={Luo, Jane and Yin, Chengyu and Zhang, Xin and Li, Qingtao and Liu, Steven and Huang, Yiming and Wu, Jie and Liu, Hao and Huang, Yangyu and Kang, Yu and others},
  journal={arXiv preprint arXiv:2602.02084},
  year={2026}
}

Acknowledgements

We thank the following projects for inspiration and valuable prior work that helped shape this project:

License

MIT License — see LICENSE for details.

About

[ICLR 2026] RPG: A Repository Planning Graph for Unified and Scalable Codebase Generation

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages