TL;DR
Automated code documentation usually reads like a list of ingredients rather than a recipe: it tells you what every single function does, without ever explaining why the system was built that way. RepoScope solves this by mapping both a codebase's folder layout and its execution flow, then running a hypothesis-driven loop that infers high-level architectural intent and fact-checks it against raw code. The result is cohesive, human-like documentation that massively boosts how well both engineers and AI coding agents navigate sprawling, unfamiliar repositories.
What Problem Does This Paper Address?
As AI coding assistants accelerate how fast we generate and modify software, human-written documentation struggles to keep up. Existing automated tools try to bridge this gap from the bottom up: they chop a repository into individual files or functions, summarize each one using an LLM, and stack those summaries together.
That sounds reasonable, until you look at a real-world codebase and hit two major roadblocks:
- Physical–Logical Misalignment: How developers organize folders (physical layout) rarely matches how functions actually call one another (logical flow). A single feature might span five directories, while a humble logging utility gets called everywhere, tangling the dependency graph into a hairball. Relying on folders or call graphs alone gives you fragmented or distorted chunks of code.
- Contextual Isolation: Code rarely states its grander architectural purpose explicitly. Two functions might look nearly identical in isolation, yet serve wildly different roles in the broader system. Pure bottom-up summarization captures local mechanics ("this parses a JSON string") while completely missing architectural intent ("this acts as the security boundary for incoming webhooks").
Methods
RepoScope abandons one-way summarization in favor of a two-stage pipeline that reconciles structure and tests architectural hypotheses.
First, Physical-Logical Partitioning (PLP) carves the repository into coherent, document-worthy units called Buckets:
- It scans the call graph to find "entry anchors"—starting-point functions with few incoming internal calls—and traces what they reach downstream, discounting globally shared utilities so helper files don't glue unrelated modules together.
- It projects these logical groups onto the folder tree and refines the boundaries using local confidence weights—trusting the call graph where execution flow is clear, and leaning on folder structure where calls get noisy. Non-code artifacts like configs and tests are attached to whichever bucket they best support.
Second, Seeded Architectural Intent Lift (SAIL) turns those buckets into a multi-level documentation hierarchy via a seed–revise–lift loop:
- Seed (Top-Down): Looking at a bucket alongside its neighbors and config files, an LLM drafts a provisional hypothesis—an intent seed—about the bucket's architectural role.
- Revise (Bottom-Up): The bucket is broken into smaller, context-sized code cells. As the LLM documents each cell using the seed as context, it can flag inaccuracies—proposing revisions only if backed by hard code evidence. An adjudicator reviews all cell proposals, updates the bucket's intent, and selectively regenerates ("replays") affected cell docs so everything stays consistent.
- Lift: Once verified, these grounded intents are aggregated upward from cells to buckets, modules, and a global repository overview.
Datasets
RepoScope is evaluated across both public benchmarks and confidential enterprise environments (no model training is involved, as it is an inference-time framework):
- CodeWikiBench: An existing public benchmark of 21 open-source repositories spanning diverse languages (Python, JS/TS, C#, Java, C, C++) and sizes (from 86k up to 1.4M lines of code in Wazuh), graded against human-authored documentation rubrics.
- Industrial C++ Systems: A newly introduced real-world evaluation across three anonymized production C++ codebases (23K–25K files, >15K header files, and up to 1.06GB of code artifacts each). On these systems, the authors introduce an agentic CLI Extraction task: measuring how well an autonomous Claude Code agent can discover and execute valid command-line APIs using the generated documentation.
Key Insights and Ideas
- Treat architecture like a scientific hypothesis: Guessing top-down architecture without reading every line leads to hallucinations; reading bottom-up without a big-picture hypothesis misses the forest for the trees. RepoScope's Grounded Intent Revision gets the best of both worlds—disabling the revision step drops benchmark scores from 73.88% down to 58.92%.
- Quality beats sheer verbosity: Generating more text doesn't mean better documentation. A baseline agent (DocAgent) produced 37% more text than RepoScope yet scored 17.51 percentage points lower, proving that structural alignment matters far more than word count.
- AI agents need maps, not just source code: Even when an autonomous coding agent has full access to raw source files, it struggles to find entry points and compose multi-step API calls in massive codebases. Good architectural docs act as force multipliers for agentic reasoning.
Key Results
On CodeWikiBench, RepoScope achieves state-of-the-art results across every single repository tested. Across the 7 core repositories, it averages a 73.88% quality score (covering 362/486 rubric targets), beating the strongest commercial baseline, DeepWiki (60.76%, 297/486 targets), by over 13 percentage points. Even on the massive 1.4M-LOC C codebase Wazuh, RepoScope scores 67.48% vs. DeepWiki's 57.09%.
On the Industrial CLI Extraction task across 282 expert-identified APIs:
- With Raw Code alone, the Claude Code agent discovered just 79 APIs and successfully executed 60.
- Equipped with RepoScope documentation, the agent discovered 227 APIs and executed 195—substantially outperforming CodeWiki (190 discovered, 149 executed).
- On the hardest industrial system requiring multi-step API composition, RepoScope more than tripled executable APIs over the best baseline (17 vs. 5). A supplementary developer study also noted lower median completion times for engineers writing test cases with RepoScope.
Limitations and Future Work
On the most complex industrial codebase (System 3), while RepoScope helped the agent find 46 out of 50 APIs, only 17 passed execution tests. The authors note that this reflects a limitation in their downstream evaluation setup: they used a generic, general-purpose Claude Code prompt (HARNESS.md) across all tests rather than a specialized agentic workflow built for multi-step API composition. Designing task-specific agent pipelines that more deeply exploit hierarchical documentation is left for future work.
Summary updated