Abstract
Understanding an unfamiliar codebase is an essential task for developers in various scenarios, such as during the onboarding process. Especially when the codebase is large and time is limited, achieving a decent level of comprehension remains challenging for both experienced and novice developers, even with the assistance of LLMs. Existing studies have shown that LLMs often fail to support users in understanding code structures or to provide user-centered, adaptive, and dynamic assistance in real-world settings. To address this, we propose learning from the perspective of a unique role, code auditors, whose work often requires them to quickly familiarize themselves with new code projects on a weekly or even daily basis. To achieve this, we recruited and interviewed 8 code auditing practitioners to understand how they master codebase understanding. We identified four design opportunities for an LLM-based codebase understanding system: supporting cognitive alignment through automated codebase information extraction, decomposition, and representation, as well as reducing manual effort and conversational distraction through interaction design. To validate these four design opportunities, we designed a system prototype, CodeMap, that provides dynamic information extraction and representation aligned with the human cognitive flow and enables interactive switching among hierarchical codebase visualizations. We then conducted a user study with nine experienced developers and six novice developers. Our results demonstrate that CodeMap significantly improved users' perceived intuitiveness, ease of use, and usefulness in supporting code comprehension, while reducing their reliance on reading and interpreting LLM responses by 79% and increasing map usage time by 90% compared to the static visualization analysis tool.
Introduction
Onboarding to a new codebase is one of the most time-consuming tasks for a software engineer. While current Large Language Models (LLMs) like ChatGPT are excellent at explaining isolated snippets of code, they struggle to provide a cohesive, repository-level understanding. Traditional static analysis tools attempt to solve this by generating dependency graphs, but these often result in overwhelming, cluttered visualizations that lack semantic context.
To build a better codebase comprehension tool, the authors looked at a unique group of professionals: code auditors. Because auditors must deeply understand new, complex codebases on a weekly or even daily basis under strict deadlines, they possess highly optimized, tacit strategies for code comprehension that standard developers lack.
Methodology
The researchers used a human-centered design approach divided into four main stages, starting from formative interviews with professional code auditors to identify design opportunities, followed by prototype design and validation.
- Formative Study: Interviews with 8 professional code auditors revealed a strict top-down cognitive workflow: Global (project overview/architecture) $\rightarrow$ Local (module/file relationships) $\rightarrow$ Detailed (specific functions/variables).
- System Design (CodeMap): Based on these insights, the authors built CodeMap, a web application powered by GPT-4o and a Retrieval-Augmented Generation (RAG) backend.
The CodeMap System
CodeMap shifts the developer's workflow from reading walls of AI-generated text to exploring structured, semantic visual representations. Instead of a standard chat interface, CodeMap uses expert-crafted prompt templates to automatically extract codebase structures and render them as interactive DOT graphs.
Key features include:
- Interactive Visualizations: Users can click on visual nodes (modules/functions) to drill down into local and detailed views.
- Iterative Refinement: To combat LLM hallucinations, the system uses a loop where the LLM checks and updates its own generated graphs over several passes.
- In-Context Querying: Users can ask questions about specific nodes, ensuring the LLM's answer is grounded in the exact module being viewed.
Key Insights and Results
The system was evaluated in an observational study with 15 participants (9 experienced developers and 6 novices), comparing CodeMap against baseline ChatGPT and a commercial static analysis tool.
Behavioral Shift
Compared to using the static visualization tool, CodeMap users spent 75% less time reading raw code and 90% more time utilizing the system-provided maps. Furthermore, participants spent 79% less time reading LLM responses compared to using baseline ChatGPT, relying instead on visual maps to build mental models.
Addressing the "Blank Canvas" Problem
Raw conversational LLMs often hinder novice developers because they don't know what questions to ask. CodeMap solves this by providing a predefined, step-by-step architectural reading guide. 100% of experienced developers found CodeMap more intuitive than both ChatGPT and the static analysis baseline.
Limitations and Future Work
CodeMap's performance is currently bottlenecked by LLM context windows and RAG retrieval accuracy, particularly for massive repositories (e.g., 79,000+ lines). Future work involves leveraging growing LLM context windows (1M+ tokens) to improve global mapping and expanding this framework into educational settings to help students navigate complex software architectures.
Summary updated