<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Shorworry</title>
    <description>The latest articles on DEV Community by Shorworry (@shorworry).</description>
    <link>https://dev.to/shorworry</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3963516%2Ff71fff5a-cac8-48d2-b6a2-97301886626a.png</url>
      <title>DEV Community: Shorworry</title>
      <link>https://dev.to/shorworry</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/shorworry"/>
    <language>en</language>
    <item>
      <title>I built an AI agent that reads codebases so you don't have to</title>
      <dc:creator>Shorworry</dc:creator>
      <pubDate>Tue, 02 Jun 2026 00:14:28 +0000</pubDate>
      <link>https://dev.to/shorworry/i-built-an-ai-agent-that-reads-codebases-so-you-dont-have-to-2nkb</link>
      <guid>https://dev.to/shorworry/i-built-an-ai-agent-that-reads-codebases-so-you-dont-have-to-2nkb</guid>
      <description>&lt;p&gt;Every developer has felt it. You join a new project, someone points you at a GitHub repo, and says "just explore the code." Two hours later you're still reading files one by one, trying to figure out which file talks to which, where the actual logic lives, and why there are four different things called "manager."&lt;br&gt;
I got tired of that. So I built something about it.&lt;/p&gt;

&lt;p&gt;The idea was simple. The execution wasn't.&lt;br&gt;
Give it a GitHub URL. It clones the repo, figures out the architecture, and hands you an interactive dependency graph with a natural-language summary of how everything fits together.&lt;br&gt;
Simple idea. Except — how do you actually teach a machine to understand a codebase the way a senior engineer would?&lt;br&gt;
You don't write rules. You give it tools and let it explore.&lt;/p&gt;

&lt;p&gt;The agent&lt;br&gt;
The core of CodeNarrator is an agentic loop. A locally-hosted LLM — Qwen2.5-Coder 7B running via Ollama — gets five tools:&lt;/p&gt;

&lt;p&gt;read_file — open a source file&lt;br&gt;
follow_import — jump to a file this one imports&lt;br&gt;
search_for_pattern — grep across the repo&lt;br&gt;
mark_architecture_insight — record a finding&lt;br&gt;
stop_analysis — finish when done&lt;/p&gt;

&lt;p&gt;The model decides what to read, what to follow, and when it has seen enough. No hardcoded traversal logic. No hand-written rules about which files matter. The agent figures it out.&lt;br&gt;
At least, that was the theory.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Problem 1: The agent was lazy&lt;/strong&gt;&lt;br&gt;
Left to its own devices, the model would find main.py or App.tsx, follow one import chain all the way down, and call it done. It explored ten files in a 44-file repo and declared victory.&lt;br&gt;
The dependency graph looked like a stick figure.&lt;br&gt;
The fix wasn't obvious. The scoring system that ranked candidate files was biased toward depth — files in the current import chain scored higher than files in unexplored directories. The agent was being rewarded for going deep rather than wide.&lt;br&gt;
I rebuilt the scoring: unvisited directories now get a bonus. The nudge logic was rewritten to surface files from folders the agent hadn't touched yet. The system prompt explicitly tells the model "after every 2-3 files in the same directory, go somewhere new."&lt;br&gt;
The graphs started looking like actual architectures.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Problem 2: Python repos had zero edges&lt;/strong&gt;&lt;br&gt;
I ran CodeNarrator on a FastAPI project and got a beautiful graph — of nothing. Every node was floating, disconnected. Zero internal edges.&lt;br&gt;
The bug was in _detect_python_package_roots. For repos where all packages live inside a backend/ or src/ wrapper, the function was returning "." as the package root instead of "backend". So when the import extractor tried to resolve import db.database, it was looking in the wrong place. Every internal import was silently treated as external.&lt;br&gt;
One wrong assumption, buried three function calls deep, was making the entire graph useless for a huge class of real-world Python projects.&lt;br&gt;
Fixed it. Went from zero edges to 35+ on the next run.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Problem 3: TypeScript components were invisible&lt;/strong&gt;&lt;br&gt;
The file scanner didn't have .tsx in its extension map. Every React component in every TypeScript project was being silently skipped — scanned past, never explored, appearing only as grey phantom nodes in the graph.&lt;br&gt;
One missing line. Hundreds of files invisible.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The two-layer design&lt;/strong&gt;&lt;br&gt;
The thing I'm most proud of isn't any single fix. It's the architecture.&lt;br&gt;
CodeNarrator has two completely independent layers. The &lt;strong&gt;deterministic layer&lt;/strong&gt; — file scanning, import extraction, dependency graph computation — runs with pure Python and no LLM. It always produces something. The &lt;strong&gt;agentic layer&lt;/strong&gt; sits on top and adds intelligence: prioritization, architectural reasoning, natural language summaries.&lt;br&gt;
If the LLM times out, crashes, or produces garbage — the report still renders. The deterministic layer already built the graph. The AI is an enhancement, not a dependency.&lt;br&gt;
That design decision saved the project from becoming a "works on my machine" demo.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What's next&lt;/strong&gt;&lt;br&gt;
The Ollama dependency is the main friction point. Running a 7B model locally requires decent hardware. Pluggable LLM backends — OpenAI, Anthropic, any OpenAI-compatible API — are next. So is a CLI, and full dependency graph support for Java, Go, Rust, and C/C++.&lt;br&gt;
The core is solid. The hard problems are solved. Everything from here is additive.&lt;/p&gt;

&lt;p&gt;Try it&lt;br&gt;
&lt;code&gt;pip install codenarrator-ai&lt;/code&gt;&lt;br&gt;
PyPI: &lt;a href="https://dev.tourl"&gt;pypi.org/project/codenarrator-ai&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>python</category>
      <category>productivity</category>
    </item>
  </channel>
</rss>
