<?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: Raghav Chamadiya</title>
    <description>The latest articles on DEV Community by Raghav Chamadiya (@raghav_builds).</description>
    <link>https://dev.to/raghav_builds</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1769627%2Ff0561aef-260b-447c-a551-33ab21f4c895.png</url>
      <title>DEV Community: Raghav Chamadiya</title>
      <link>https://dev.to/raghav_builds</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/raghav_builds"/>
    <language>en</language>
    <item>
      <title>JavaScript/TypeScript dependency graph: 5 ways to generate one</title>
      <dc:creator>Raghav Chamadiya</dc:creator>
      <pubDate>Mon, 30 Nov 2026 13:00:00 +0000</pubDate>
      <link>https://dev.to/repowise/javascripttypescript-dependency-graph-5-ways-to-generate-one-1el9</link>
      <guid>https://dev.to/repowise/javascripttypescript-dependency-graph-5-ways-to-generate-one-1el9</guid>
      <description>&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;For an interactive HTML file graph of a JS/TS project, dependency-cruiser's &lt;code&gt;dot-webpage&lt;/code&gt; reporter is the most direct route. It needs Graphviz installed.&lt;/li&gt;
&lt;li&gt;madge is the quickest way to find circular imports, and writes SVG through Graphviz or JSON and DOT without it.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;nx graph&lt;/code&gt; and esbuild's metafile answer different questions: which packages depend on which, and what a bundle actually pulls in.&lt;/li&gt;
&lt;li&gt;On react/react, repowise's default architecture view draws 1,047 files and 3,633 dependencies, with 318 third-party modules hidden.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;This post first appeared on the repowise blog. "Show me the dependency graph" means a different thing in a single package, a monorepo and a bundle, so this is one command per tool and what each one actually outputs.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;To generate a JavaScript or TypeScript dependency graph, run &lt;code&gt;npx madge --image graph.svg src/&lt;/code&gt; for a quick SVG, or &lt;code&gt;npx depcruise src -T dot-webpage -f graph.html&lt;/code&gt; for interactive HTML (both need Graphviz). Use &lt;code&gt;npx nx graph&lt;/code&gt; for a package-level monorepo graph, esbuild's &lt;code&gt;--metafile&lt;/code&gt; for what a bundle pulls in, and repowise for a browsable graph with history.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Tool (version on npm)&lt;/th&gt;
&lt;th&gt;One command&lt;/th&gt;
&lt;th&gt;Unit&lt;/th&gt;
&lt;th&gt;Output&lt;/th&gt;
&lt;th&gt;Needs&lt;/th&gt;
&lt;th&gt;Best at&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;madge 8.0.0&lt;/td&gt;
&lt;td&gt;&lt;code&gt;npx madge --extensions ts,tsx --image graph.svg src/&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;File&lt;/td&gt;
&lt;td&gt;Text, JSON, DOT, SVG or PNG&lt;/td&gt;
&lt;td&gt;Graphviz for images, Node 18+&lt;/td&gt;
&lt;td&gt;Circular imports, a quick picture&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;dependency-cruiser 18.5.0&lt;/td&gt;
&lt;td&gt;&lt;code&gt;npx depcruise src -T dot-webpage -f graph.html&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;File, or folder with &lt;code&gt;archi&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;dot, mermaid, d2, json, csv, HTML matrix, interactive HTML&lt;/td&gt;
&lt;td&gt;Graphviz for dot-webpage and SVG, Node 22+&lt;/td&gt;
&lt;td&gt;Rules in CI, focused views&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Nx 23.2.1&lt;/td&gt;
&lt;td&gt;&lt;code&gt;npx nx graph --file=graph.html&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Project and task&lt;/td&gt;
&lt;td&gt;Browser UI, static HTML, JSON&lt;/td&gt;
&lt;td&gt;Nx in the repo (&lt;code&gt;nx init&lt;/code&gt;)&lt;/td&gt;
&lt;td&gt;Package graph in a monorepo&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;esbuild 0.28.2&lt;/td&gt;
&lt;td&gt;&lt;code&gt;npx esbuild src/index.ts --bundle --metafile=meta.json --outfile=out.js&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;File reached from an entry point&lt;/td&gt;
&lt;td&gt;JSON metafile, text with &lt;code&gt;--analyze&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;An entry point that bundles&lt;/td&gt;
&lt;td&gt;What ships in the bundle&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;repowise&lt;/td&gt;
&lt;td&gt;Paste a GitHub URL, or &lt;code&gt;repowise init&lt;/code&gt; then &lt;code&gt;repowise serve&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;File, symbol, layer&lt;/td&gt;
&lt;td&gt;Interactive graph in the browser, JSON, Structurizr DSL&lt;/td&gt;
&lt;td&gt;Nothing for a public repo, &lt;code&gt;pip install repowise&lt;/code&gt; locally&lt;/td&gt;
&lt;td&gt;Tracing paths, packages vs imports, co-change&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  1. madge: the quick graph and circular imports
&lt;/h2&gt;

&lt;p&gt;madge reads imports with a resolver per file type and prints, draws or exports the result.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# list each file's dependencies&lt;/span&gt;
npx madge --extensions ts,tsx --ts-config tsconfig.json src/

&lt;span class="c"&gt;# circular imports only&lt;/span&gt;
npx madge --circular --extensions ts,tsx src/

&lt;span class="c"&gt;# SVG image (needs Graphviz: brew install graphviz / apt-get install graphviz)&lt;/span&gt;
npx madge --extensions ts,tsx --image graph.svg src/

&lt;span class="c"&gt;# raw data&lt;/span&gt;
npx madge --extensions ts,tsx --json src/ &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; graph.json
npx madge --extensions ts,tsx --dot src/ &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; graph.gv
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;--orphans&lt;/code&gt; lists files nothing imports and &lt;code&gt;--leaves&lt;/code&gt; lists files that import nothing. Pass &lt;code&gt;--ts-config&lt;/code&gt; so path aliases like &lt;code&gt;@/components&lt;/code&gt; resolve. Without it they show up as missing.&lt;/p&gt;

&lt;p&gt;madge outputs text in the terminal, JSON, DOT, or an image whose format comes from the file extension, and it has no HTML output. Past a few hundred files the SVG gets too dense to read, so point it at one folder or use &lt;code&gt;--circular --image&lt;/code&gt; to draw only the cycles.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. dependency-cruiser: interactive HTML and rules
&lt;/h2&gt;

&lt;p&gt;dependency-cruiser does what madge does and adds rules you can enforce in CI. It has the widest choice of output formats of any tool here.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm install --save-dev dependency-cruiser
npx depcruise --init        &lt;span class="c"&gt;# writes a config with rules like no-circular and no-orphans&lt;/span&gt;

&lt;span class="c"&gt;# interactive HTML: hover a module to highlight what it imports and what imports it&lt;/span&gt;
npx depcruise src --include-only &lt;span class="s2"&gt;"^src"&lt;/span&gt; -T dot-webpage -f graph.html

&lt;span class="c"&gt;# SVG&lt;/span&gt;
npx depcruise src --include-only &lt;span class="s2"&gt;"^src"&lt;/span&gt; -T dot &lt;span class="o"&gt;|&lt;/span&gt; dot -T svg &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; graph.svg

&lt;span class="c"&gt;# folder-level overview instead of every file&lt;/span&gt;
npx depcruise src -T archi &lt;span class="o"&gt;|&lt;/span&gt; dot -T svg &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; overview.svg

&lt;span class="c"&gt;# text formats that need no Graphviz&lt;/span&gt;
npx depcruise src -T mermaid -f graph.mmd
npx depcruise src -T json -f graph.json
npx depcruise src -T html -f matrix.html    &lt;span class="c"&gt;# a dependency matrix, not a drawing&lt;/span&gt;

&lt;span class="c"&gt;# rules as a CI gate&lt;/span&gt;
npx depcruise src --config
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The flags that keep the graph readable on a real codebase are &lt;code&gt;--focus&lt;/code&gt; (a module and its neighbours), &lt;code&gt;--reaches&lt;/code&gt; (everything that depends on a module), &lt;code&gt;--affected&lt;/code&gt; (only what changed since a git revision, plus what reaches it) and &lt;code&gt;--collapse&lt;/code&gt; (summarise to a folder depth).&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;dot-webpage&lt;/code&gt; reporter runs Graphviz and wraps the SVG in an HTML page with hover highlighting and click-through to source. The reporter used to be called &lt;code&gt;x-dot-webpage&lt;/code&gt;, and the old name still works. Mermaid output renders directly in GitHub markdown. The current release needs Node 22 or newer.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. How do I use nx graph? The package view of a monorepo
&lt;/h2&gt;

&lt;p&gt;Nx draws a graph of projects and tasks, and it does not show individual files. In an existing npm, yarn or pnpm workspace, run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx nx@latest init          &lt;span class="c"&gt;# adds Nx to the repo&lt;/span&gt;
npx nx graph                &lt;span class="c"&gt;# opens the interactive graph in a browser&lt;/span&gt;
npx nx graph --focus=my-app &lt;span class="c"&gt;# one project and everything connected to it&lt;/span&gt;
npx nx graph --affected     &lt;span class="c"&gt;# highlight what your changes touch&lt;/span&gt;
npx nx graph --file=graph.html   &lt;span class="c"&gt;# static site you can host or attach&lt;/span&gt;
npx nx graph --file=graph.json   &lt;span class="c"&gt;# raw project graph&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Nx works out dependencies by analysing source code, installed packages and TypeScript config, so an import between packages shows up even if a package.json forgot to declare it.&lt;/p&gt;

&lt;p&gt;Nx gives you a browser UI with a button that saves the view as PNG, a static HTML site with its assets, or JSON. It is the right graph for "which packages depend on which" and the wrong one for "which file imports which".&lt;/p&gt;

&lt;h2&gt;
  
  
  4. esbuild's metafile: what a bundle really pulls in
&lt;/h2&gt;

&lt;p&gt;The other tools read every file in a folder. esbuild starts at an entry point and follows imports the way your build does, so its graph is exactly what ships.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx esbuild src/index.ts --bundle --metafile=meta.json --outfile=out.js

&lt;span class="c"&gt;# text tree, verbose shows the import path that pulled each file in&lt;/span&gt;
npx esbuild src/index.ts --bundle --outfile=out.js --analyze=verbose
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;meta.json&lt;/code&gt; lists every input with its imports. Upload it to the &lt;a href="https://esbuild.github.io/analyze/" rel="noopener noreferrer"&gt;esbuild bundle analyzer&lt;/a&gt; for a size breakdown, or turn it into a DOT graph with jq:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;(&lt;/span&gt; &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;'digraph deps {'&lt;/span&gt;
  jq -r &lt;span class="s1"&gt;'.inputs | to_entries[] | .key as $f | .value.imports[]
         | select(.external != true) | "  \"\($f)\" -&amp;gt; \"\(.path)\";"'&lt;/span&gt; meta.json
  &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;'}'&lt;/span&gt; &lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; deps.dot
dot -Tsvg deps.dot &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; deps.svg
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;esbuild writes JSON, plus a text report. It includes &lt;code&gt;node_modules&lt;/code&gt; on purpose, because its job is to answer "why is this package in my bundle". If you only want the file list, TypeScript's &lt;code&gt;tsc --explainFiles&lt;/code&gt; prints every file in the compile and the reason it was included, with no bundling.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. repowise: a browsable graph with history
&lt;/h2&gt;

&lt;p&gt;repowise parses imports and calls into a file and symbol graph, resolves tsconfig path aliases and npm, yarn and pnpm workspaces, and adds one thing the files never say: which files change together in git history.&lt;/p&gt;

&lt;p&gt;For a public repo, paste the GitHub URL on the repowise.dev homepage and there is nothing to install. To run it locally on any repo:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip install repowise
&lt;span class="nb"&gt;cd&lt;/span&gt; your-repo
repowise init        &lt;span class="c"&gt;# no API key needed for the graph&lt;/span&gt;
repowise serve       &lt;span class="c"&gt;# web UI on localhost:3000&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;repowise gives you an interactive graph in the browser, a layered &lt;code&gt;knowledge-graph.json&lt;/code&gt; in &lt;code&gt;.repowise/&lt;/code&gt;, and &lt;code&gt;repowise export --format structurizr&lt;/code&gt; for a C4 model. The graph covers the whole repo across 28 AST-parsed languages, so a TypeScript frontend and the Python or Go service beside it sit in one view. The same index answers coding agents over MCP (Model Context Protocol, the standard way agents call tools) through its MCP tools, for example &lt;code&gt;get_context(targets=["src/app.ts"], include=["callers"])&lt;/code&gt; for what depends on a file.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fnp3dmsie5u6h8uq6r00j.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fnp3dmsie5u6h8uq6r00j.webp" alt="The repowise Map view of the repowise repository: 1,308 files grouped into colored communities, with import edges between them and a Trace control for tracing a path between two files" width="799" height="596"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Worked example: react/react
&lt;/h2&gt;

&lt;p&gt;React is a JavaScript monorepo with TypeScript and Rust alongside, so it exercises most of what these tools do. On &lt;a href="https://repowise.dev/repo/react/react/architecture?utm_source=devto&amp;amp;utm_medium=community&amp;amp;utm_campaign=devto-18-javascript-typescript-dependency-graph" rel="noopener noreferrer"&gt;react/react's architecture page&lt;/a&gt;, the index covers 2,764 source files and 15,233 symbols, with 64 files marked as entry points.&lt;/p&gt;

&lt;p&gt;The default Map view draws 1,047 files and 3,633 dependencies, with 318 third-party modules hidden and 135 unlinked files left out so the picture stays readable. You can pick two files and trace the path between them, switch to communities (the clusters found in the graph, such as &lt;code&gt;react-reconciler, react-dom-bindings&lt;/code&gt; and &lt;code&gt;compiler/crates&lt;/code&gt;), or filter to hotspots. The Packages view on the same page joins 360 declared third-party packages, across 70 manifests, to the imports that use them.&lt;/p&gt;

&lt;p&gt;madge or dependency-cruiser give a file graph of whatever folder you point them at, and Nx gives the package graph. The repowise browser view is for the question in between, which is how a change in one package reaches another.&lt;/p&gt;

&lt;h2&gt;
  
  
  Which one should you use?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;"Do I have circular imports?" Use madge &lt;code&gt;--circular&lt;/code&gt;, or dependency-cruiser's &lt;code&gt;no-circular&lt;/code&gt; rule in CI. &lt;a href="https://repowise.dev/blog/guides/find-circular-dependencies-monorepo?utm_source=devto&amp;amp;utm_medium=community&amp;amp;utm_campaign=devto-18-javascript-typescript-dependency-graph" rel="noopener noreferrer"&gt;Finding circular dependencies in a monorepo&lt;/a&gt; has recipes for TS, Python and Go.&lt;/li&gt;
&lt;li&gt;"I need an HTML graph to share." Use dependency-cruiser &lt;code&gt;dot-webpage&lt;/code&gt;, or &lt;code&gt;nx graph --file=graph.html&lt;/code&gt; for packages.&lt;/li&gt;
&lt;li&gt;"Which packages depend on this one?" Use Nx graph with &lt;code&gt;--focus&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;"Why is this in my bundle?" Use esbuild &lt;code&gt;--analyze=verbose&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;"How does this codebase fit together, and what changes with what?" Use repowise.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If your services live in separate repos, an import graph stops at the repo edge. For a broader comparison, see &lt;a href="https://repowise.dev/blog/comparisons/best-dependency-graph-tools-monorepos?utm_source=devto&amp;amp;utm_medium=community&amp;amp;utm_campaign=devto-18-javascript-typescript-dependency-graph" rel="noopener noreferrer"&gt;best dependency graph tools for monorepos&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  How we measured
&lt;/h2&gt;

&lt;p&gt;On 2026-10-06 we checked every flag above against each tool's current README or docs, and read each package's latest version and Node engine from the npm registry. We tested the jq conversion on a sample metafile. We did not time the tools against each other or run them on react/react. The react/react numbers come from repowise's hosted index (snapshot completed 2026-10-02), read from the live architecture page and the database the same day, and describe one commit.&lt;/p&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;How do I make an HTML dependency graph?&lt;/strong&gt;&lt;br&gt;
Run &lt;code&gt;npx depcruise src --include-only "^src" -T dot-webpage -f graph.html&lt;/code&gt; with Graphviz installed. It writes one HTML file with hover highlighting. For a package-level graph in a monorepo, &lt;code&gt;npx nx graph --file=graph.html&lt;/code&gt; writes a static site.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is the best dependency graph tool for JavaScript?&lt;/strong&gt;&lt;br&gt;
The answer depends on the question you have: madge is the fastest start, dependency-cruiser is the most configurable and enforces rules, Nx is best for packages in a monorepo, and esbuild shows what a bundle includes. Most teams end up using two, one for a picture and one for CI.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How do I see which npm packages depend on a package?&lt;/strong&gt;&lt;br&gt;
For installed packages, &lt;code&gt;npm explain &amp;lt;name&amp;gt;&lt;/code&gt; shows why a package is in &lt;code&gt;node_modules&lt;/code&gt;, and &lt;code&gt;npm ls --all&lt;/code&gt; prints the whole tree. In a pnpm project, &lt;code&gt;pnpm why &amp;lt;name&amp;gt;&lt;/code&gt; does the same job. For packages inside your own monorepo, &lt;code&gt;nx graph --focus=&amp;lt;project&amp;gt;&lt;/code&gt; or dependency-cruiser's &lt;code&gt;--reaches&lt;/code&gt; answers it from the code.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>typescript</category>
      <category>webdev</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Code churn in 51 Python repos: Django's busiest 10% of files take 96% of the changes</title>
      <dc:creator>Raghav Chamadiya</dc:creator>
      <pubDate>Sun, 29 Nov 2026 13:00:00 +0000</pubDate>
      <link>https://dev.to/repowise/code-churn-in-51-python-repos-djangos-busiest-10-of-files-take-96-of-the-changes-3mk5</link>
      <guid>https://dev.to/repowise/code-churn-in-51-python-repos-djangos-busiest-10-of-files-take-96-of-the-changes-3mk5</guid>
      <description>&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Code churn is lines added plus lines deleted per file over a time window. Over 90 days, in the median of 51 popular Python repos, the busiest 10% of production files took 66% of all churn and the busiest 1% took 23%.&lt;/li&gt;
&lt;li&gt;Django sits at the top of that range: 96% of its 90-day churn landed in 10% of its production files at its July index. A fresh &lt;code&gt;git log&lt;/code&gt; run on 17 November gives 92%.&lt;/li&gt;
&lt;li&gt;The spread between repos follows one thing: how many files changed at all. Repos where under half the files moved have a median of 93%. Repos where nearly every file moved have 46%.&lt;/li&gt;
&lt;li&gt;Numbers come from repowise's index of 195 public repos with 1,000+ GitHub stars (November 2026), plus fresh git runs on django, fastapi and langchain.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Most of a mature Python codebase sits still for months at a time. In Django, 149 of 869 production files changed in the 90 days before its July index, and the busiest tenth of the codebase took 96% of every line added or deleted. That pattern is not specific to Django. I looked at the 51 Python repos in a set of popular open-source projects, and in 39 of them half or more of all churn landed in 10% of files.&lt;/p&gt;

&lt;p&gt;This post covers what the numbers look like across those 51 repos, a script that gives you the same numbers for your own repo, which files turn out to be the busy ones in Django, FastAPI and LangChain, and what a high concentration tells you when you start reading a codebase.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is code churn?
&lt;/h2&gt;

&lt;p&gt;Code churn is the number of lines added plus the number of lines deleted in a file over a period. Git records both per file per commit, and &lt;code&gt;git log --numstat&lt;/code&gt; prints them:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git log -1 --numstat --format='%h %s' 0804aed320
0804aed320 Fixed #35899 -- Allowed multiline template tags.

71  24  django/template/base.py
1   1   django/template/defaulttags.py
1   1   django/template/loader_tags.py
19  0   docs/ref/templates/language.txt
53  0   docs/releases/6.2.txt
146 0   tests/template_tests/syntax_tests/test_basic.py
5   0   tests/template_tests/syntax_tests/test_comment.py
10  0   tests/template_tests/syntax_tests/test_named_endblock.py
32  7   tests/template_tests/syntax_tests/test_partials.py
24  5   tests/template_tests/syntax_tests/test_verbatim.py
9   0   tests/template_tests/test_base.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That commit added 71 lines and deleted 24 in &lt;code&gt;django/template/base.py&lt;/code&gt;, so it contributes 95 lines of churn to that file. Most of its lines went into tests and docs, which is why the numbers below are measured on production files only. A one-line change that rewrites a line counts as 1 added plus 1 deleted. Sum over every commit in the window and you have the file's churn.&lt;/p&gt;

&lt;p&gt;The number in this post is one step up from that: rank every file by its churn, then ask what share of the total the busiest 1%, 5%, 10% and 20% of files hold. That is churn concentration. A high share means work is focused on a few files. A low share means it is spread out.&lt;/p&gt;

&lt;h2&gt;
  
  
  How concentrated is churn in popular Python repos?
&lt;/h2&gt;

&lt;p&gt;The data covers production source files only (tests, generated code, vendored copies, build scripts, tooling and docs examples are left out) in the 51 Python repos of a &lt;a href="https://repowise.dev/research/code-health-2026?utm_source=devto&amp;amp;utm_medium=community&amp;amp;utm_campaign=devto-17-code-churn-python-repos#finding-1" rel="noopener noreferrer"&gt;set of 195 public repos with 1,000+ GitHub stars&lt;/a&gt;. Churn is lines added plus deleted in the 90 days before each repo's latest index.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Over 90 days&lt;/th&gt;
&lt;th&gt;Python p25&lt;/th&gt;
&lt;th&gt;Python median&lt;/th&gt;
&lt;th&gt;Python p75&lt;/th&gt;
&lt;th&gt;All 195 repos, median&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Churn in the busiest 1% of files&lt;/td&gt;
&lt;td&gt;15%&lt;/td&gt;
&lt;td&gt;23%&lt;/td&gt;
&lt;td&gt;34%&lt;/td&gt;
&lt;td&gt;23%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Churn in the busiest 5%&lt;/td&gt;
&lt;td&gt;37%&lt;/td&gt;
&lt;td&gt;50%&lt;/td&gt;
&lt;td&gt;66%&lt;/td&gt;
&lt;td&gt;52%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Churn in the busiest 10%&lt;/td&gt;
&lt;td&gt;51%&lt;/td&gt;
&lt;td&gt;66%&lt;/td&gt;
&lt;td&gt;82%&lt;/td&gt;
&lt;td&gt;68%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Churn in the busiest 20%&lt;/td&gt;
&lt;td&gt;69%&lt;/td&gt;
&lt;td&gt;82%&lt;/td&gt;
&lt;td&gt;97%&lt;/td&gt;
&lt;td&gt;85%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Commits touching the busiest 10%&lt;/td&gt;
&lt;td&gt;38%&lt;/td&gt;
&lt;td&gt;53%&lt;/td&gt;
&lt;td&gt;65%&lt;/td&gt;
&lt;td&gt;52%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Production files changed at all&lt;/td&gt;
&lt;td&gt;34%&lt;/td&gt;
&lt;td&gt;68%&lt;/td&gt;
&lt;td&gt;94%&lt;/td&gt;
&lt;td&gt;62%&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Python looks like every other language here. The median Python repo puts two thirds of its churn into a tenth of its files, and about half of its commits touch one of those files. 39 of the 51 repos have at least 50% of churn in the busiest 10%, and 10 of them have 90% or more.&lt;/p&gt;

&lt;p&gt;Repos with 90% or more include django/django, langchain-ai/langchain, saleor/saleor, PrefectHQ/prefect, frappe/erpnext and litestar-org/litestar. &lt;/p&gt;

&lt;h2&gt;
  
  
  Why does churn concentration vary so much between repos?
&lt;/h2&gt;

&lt;p&gt;The p25 to p75 range runs from 51% to 82%, which is wide. Most of that spread lines up with one number, the share of production files that changed at all in the window:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Production files changed in 90 days&lt;/th&gt;
&lt;th&gt;Python repos&lt;/th&gt;
&lt;th&gt;Median churn in the busiest 10%&lt;/th&gt;
&lt;th&gt;Median churn in the busiest 1%&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Under half&lt;/td&gt;
&lt;td&gt;18&lt;/td&gt;
&lt;td&gt;93%&lt;/td&gt;
&lt;td&gt;39%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Half to 90%&lt;/td&gt;
&lt;td&gt;15&lt;/td&gt;
&lt;td&gt;66%&lt;/td&gt;
&lt;td&gt;24%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;90% or more&lt;/td&gt;
&lt;td&gt;18&lt;/td&gt;
&lt;td&gt;46%&lt;/td&gt;
&lt;td&gt;13%&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;This is close to arithmetic. If only 149 of 869 files changed, the other 720 contribute zero, and the busiest 87 are drawn from a small active set. In the extreme, three of the 51 repos changed fewer than 10% of their files in the window, so the busiest 10% hold 100% of churn by definition. On the other side, a codebase where nearly every file moved spreads its churn across all of them.&lt;/p&gt;

&lt;p&gt;Two things can put a repo in the "90% or more" row. A young project still being built can touch most files every month. And when the recorded history starts inside the window, the first commit counts every file as added. In 10 of the 51 Python repos every production file shows a change in the 90 days. Both cases push concentration down, and the second one is about the history, not the code. The script below runs into the same thing on a shallow clone, which I show further down.&lt;/p&gt;

&lt;p&gt;So read a churn concentration number together with the share of files changed. "92% of churn in 10% of files, with 21% of files changed" describes a stable codebase with a few areas in active development. "46% in 10%, with every file changed" describes a codebase that is moving everywhere at once.&lt;/p&gt;

&lt;h2&gt;
  
  
  How do you measure code churn with git?
&lt;/h2&gt;

&lt;p&gt;This script prints the four shares for any set of paths. It runs one &lt;code&gt;git log&lt;/code&gt;, keeps only files that still exist (renamed and deleted paths drop out), and uses the current file count as the denominator, so unchanged files count:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# churn.sh: share of 90-day line churn held by the busiest 1, 5, 10 and 20% of files&lt;/span&gt;
&lt;span class="c"&gt;# usage: bash churn.sh &amp;lt;pathspec&amp;gt;...&lt;/span&gt;
&lt;span class="nv"&gt;N&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;git ls-files -- &lt;span class="s2"&gt;"$@"&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; wc -l&lt;span class="o"&gt;)&lt;/span&gt;
git log --no-merges --since=&lt;span class="s2"&gt;"90 days ago"&lt;/span&gt; --numstat --format=&lt;span class="s2"&gt;""&lt;/span&gt; -- &lt;span class="s2"&gt;"$@"&lt;/span&gt; \
  &lt;span class="o"&gt;|&lt;/span&gt; awk &lt;span class="s1"&gt;'NR == FNR {live[$0] = 1; next}
         NF == 3 &amp;amp;&amp;amp; $1 != "-" &amp;amp;&amp;amp; ($3 in live) {c[$3] += $1 + $2}
         END {for (f in c) print c[f]}'&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;git ls-files -- &lt;span class="s2"&gt;"$@"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; - \
  &lt;span class="o"&gt;|&lt;/span&gt; sort -rn \
  &lt;span class="o"&gt;|&lt;/span&gt; awk -v &lt;span class="nv"&gt;n&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"$N"&lt;/span&gt; &lt;span class="s1"&gt;'{v[NR] = $1; t += $1} END {
      printf "%d files, %d changed in 90 days, %d lines of churn\n", n, NR, t
      split("1 5 10 20", p, " ")
      for (i = 1; i &amp;lt;= 4; i++) {
        k = int(n * p[i] / 100); if (k &amp;lt; 1) k = 1; s = 0
        for (j = 1; j &amp;lt;= k &amp;amp;&amp;amp; j &amp;lt;= NR; j++) s += v[j]
        printf "busiest %2d%% (%4d files): %3.0f%% of churn\n", p[i], k, 100 * s / t } }'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;$1 != "-"&lt;/code&gt; skips binary files, which &lt;code&gt;--numstat&lt;/code&gt; reports as &lt;code&gt;-&lt;/code&gt;. The pathspecs are how you approximate "production files": point it at the package and exclude tests.&lt;/p&gt;

&lt;p&gt;On a full clone of Django (HEAD &lt;code&gt;d3954c9&lt;/code&gt;, 17 November 2026):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ bash churn.sh 'django/*.py'
909 files, 195 changed in 90 days, 3670 lines of churn
busiest  1% (   9 files):  36% of churn
busiest  5% (  45 files):  76% of churn
busiest 10% (  90 files):  92% of churn
busiest 20% ( 181 files):  99% of churn
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two snapshots of the same repo, four months apart:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;django/django&lt;/th&gt;
&lt;th&gt;Index, 29 July 2026 (&lt;code&gt;50e5264&lt;/code&gt;)&lt;/th&gt;
&lt;th&gt;Fresh git run, 17 November 2026 (&lt;code&gt;d3954c9&lt;/code&gt;)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Files counted&lt;/td&gt;
&lt;td&gt;869 production files&lt;/td&gt;
&lt;td&gt;909 &lt;code&gt;.py&lt;/code&gt; files under &lt;code&gt;django/&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Changed in 90 days&lt;/td&gt;
&lt;td&gt;149&lt;/td&gt;
&lt;td&gt;195&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Lines of churn&lt;/td&gt;
&lt;td&gt;4,319&lt;/td&gt;
&lt;td&gt;3,670&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Busiest 1% / 5% / 10% / 20%&lt;/td&gt;
&lt;td&gt;40% / 81% / 96% / 100%&lt;/td&gt;
&lt;td&gt;36% / 76% / 92% / 99%&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The numbers moved because the window moved and the file sets differ a little (the pathspec keeps a few test helpers inside &lt;code&gt;django/&lt;/code&gt; that a production filter leaves out). The shape held: about nine files in a hundred take nine tenths of the churn.&lt;/p&gt;

&lt;p&gt;The same script on FastAPI (&lt;code&gt;a1b3be0&lt;/code&gt;) and LangChain (&lt;code&gt;92c7def&lt;/code&gt;), both full clones:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ bash churn.sh 'fastapi/*.py'
52 files, 21 changed in 90 days, 4501 lines of churn
busiest  1% (   1 files):  39% of churn
busiest  5% (   2 files):  51% of churn
busiest 10% (   5 files):  76% of churn
busiest 20% (  10 files):  95% of churn

$ bash churn.sh 'libs/*.py' ':!:*/tests/*' ':!:*/scripts/*'
2657 files, 239 changed in 90 days, 26664 lines of churn
busiest  1% (  26 files):  73% of churn
busiest  5% ( 132 files):  98% of churn
busiest 10% ( 265 files): 100% of churn
busiest 20% ( 531 files): 100% of churn
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At their November 4 indexes the dataset had FastAPI at 79% and LangChain at 99.9% for the busiest 10%. LangChain is the "fewer than 10% of files changed" case from above: 239 of 2,657 files moved, so the busiest 10% covers all of them.&lt;/p&gt;

&lt;h3&gt;
  
  
  Use a full clone
&lt;/h3&gt;

&lt;p&gt;Here is the shallow-history effect from earlier, made on purpose. A &lt;code&gt;--depth 20&lt;/code&gt; clone of the same FastAPI commit:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git clone --depth 20 &amp;lt;fastapi&amp;gt; shallow &amp;amp;&amp;amp; cd shallow
$ bash churn.sh 'fastapi/*.py'
52 files, 52 changed in 90 days, 22937 lines of churn
busiest  1% (   1 files):  29% of churn
busiest  5% (   2 files):  50% of churn
busiest 10% (   5 files):  71% of churn
busiest 20% (  10 files):  83% of churn
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Every file "changed", and churn is five times the real number, because git shows the oldest commit of a shallow clone as adding every file from nothing. CI checkouts are often shallow (&lt;code&gt;actions/checkout&lt;/code&gt; fetches one commit by default), so set &lt;code&gt;fetch-depth: 0&lt;/code&gt; before you measure churn in a pipeline.&lt;/p&gt;

&lt;h2&gt;
  
  
  Which files take most of the churn?
&lt;/h2&gt;

&lt;p&gt;Concentration tells you how focused the work is. To see where, list the files. This prints churn and commit count per file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git log --no-merges --since=&lt;span class="s2"&gt;"90 days ago"&lt;/span&gt; --numstat --format=&lt;span class="s1"&gt;'tformat:@'&lt;/span&gt; -- &lt;span class="s1"&gt;'django/*.py'&lt;/span&gt; \
  &lt;span class="o"&gt;|&lt;/span&gt; awk &lt;span class="s1"&gt;'$1 == "@" {next} NF == 3 &amp;amp;&amp;amp; $1 != "-" {churn[$3] += $1 + $2; n[$3]++}
         END {for (f in churn) printf "%6d %3d  %s\n", churn[f], n[f], f}'&lt;/span&gt; \
  &lt;span class="o"&gt;|&lt;/span&gt; sort -rn &lt;span class="o"&gt;|&lt;/span&gt; head -12
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Django: the template engine, the ORM, and a few one-off changes
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   279   5  django/template/base.py
   175   1  django/contrib/gis/geos/prototypes/io.py
   172   7  django/db/models/sql/query.py
   170   1  django/utils/version.py
   127   2  django/contrib/gis/gdal/geojson.py
   111   8  django/db/models/query.py
   106   5  django/contrib/admin/options.py
   100   2  django/test/client.py
    98   1  django/contrib/auth/management/__init__.py
    95   1  django/core/validators.py
    81   5  django/db/models/fields/json.py
    73   1  django/utils/translation/trans_real.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two kinds of file share this list. The first kind changes in many small commits. &lt;code&gt;db/models/sql/query.py&lt;/code&gt; had seven commits in the window, each a separate ticket: a &lt;code&gt;QuerySet.values()&lt;/code&gt; crash, join promotion for XOR conditions, &lt;code&gt;distinct()&lt;/code&gt; with aliases. &lt;code&gt;template/base.py&lt;/code&gt; had five: two for one feature (multiline template tags), two parser fixes for &lt;code&gt;verbatim&lt;/code&gt; and &lt;code&gt;comment&lt;/code&gt; tags, and one deprecation rename. These files are where development is happening.&lt;/p&gt;

&lt;p&gt;The second kind changes once, in a big commit. &lt;code&gt;utils/version.py&lt;/code&gt; got 170 lines in one commit that added calendar version support. &lt;code&gt;geos/prototypes/io.py&lt;/code&gt; got 175 in one security fix. Neither file is under active development. Each had one large job done to it.&lt;/p&gt;

&lt;p&gt;Churn alone does not separate the two. The commit count column does. repowise ranks hotspots by recency-weighted change activity with minimum activity floors, not by line volume, which is why the files repowise ranks as Django's top hotspots (&lt;code&gt;contrib/admin/options.py&lt;/code&gt;, &lt;code&gt;db/models/query.py&lt;/code&gt;) are not the top of this churn list.&lt;/p&gt;

&lt;h3&gt;
  
  
  FastAPI: one file holds most of the framework's logic
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  1735  28  fastapi/dependencies/utils.py
   555   4  fastapi/param_functions.py
   469   3  fastapi/telemetry/_asgi.py
   396   4  fastapi/params.py
   286   2  fastapi/telemetry/_api.py
   252   3  fastapi/telemetry/_runtime.py
   209   8  fastapi/routing.py
   142   4  fastapi/applications.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;dependencies/utils.py&lt;/code&gt; took 28 commits and 39% of all churn in the package. That is the file that resolves &lt;code&gt;Depends()&lt;/code&gt;, query, header, cookie and form parameters, and the commit subjects show a run of features in exactly that area: combining form models, optional parameter models, &lt;code&gt;Depends(max_concurrency=...)&lt;/code&gt;. The &lt;code&gt;telemetry/&lt;/code&gt; files are a new module (native OpenTelemetry support, added in September) being built out. In a 52-file package, five files (the central one, the two parameter modules and two of the new telemetry files) hold three quarters of the churn.&lt;/p&gt;

&lt;h3&gt;
  
  
  LangChain: generated data at the top
&lt;/h3&gt;

&lt;p&gt;The first run of the list on LangChain put this at the top:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  7256  71  libs/partners/openrouter/langchain_openrouter/data/_profiles.py
  1329  24  libs/partners/fireworks/langchain_fireworks/data/_profiles.py
   908  21  libs/partners/anthropic/langchain_anthropic/chat_models.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ head -4 libs/partners/openrouter/langchain_openrouter/data/_profiles.py
"""Auto-generated model profiles.

DO NOT EDIT THIS FILE MANUALLY.
This file is generated by the langchain-profiles CLI tool.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The ten &lt;code&gt;_profiles.py&lt;/code&gt; files are model metadata regenerated by an automated commit ("refresh model profile data"), 71 of those in 90 days. They are 10,762 of the 26,664 lines of churn. Tools that classify code origin read banners like this one. A plain &lt;code&gt;git log&lt;/code&gt; does not, so add the exclusion yourself:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ bash churn.sh 'libs/*.py' ':!:*/tests/*' ':!:*/scripts/*' ':!:*/data/_profiles.py'
2647 files, 229 changed in 90 days, 15902 lines of churn
busiest  1% (  26 files):  64% of churn
...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With generated files out, the top of the list is hand-written code: the Anthropic and Fireworks chat model integrations (21 and 10 commits), new middleware for agents, and a new &lt;code&gt;typesafe&lt;/code&gt; partner package added in September. 26 files, 1% of the package, hold 64% of the churn. LangChain is a monorepo of many packages, and in any given quarter work happens in a handful of them.&lt;/p&gt;

&lt;p&gt;Generated files, lockfiles, vendored copies and snapshots are the most common reason a churn list looks wrong. Check the top five entries by hand before you trust the percentages.&lt;/p&gt;

&lt;h2&gt;
  
  
  What does high churn concentration mean for you?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;It tells you where to start reading.&lt;/strong&gt; If 9 files take a third of the churn, as in Django, those 9 files are where the current work is, where reviewers have recent context, and where your first contribution will most likely land. The other 800 files are stable enough that you can treat them as a library for now.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Read it with the commit count.&lt;/strong&gt; A file with 28 commits in 90 days is a place people keep coming back to. A file with one 170-line commit had a single job done to it. The first kind is worth understanding in depth. The second is worth knowing about.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Concentration is not good or bad on its own.&lt;/strong&gt; A framework that has settled its design shows high concentration because most of it is done. A young project shows low concentration because most of it is new. Both are healthy for what they are. What changes is how you approach them: in the first, read the busy files first. In the second, read the entry points and the module layout first, because everything is in motion.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Combine it with something else before you act on it.&lt;/strong&gt; Churn says where change happens. Complexity says which of those files are hard to change. Bug-fix history says which of them have broken before. A file high on all three is the one worth a test or a refactor first. The &lt;a href="https://repowise.dev/blog/guides/code-churn?utm_source=devto&amp;amp;utm_medium=community&amp;amp;utm_campaign=devto-17-code-churn-python-repos" rel="noopener noreferrer"&gt;code churn guide&lt;/a&gt; covers the churn-plus-complexity ranking and the traps in measuring it.&lt;/p&gt;

&lt;p&gt;If you want Django's recent changes without running anything, &lt;a href="https://repowise.dev/repo/django/django/commits?utm_source=devto&amp;amp;utm_medium=community&amp;amp;utm_campaign=devto-17-code-churn-python-repos" rel="noopener noreferrer"&gt;its commit history on repowise&lt;/a&gt; lists them with the files each one touched.&lt;/p&gt;

&lt;p&gt;Which file in your repo would top this list, and is it the one you expected?&lt;/p&gt;

&lt;h2&gt;
  
  
  How I got these numbers
&lt;/h2&gt;

&lt;p&gt;The cohort is 195 of the most-starred public repositories indexed on repowise.dev (1,000+ GitHub stars each, 253,688 production source files, November 2026). The Python rows are the 51 repos whose GitHub primary language is Python, each measured at its own latest index between May and November 2026, so each number is a snapshot per repo. Churn is lines added plus deleted per production file in the 90 days before the index. Files are classified by repowise's code-origin rules (production, test, generated, vendored, build, docs example, tooling), and only production source files count. The grouped table splits the 51 repos by the share of production files changed in the window.&lt;/p&gt;

&lt;p&gt;The fresh runs used full clones fetched on 17 November 2026: django/django at &lt;code&gt;d3954c9&lt;/code&gt;, fastapi/fastapi at &lt;code&gt;a1b3be0&lt;/code&gt; and langchain-ai/langchain at &lt;code&gt;92c7def&lt;/code&gt;, with Git 2.51.0 in a bash shell. The shallow example is a &lt;code&gt;--depth 20&lt;/code&gt; clone of the same FastAPI commit. Every block of output above is pasted as printed.&lt;/p&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;What is code churn in software engineering?&lt;/strong&gt;&lt;br&gt;
Code churn is the amount of code added, changed or deleted over a period, usually measured as lines added plus lines deleted per file. Git records both per commit, so &lt;code&gt;git log --numstat&lt;/code&gt; over a time window and a sum per file gives you churn.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How do I calculate code churn with git?&lt;/strong&gt;&lt;br&gt;
Run &lt;code&gt;git log --since="90 days ago" --numstat --format=""&lt;/code&gt; on a path, then add the first two columns per file name with &lt;code&gt;awk&lt;/code&gt;. The script above also ranks files and prints the share held by the busiest 1%, 5%, 10% and 20%. Run it on a full clone, not a shallow one.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Is high code churn bad?&lt;/strong&gt;&lt;br&gt;
Not by itself. Churn shows where work is happening, which in a healthy project is where features and fixes land. It becomes a warning sign when the same file is also complex and keeps needing bug fixes. Look at those three together before deciding a file needs attention.&lt;/p&gt;

</description>
      <category>python</category>
      <category>git</category>
      <category>opensource</category>
      <category>programming</category>
    </item>
    <item>
      <title>I read the CLAUDE.md files of 30 popular repos. Here is what they put in</title>
      <dc:creator>Raghav Chamadiya</dc:creator>
      <pubDate>Sat, 28 Nov 2026 13:00:00 +0000</pubDate>
      <link>https://dev.to/repowise/i-read-the-claudemd-files-of-30-popular-repos-here-is-what-they-put-in-iif</link>
      <guid>https://dev.to/repowise/i-read-the-claudemd-files-of-30-popular-repos-here-is-what-they-put-in-iif</guid>
      <description>&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;I pulled the root &lt;code&gt;CLAUDE.md&lt;/code&gt; of 30 popular repos (25k to 282k stars) at a pinned commit. In 21 of them it is a symlink or a wrapper of 1 to 13 lines that hands off to &lt;code&gt;AGENTS.md&lt;/code&gt;. Grafana's is one line: &lt;code&gt;@AGENTS.md&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;What an agent ends up reading is a median of 179 lines, from 13 to 1,067.&lt;/li&gt;
&lt;li&gt;The most common contents are pointers to other docs (29 of 30), "never / do not" rules (28), build and test commands (26) and commit or PR rules (25). Code style rules come last, in 22.&lt;/li&gt;
&lt;li&gt;Across the wider set of 194 repos I checked, a root &lt;code&gt;AGENTS.md&lt;/code&gt; (88 repos) is more common than a root &lt;code&gt;CLAUDE.md&lt;/code&gt; (58).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I wanted real CLAUDE.md examples instead of advice about them, so I read the files that popular open-source projects actually commit. The pool was the 195 repos in our code-health dataset: we analysed 195 of the most-starred public repositories indexed on repowise.dev (1,000+ GitHub stars each, 253,688 production source files, November 2026). I checked each one's default branch on GitHub on 17 November 2026, and took the 30 most-starred repos that have a &lt;code&gt;CLAUDE.md&lt;/code&gt; at the root.&lt;/p&gt;

&lt;p&gt;The 30 are mostly TypeScript (11) and Python (6), with Go (4), JavaScript (3), Rust (3), Dart (2) and Ruby (1). They include react, ollama, anthropics/claude-code, grafana, apache/airflow, docker/compose, mem0, localsend, chatwoot and repomix. The median repo has 60,092 stars.&lt;/p&gt;

&lt;h2&gt;
  
  
  Do popular repos still write a CLAUDE.md, or an AGENTS.md?
&lt;/h2&gt;

&lt;p&gt;Both, and mostly they keep one source of truth. First the wider count, across 194 of the 195 dataset repos (one returned 404):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;repos 195 ok 194 errors 1
root CLAUDE.md 58
root AGENTS.md 88
either 96
both 50
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So &lt;code&gt;AGENTS.md&lt;/code&gt;, the file Codex, Cursor and other agents read, is already more common than &lt;code&gt;CLAUDE.md&lt;/code&gt; at the root of these repos. About half the repos that have either file have both (50 of 96).&lt;/p&gt;

&lt;p&gt;Inside the 30, I looked at what &lt;code&gt;CLAUDE.md&lt;/code&gt; actually is. The git tree tells you whether a file is a symlink (mode &lt;code&gt;120000&lt;/code&gt;), and the content tells you the rest:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;What CLAUDE.md is&lt;/th&gt;
&lt;th&gt;Repos&lt;/th&gt;
&lt;th&gt;Examples&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;A git symlink to &lt;code&gt;AGENTS.md&lt;/code&gt; (or to the same file &lt;code&gt;AGENTS.md&lt;/code&gt; links to)&lt;/td&gt;
&lt;td&gt;8&lt;/td&gt;
&lt;td&gt;airflow, compose, chatwoot, mem0, repomix&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;A wrapper of 1 to 13 lines that points to &lt;code&gt;AGENTS.md&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;13&lt;/td&gt;
&lt;td&gt;grafana, ollama, localsend, nautilus_trader, t3code&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Its own full file&lt;/td&gt;
&lt;td&gt;9&lt;/td&gt;
&lt;td&gt;react, claude-code, hindsight, cognee, shannon&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Ten of the 13 wrappers use Claude Code's import syntax, a line with &lt;code&gt;@AGENTS.md&lt;/code&gt;, so the content is loaded into context at session start. The other three say "see AGENTS.md" in plain text and leave the agent to open it. Three of the nine full files also cross-reference an &lt;code&gt;AGENTS.md&lt;/code&gt; they keep next to them, and in hindsight it runs the other way: its &lt;code&gt;AGENTS.md&lt;/code&gt; is three lines pointing to &lt;code&gt;CLAUDE.md&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Count it up and 25 of the 30 repos tie the two files together on purpose. Only four (react, claude-code, shannon, pentagi) have no root &lt;code&gt;AGENTS.md&lt;/code&gt; at all.&lt;/p&gt;

&lt;h2&gt;
  
  
  What a CLAUDE.md wrapper looks like
&lt;/h2&gt;

&lt;p&gt;Grafana's &lt;a href="https://github.com/grafana/grafana/blob/60c6aeeadf3f07325d859ea7dea7d33e56214842/CLAUDE.md" rel="noopener noreferrer"&gt;CLAUDE.md&lt;/a&gt; is the shortest possible version:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;@AGENTS.md
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;localsend's &lt;a href="https://github.com/localsend/localsend/blob/d1e6198f401939a9b76854f406f7dbb27d67a808/CLAUDE.md" rel="noopener noreferrer"&gt;CLAUDE.md&lt;/a&gt; adds the one rule it wants Claude to see first, then imports the rest:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;&lt;span class="gu"&gt;# CLAUDE.md
&lt;/span&gt;
Always use &lt;span class="gs"&gt;**`fvm flutter`**&lt;/span&gt; / &lt;span class="gs"&gt;**`fvm dart`**&lt;/span&gt;, never the bare &lt;span class="sb"&gt;`flutter`&lt;/span&gt; / &lt;span class="sb"&gt;`dart`&lt;/span&gt; binaries ...

Full guidance for this repository lives in AGENTS.md:

@AGENTS.md
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That is the pattern I would copy. Shared guidance lives in &lt;code&gt;AGENTS.md&lt;/code&gt;, so every agent gets the same rules. &lt;code&gt;CLAUDE.md&lt;/code&gt; holds only what is specific to Claude Code, or nothing.&lt;/p&gt;

&lt;p&gt;If you go the symlink route, check how your team's Windows machines handle it. Git on Windows checks symlinks out as small text files unless &lt;code&gt;core.symlinks&lt;/code&gt; is enabled, and then &lt;code&gt;CLAUDE.md&lt;/code&gt; contains the literal text &lt;code&gt;AGENTS.md&lt;/code&gt;. The &lt;code&gt;@AGENTS.md&lt;/code&gt; import works everywhere.&lt;/p&gt;

&lt;h2&gt;
  
  
  How long is a CLAUDE.md file?
&lt;/h2&gt;

&lt;p&gt;I measured what the agent ends up reading: the symlink target for symlinks, &lt;code&gt;CLAUDE.md&lt;/code&gt; plus &lt;code&gt;AGENTS.md&lt;/code&gt; for wrappers, and the file itself for full files.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Median lines&lt;/th&gt;
&lt;th&gt;Range (lines)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;All 30&lt;/td&gt;
&lt;td&gt;179&lt;/td&gt;
&lt;td&gt;13 to 1,067&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Symlinks (8)&lt;/td&gt;
&lt;td&gt;153&lt;/td&gt;
&lt;td&gt;89 to 479&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Wrappers (13)&lt;/td&gt;
&lt;td&gt;183&lt;/td&gt;
&lt;td&gt;25 to 734&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Full files (9)&lt;/td&gt;
&lt;td&gt;267&lt;/td&gt;
&lt;td&gt;13 to 1,067&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The middle half of the 30 sits between 107 and 267 lines. 19 of the 30 are 200 lines or shorter, and 6 are over 300. In words the median is about 1,900 (word counts undercount one repo whose file is mostly Chinese, so I lead with lines).&lt;/p&gt;

&lt;p&gt;The short end is deliberate. React's file is 13 lines and does one job: it tells the agent which part of the monorepo it is in and that the compiler has its own instructions (&lt;a href="https://github.com/react/react/blob/1cd5eb8e0edb0b3a1ba33de9c886d91627f8b5ac/CLAUDE.md#L5-L8" rel="noopener noreferrer"&gt;CLAUDE.md&lt;/a&gt;):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;&lt;span class="gu"&gt;## Monorepo Overview
&lt;/span&gt;
&lt;span class="k"&gt;- &lt;/span&gt;&lt;span class="gs"&gt;**React**&lt;/span&gt;: All files outside &lt;span class="sb"&gt;`/compiler/`&lt;/span&gt;
&lt;span class="k"&gt;- &lt;/span&gt;&lt;span class="gs"&gt;**React Compiler**&lt;/span&gt;: &lt;span class="sb"&gt;`/compiler/`&lt;/span&gt; directory (has its own instructions)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That is the other common way to keep the root file small: put guides in subdirectories. 7 of the 30 point to nested &lt;code&gt;AGENTS.md&lt;/code&gt; files, for example Grafana's &lt;code&gt;docs/AGENTS.md&lt;/code&gt; and mem0's per-package guides.&lt;/p&gt;

&lt;h2&gt;
  
  
  What do people put in CLAUDE.md?
&lt;/h2&gt;

&lt;p&gt;I tagged each file by section type with a script (headings plus a few body patterns), then went through every file by hand and corrected 14 tags. A file counts for a type if it has that content anywhere, as its own section or not.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Section type&lt;/th&gt;
&lt;th&gt;Files&lt;/th&gt;
&lt;th&gt;Share&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Pointers to other docs (&lt;code&gt;CONTRIBUTING.md&lt;/code&gt;, &lt;code&gt;docs/...&lt;/code&gt;, nested guides)&lt;/td&gt;
&lt;td&gt;29&lt;/td&gt;
&lt;td&gt;97%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;"Never" / "do not" rules (off-limits paths, actions the agent must not take)&lt;/td&gt;
&lt;td&gt;28&lt;/td&gt;
&lt;td&gt;93%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Build, test or lint commands&lt;/td&gt;
&lt;td&gt;26&lt;/td&gt;
&lt;td&gt;87%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Commit, PR, branch or review rules&lt;/td&gt;
&lt;td&gt;25&lt;/td&gt;
&lt;td&gt;83%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Repo layout (where code lives)&lt;/td&gt;
&lt;td&gt;24&lt;/td&gt;
&lt;td&gt;80%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Code conventions (style, naming, patterns)&lt;/td&gt;
&lt;td&gt;22&lt;/td&gt;
&lt;td&gt;73%&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Two things stood out to me.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Rules about behaviour are more common than rules about code.&lt;/strong&gt; Style and naming came last. Linters and formatters already enforce most of that, and the files say so (mem0 lists which linter config applies to which folder). What a linter cannot enforce is "do not open a PR without asking" or "do not touch the release workflows", and that is where these files spend their words.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Almost every file is an index.&lt;/strong&gt; 29 of 30 send the agent somewhere else: &lt;code&gt;CONTRIBUTING.md&lt;/code&gt;, an AI policy, an architecture doc, a style guide. The root file stays short and the detail is read only when it is needed.&lt;/p&gt;

&lt;h2&gt;
  
  
  Real CLAUDE.md examples, by section
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Commands.&lt;/strong&gt; docker/compose (its &lt;code&gt;CLAUDE.md&lt;/code&gt; is a symlink to &lt;a href="https://github.com/docker/compose/blob/480ac8358f44b696c823f88baee0a98a6992f380/AGENTS.md#L6-L9" rel="noopener noreferrer"&gt;AGENTS.md&lt;/a&gt;) opens with exactly what to run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;&lt;span class="gu"&gt;## Build &amp;amp; Test
&lt;/span&gt;
&lt;span class="k"&gt;- &lt;/span&gt;Build: &lt;span class="sb"&gt;`make build`&lt;/span&gt;
&lt;span class="k"&gt;- &lt;/span&gt;Test all: &lt;span class="sb"&gt;`make test`&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The rest of that section covers the unit test command that needs no Docker daemon and the e2e command that does. That kind of note saves an agent a failed run.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Do-not rules.&lt;/strong&gt; mem0 (symlink to &lt;a href="https://github.com/mem0ai/mem0/blob/f1791daa86d469249c9b002f62644d58a1eb96a0/AGENTS.md#L10-L21" rel="noopener noreferrer"&gt;AGENTS.md&lt;/a&gt;) puts its "Do NOT" list at the top of the file, before the repository map:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;&lt;span class="gu"&gt;## Do NOT
&lt;/span&gt;
&lt;span class="k"&gt;- &lt;/span&gt;Modify anything in &lt;span class="sb"&gt;`.github/workflows/`&lt;/span&gt; without explicit maintainer approval. Publishing credentials are pinned to workflow filenames.
&lt;span class="k"&gt;- &lt;/span&gt;Commit &lt;span class="sb"&gt;`.env`&lt;/span&gt; files, API keys, or credentials.
&lt;span class="k"&gt;- &lt;/span&gt;Skip pre-commit hooks.
&lt;span class="k"&gt;- &lt;/span&gt;Use npm or yarn in TypeScript packages. This repo is pnpm-only (Bun in &lt;span class="sb"&gt;`integrations/opencode-plugin/`&lt;/span&gt;).
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each rule carries its reason or its alternative, which is what makes it usable.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Workflow.&lt;/strong&gt; docker/compose again (&lt;a href="https://github.com/docker/compose/blob/480ac8358f44b696c823f88baee0a98a6992f380/AGENTS.md#L104" rel="noopener noreferrer"&gt;AGENTS.md&lt;/a&gt;):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;&lt;span class="k"&gt;- &lt;/span&gt;Never create an issue or pull request without the user's explicit instruction.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Several repos write rules like this one, about what the agent may do in public on the maintainers' behalf. They read like a contributing guide written for a new kind of contributor.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Safety for CI.&lt;/strong&gt; anthropics/claude-code's own &lt;a href="https://github.com/anthropics/claude-code/blob/1ad046cb015cfcb6ad90293c605ee4e38326bd13/CLAUDE.md" rel="noopener noreferrer"&gt;CLAUDE.md&lt;/a&gt; is 40 lines on a single topic, how GitHub Actions jobs that call Claude are locked down, and it starts with "Keep them when you add or edit a workflow." A short file on the one thing an agent is most likely to get wrong in that repo.&lt;/p&gt;

&lt;h2&gt;
  
  
  A CLAUDE.md template from what these files share
&lt;/h2&gt;

&lt;p&gt;Putting the counts together, this is the shape most of the 30 repos converge on. Shared content goes in &lt;code&gt;AGENTS.md&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;&lt;span class="gu"&gt;# AGENTS.md
&lt;/span&gt;
One or two sentences on what this repo is.

&lt;span class="gu"&gt;## Do not
&lt;/span&gt;&lt;span class="k"&gt;- &lt;/span&gt;Paths the agent must not edit, and why (generated code, release workflows, vendored code).
&lt;span class="k"&gt;- &lt;/span&gt;Actions that need a human first (opening PRs, publishing, migrations).
&lt;span class="k"&gt;- &lt;/span&gt;Secrets: never commit &lt;span class="sb"&gt;`.env`&lt;/span&gt; or keys.

&lt;span class="gu"&gt;## Commands
&lt;/span&gt;&lt;span class="k"&gt;- &lt;/span&gt;Install: &lt;span class="sb"&gt;`...`&lt;/span&gt;
&lt;span class="k"&gt;- &lt;/span&gt;Build: &lt;span class="sb"&gt;`...`&lt;/span&gt;
&lt;span class="k"&gt;- &lt;/span&gt;Test one file: &lt;span class="sb"&gt;`...`&lt;/span&gt;   (the fast loop the agent should use)
&lt;span class="k"&gt;- &lt;/span&gt;Test all / lint: &lt;span class="sb"&gt;`...`&lt;/span&gt;  (what CI runs)

&lt;span class="gu"&gt;## Where code lives
&lt;/span&gt;&lt;span class="k"&gt;- &lt;/span&gt;&lt;span class="sb"&gt;`src/api/`&lt;/span&gt;: ...
&lt;span class="k"&gt;- &lt;/span&gt;&lt;span class="sb"&gt;`src/web/`&lt;/span&gt;: ... (has its own AGENTS.md)

&lt;span class="gu"&gt;## Conventions the linter does not catch
&lt;/span&gt;&lt;span class="k"&gt;- &lt;/span&gt;...

&lt;span class="gu"&gt;## Commits and PRs
&lt;/span&gt;&lt;span class="k"&gt;- &lt;/span&gt;Commit message format, branch to target, what a PR must include.

&lt;span class="gu"&gt;## Read before you change
&lt;/span&gt;&lt;span class="k"&gt;- &lt;/span&gt;&lt;span class="sb"&gt;`CONTRIBUTING.md`&lt;/span&gt;, &lt;span class="sb"&gt;`docs/architecture.md`&lt;/span&gt;, nested guides.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And &lt;code&gt;CLAUDE.md&lt;/code&gt; becomes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;@AGENTS.md

&amp;lt;!-- Claude Code only notes go here, if any. --&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Keep the root file around the middle of the range above, a couple of hundred lines at most, and push detail into the docs it points to. Our &lt;a href="https://repowise.dev/blog/guides/claude-md-agents-md-guide?utm_source=devto&amp;amp;utm_medium=community&amp;amp;utm_campaign=devto-16-claude-md-files-of-30-repos" rel="noopener noreferrer"&gt;CLAUDE.md and AGENTS.md guide&lt;/a&gt; covers how Claude Code and other agents load these files, including imports and nested files.&lt;/p&gt;

&lt;h2&gt;
  
  
  How I got these numbers
&lt;/h2&gt;

&lt;p&gt;All data was pulled on 17 November 2026 with the GitHub CLI, at each repo's default branch head. I recorded the commit SHA for every repo, so every file can be read exactly as I read it.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Pool.&lt;/strong&gt; The 195 repos in the dataset above (selected for 1,000+ stars, before this post). For each one: &lt;code&gt;gh api repos/{repo}&lt;/code&gt; for stars and default branch, &lt;code&gt;gh api repos/{repo}/commits/{branch}&lt;/code&gt; for the SHA, and &lt;code&gt;gh api "repos/{repo}/contents?ref={sha}"&lt;/code&gt; for the root listing.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Sample.&lt;/strong&gt; The 30 repos with a root &lt;code&gt;CLAUDE.md&lt;/code&gt; and the most stars at that moment (25,043 to 282,481). I took them in star order and dropped none.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Files.&lt;/strong&gt; Each &lt;code&gt;CLAUDE.md&lt;/code&gt; and &lt;code&gt;AGENTS.md&lt;/code&gt; downloaded raw at the pinned SHA. Symlinks found from the git tree (&lt;code&gt;gh api repos/{repo}/git/trees/{sha}&lt;/code&gt;, mode &lt;code&gt;120000&lt;/code&gt;) and their targets read from the blob.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tagging.&lt;/strong&gt; A Python script matched headings and a few body patterns per section type, printed the evidence line for each tag, and a hand check of all 30 files changed 14 of the 180 tags (for example a &lt;code&gt;# Single test file / pattern&lt;/code&gt; comment inside a code block that the script took for a conventions heading).
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;N 30
shape symlink 8
shape wrapper 13
shape full 9
at_import (@file.md line in CLAUDE.md) 10
commands     26/30 = 87%
layout       24/30 = 80%
conventions  22/30 = 73%
safety       28/30 = 93%
workflow     25/30 = 83%
pointers     29/30 = 97%
eff_lines median 179.0 min 13 max 1067 p25 107 p75 267
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Lengths count the files an agent reads at the root (&lt;code&gt;CLAUDE.md&lt;/code&gt;, and &lt;code&gt;AGENTS.md&lt;/code&gt; where &lt;code&gt;CLAUDE.md&lt;/code&gt; hands off to it), not docs those files point to. The repo pool came from repowise, the code index I work on. If you want a starting point for your own repo, repowise can &lt;a href="https://repowise.dev/blog/guides/how-to-generate-claude-md?utm_source=devto&amp;amp;utm_medium=community&amp;amp;utm_campaign=devto-16-claude-md-files-of-30-repos" rel="noopener noreferrer"&gt;generate a CLAUDE.md section&lt;/a&gt; from the indexed code and keeps it between markers, so the rules you write by hand stay yours.&lt;/p&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;What should a CLAUDE.md file contain?&lt;/strong&gt;&lt;br&gt;
In these 30 repos: pointers to deeper docs, a short list of things the agent must not do, the build and test commands, commit and PR rules, and a map of where code lives. Style rules were the least common, because linters already enforce most of them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Should I use CLAUDE.md or AGENTS.md?&lt;/strong&gt;&lt;br&gt;
Most of these repos use both, with one source of truth. 21 of the 30 make &lt;code&gt;CLAUDE.md&lt;/code&gt; a symlink to &lt;code&gt;AGENTS.md&lt;/code&gt; or a short file that imports it with &lt;code&gt;@AGENTS.md&lt;/code&gt;, so Claude Code and other agents read the same rules.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How long should a CLAUDE.md be?&lt;/strong&gt;&lt;br&gt;
What the agent reads in these repos is a median of 179 lines, and the middle half is 107 to 267 lines. Files at the short end stay small by pointing to nested guides and other docs instead of copying them in.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>claude</category>
      <category>productivity</category>
      <category>opensource</category>
    </item>
    <item>
      <title>Dead code is a git problem before it is a linter problem</title>
      <dc:creator>Raghav Chamadiya</dc:creator>
      <pubDate>Fri, 27 Nov 2026 13:00:00 +0000</pubDate>
      <link>https://dev.to/repowise/dead-code-is-a-git-problem-before-it-is-a-linter-problem-4ca1</link>
      <guid>https://dev.to/repowise/dead-code-is-a-git-problem-before-it-is-a-linter-problem-4ca1</guid>
      <description>&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Linters find unused code inside a file: an unused import, a variable, a private function. A whole file that nothing imports, or code nobody has changed in years, only shows up in the import graph and in git history.&lt;/li&gt;
&lt;li&gt;170 of 190 popular repos (89%) have at least one production file nothing imports. In the median repo that is 3.2% of production files. Pooled: 19,697 files flagged as unreachable and 39,863 unused exports.&lt;/li&gt;
&lt;li&gt;On Django, plain &lt;code&gt;git log&lt;/code&gt; dated 90 of 92 flagged files to 2022 or later, because of repo-wide formatting commits. Skipping the commits in &lt;code&gt;.git-blame-ignore-revs&lt;/code&gt;, 68 were last changed in 2020 or earlier.&lt;/li&gt;
&lt;li&gt;Old plus unimported is a lead, not a verdict. The last step is always a string search.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Data: repowise's index of 195 public repos with 1,000+ GitHub stars, plus git and ripgrep on a full clone of Django.&lt;/p&gt;

&lt;p&gt;Most teams treat unused code as a linter setting. Turn on &lt;code&gt;no-unused-vars&lt;/code&gt;, Ruff's F401, &lt;code&gt;noUnusedLocals&lt;/code&gt;, and the problem looks handled. They are useful, and they work one file at a time. The unused code that costs you the most is a whole module nobody imports and nobody has opened since a migration three years ago. No single-file check can see that. You need two things a linter does not read: who imports the file, and when it last changed.&lt;/p&gt;

&lt;h2&gt;
  
  
  How much unused code do popular repos carry?
&lt;/h2&gt;

&lt;p&gt;From the 190 repos with dead-code data:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;182 of 190 (96%) have at least one dead-code finding in production code.&lt;/li&gt;
&lt;li&gt;170 of 190 (89%) have at least one production file nothing imports. In the median repo that is 3.2% of production files, and in 44 repos (23%) it is 10% or more.&lt;/li&gt;
&lt;li&gt;Pooled, 19,697 production files are flagged as unreachable and 39,863 exports are unused, covering 3.5 million lines.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Single-file lint rules report neither kind. An unused export looks fine from inside its own file, and an unreachable file has nothing wrong in it at all.&lt;/p&gt;

&lt;h2&gt;
  
  
  What does git history say about a file nothing imports?
&lt;/h2&gt;

&lt;p&gt;I took the 92 files repowise flags as unreachable in Django and asked git when each last changed. Plain &lt;code&gt;git log&lt;/code&gt; first:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git log -1 --format=%ad --date=short -- django/conf/locale/bs/formats.py
2022-02-03
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That looks recent-ish. It is not:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git log -3 --format='%h %ad %s' --date=short -- django/conf/locale/bs/formats.py
9c19aff7c7 2022-02-03 Refs #33476 -- Reformatted code with Black.
82f286cf6f 2018-09-25 Refs #29784 -- Switched to https:// links where available.
d7b9aaa366 2016-11-19 Refs #23919 -- Removed encoding preambles and future imports
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The last commit is the repo-wide Black reformat. The admin JavaScript has the same story with a 2026 "Formatted JavaScript files." commit. Across all 92 files, plain &lt;code&gt;git log&lt;/code&gt; put 90 of them in 2022 or later. Django lists its formatting commits in &lt;code&gt;.git-blame-ignore-revs&lt;/code&gt;. Skip those, and 68 of the 92 were last really changed in 2020 or earlier.&lt;/p&gt;

&lt;p&gt;So git age is a strong signal, but only after you remove the commits that touched everything.&lt;/p&gt;

&lt;p&gt;Then the import check, which is where it gets humbling:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ rg -n "locale\.bs" --type py

$ rg -n "conf\.locale" --type py django
django\utils\translation\__init__.py:270:    from django.conf.locale import LANG_INFO
django\utils\formats.py:76:    format_locations.append("django.conf.locale.%s")
django\utils\translation\trans_real.py:14:from django.conf.locale import LANG_INFO

$ rg -n "cancel\.js"
django\contrib\admin\templates\admin\delete_selected_confirmation.html:7:    &amp;lt;script src="{% static 'admin/js/cancel.js' %}" async {% csp_nonce_attr %}&amp;gt;&amp;lt;/script&amp;gt;
django\contrib\admin\templates\admin\delete_confirmation.html:7:    &amp;lt;script src="{% static 'admin/js/cancel.js' %}" async {% csp_nonce_attr %}&amp;gt;&amp;lt;/script&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Nothing imports the Bosnian formats file by name, but &lt;code&gt;django/utils/formats.py&lt;/code&gt; builds the module path as a string and imports it at runtime. &lt;code&gt;cancel.js&lt;/code&gt; is served to the browser from two admin templates. The Sphinx files under &lt;code&gt;docs/&lt;/code&gt; are loaded by Sphinx. The Django files I looked at are all reached another way, the same thing I found when I &lt;a href="https://dev.to/repowise/python-dead-code-what-51-popular-python-repos-ship-that-nothing-imports-3eg3"&gt;hand-checked Django, LangChain and Airflow&lt;/a&gt;. In a well-kept repo, that is the expected result.&lt;/p&gt;

&lt;h2&gt;
  
  
  A routine for finding old, unused files
&lt;/h2&gt;

&lt;p&gt;Step 1, the last real change for every file, skipping formatting commits:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git log --format=&lt;span class="s1"&gt;'@%H %ad'&lt;/span&gt; --date=short --name-only \
  &lt;span class="o"&gt;|&lt;/span&gt; awk &lt;span class="s1"&gt;'NR==FNR{ig[$1]=1;next} /^@/{h=substr($1,2);d=$2;next} NF &amp;amp;&amp;amp; !(h in ig) &amp;amp;&amp;amp; !seen[$0]++ {print d, $0}'&lt;/span&gt; \
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;grep -o &lt;span class="s1"&gt;'^[0-9a-f]\{40\}'&lt;/span&gt; .git-blame-ignore-revs&lt;span class="o"&gt;)&lt;/span&gt; - \
  &lt;span class="o"&gt;|&lt;/span&gt; sort &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; last-change.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If your repo has no &lt;code&gt;.git-blame-ignore-revs&lt;/code&gt;, start one. List the formatter commits there once and &lt;code&gt;git blame&lt;/code&gt; uses it too (&lt;code&gt;git config blame.ignoreRevsFile .git-blame-ignore-revs&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;Step 2, keep files that still exist and have not changed in three years:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ awk 'NR==FNR{t[$0]=1;next} ($2 in t) &amp;amp;&amp;amp; $2 ~ /^django\/.*\.py$/ &amp;amp;&amp;amp; $1 &amp;lt; "2023-11-17"' \
    &amp;lt;(git ls-files) last-change.txt &amp;gt; old.txt
$ wc -l &amp;lt; old.txt
449
$ head -3 old.txt
2005-07-13 django/core/__init__.py
2005-07-13 django/utils/__init__.py
2005-07-13 django/views/decorators/__init__.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;449 of Django's 909 Python files under &lt;code&gt;django/&lt;/code&gt; have not really changed in three years. Old on its own means stable, not dead. &lt;code&gt;django/core/__init__.py&lt;/code&gt; has been fine since 2005.&lt;/p&gt;

&lt;p&gt;Step 3, keep the old files that nothing imports. Get the unreachable list from an import-graph tool (Knip for TypeScript, as in &lt;a href="https://dev.to/repowise/typescript-unused-exports-what-52-popular-ts-repos-carry-and-how-to-clean-yours-with-knip-52j3"&gt;the Knip walkthrough&lt;/a&gt;, or &lt;code&gt;repowise dead-code&lt;/code&gt; for any language), one path per line, and join:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ awk 'NR==FNR{f[$0]=1;next} ($2 in f)' unreachable.txt old.txt | wc -l
75
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;From 449 old files to 75 old and unimported. All 75 are Django locale &lt;code&gt;formats.py&lt;/code&gt; files, and step 4 is what clears them.&lt;/p&gt;

&lt;p&gt;Step 4, search for each candidate as a string: its dotted module name, its file stem, its path in templates, configs, &lt;code&gt;package.json&lt;/code&gt;, &lt;code&gt;pyproject.toml&lt;/code&gt; entry points and CI files. If a prefix shows up next to &lt;code&gt;%s&lt;/code&gt;, &lt;code&gt;import_module&lt;/code&gt;, &lt;code&gt;require(&lt;/code&gt; or a glob, the file is loaded by name.&lt;/p&gt;

&lt;p&gt;repowise joins the import graph and git age in one pass. A file nothing reaches gets its confidence from git: any commit in the last 90 days caps it low, and a year without one gives the top score. &lt;a href="https://repowise.dev/blog/engineering/how-repowise-dead-code-detection-works?utm_source=devto&amp;amp;utm_medium=community&amp;amp;utm_campaign=devto-15-dead-code-is-a-git-problem" rel="noopener noreferrer"&gt;How that scoring works&lt;/a&gt; is written up separately. Step 4 still belongs to you.&lt;/p&gt;

&lt;h2&gt;
  
  
  When is deleting unused code safe?
&lt;/h2&gt;

&lt;p&gt;When all of these hold:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Nothing imports it, and a string search for its name and path finds nothing.&lt;/li&gt;
&lt;li&gt;It has not really changed in a long time, after skipping formatting commits.&lt;/li&gt;
&lt;li&gt;It is not part of a published package's public surface. Users import those paths from outside your repo.&lt;/li&gt;
&lt;li&gt;The tests pass and every module still imports after the delete.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Delete it in a small pull request. Git keeps it. If someone needs it next year, &lt;code&gt;git log --diff-filter=D -- path/to/file&lt;/code&gt; finds the deleting commit and &lt;code&gt;git restore --source=&amp;lt;sha&amp;gt;^ -- path/to/file&lt;/code&gt; brings it back. That is the other half of why this is a git problem. Deleting is cheap because history is the backup.&lt;/p&gt;

&lt;h2&gt;
  
  
  How I got these numbers
&lt;/h2&gt;

&lt;p&gt;The cohort numbers come from 195 of the most-starred public repositories indexed on repowise.dev (1,000+ GitHub stars each, 253,688 production source files, November 2026), with dead-code data for 190 of them. Findings are counted on production files at confidence 0.4 and above, each repo at its own latest index. The full breakdown is in the &lt;a href="https://repowise.dev/research/code-health-2026?utm_source=devto&amp;amp;utm_medium=community&amp;amp;utm_campaign=devto-15-dead-code-is-a-git-problem#dead-code" rel="noopener noreferrer"&gt;code health 2026 report&lt;/a&gt;. The Django run used a full clone at &lt;code&gt;d3954c9&lt;/code&gt; (12 November 2026), git 2.51 and ripgrep 15.1. The 92 flagged files come from a repowise 0.60.1 index of the same clone at &lt;code&gt;6a8248f&lt;/code&gt;, and none of them changed between the two commits.&lt;/p&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;What is unused code?&lt;/strong&gt;&lt;br&gt;
Code that nothing in the program reaches: a variable or import never read, a function never called, an exported symbol no other module imports, or a whole file no other file imports and no entry point loads. Linters cover the first two kinds inside one file. The last two need the import graph of the whole repo.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How do I find unused code in a large codebase?&lt;/strong&gt;&lt;br&gt;
Run your linter's unused rules for names inside files, then an import-graph tool for unused exports and files (Knip for JavaScript and TypeScript, vulture for Python names, repowise for files and exports across languages). Sort the results by last real change in git and search each candidate's name as a string before deleting.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Is it safe to remove unused code?&lt;/strong&gt;&lt;br&gt;
It is safe when nothing imports it, no string or config refers to it, it is not part of a published API, and the tests and an import of every module pass afterwards. Git keeps every deleted file, so a wrong call is one &lt;code&gt;git restore&lt;/code&gt; away.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>discuss</category>
      <category>codequality</category>
      <category>opensource</category>
    </item>
    <item>
      <title>What is eating your Claude Code context window in a big repo</title>
      <dc:creator>Raghav Chamadiya</dc:creator>
      <pubDate>Thu, 26 Nov 2026 13:00:00 +0000</pubDate>
      <link>https://dev.to/repowise/what-is-eating-your-claude-code-context-window-in-a-big-repo-26do</link>
      <guid>https://dev.to/repowise/what-is-eating-your-claude-code-context-window-in-a-big-repo-26do</guid>
      <description>&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In a Grafana clone, Claude Code 2.1.288 on Sonnet sent about 38,100 tokens on the first request of a plain session, before reading a single file.&lt;/li&gt;
&lt;li&gt;In that Claude Code setup, built-in tool definitions (23.3k tokens) were the biggest item in &lt;code&gt;/context&lt;/code&gt;, and reading one 1,100-line file in full added 16,481 tokens.&lt;/li&gt;
&lt;li&gt;A 310 KB &lt;code&gt;git grep&lt;/code&gt; added only 1,142 tokens, because Claude Code saved the output to a file and gave the model a 2 KB preview.&lt;/li&gt;
&lt;li&gt;Measured on 10 November 2026 from the usage field of every API request; some runs also had repowise, the code index I work on, connected over MCP.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I wanted to know where the tokens go when Claude Code works in a large repository, so I stopped guessing and logged every request. I used Grafana (a shallow clone at &lt;code&gt;12c49a4d&lt;/code&gt;, 24,428 tracked files, Go backend and TypeScript frontend), Claude Code 2.1.288 and Sonnet, and ran everything headless with &lt;code&gt;--output-format stream-json&lt;/code&gt;, which prints the token usage of every API call.&lt;/p&gt;

&lt;p&gt;The first request of every session carried about 38,100 tokens. That is before the agent had read a single file. A whole cross-stack exploration task added 12,412 tokens on top of it. Reading one 1,100-line file in full added 16,481.&lt;/p&gt;

&lt;p&gt;Here is what makes up those numbers, how to see them in your own sessions, and what changed them.&lt;/p&gt;

&lt;h2&gt;
  
  
  See it first: /context
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;/context&lt;/code&gt; prints the breakdown of the current window. It also works in print mode, which is how I got it without opening a session:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; grafana
claude -p &lt;span class="s2"&gt;"/context"&lt;/span&gt; --model sonnet
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(On Git Bash for Windows, set &lt;code&gt;MSYS_NO_PATHCONV=1&lt;/code&gt; first. Otherwise Git Bash rewrites &lt;code&gt;/context&lt;/code&gt; into &lt;code&gt;C:/Program Files/Git/context&lt;/code&gt; and the model gets a confusing message instead of the command.)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;**Model:** claude-sonnet-5-5
**Tokens:** 32.5k / 1m (3%)

| Category | Tokens | Percentage |
|----------|--------|------------|
| System prompt | 2.2k | 0.2% |
| System tools | 23.3k | 2.3% |
| System tools (deferred) | 19.9k | 2.0% |
| Memory files | 3.9k | 0.4% |
| Skills | 3.1k | 0.3% |
| Messages | 10 | 0.0% |
| Free space | 934.5k | 93.5% |
| Autocompact buffer | 33k | 3.3% |

### Memory Files

| Type | Path | Tokens |
|------|------|--------|
| Project | ./CLAUDE.md | 16 |
| Project | ./AGENTS.md | 3.9k |
...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On this model Claude Code reports a 1M window, so 32.5k is 3%. The same fixed cost on a 200k window would be about a sixth of it.&lt;/p&gt;

&lt;h2&gt;
  
  
  What fills the Claude Code context window before you type?
&lt;/h2&gt;

&lt;p&gt;Going down that table:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;System tools, 23.3k.&lt;/strong&gt; The definitions of the built-in tools (Read, Grep, Bash, Edit, Agent and the rest). This is the biggest single item, and you pay it on every request. The "deferred" 19.9k are tools whose full definitions are only loaded when the model searches for them, so they are not counted in the 32.5k.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Memory files, 3.9k.&lt;/strong&gt; Grafana ships a &lt;code&gt;CLAUDE.md&lt;/code&gt; that is one line, &lt;code&gt;@AGENTS.md&lt;/code&gt;. That import pulls in a 10.8 KB &lt;code&gt;AGENTS.md&lt;/code&gt; with build commands, test commands, review rules and pointers to four directory-level &lt;code&gt;AGENTS.md&lt;/code&gt; files. Every session in this repo starts with it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Skills, 3.1k.&lt;/strong&gt; Only the name and description of each skill load up front. Grafana adds three of its own under &lt;code&gt;.claude/skills/&lt;/code&gt; (about 580 tokens together), the rest are built in.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;MCP servers.&lt;/strong&gt; I ran a second &lt;code&gt;/context&lt;/code&gt; with one MCP server connected (repowise, which I use below). It added 344 tokens of server instructions. Its 10 tools, 6.2k tokens of definitions, stayed in the deferred bucket until used.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The first API request in my runs was slightly bigger than &lt;code&gt;/context&lt;/code&gt;'s estimate: 38,120 to 38,170 tokens with no MCP server, about 38,700 with one, and 40,014 when I also added a 3.4 KB generated &lt;code&gt;CLAUDE.md&lt;/code&gt; section.&lt;/p&gt;

&lt;p&gt;If you install a lot of plugins and skills globally, this part grows in every repo you open. My runs used &lt;code&gt;--setting-sources project,local&lt;/code&gt; to skip my own user settings, so the numbers above are Grafana's own setup plus Claude Code's defaults.&lt;/p&gt;

&lt;h2&gt;
  
  
  What grows the context window during a task?
&lt;/h2&gt;

&lt;p&gt;To isolate single actions, I gave Claude Code one instruction per session and diffed the window between the request before the action and the request after it.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Action&lt;/th&gt;
&lt;th&gt;Window growth&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;Read&lt;/code&gt; of &lt;code&gt;public/app/features/dashboard/state/DashboardMigrator.ts&lt;/code&gt; in full (1,104 lines, 36 KB)&lt;/td&gt;
&lt;td&gt;+16,481 tokens&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;The step that read &lt;code&gt;apps/dashboard/pkg/migration/schemaversion/README.md&lt;/code&gt; (16.7k characters) plus two small greps&lt;/td&gt;
&lt;td&gt;+7,864 tokens&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;git grep -n -i schemaversion&lt;/code&gt; over the whole repo (310 KB of output)&lt;/td&gt;
&lt;td&gt;+1,142 tokens&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;A subagent reads &lt;code&gt;DashboardMigrator.ts&lt;/code&gt; and returns a 5-line summary&lt;/td&gt;
&lt;td&gt;+1,256 tokens in the main window&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;14 targeted &lt;code&gt;Grep&lt;/code&gt;/&lt;code&gt;Glob&lt;/code&gt; calls and one &lt;code&gt;Read&lt;/code&gt; while tracing the dashboard save path&lt;/td&gt;
&lt;td&gt;+12,412 tokens for the whole task&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Two of these surprised me.&lt;/p&gt;

&lt;p&gt;The 310 KB grep cost almost nothing. Claude Code did not put it in the window. It saved the output to a file and gave the model a 2 KB preview with the path:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;persisted-output&amp;gt;
Output too large (310.2KB). Full output saved to: ~/.claude/projects/&amp;lt;project&amp;gt;/.../tool-results/b2o2qaoan.txt

Preview (first 2KB):
apps/alerting/notifications/kinds/manifest.cue:104: versions: [...#IntegrationTypeSchemaVersion]
...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The model then ran &lt;code&gt;tail&lt;/code&gt; on that file to get the line it needed. Huge command output is less of a threat than it used to be. The full-file &lt;code&gt;Read&lt;/code&gt; has no such guard, because a 36 KB file is under the limit, and it was the single most expensive action I measured.&lt;/p&gt;

&lt;p&gt;The subagent kept the main window small, but it was not cheaper. It started its own context at 32,216 tokens (it gets its own system prompt and tools) and then read the same file. The session cost $0.21, against $0.12 for reading the file directly. In this run the subagent protected the window I was working in, and it did not save money.&lt;/p&gt;

&lt;h2&gt;
  
  
  Two real tasks, measured
&lt;/h2&gt;

&lt;p&gt;Then I gave Claude Code two questions a new contributor to Grafana might ask, and logged each run end to end.&lt;/p&gt;

&lt;p&gt;Task 1: "Where is the dashboard JSON schema migrated between versions, and which files would I touch to add a new migration step?"&lt;/p&gt;

&lt;p&gt;Task 2: "Trace what happens when a user clicks Save on a dashboard in the Grafana UI, through the frontend and the Go backend, down to where the dashboard is written to storage."&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Run&lt;/th&gt;
&lt;th&gt;Tool calls&lt;/th&gt;
&lt;th&gt;
&lt;code&gt;Read&lt;/code&gt; calls&lt;/th&gt;
&lt;th&gt;Window at start&lt;/th&gt;
&lt;th&gt;Window at answer&lt;/th&gt;
&lt;th&gt;Growth&lt;/th&gt;
&lt;th&gt;Wall time&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Task 1, plain&lt;/td&gt;
&lt;td&gt;8&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;38,129&lt;/td&gt;
&lt;td&gt;50,614&lt;/td&gt;
&lt;td&gt;12,485&lt;/td&gt;
&lt;td&gt;18.3 s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Task 1, MCP server connected&lt;/td&gt;
&lt;td&gt;6&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;38,680&lt;/td&gt;
&lt;td&gt;45,082&lt;/td&gt;
&lt;td&gt;6,402&lt;/td&gt;
&lt;td&gt;14.7 s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Task 2, plain&lt;/td&gt;
&lt;td&gt;15&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;38,170&lt;/td&gt;
&lt;td&gt;50,582&lt;/td&gt;
&lt;td&gt;12,412&lt;/td&gt;
&lt;td&gt;29.5 s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Task 2, MCP + generated CLAUDE.md section&lt;/td&gt;
&lt;td&gt;20&lt;/td&gt;
&lt;td&gt;6&lt;/td&gt;
&lt;td&gt;40,014&lt;/td&gt;
&lt;td&gt;55,677&lt;/td&gt;
&lt;td&gt;15,663&lt;/td&gt;
&lt;td&gt;28.7 s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Task 2, MCP, prompt says to use it&lt;/td&gt;
&lt;td&gt;6&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;38,736&lt;/td&gt;
&lt;td&gt;48,239&lt;/td&gt;
&lt;td&gt;9,503&lt;/td&gt;
&lt;td&gt;30.0 s&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;"Window at answer" is the input of the last request, when the model wrote its reply. I am comparing tokens, not dollars. Prompt caching makes the dollar figure depend on run order: the first run paid to write 38k tokens to the cache and every later run read them back cheaply.&lt;/p&gt;

&lt;p&gt;What I take from this:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The fixed part was the biggest part.&lt;/strong&gt; In every run, the 38k loaded before the task was two and a half to six times what the task itself added. On a short question, trimming your setup moves the number more than any prompt trick.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Sonnet was careful on its own.&lt;/strong&gt; It grepped with &lt;code&gt;head_limit&lt;/code&gt;, used &lt;code&gt;files_with_matches&lt;/code&gt; before asking for content, and in the second task-2 run it read six slices of files with &lt;code&gt;offset&lt;/code&gt; and &lt;code&gt;limit&lt;/code&gt; (1 to 6 KB each) instead of whole files. The full reads it did choose were a 15 KB README and a 6 KB hook file.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Grafana's own docs did the heavy lifting on task 1.&lt;/strong&gt; The plain run found &lt;code&gt;apps/dashboard/pkg/migration/schemaversion/README.md&lt;/code&gt;, a step-by-step guide for adding a schema migration, read it, and answered from it. Both runs named the same files: &lt;code&gt;schemaversion/vN.go&lt;/code&gt;, &lt;code&gt;migrations.go&lt;/code&gt; (where &lt;code&gt;LATEST_VERSION = 42&lt;/code&gt; lives), the test fixtures and the frontend &lt;code&gt;DashboardMigrator.ts&lt;/code&gt;. A good README sitting next to the code is worth more than any amount of agent cleverness.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;One run per condition is anecdotal.&lt;/strong&gt; The two task-1 runs differ only by an MCP server that was never called, and they still differ by 6,000 tokens, because one run read the README and the other answered from grep results. Treat any single-run difference smaller than that as noise.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to make Claude Code show the context window while you work
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;/context&lt;/code&gt; for the breakdown above, any time during a session.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;/usage&lt;/code&gt; for session cost and plan usage. &lt;code&gt;/cost&lt;/code&gt; and &lt;code&gt;/stats&lt;/code&gt; are aliases of it in 2.1.288.&lt;/li&gt;
&lt;li&gt;A statusline, so the number is always on screen. Claude Code pipes JSON to your statusline command, and it includes &lt;code&gt;context_window.total_input_tokens&lt;/code&gt;, &lt;code&gt;context_window.context_window_size&lt;/code&gt;, &lt;code&gt;context_window.used_percentage&lt;/code&gt; and &lt;code&gt;cost.total_cost_usd&lt;/code&gt;. Mine is a few lines of Python:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# ~/.claude/statusline.py&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sys&lt;/span&gt;
&lt;span class="n"&gt;d&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;load&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;stdin&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;cw&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"context_window"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="n"&gt;used&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;cw&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"total_input_tokens"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
&lt;span class="n"&gt;size&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;cw&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"context_window_size"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
&lt;span class="n"&gt;cost&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"cost"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"total_cost_usd"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"{d['model']['display_name']} | context {used/1000:.1f}k / {size/1000:.0f}k | ${cost:.2f}"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"statusLine"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"command"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"command"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"python ~/.claude/statusline.py"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That goes in &lt;code&gt;~/.claude/settings.json&lt;/code&gt;, and it prints something like &lt;code&gt;Sonnet | context 50.6k / 1000k | $0.25&lt;/code&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;For scripted measurement, &lt;code&gt;claude -p "&amp;lt;task&amp;gt;" --output-format stream-json --verbose&lt;/code&gt; gives &lt;code&gt;input_tokens&lt;/code&gt;, &lt;code&gt;cache_creation_input_tokens&lt;/code&gt;, &lt;code&gt;cache_read_input_tokens&lt;/code&gt; and &lt;code&gt;output_tokens&lt;/code&gt; for every request. Their sum is the window at that request. That is all I used for the tables above.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  How to reduce Claude Code context usage
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Prune what loads every session.&lt;/strong&gt; The fixed ~38k was the biggest part of every run, so that is where I would start. Look at the Memory files and Skills rows in &lt;code&gt;/context&lt;/code&gt;. Grafana's approach is a good model: one root file of commands and rules, and a list of directory-level &lt;code&gt;AGENTS.md&lt;/code&gt; files the agent reads only when it works in that directory. Global plugins and skills you installed once and forgot about load in every repo.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Point at files, ask for slices.&lt;/strong&gt; "Read &lt;code&gt;DashboardMigrator.ts&lt;/code&gt; lines 1 to 120" or "find where &lt;code&gt;LATEST_VERSION&lt;/code&gt; is set" costs a fraction of a full read. The full read was 16,481 tokens, the six slices in my second task-2 run were 1 to 6 KB of text each, roughly 250 to 1,500 tokens.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Use subagents for wide exploration you do not need to keep.&lt;/strong&gt; They keep your working window clean (+1,256 instead of +16,481 here), though in my run the total cost was higher.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;/clear&lt;/code&gt; between unrelated tasks, &lt;code&gt;/compact&lt;/code&gt; with a focus inside a long one.&lt;/strong&gt; My runs were single questions, so none of them got close to the 33k autocompact buffer. In a long interactive session, everything above stays in the window and is sent again on every turn until you clear or compact. &lt;a href="https://repowise.dev/blog/mcp/claude-code-context-large-codebases?utm_source=devto&amp;amp;utm_medium=community&amp;amp;utm_campaign=devto-14-claude-code-context-window" rel="noopener noreferrer"&gt;This guide on Claude Code in large codebases&lt;/a&gt; covers what to put in &lt;code&gt;CLAUDE.md&lt;/code&gt; and how to steer &lt;code&gt;/compact&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Name the tool you want used.&lt;/strong&gt; MCP tools are deferred behind tool search, so the model has to decide to look for them. That turned out to matter, below.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where an index fit in
&lt;/h2&gt;

&lt;p&gt;I connected repowise, the open-source tool I work on, over MCP (&lt;code&gt;repowise mcp &amp;lt;path&amp;gt;&lt;/code&gt;) after indexing Grafana with &lt;code&gt;repowise init&lt;/code&gt;. It answers "how does X flow" and "where is Y" questions from a code graph instead of from file reads.&lt;/p&gt;

&lt;p&gt;In the two runs where the server was just connected, Sonnet never called it. It went straight to Grep, same as the plain runs, so the only effect was the 344 tokens of instructions (and about 1.3k more for the generated &lt;code&gt;CLAUDE.md&lt;/code&gt; section in the second one, which tells the agent when to use each tool).&lt;/p&gt;

&lt;p&gt;When the prompt said "Use the repowise MCP tools before reading files", it made one &lt;code&gt;get_answer&lt;/code&gt; call and three &lt;code&gt;search_codebase&lt;/code&gt; calls, read zero files, and finished task 2 with 6 tool calls against 15, and 9,503 tokens of growth against 12,412. It listed the same frontend chain (&lt;code&gt;SaveDashboardDrawer.tsx&lt;/code&gt;, &lt;code&gt;useSaveDashboard.ts&lt;/code&gt;, &lt;code&gt;dashboard/api/v1.ts&lt;/code&gt;) and the same unified storage files down to the SQL backend's &lt;code&gt;backend.go&lt;/code&gt;, marked two middle hops of the backend as inferred from file names, and offered to open them.&lt;/p&gt;

&lt;p&gt;If you use any MCP server for code context, saying so in the prompt or in your own instructions is what gets it used. The &lt;a href="https://repowise.dev/claude-code?utm_source=devto&amp;amp;utm_medium=community&amp;amp;utm_campaign=devto-14-claude-code-context-window" rel="noopener noreferrer"&gt;Claude Code setup page&lt;/a&gt; shows how repowise wires itself into Claude Code beyond a bare MCP server.&lt;/p&gt;

&lt;p&gt;What do you see in &lt;code&gt;/context&lt;/code&gt; on your largest repo? I would like to know which row is the biggest for people with a lot of plugins installed.&lt;/p&gt;

&lt;h2&gt;
  
  
  How I ran this
&lt;/h2&gt;

&lt;p&gt;All runs on 10 November 2026, Windows 11, Git Bash. Grafana shallow clone at &lt;code&gt;12c49a4d&lt;/code&gt; (24,428 tracked files). Claude Code 2.1.288, model alias &lt;code&gt;sonnet&lt;/code&gt; (reported as &lt;code&gt;claude-sonnet-5-5&lt;/code&gt;, 1M window), repowise 0.60.1 indexed with &lt;code&gt;repowise init --yes --no-prose --no-editor-setup&lt;/code&gt; (no model used for the index).&lt;/p&gt;

&lt;p&gt;Every run used the same isolation flags, so my own setup did not leak in:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;claude -p &lt;span class="s2"&gt;"&amp;lt;task&amp;gt;"&lt;/span&gt; --model sonnet --output-format stream-json --verbose \
  --strict-mcp-config --mcp-config &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;empty or repowise-only config&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; \
  --setting-sources project,local --no-session-persistence \
  --permission-prompts none --disallowedTools &lt;span class="s2"&gt;"Edit Write NotebookEdit"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;--setting-sources project,local&lt;/code&gt; skips user settings, plugins and hooks. Built-in skills and Claude Code's own system prompt still load, and I added &lt;code&gt;.repowise/&lt;/code&gt; to &lt;code&gt;.git/info/exclude&lt;/code&gt; so search tools would not wander into the index. One run per condition. Total spend for every run in this post was about $1.35. All five task runs named the right main files, which I checked against the clone. The token figures come straight from the &lt;code&gt;usage&lt;/code&gt; field of each request.&lt;/p&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;What does a 200K context window mean in Claude Code?&lt;/strong&gt;&lt;br&gt;
It is the most tokens the model can take in one request, and everything counts toward it: system prompt, tool definitions, memory files, skills and the whole conversation so far. In my Grafana runs &lt;code&gt;/context&lt;/code&gt; counted 32.5k before the first message, which would be about a sixth of a 200K window.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What happens when I hit my context window in Claude Code?&lt;/strong&gt;&lt;br&gt;
Claude Code compacts automatically when the window gets close to full, summarizing the earlier conversation to free space. &lt;code&gt;/context&lt;/code&gt; shows the reserved autocompact buffer (33k in my runs), and you can run &lt;code&gt;/compact&lt;/code&gt; yourself or &lt;code&gt;/clear&lt;/code&gt; to start fresh between tasks.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How do I make Claude Code show the context window?&lt;/strong&gt;&lt;br&gt;
Run &lt;code&gt;/context&lt;/code&gt; at any point for the full breakdown. For a number that is always on screen, use a statusline command that reads &lt;code&gt;context_window.used_percentage&lt;/code&gt; or &lt;code&gt;context_window.total_input_tokens&lt;/code&gt; from the JSON Claude Code passes to it.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>claude</category>
      <category>productivity</category>
      <category>programming</category>
    </item>
    <item>
      <title>Rust circular dependencies: 22% of files sit in a module cycle and 79% have one main author</title>
      <dc:creator>Raghav Chamadiya</dc:creator>
      <pubDate>Wed, 25 Nov 2026 13:00:00 +0000</pubDate>
      <link>https://dev.to/repowise/rust-circular-dependencies-22-of-files-sit-in-a-module-cycle-and-79-have-one-main-author-49mc</link>
      <guid>https://dev.to/repowise/rust-circular-dependencies-22-of-files-sit-in-a-module-cycle-and-79-have-one-main-author-49mc</guid>
      <description>&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Cargo refuses to build two Rust crates that depend on each other ("cyclic package dependency"), but modules inside one crate can &lt;code&gt;use&lt;/code&gt; each other freely.&lt;/li&gt;
&lt;li&gt;In the median of 15 Rust repos with 1,000+ GitHub stars, 22.2% of production files sit in a circular import chain between files, against 9.2% across all 195 repos in the set.&lt;/li&gt;
&lt;li&gt;In bevy, all 75 of those cycle groups stay inside a single crate, and cargo machete flagged 34 unused dependencies across 25 manifests in 4.6 seconds.&lt;/li&gt;
&lt;li&gt;Numbers come from repowise's index of 195 public repos with 1,000+ GitHub stars (November 2026), plus fresh runs on bevy and ratatui.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Two crates that depend on each other will not build. Cargo stops before compiling anything:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;error: cyclic package dependency: package `cart v0.1.0 (./split/cart)` depends on itself. Cycle:
package `cart v0.1.0 (./split/cart)`
    ... which satisfies path dependency `cart` of package `pricing v0.1.0 (./split/pricing)`
    ... which satisfies path dependency `pricing` of package `cart v0.1.0 (./split/cart)`
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Put the same two files in one crate as modules and it compiles in under a second. That difference explains most of what I found when I looked at the file-level import graphs of 15 popular Rust repositories: a median of 22% of production files sit inside a circular import chain between files (a cycle of &lt;code&gt;use&lt;/code&gt; statements), more than in Python, TypeScript or Go. In bevy, the repo I checked by hand, not one of those chains crosses a crate boundary.&lt;/p&gt;

&lt;h2&gt;
  
  
  How common are circular dependencies in Rust repos?
&lt;/h2&gt;

&lt;p&gt;I looked at production source files (tests, examples, generated and vendored code excluded) in public repos with 1,000+ GitHub stars, as part of a &lt;a href="https://repowise.dev/research/code-health-2026?utm_source=devto&amp;amp;utm_medium=community&amp;amp;utm_campaign=devto-13-rust-circular-dependency#by-language" rel="noopener noreferrer"&gt;larger set of 195 repos&lt;/a&gt;. Fifteen of them have Rust as their primary language. That is a small group, so read the Rust column as indicative.&lt;/p&gt;

&lt;p&gt;A "cycle group" here is a set of two or more files that can all reach each other through imports. In Rust that means &lt;code&gt;use crate::...&lt;/code&gt;, &lt;code&gt;use super::...&lt;/code&gt; and friends between files of the same crate.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Median per repo&lt;/th&gt;
&lt;th&gt;Rust (15 repos)&lt;/th&gt;
&lt;th&gt;All 195 repos&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Repos with at least one cycle group&lt;/td&gt;
&lt;td&gt;14 of 15 (93%)&lt;/td&gt;
&lt;td&gt;89%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Production files inside a cycle group&lt;/td&gt;
&lt;td&gt;22.2%&lt;/td&gt;
&lt;td&gt;9.2%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cycle groups per repo&lt;/td&gt;
&lt;td&gt;13&lt;/td&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Files in the largest group&lt;/td&gt;
&lt;td&gt;37&lt;/td&gt;
&lt;td&gt;16&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Files where one author made 80%+ of the commits&lt;/td&gt;
&lt;td&gt;79%&lt;/td&gt;
&lt;td&gt;60%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Dead-code findings per 100 files&lt;/td&gt;
&lt;td&gt;5.0&lt;/td&gt;
&lt;td&gt;16.2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Test files per production file&lt;/td&gt;
&lt;td&gt;0.19&lt;/td&gt;
&lt;td&gt;0.52&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The &lt;a href="https://dev.to/repowise/go-repos-barely-have-import-cycles-here-is-what-hugo-gin-and-temporal-do-7em"&gt;Go post in this series&lt;/a&gt; compares cycle rates across languages. Here I want to go into why Rust looks like this, what the cycles actually are, and what the last two rows mean, because both are easy to misread.&lt;/p&gt;

&lt;h2&gt;
  
  
  Can Rust crates have circular dependencies?
&lt;/h2&gt;

&lt;p&gt;Not between crates. Inside one crate, modules can import each other in a cycle.&lt;/p&gt;

&lt;p&gt;The crate is Rust's compilation unit. &lt;code&gt;rustc&lt;/code&gt; reads every module of a crate together and resolves names across the whole crate at once. Items can be declared in any order and in any file, and a &lt;code&gt;use&lt;/code&gt; is a path into that crate-wide namespace. There is no load order like Python's import-time execution, so &lt;code&gt;a.rs&lt;/code&gt; naming something in &lt;code&gt;b.rs&lt;/code&gt; while &lt;code&gt;b.rs&lt;/code&gt; names something in &lt;code&gt;a.rs&lt;/code&gt; costs nothing.&lt;/p&gt;

&lt;p&gt;Here is the smallest version. One crate, two modules that use each other:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="c1"&gt;// src/lib.rs&lt;/span&gt;
&lt;span class="k"&gt;pub&lt;/span&gt; &lt;span class="k"&gt;mod&lt;/span&gt; &lt;span class="nf"&gt;cart&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;pub&lt;/span&gt; &lt;span class="k"&gt;mod&lt;/span&gt; &lt;span class="nf"&gt;pricing&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="c1"&gt;// src/cart.rs&lt;/span&gt;
&lt;span class="k"&gt;use&lt;/span&gt; &lt;span class="k"&gt;crate&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;pricing&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;price_of&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;pub&lt;/span&gt; &lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="nc"&gt;Item&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;pub&lt;/span&gt; &lt;span class="n"&gt;sku&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="k"&gt;pub&lt;/span&gt; &lt;span class="n"&gt;qty&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;u32&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;pub&lt;/span&gt; &lt;span class="k"&gt;fn&lt;/span&gt; &lt;span class="nf"&gt;total&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;items&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nc"&gt;Item&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="kt"&gt;u32&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;items&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;iter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nf"&gt;price_of&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;qty&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="c1"&gt;// src/pricing.rs&lt;/span&gt;
&lt;span class="k"&gt;use&lt;/span&gt; &lt;span class="k"&gt;crate&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;cart&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nc"&gt;Item&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;pub&lt;/span&gt; &lt;span class="k"&gt;fn&lt;/span&gt; &lt;span class="nf"&gt;price_of&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="nc"&gt;Item&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="kt"&gt;u32&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sku&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;starts_with&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"gift-"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="mi"&gt;500&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ cargo build
   Compiling shop v0.1.0 (./shop)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.43s
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Cargo works one level up. It compiles crates in dependency order, so the graph between packages has to be a DAG. Move &lt;code&gt;cart&lt;/code&gt; and &lt;code&gt;pricing&lt;/code&gt; into a workspace as two crates, give each a path dependency on the other, and you get the error at the top of this post. It fails at dependency resolution, before &lt;code&gt;rustc&lt;/code&gt; runs at all.&lt;/p&gt;

&lt;p&gt;The fix is the same one you would use in Go: move what both sides need into a crate that depends on neither. Here &lt;code&gt;Item&lt;/code&gt; goes into its own &lt;code&gt;item&lt;/code&gt; crate:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ cargo build &amp;amp;&amp;amp; cargo tree
   Compiling item v0.1.0 (./split-fixed/item)
   Compiling pricing v0.1.0 (./split-fixed/pricing)
   Compiling cart v0.1.0 (./split-fixed/cart)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.48s
cart v0.1.0 (./split-fixed/cart)
├── item v0.1.0 (./split-fixed/item)
└── pricing v0.1.0 (./split-fixed/pricing)
    └── item v0.1.0 (./split-fixed/item)
...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So Rust has two rules at two levels. Inside a crate, anything goes. Between crates, strict layering. The 22% is the first rule showing up in the data.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the cycles look like in a real repo: bevy
&lt;/h2&gt;

&lt;p&gt;To check the numbers on a real codebase, I cloned &lt;a href="https://github.com/bevyengine/bevy" rel="noopener noreferrer"&gt;bevy&lt;/a&gt; (shallow, commit &lt;code&gt;6a91165&lt;/code&gt;, 10 November 2026), indexed it, and ran a strongly connected components pass over the stored file import graph:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;production .rs files: 1304  import edges: 10573
cycle groups: 75  files in a group: 725 (55.6%)
largest groups: [142, 60, 37, 35, 31, 26, 25, 21, 20, 20]
groups spanning more than one crate: 0

largest group by crate: [('crates/bevy_ecs', 142)]
file names in largest group: [('mod.rs', 20), ('error.rs', 3), ('access.rs', 2), ('map_entities.rs', 2), ('system_param.rs', 2), ('builder.rs', 2)]

most imported inside the largest group:
    84  crates/bevy_ecs/src/world/mod.rs
    68  crates/bevy_ecs/src/component/mod.rs
    66  crates/bevy_ecs/src/entity/mod.rs
    65  crates/bevy_ecs/src/change_detection/mod.rs
    62  crates/bevy_ecs/src/schedule/mod.rs
    58  crates/bevy_ecs/src/system/mod.rs
    36  crates/bevy_ecs/src/world/unsafe_world_cell.rs
    33  crates/bevy_ecs/src/query/mod.rs
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The same 75 groups and the same 142-file largest group showed up at bevy's last index on repowise.dev, so this is a stable property of the codebase.&lt;/p&gt;

&lt;p&gt;The line that matters is &lt;code&gt;groups spanning more than one crate: 0&lt;/code&gt;. Bevy is a workspace with 66 crates under &lt;code&gt;crates/&lt;/code&gt;, and every one of its 75 cycle groups stays inside a single crate, exactly as Cargo requires. The biggest one is &lt;code&gt;bevy_ecs&lt;/code&gt;, the ECS core, where nearly everything takes or returns a &lt;code&gt;World&lt;/code&gt;, an &lt;code&gt;Entity&lt;/code&gt; or a &lt;code&gt;Component&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The files at the center are &lt;code&gt;mod.rs&lt;/code&gt; files. This is the most common shape of a Rust module cycle, and you can see it in two lines of &lt;code&gt;world/mod.rs&lt;/code&gt; and &lt;code&gt;world/deferred_world.rs&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="c1"&gt;// crates/bevy_ecs/src/world/mod.rs&lt;/span&gt;
&lt;span class="k"&gt;mod&lt;/span&gt; &lt;span class="nf"&gt;deferred_world&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;// ...&lt;/span&gt;
&lt;span class="k"&gt;pub&lt;/span&gt; &lt;span class="k"&gt;use&lt;/span&gt; &lt;span class="n"&gt;deferred_world&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nc"&gt;DeferredWorld&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="c1"&gt;// crates/bevy_ecs/src/world/deferred_world.rs&lt;/span&gt;
&lt;span class="k"&gt;use&lt;/span&gt; &lt;span class="k"&gt;super&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;unsafe_world_cell&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nc"&gt;UnsafeWorldCell&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Mut&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;World&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The parent declares the child and re-exports its public type so callers can write &lt;code&gt;bevy_ecs::world::DeferredWorld&lt;/code&gt;. The child reaches back up with &lt;code&gt;use super::&lt;/code&gt; for &lt;code&gt;World&lt;/code&gt;, which is defined in the parent. That is a two-file cycle by construction, and it is the normal way to organize a Rust module. Repeat it for every child of &lt;code&gt;world/&lt;/code&gt;, add the edges between &lt;code&gt;world/&lt;/code&gt;, &lt;code&gt;component/&lt;/code&gt; and &lt;code&gt;entity/&lt;/code&gt; that any ECS needs, and you get one group of 142 files.&lt;/p&gt;

&lt;p&gt;The newer layout without &lt;code&gt;mod.rs&lt;/code&gt; (a &lt;code&gt;layout.rs&lt;/code&gt; file next to a &lt;code&gt;layout/&lt;/code&gt; directory) has the same shape. In ratatui's &lt;code&gt;ratatui-core&lt;/code&gt;, &lt;code&gt;layout.rs&lt;/code&gt; declares &lt;code&gt;mod rect;&lt;/code&gt; and &lt;code&gt;layout/rect.rs&lt;/code&gt; starts with &lt;code&gt;use crate::layout::{Margin, Offset, Position, Size};&lt;/code&gt;. (ratatui is the one Rust repo with no cycle group at its August index. A fresh index of today's code finds 8 groups, the largest 31 files inside &lt;code&gt;ratatui-core&lt;/code&gt;, and none of them crosses a crate either.)&lt;/p&gt;

&lt;p&gt;So when a tool tells you a Rust crate has a 100-file cycle, read it as "this crate is one tightly connected unit". That is a statement about where crate boundaries could go, not about anything being broken.&lt;/p&gt;

&lt;p&gt;One note on the dataset: "primary language" is GitHub's label, and the graph covers every production file in the repo. A few of the Rust repos carry a TypeScript or Python layer too, and those files are counted with the rest.&lt;/p&gt;

&lt;h2&gt;
  
  
  Do Rust repos really have fewer tests?
&lt;/h2&gt;

&lt;p&gt;The cohort median is 0.52 test files per production file. For Rust it is 0.19. That does not mean Rust projects test less. Rust unit tests usually live inside the source file they test, in a &lt;code&gt;#[cfg(test)] mod tests&lt;/code&gt; block, so a file-level count classifies the file as production and never sees them.&lt;/p&gt;

&lt;p&gt;I counted test functions (&lt;code&gt;#[test]&lt;/code&gt;, &lt;code&gt;#[rstest]&lt;/code&gt;, &lt;code&gt;#[tokio::test]&lt;/code&gt;) in two repos. In bevy, 3,275 sit inside production files and 154 in separate test files (95% inline). In ratatui it is 1,317 against 135 (91%). Counting files makes Rust look thin on tests. Count test functions or run &lt;code&gt;cargo llvm-cov&lt;/code&gt; instead.&lt;/p&gt;

&lt;p&gt;The low dead-code number (files flagged as unreachable plus public items nothing imports) has a Rust-specific root too. A file only becomes part of a crate when some parent declares it with &lt;code&gt;mod&lt;/code&gt;, so a file nothing points to is not compiled at all, and it tends to get noticed and deleted. Pooled across the 15 repos, 1,701 of the 2,208 findings are public items nothing inside the repo uses, which in a library is often the public API.&lt;/p&gt;

&lt;h2&gt;
  
  
  Unused Cargo dependencies: cargo machete on bevy
&lt;/h2&gt;

&lt;p&gt;The dependency-level cousin of dead code is a crate listed in &lt;code&gt;Cargo.toml&lt;/code&gt; that the code never uses. &lt;a href="https://github.com/bnjbvr/cargo-machete" rel="noopener noreferrer"&gt;cargo-machete&lt;/a&gt; finds these without building anything. It reads the manifests and searches the source for each dependency's name, so it runs in seconds on a large workspace.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;cargo install cargo-machete
cargo machete
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On bevy (cargo-machete 0.9.2, 103 &lt;code&gt;Cargo.toml&lt;/code&gt; files):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Analyzing dependencies of crates in this directory...
cargo-machete found the following unused dependencies in this directory:
benches -- .\benches\Cargo.toml:
    nonmax
bevy_anti_alias -- .\crates\bevy_anti_alias\Cargo.toml:
    bevy_extract
bevy_asset -- .\crates\bevy_asset\Cargo.toml:
    either
...
bevy_mesh -- .\crates\bevy_mesh\Cargo.toml:
    glam
bevy_platform -- .\crates\bevy_platform\Cargo.toml:
    critical-section
...
bevy_render -- .\crates\bevy_render\Cargo.toml:
    derive_more
    downcast-rs
    profiling
...
If you believe cargo-machete has detected an unused dependency incorrectly,
you can add the dependency to the list of dependencies to ignore in the
`[package.metadata.cargo-machete]` section of the appropriate Cargo.toml.
...
Done!

real    0m4.591s
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;34 dependencies across 25 manifests in 4.6 seconds. Each line is a lead to check. Several of the ones I checked exist only to switch on a feature: &lt;code&gt;bevy_mesh&lt;/code&gt; has &lt;code&gt;morph = ["glam/encase-013"]&lt;/code&gt;, &lt;code&gt;bevy_platform&lt;/code&gt; forwards &lt;code&gt;critical-section&lt;/code&gt; features, and &lt;code&gt;bevy_render&lt;/code&gt; pulls in &lt;code&gt;profiling&lt;/code&gt; behind its &lt;code&gt;trace&lt;/code&gt; feature. None of those names needs to appear in the source, so a grep-based tool cannot see them. Mark them in &lt;code&gt;[package.metadata.cargo-machete] ignored = [...]&lt;/code&gt;, and for the rest, remove the line and build.&lt;/p&gt;

&lt;p&gt;For more precise answers at the cost of a build, &lt;a href="https://github.com/est31/cargo-udeps" rel="noopener noreferrer"&gt;cargo-udeps&lt;/a&gt; asks the compiler which crates each target used (it needs nightly and compiles the workspace), and &lt;code&gt;rustc&lt;/code&gt;'s built-in &lt;code&gt;unused_crate_dependencies&lt;/code&gt; lint turns on with &lt;code&gt;[lints.rust] unused_crate_dependencies = "warn"&lt;/code&gt; in &lt;code&gt;Cargo.toml&lt;/code&gt;. Machete fits in CI because it is fast. The other two are better run once in a while.&lt;/p&gt;

&lt;h2&gt;
  
  
  One main author on 79% of files
&lt;/h2&gt;

&lt;p&gt;The ownership number is the one I find more interesting. In the median Rust repo in the set, one person made at least 80% of the commits to 79% of the production files. Across all 195 repos the median is 60% (&lt;a href="https://dev.to/repowise/bus-factor-1-is-the-default-per-language-ownership-in-195-popular-repos-54kh"&gt;the bus factor post in this series&lt;/a&gt; has the per-language table).&lt;/p&gt;

&lt;p&gt;Part of it is age and team size. Several of the Rust repos in the set are young projects with a handful of contributors. The median Rust repo has 38 contributors in its indexed history, against 59 across all 195. A two-year-old project built by three people will have one main author per file almost everywhere, and that is fine.&lt;/p&gt;

&lt;p&gt;The counterexample is bevy. At its last index on repowise.dev, 168 of its 1,262 production files (13%) had one main author. With 1,670 contributors in its history, knowledge of most files is spread across several people.&lt;/p&gt;

&lt;p&gt;To measure this on your own repo, this script makes one pass over &lt;code&gt;git log&lt;/code&gt; instead of running &lt;code&gt;git shortlog&lt;/code&gt; per file, so it is quick even on a large history. It counts, for every current &lt;code&gt;.rs&lt;/code&gt; source file, how many of its commits came from its most frequent author:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# bf1.sh: share of .rs source files where one author made 80%+ of the commits&lt;/span&gt;
awk &lt;span class="s1"&gt;'NR == FNR { live[$0] = 1; next }
     /^@/      { a = substr($0, 2); next }
     ($0 in live) { n[$0]++; k = $0 SUBSEP a; c[k]++; if (c[k] &amp;gt; top[$0]) top[$0] = c[k] }
     END { for (f in n) { t++; if (top[f] &amp;gt;= 0.8 * n[f]) b++ }
           printf "%d of %d files: one author made 80%%+ of the commits (%.0f%%)\n", b, t, 100 * b / t }'&lt;/span&gt; \
  &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;git ls-files &lt;span class="s1"&gt;'*.rs'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; grep -vE &lt;span class="s1"&gt;'(^|/)(tests|examples|benches)/'&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; \
  &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;git log --no-merges --format=&lt;span class="s1"&gt;'@%aE'&lt;/span&gt; --name-only &lt;span class="s2"&gt;"$@"&lt;/span&gt; -- &lt;span class="s1"&gt;'*.rs'&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run it at the root of a full clone. Extra arguments go to &lt;code&gt;git log&lt;/code&gt;. On ratatui (full clone, &lt;code&gt;2b7b78e&lt;/code&gt;, 2,456 commits):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ bash bf1.sh
26 of 127 files: one author made 80%+ of the commits (20%)
$ bash bf1.sh --since="1 year ago"
43 of 92 files: one author made 80%+ of the commits (47%)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A few notes on reading it. &lt;code&gt;%aE&lt;/code&gt; respects &lt;code&gt;.mailmap&lt;/code&gt;, so add one if people commit from several addresses. The script does not follow renames, so a file that moved into a new crate starts with a fresh history. And the time window changes the answer a lot: over the last year, the share of single-author files more than doubles, because recent work on any given file tends to come from fewer people. For which of those files actually matter (the ones still changing while their main author has gone quiet), the &lt;a href="https://repowise.dev/blog/guides/code-ownership-bus-factor-git?utm_source=devto&amp;amp;utm_medium=community&amp;amp;utm_campaign=devto-13-rust-circular-dependency" rel="noopener noreferrer"&gt;guide to measuring bus factor from git&lt;/a&gt; covers the method and what to do about them.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I would do with this in a Rust codebase
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Leave module cycles alone by default.&lt;/strong&gt; A &lt;code&gt;mod.rs&lt;/code&gt; that re-exports its children while the children &lt;code&gt;use super::&lt;/code&gt; is idiomatic Rust. Breaking it buys nothing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Split a crate when you want a boundary the compiler enforces.&lt;/strong&gt; The real reasons are build time (Cargo compiles independent crates in parallel and only rebuilds what changed), a piece of code other projects want to depend on alone, or a layer you want to stop people from reaching around. A big cycle group is a useful map for that decision. Files that sit outside the group, and that the group only imports, are the easy candidates for a lower crate. Files deep inside it will drag half the crate with them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Use &lt;code&gt;pub(crate)&lt;/code&gt; before you split.&lt;/strong&gt; If the goal is "nothing outside this crate should call this", &lt;code&gt;pub(crate)&lt;/code&gt; gives you that today with no new manifest. Bevy's &lt;code&gt;world/mod.rs&lt;/code&gt; does exactly this with &lt;code&gt;pub(crate) mod command_queue;&lt;/code&gt;. Reach for a new crate when you need the boundary inside the crate too.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Give the workspace a clear bottom layer.&lt;/strong&gt; Workspaces that stay easy to change usually have a small set of leaf crates (types, errors, platform shims) that depend on nothing else in the workspace, with everything else stacked on top. In bevy, &lt;code&gt;bevy_platform&lt;/code&gt; has no bevy dependencies at all and &lt;code&gt;bevy_utils&lt;/code&gt; builds only on it. When you hit the &lt;code&gt;cyclic package dependency&lt;/code&gt; error, the shared piece usually belongs in that layer, same as the &lt;code&gt;item&lt;/code&gt; crate above.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Put the shared types in one place, not in a &lt;code&gt;common&lt;/code&gt; crate that grows forever.&lt;/strong&gt; The leaf crate trick works because the leaf stays small. If it becomes the place where everything goes, every crate rebuilds whenever it changes.&lt;/p&gt;

&lt;p&gt;To see how bevy's crates and modules layer on top of each other, the &lt;a href="https://repowise.dev/repo/bevyengine/bevy/architecture?utm_source=devto&amp;amp;utm_medium=community&amp;amp;utm_campaign=devto-13-rust-circular-dependency" rel="noopener noreferrer"&gt;bevy architecture view&lt;/a&gt; shows the dependency graph and its layers.&lt;/p&gt;

&lt;p&gt;If you have split a large Rust crate into a workspace, which piece did you pull out first, and did the compile time win justify it?&lt;/p&gt;

&lt;h2&gt;
  
  
  How I ran this
&lt;/h2&gt;

&lt;p&gt;The cohort is 195 of the most-starred public repositories indexed on repowise (1,000+ GitHub stars each, 253,688 production source files, November 2026). The Rust rows are the 15 repos whose GitHub primary language is Rust, each measured at its own latest index between July and November 2026. Cycle groups are strongly connected components of the file import graph among production files. Bus factor 1 means one author made at least 80% of a file's commits in the indexed history. Unreachable findings come from repowise's dead-code analysis.&lt;/p&gt;

&lt;p&gt;The bevy check was &lt;code&gt;repowise init --yes --no-prose --no-editor-setup&lt;/code&gt; on a shallow clone at &lt;code&gt;6a91165&lt;/code&gt;, then an SCC pass over the stored graph restricted to production &lt;code&gt;.rs&lt;/code&gt; files. The ratatui runs used a full clone at &lt;code&gt;2b7b78e&lt;/code&gt;. The Cargo demos were built with &lt;code&gt;cargo 1.99.0&lt;/code&gt; and &lt;code&gt;rustc 1.99.0&lt;/code&gt;, and cargo-machete was version 0.9.2.&lt;/p&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;How do you fix a circular dependency between Rust crates?&lt;/strong&gt;&lt;br&gt;
Move whatever both crates need (usually shared types or errors) into a new crate that depends on neither, and have both depend on it. In the example above, &lt;code&gt;Item&lt;/code&gt; moved into an &lt;code&gt;item&lt;/code&gt; crate and the workspace built.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What does cargo machete do?&lt;/strong&gt;&lt;br&gt;
cargo-machete lists dependencies in &lt;code&gt;Cargo.toml&lt;/code&gt; files that the source never seems to use. It searches the source for each dependency's name without building, so it is fast (4.6 seconds on bevy), but it misses dependencies that exist only to turn on a feature.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Are circular imports between modules a problem in Rust?&lt;/strong&gt;&lt;br&gt;
Usually not. &lt;code&gt;rustc&lt;/code&gt; compiles a whole crate at once, so a &lt;code&gt;mod.rs&lt;/code&gt; that re-exports its children while the children &lt;code&gt;use super::&lt;/code&gt; is normal Rust. A large cycle group is a hint about where a crate boundary could go.&lt;/p&gt;

</description>
      <category>rust</category>
      <category>opensource</category>
      <category>programming</category>
      <category>architecture</category>
    </item>
    <item>
      <title>How to read a large codebase you did not write: a first-day routine with real commands</title>
      <dc:creator>Raghav Chamadiya</dc:creator>
      <pubDate>Tue, 24 Nov 2026 13:00:00 +0000</pubDate>
      <link>https://dev.to/repowise/how-to-read-a-large-codebase-you-did-not-write-a-first-day-routine-with-real-commands-487k</link>
      <guid>https://dev.to/repowise/how-to-read-a-large-codebase-you-did-not-write-a-first-day-routine-with-real-commands-487k</guid>
      <description>&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;To read a large codebase on day one, learn what it is made of and how it starts, find the file everything imports, see where work is happening now, then trace one feature end to end.&lt;/li&gt;
&lt;li&gt;In paperless-ngx (about 200k lines of code), only 166 of 416 Python files are application code, and &lt;code&gt;documents/models.py&lt;/code&gt; is imported by 49 of those 166.&lt;/li&gt;
&lt;li&gt;Tracing one paperless-ngx upload from the browser drop zone to a searchable document took 11 steps across 10 files, found with nothing but &lt;code&gt;git grep&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;For scale: the median public repo with 1,000+ GitHub stars has 513 production source files across 7 top-level modules (repowise's index of 195 such repos, November 2026).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A codebase is everything that makes one piece of software: the source, the config, the build files, and the git history that explains how it got that way. Reading one you did not write is a skill, and most of it is knowing what to skip.&lt;/p&gt;

&lt;p&gt;This is the routine I use on the first day in a large repo. To keep it honest I ran every step on a real project I had never read, &lt;a href="https://github.com/paperless-ngx/paperless-ngx" rel="noopener noreferrer"&gt;paperless-ngx&lt;/a&gt;, the self-hosted document archive (about 48k stars). Full clone, HEAD &lt;code&gt;936b1b3&lt;/code&gt; from 9 November 2026, 12,474 commits. Every block below is real output, trimmed only where you see &lt;code&gt;...&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The goal for day one is small. By the end you should be able to say what the system is made of, how it starts, which file everything leans on, where people are working right now, and how one real feature flows through the code.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: what is this thing, and how big is it
&lt;/h2&gt;

&lt;p&gt;Start with the README, but only the first screen. You want one sentence and the stack.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/paperless-ngx/paperless-ngx.git
&lt;span class="nb"&gt;cd&lt;/span&gt; paperless-ngx
head -40 README.md
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;...
# Paperless-ngx

Paperless-ngx is a document management system that transforms your physical documents into a searchable online archive so you can keep, well, _less paper_.
...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then the manifests. They tell you the stack faster than any architecture page:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;grep -nE &lt;span class="s1"&gt;'requires-python|"(django|celery\[redis\]|channels|redis\[hiredis\]|granian\[uvloop\])[~=&amp;gt;&amp;lt;]'&lt;/span&gt; pyproject.toml
grep -n -i ocrmypdf pyproject.toml
grep &lt;span class="s1"&gt;'"@angular/core"'&lt;/span&gt; src-ui/package.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;8:requires-python = "&amp;gt;=3.11"
22:  "celery[redis]~=5.6.2",
23:  "channels~=4.2",
29:  "django~=5.2.18",
69:  "redis[hiredis]~=6.4.0",
95:  "granian[uvloop]&amp;gt;=2.7,&amp;lt;2.9",
59:  "ocrmypdf[heic]&amp;gt;=17.12,&amp;lt;17.13",
    "@angular/core": "~22.2.3",
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So: a Django backend, Celery workers on Redis, an Angular frontend, and OCRmyPDF doing the OCR. That is already a mental model with four boxes.&lt;/p&gt;

&lt;p&gt;Now the shape. This one-liner counts tracked files per top-level folder, and it works in any repo:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git ls-files &lt;span class="o"&gt;|&lt;/span&gt; cut -d/ -f1 &lt;span class="o"&gt;|&lt;/span&gt; sort &lt;span class="o"&gt;|&lt;/span&gt; uniq -c &lt;span class="o"&gt;|&lt;/span&gt; sort -rn &lt;span class="o"&gt;|&lt;/span&gt; head -8
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    727 src-ui
    581 src
    142 docker
     52 docs
     27 .github
      7 scripts
      7 .devcontainer
      1 zensical.toml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two apps, really. &lt;code&gt;src&lt;/code&gt; is the Python backend and &lt;code&gt;src-ui&lt;/code&gt; is the Angular frontend. Go one level down in the backend:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git ls-files src &lt;span class="o"&gt;|&lt;/span&gt; cut -d/ -f2 &lt;span class="o"&gt;|&lt;/span&gt; sort &lt;span class="o"&gt;|&lt;/span&gt; uniq -c &lt;span class="o"&gt;|&lt;/span&gt; sort -rn
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    302 documents
    131 paperless
     53 locale
     39 paperless_ai
     37 paperless_mail
     17 paperless_testing
      1 manage.py
      1 conftest.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;documents&lt;/code&gt; is the core app, &lt;code&gt;paperless&lt;/code&gt; is the Django project (settings, URLs, parsers), and mail and AI are add-ons. &lt;code&gt;locale&lt;/code&gt; is translations, which you can ignore on day one.&lt;/p&gt;

&lt;p&gt;File counts include tests and migrations, so for a line count I used &lt;a href="https://github.com/boyter/scc" rel="noopener noreferrer"&gt;scc&lt;/a&gt; (&lt;code&gt;cloc&lt;/code&gt; and &lt;code&gt;tokei&lt;/code&gt; give the same kind of table):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;scc --no-cocomo src src-ui docker scripts
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;───────────────────────────────────────────────────────────────────────────────
Language                 Files     Lines   Blanks  Comments     Code Complexity
───────────────────────────────────────────────────────────────────────────────
TypeScript                 438     73533     7257       748    65528       4315
Python                     416    147488    11326     14805   121357       6242
HTML                       126     10248      308         6     9934          0
Sass                       106      4058      662        67     3329          0
...
───────────────────────────────────────────────────────────────────────────────
Total                     1133    237616    19760     16040   201816      10569
───────────────────────────────────────────────────────────────────────────────
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;About 200k lines of code. Big, but a good share of the Python is tests and migrations:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git ls-files &lt;span class="s1"&gt;'src/*.py'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; grep -c &lt;span class="s1"&gt;'/tests/'&lt;/span&gt;        &lt;span class="c"&gt;# 192&lt;/span&gt;
git ls-files &lt;span class="s1"&gt;'src/*.py'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; grep -c &lt;span class="s1"&gt;'/migrations/'&lt;/span&gt;   &lt;span class="c"&gt;# 55&lt;/span&gt;
git ls-files &lt;span class="s1"&gt;'src/*.py'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; grep -vE &lt;span class="s1"&gt;'/tests/|/migrations/'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; wc -l   &lt;span class="c"&gt;# 166&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;166 Python files of real application code. That is a much less scary number than 416.&lt;/p&gt;

&lt;h3&gt;
  
  
  How big is a typical large codebase?
&lt;/h3&gt;

&lt;p&gt;For a reference point: we analysed &lt;a href="https://repowise.dev/research/code-health-2026?utm_source=devto&amp;amp;utm_medium=community&amp;amp;utm_campaign=devto-12-read-large-codebase-first-day#hub-files" rel="noopener noreferrer"&gt;195 of the most-starred public repositories indexed on repowise.dev&lt;/a&gt; (1,000+ GitHub stars each, 253,688 production source files, November 2026). The median repo there has 513 production source files across 7 top-level modules, with 3.0 import edges per file.&lt;/p&gt;

&lt;p&gt;On my run, paperless-ngx has 451 production code files (167 Python, 242 TypeScript, 40 shell, 2 JavaScript) and 3.8 import edges per file. Python is 167 here and 166 above because the index skips &lt;code&gt;src/conftest.py&lt;/code&gt; and counts two helper scripts under &lt;code&gt;docker/&lt;/code&gt;. So paperless-ngx is a little smaller than the median popular repo and a little more connected. Both numbers mean it is readable in a week, and that a few files will be imported from almost everywhere. Step 3 finds them.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: how does it start
&lt;/h2&gt;

&lt;p&gt;Every program has a small number of front doors. Find them before you read anything else, because everything else hangs off them.&lt;/p&gt;

&lt;p&gt;For a Django project, &lt;code&gt;manage.py&lt;/code&gt; is one. For anything shipped as a container, the Dockerfile is the best map you will get:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;grep -nE &lt;span class="s1"&gt;'^(ENTRYPOINT|CMD|EXPOSE)'&lt;/span&gt; Dockerfile
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;250:ENTRYPOINT ["/init"]
252:EXPOSE 8000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;/init&lt;/code&gt; is the &lt;a href="https://github.com/just-containers/s6-overlay" rel="noopener noreferrer"&gt;s6-overlay&lt;/a&gt; process supervisor, so the real list of processes lives in its service folder:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ls docker/rootfs/etc/s6-overlay/s6-rc.d &lt;span class="o"&gt;|&lt;/span&gt; grep svc
&lt;span class="k"&gt;for&lt;/span&gt; s &lt;span class="k"&gt;in&lt;/span&gt; docker/rootfs/etc/s6-overlay/s6-rc.d/svc-*/run&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"== $s"&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; grep &lt;span class="nb"&gt;exec&lt;/span&gt; &lt;span class="s2"&gt;"$s"&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; tail -1&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;svc-consumer
svc-flower
svc-scheduler
svc-webserver
svc-worker
== docker/rootfs/etc/s6-overlay/s6-rc.d/svc-consumer/run
        exec s6-setuidgid paperless python3 manage.py document_consumer --skip-checks
...
== docker/rootfs/etc/s6-overlay/s6-rc.d/svc-scheduler/run
    exec s6-setuidgid paperless /usr/local/bin/celery --skip-checks --app paperless beat --loglevel INFO
== docker/rootfs/etc/s6-overlay/s6-rc.d/svc-webserver/run
    exec s6-setuidgid paperless granian --interface asginl --ws --loop uvloop "paperless.asgi:application"
== docker/rootfs/etc/s6-overlay/s6-rc.d/svc-worker/run
    exec s6-setuidgid paperless /usr/local/bin/celery --skip-checks --app paperless worker --loglevel INFO --without-mingle --without-gossip
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So paperless-ngx is four long-running processes (Flower is an optional Celery dashboard):&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;a web server running &lt;code&gt;paperless.asgi&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;a Celery worker that does the heavy jobs&lt;/li&gt;
&lt;li&gt;Celery beat, which schedules recurring jobs&lt;/li&gt;
&lt;li&gt;a &lt;code&gt;document_consumer&lt;/code&gt; management command that watches a folder for new files&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The frontend has its own front door in &lt;code&gt;package.json&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python -c &lt;span class="s2"&gt;"import json; print(json.load(open('src-ui/package.json'))['scripts'])"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{'preinstall': 'npx only-allow pnpm', 'ng': 'ng', 'start': 'ng serve', 'build': 'ng build', 'e2e': 'playwright test', ...}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Standard Angular CLI. &lt;code&gt;ng serve&lt;/code&gt; for development, &lt;code&gt;ng build&lt;/code&gt; for the bundle Django serves.&lt;/p&gt;

&lt;p&gt;If a repo has no Dockerfile, look for &lt;code&gt;main&lt;/code&gt; functions, &lt;code&gt;[project.scripts]&lt;/code&gt; in &lt;code&gt;pyproject.toml&lt;/code&gt;, &lt;code&gt;bin&lt;/code&gt; in &lt;code&gt;package.json&lt;/code&gt;, &lt;code&gt;cmd/&lt;/code&gt; folders in Go, or the CI workflow that starts the app for end-to-end tests.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: find the file everything leans on
&lt;/h2&gt;

&lt;p&gt;In most codebases one or two files are imported by a large share of everything else. That file defines the vocabulary of the project. Read it early and the rest of the code stops looking like a foreign language.&lt;/p&gt;

&lt;p&gt;You can find it with grep. This counts, for each internal Python module, how many production files import it (tests and migrations excluded, each file counted once):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git ls-files &lt;span class="s1"&gt;'src/*.py'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; grep -vE &lt;span class="s1"&gt;'/tests/|/migrations/'&lt;/span&gt; \
  &lt;span class="o"&gt;|&lt;/span&gt; xargs grep -oE &lt;span class="s1"&gt;'^\s*(from|import) (documents|paperless[a-z_]*)[a-z_.]*'&lt;/span&gt; \
  &lt;span class="o"&gt;|&lt;/span&gt; sed -E &lt;span class="s1"&gt;'s/:\s*(from|import) / /'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; sort -u \
  &lt;span class="o"&gt;|&lt;/span&gt; awk &lt;span class="s1"&gt;'{print $2}'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; sort &lt;span class="o"&gt;|&lt;/span&gt; uniq -c &lt;span class="o"&gt;|&lt;/span&gt; sort -rn &lt;span class="o"&gt;|&lt;/span&gt; head -6
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;     49 documents.models
     17 paperless.config
     16 documents.permissions
     15 documents.utils
     14 documents.data_models
     12 documents.tasks
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;documents/models.py&lt;/code&gt; is imported by 49 of the 166 application files, nearly three times the next one. It holds &lt;code&gt;Document&lt;/code&gt;, &lt;code&gt;Tag&lt;/code&gt;, &lt;code&gt;Correspondent&lt;/code&gt;, &lt;code&gt;DocumentType&lt;/code&gt;, &lt;code&gt;StoragePath&lt;/code&gt;, custom fields and saved views. Read the class names and fields, skip the method bodies. That is the data model of the whole product.&lt;/p&gt;

&lt;p&gt;Same idea for the frontend, counting project imports (relative paths and the &lt;code&gt;src/&lt;/code&gt; alias), spec files excluded:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git ls-files &lt;span class="s1"&gt;'src-ui/src/*.ts'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; grep -v &lt;span class="s1"&gt;'\.spec\.ts$'&lt;/span&gt; \
  &lt;span class="o"&gt;|&lt;/span&gt; xargs grep -oE &lt;span class="s2"&gt;"from '(\.|src/)[^']*'"&lt;/span&gt; \
  &lt;span class="o"&gt;|&lt;/span&gt; sed -E &lt;span class="s2"&gt;"s#:from '.*/([^/']+)'# \1#"&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; sort -u \
  &lt;span class="o"&gt;|&lt;/span&gt; awk &lt;span class="s1"&gt;'{print $2}'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; sort &lt;span class="o"&gt;|&lt;/span&gt; uniq -c &lt;span class="o"&gt;|&lt;/span&gt; sort -rn &lt;span class="o"&gt;|&lt;/span&gt; head -6
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;     76 bootstrap-icon.component
     51 settings.service
     46 permissions.service
     40 toast.service
     30 ui-settings
     26 document.service
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here is a lesson I did not expect. The top file is an icon component, and &lt;code&gt;git log&lt;/code&gt; says it was added this month:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git log --diff-filter=A --format=&lt;span class="s1"&gt;'%h %ad %s'&lt;/span&gt; --date=short -- \
  src-ui/src/app/components/common/bootstrap-icon/bootstrap-icon.component.ts
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;7cdf8ec3c 2026-11-02 Chore: ditch the abandoned ngx-bootstrap-icons, roll our own (#14665)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The team replaced a third-party icon package with their own component, so every component that shows an icon now imports it. Busy, but not the thing to read first. The most imported file is not always the most important one. Look at the top few and pick the one that defines concepts, here &lt;code&gt;settings.service.ts&lt;/code&gt; and &lt;code&gt;permissions.service.ts&lt;/code&gt; on the frontend and &lt;code&gt;models.py&lt;/code&gt; on the backend.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4: where is work happening right now
&lt;/h2&gt;

&lt;p&gt;The code people are changing this month is the code your first ticket will touch, and the code a reviewer will know best. I covered file-level &lt;code&gt;git log&lt;/code&gt; commands in &lt;a href="https://dev.to/repowise/five-git-log-commands-that-show-where-a-codebase-actually-changes-jld"&gt;an earlier post&lt;/a&gt;. On day one I prefer one level up: how many commits touched each area.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# count commits per area (src/&amp;lt;app&amp;gt;, or src-ui as one area), each commit once&lt;/span&gt;
areas&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  awk &lt;span class="s1"&gt;'/^@/{delete seen; next}
       NF{split($0,p,"/"); a=(p[1]=="src-ui")?"src-ui":p[1]"/"p[2];
          if(!(a in seen)){seen[a]=1; c[a]++}}
       END{for(k in c) print c[k], k}'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; sort -rn &lt;span class="o"&gt;|&lt;/span&gt; head -6
&lt;span class="o"&gt;}&lt;/span&gt;
git log --since=&lt;span class="s2"&gt;"90 days ago"&lt;/span&gt; --no-merges --format=&lt;span class="s1"&gt;'@%h'&lt;/span&gt; --name-only -- src src-ui &lt;span class="o"&gt;|&lt;/span&gt; areas
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;273 src-ui
149 src/documents
86 src/locale
68 src/paperless
29 src/paperless_ai
21 src/paperless_mail
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;--format='@%h'&lt;/code&gt; line marks where each commit starts, so the &lt;code&gt;awk&lt;/code&gt; can count a commit once per area even when it touched twenty files there. The frontend and &lt;code&gt;documents&lt;/code&gt; carry most of the work. &lt;code&gt;src/locale&lt;/code&gt; looks busy, but those are automated translation commits (144 of the 628 commits in the window have the subject "Auto translate strings"). Add &lt;code&gt;--invert-grep --grep='^Auto translate'&lt;/code&gt; to drop them.&lt;/p&gt;

&lt;p&gt;Same function, limited to bug fixes over six months. paperless-ngx prefixes fixes with &lt;code&gt;Fix:&lt;/code&gt;, so &lt;code&gt;-i --grep='^fix'&lt;/code&gt; finds them (318 commits in the window):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git log --since=&lt;span class="s2"&gt;"180 days ago"&lt;/span&gt; --no-merges -i --grep=&lt;span class="s1"&gt;'^fix'&lt;/span&gt; --format=&lt;span class="s1"&gt;'@%h'&lt;/span&gt; --name-only -- src src-ui &lt;span class="o"&gt;|&lt;/span&gt; areas
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;143 src/documents
118 src-ui
34 src/paperless_ai
34 src/paperless
17 src/paperless_mail
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;More fix commits land in &lt;code&gt;src/documents&lt;/code&gt; than in the frontend, even though the frontend gets more commits overall. That tells me where to read slowly and where to ask before changing anything.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 5: who knows which area
&lt;/h2&gt;

&lt;p&gt;You want to know who to ask, not to rank anyone, so I print counts only. This takes the last 12 months per area, drops bot accounts, and reports how concentrated the commits are:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="k"&gt;for&lt;/span&gt; a &lt;span class="k"&gt;in&lt;/span&gt; src/documents src/paperless src/paperless_mail src/paperless_ai src-ui&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  git shortlog -sn --no-merges --since=&lt;span class="s2"&gt;"1 year ago"&lt;/span&gt; HEAD -- &lt;span class="nv"&gt;$a&lt;/span&gt; \
  &lt;span class="o"&gt;|&lt;/span&gt; grep -vE &lt;span class="s1"&gt;'\[bot\]|GitHub Actions'&lt;/span&gt; \
  &lt;span class="o"&gt;|&lt;/span&gt; awk -v &lt;span class="nv"&gt;a&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$a&lt;/span&gt; &lt;span class="s1"&gt;'{t+=$1; c[NR]=$1} END{printf "%-20s %3d people, %4d commits, top 1: %2.0f%%, top 2: %2.0f%%\n",
      a, NR, t, 100*c[1]/t, 100*(c[1]+c[2])/t}'&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;src/documents         22 people,  451 commits, top 1: 48%, top 2: 94%
src/paperless         19 people,  188 commits, top 1: 51%, top 2: 90%
src/paperless_mail     5 people,   67 commits, top 1: 55%, top 2: 96%
src/paperless_ai       5 people,   82 commits, top 1: 49%, top 2: 96%
src-ui                17 people,  368 commits, top 1: 91%, top 2: 94%
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two people make about nine in ten commits in every area, and the frontend has one main author. That is common for a focused open-source project, and it is useful to know on day one: backend questions go to one of two people, and one person writes most of the frontend. Drop the &lt;code&gt;awk&lt;/code&gt; to see the names when you need them. (Pass &lt;code&gt;HEAD&lt;/code&gt; explicitly, or &lt;code&gt;git shortlog&lt;/code&gt; waits on standard input inside a pipe.)&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 6: trace one real feature end to end
&lt;/h2&gt;

&lt;p&gt;This is the step that turns a pile of files into a system. Pick one thing a user does and follow it from the button to the database. For paperless-ngx the obvious one is: I drop a PDF in the browser, and later it shows up searchable with OCR text.&lt;/p&gt;

&lt;p&gt;I did it with nothing but &lt;code&gt;git grep&lt;/code&gt;, starting from the API name and following each call:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git grep -n &lt;span class="s2"&gt;"post_document"&lt;/span&gt; -- src-ui/src src &lt;span class="s1"&gt;':!*spec.ts'&lt;/span&gt; &lt;span class="s1"&gt;':!*/tests/*'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;src-ui/src/app/services/rest/document.service.ts:318:      this.getResourceUrl(null, 'post_document'),
src/documents/consumer.py:879:                f"Creation date from post_documents parameter: {create_date}",
src/paperless/urls.py:150:                                "^post_document/",
src/paperless/urls.py:152:                                name="post_document",
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;urls.py&lt;/code&gt; maps it to &lt;code&gt;PostDocumentView&lt;/code&gt; in &lt;code&gt;src/documents/views.py&lt;/code&gt;. That view writes the upload to a scratch folder and does not process it at all. It queues a job and returns the task id:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;        &lt;span class="n"&gt;async_task&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;consume_file&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;apply_async&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
            &lt;span class="n"&gt;kwargs&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"input_doc"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;input_doc&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"overrides"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;input_doc_overrides&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;
        &lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;Response&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;async_task&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So the work happens in the Celery worker from step 2. Who else queues that same job?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git grep -n &lt;span class="s2"&gt;"consume_file.apply_async\|consume_file.s("&lt;/span&gt; -- src &lt;span class="s1"&gt;':!*/tests/*'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;src/documents/barcodes.py:215:                task = tasks.consume_file.apply_async(
src/documents/bulk_edit.py:523:            consume_file.apply_async(
...
src/documents/management/commands/document_consumer.py:360:        consume_file.apply_async(
src/documents/views.py:2214:            async_task = consume_file.apply_async(
src/documents/views.py:3539:        async_task = consume_file.apply_async(
src/paperless_mail/mail.py:1097:                consume_task = consume_file.s(
src/paperless_mail/mail.py:1188:        consume_task = consume_file.s(
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The web upload, the watched folder (the &lt;code&gt;document_consumer&lt;/code&gt; process from step 2), the mail fetcher and bulk edits all funnel into one Celery task. Understand &lt;code&gt;consume_file&lt;/code&gt; and you understand every way a document gets in.&lt;/p&gt;

&lt;p&gt;Following it the rest of the way, here is the whole path with file and line:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;#&lt;/th&gt;
&lt;th&gt;What happens&lt;/th&gt;
&lt;th&gt;Where&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;Drop zone or upload widget hands files to a service&lt;/td&gt;
&lt;td&gt;&lt;code&gt;src-ui/src/app/components/file-drop/file-drop.component.ts:137&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;Upload service wraps each file in form data and calls the REST service&lt;/td&gt;
&lt;td&gt;&lt;code&gt;src-ui/src/app/services/upload-documents.service.ts:44&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;HTTP POST to &lt;code&gt;/api/documents/post_document/&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;&lt;code&gt;src-ui/src/app/services/rest/document.service.ts:316&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;URL route&lt;/td&gt;
&lt;td&gt;&lt;code&gt;src/paperless/urls.py:150&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;PostDocumentView.post&lt;/code&gt; saves to scratch, queues the task&lt;/td&gt;
&lt;td&gt;&lt;code&gt;src/documents/views.py:3482&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;6&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;consume_file&lt;/code&gt; runs a chain of plugins: preflight, ASN check, collate, barcodes, workflow triggers, then the consumer&lt;/td&gt;
&lt;td&gt;&lt;code&gt;src/documents/tasks.py:183&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;7&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;ConsumerPlugin.run&lt;/code&gt; picks a parser by MIME type&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;src/documents/consumer.py:405&lt;/code&gt;, &lt;code&gt;:468&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;8&lt;/td&gt;
&lt;td&gt;Parser registry scores parsers, highest wins&lt;/td&gt;
&lt;td&gt;&lt;code&gt;src/paperless/parsers/registry.py:332&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;9&lt;/td&gt;
&lt;td&gt;Tesseract parser calls OCRmyPDF&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;src/paperless/parsers/tesseract.py:490&lt;/code&gt;, &lt;code&gt;:599&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;10&lt;/td&gt;
&lt;td&gt;Inside one DB transaction: store the &lt;code&gt;Document&lt;/code&gt;, copy files into place&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;src/documents/consumer.py:608&lt;/code&gt;, &lt;code&gt;:672&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;11&lt;/td&gt;
&lt;td&gt;Signal fires, handlers auto-tag, set correspondent and type, run workflows, add to the search index&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;src/documents/consumer.py:686&lt;/code&gt;, &lt;code&gt;src/documents/apps.py:24&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Eleven steps across ten files, from the drop zone to a searchable document. The last hop is the one people miss, because nothing calls those handlers by name. They are wired up in &lt;code&gt;apps.py&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git grep -n &lt;span class="s2"&gt;"document_consumption_finished.connect"&lt;/span&gt; -- src
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;src/documents/apps.py:24:        document_consumption_finished.connect(add_inbox_tags)
src/documents/apps.py:25:        document_consumption_finished.connect(set_correspondent)
src/documents/apps.py:26:        document_consumption_finished.connect(set_document_type)
src/documents/apps.py:27:        document_consumption_finished.connect(set_tags)
src/documents/apps.py:28:        document_consumption_finished.connect(set_storage_path)
src/documents/apps.py:29:        document_consumption_finished.connect(run_workflows_added)
src/documents/apps.py:30:        document_consumption_finished.connect(add_to_index)
src/documents/apps.py:31:        document_consumption_finished.connect(add_or_update_document_in_llm_index)
...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Django signals, Celery tasks, plugin lists, framework routing: these are the places where "find usages" in an editor comes back empty and the code still runs. When the trail goes cold, search for the string name, the task name or the signal name.&lt;/p&gt;

&lt;p&gt;If you can run the app, set a breakpoint in &lt;code&gt;consume_file&lt;/code&gt; and upload something. The table above is the map. The debugger tells you whether the map is right.&lt;/p&gt;

&lt;h2&gt;
  
  
  A shortcut for step 3
&lt;/h2&gt;

&lt;p&gt;I also indexed the clone with repowise, the tool I work on (&lt;code&gt;repowise init --yes --no-prose --no-editor-setup&lt;/code&gt;, runs locally, no API key, 3 min 51 s here). Its &lt;code&gt;context&lt;/code&gt; command answers the hub question with test importers split out and a layer label:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;repowise context src-ui/src/app/components/common/bootstrap-icon/bootstrap-icon.component.ts
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;| Summary | `bootstrap-icon.component.ts` defines `BootstrapIconComponent`. It is imported by 77 files (1 of them tests).
| Layer   | Utility
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The 76 non-test importers match the grep count, and "Utility" is the hint I needed &lt;code&gt;git log&lt;/code&gt; for. For open-source projects that are already indexed, &lt;a href="https://repowise.dev/explore?utm_source=devto&amp;amp;utm_medium=community&amp;amp;utm_campaign=devto-12-read-large-codebase-first-day" rel="noopener noreferrer"&gt;repowise.dev/explore&lt;/a&gt; shows the same graph and history without cloning anything.&lt;/p&gt;

&lt;h2&gt;
  
  
  What should you write down after day one in a new codebase?
&lt;/h2&gt;

&lt;p&gt;Keep it to one page, in your own words. Mine for paperless-ngx:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What it is: a Django + Celery + Angular app that turns uploaded or scanned files into an OCRed, tagged, searchable archive.&lt;/li&gt;
&lt;li&gt;Front doors: &lt;code&gt;paperless.asgi&lt;/code&gt; (web), Celery worker, Celery beat, &lt;code&gt;manage.py document_consumer&lt;/code&gt; (folder watcher). Frontend: &lt;code&gt;ng serve&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;The vocabulary file is &lt;code&gt;src/documents/models.py&lt;/code&gt;. On the frontend, &lt;code&gt;settings.service.ts&lt;/code&gt; and &lt;code&gt;permissions.service.ts&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Work is happening in &lt;code&gt;src-ui&lt;/code&gt; and &lt;code&gt;src/documents&lt;/code&gt;, and most fix commits land in &lt;code&gt;src/documents&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Who to ask: two people per backend area, one main author for the frontend.&lt;/li&gt;
&lt;li&gt;One traced path, the 11-step table above.&lt;/li&gt;
&lt;li&gt;Skipped on purpose: &lt;code&gt;locale/&lt;/code&gt;, migrations, tests, the &lt;code&gt;docker/compose&lt;/code&gt; variants, the AI and mail apps.&lt;/li&gt;
&lt;li&gt;Open questions. How the parser registry handles a parser from a third-party package. What the ASN check does. Why the plugin chain runs &lt;code&gt;AsnCheckPlugin&lt;/code&gt; twice (the comment says "Re-run ASN check after barcode reading", which I want to understand).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The open questions are the most useful part. They are your reading list for day two. For the rest of the week (getting it running, sketching modules with owners, shipping a first small change), I follow &lt;a href="https://repowise.dev/blog/guides/how-to-learn-a-new-codebase-first-week?utm_source=devto&amp;amp;utm_medium=community&amp;amp;utm_campaign=devto-12-read-large-codebase-first-day" rel="noopener noreferrer"&gt;this five-day plan for learning a new codebase&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Which feature would you trace first in a repo like this one, the happy path or the one that breaks most often?&lt;/p&gt;

&lt;h2&gt;
  
  
  How I ran this
&lt;/h2&gt;

&lt;p&gt;Full clone of &lt;code&gt;paperless-ngx/paperless-ngx&lt;/code&gt; at &lt;code&gt;936b1b3&lt;/code&gt; (9 November 2026, 12,474 commits), commands run on 10 November 2026 in Git for Windows bash. scc 3.5.0, repowise 0.60.1 (&lt;code&gt;init --yes --no-prose --no-editor-setup&lt;/code&gt;, 3 min 51 s). The production file count (451) and edges per file (3.8) come from that local index, using repowise's stored code-origin labels (tests, tooling and generated code excluded). The 513 / 7 / 3.0 medians come from a set of 195 of the most-starred public repositories indexed on repowise.dev (1,000+ GitHub stars each, 253,688 production source files, November 2026), each measured at its own latest index. Author names were looked up to remove bot accounts and are not printed anywhere above.&lt;/p&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;What is a codebase?&lt;/strong&gt;&lt;br&gt;
A codebase is all the source code, config, build files and version history that make up one piece of software. In paperless-ngx that means a Django backend in &lt;code&gt;src&lt;/code&gt;, an Angular frontend in &lt;code&gt;src-ui&lt;/code&gt;, Docker setup and docs, plus 12,474 commits of history.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How do you read a large codebase as a beginner?&lt;/strong&gt;&lt;br&gt;
Do not read it top to bottom. Find the entry points, read the most imported file for its names and fields only, and trace one user action from the UI to the database with &lt;code&gt;git grep&lt;/code&gt;. Write down what you skipped and what you still do not understand.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How do you read code you did not write?&lt;/strong&gt;&lt;br&gt;
Start from what the code does for a user, not from the folder tree. Follow one real feature through the files it touches, and when "find usages" comes back empty, search for the string name of the task, signal or route instead.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>programming</category>
      <category>career</category>
      <category>productivity</category>
    </item>
    <item>
      <title>The 6,967-line function: the longest functions in popular open-source repos</title>
      <dc:creator>Raghav Chamadiya</dc:creator>
      <pubDate>Mon, 23 Nov 2026 13:00:00 +0000</pubDate>
      <link>https://dev.to/repowise/the-6967-line-function-the-longest-functions-in-popular-open-source-repos-3l8g</link>
      <guid>https://dev.to/repowise/the-6967-line-function-the-longest-functions-in-popular-open-source-repos-3l8g</guid>
      <description>&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Among the 53 repos with 10,000+ GitHub stars that have a function-length record in repowise's index, the longest function is &lt;code&gt;RunPanoramaStitchSelfTest&lt;/code&gt; in Microsoft PowerToys: 6,967 lines of C++, written as one self-test suite.&lt;/li&gt;
&lt;li&gt;The ten longest functions in those repos run from 2,223 to 6,967 lines. Half of them are registries that define every route, tool or command in one function; long functions in popular repos are mostly registries, generated code or tests, not the textbook long method.&lt;/li&gt;
&lt;li&gt;Two of the long agent loops, Hermes Agent's &lt;code&gt;run_conversation&lt;/code&gt; (6,591 lines) and openclaw's &lt;code&gt;runEmbeddedAttempt&lt;/code&gt; (4,972 lines), have since been split down to 48 and 35 lines.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;This post first appeared on the repowise blog. Function length limits come up in a lot of code reviews, so we looked at the real extremes: the longest functions in popular open-source repos, each opened and read at the commit we indexed. Most of them turned out to be something other than the long method that style guides warn about.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The longest function in any open-source repo with 10,000+ GitHub stars that we index is &lt;code&gt;RunPanoramaStitchSelfTest&lt;/code&gt; in Microsoft PowerToys: &lt;a href="https://github.com/microsoft/PowerToys/blob/5c351aee5fd67e51d8e2b26c0c18b102a12b8173/src/modules/ZoomIt/ZoomIt/PanoramaCapture.cpp#L10956-L17922" rel="noopener noreferrer"&gt;6,967 lines&lt;/a&gt; in an 18,048-line C++ file, and it is a test suite written as one function. It is the longest of 53 repos at that star count with a function-length record in our index.&lt;/p&gt;

&lt;p&gt;We record the longest function in every repo we index. For this study we took the popular ones, opened each function in the source at the exact commit we indexed, measured it again by hand, and read it to find out why it got that long. Almost none of them are the textbook "long method".&lt;/p&gt;

&lt;h2&gt;
  
  
  What are the longest functions in popular open-source repos?
&lt;/h2&gt;

&lt;p&gt;The ten longest functions in repos with 10,000+ stars run from 2,223 to 6,967 lines. The table lists them longest first, then three more from further down the list that explain something. Lengths are at the commit we indexed (linked). The last column is the function on the default branch on 6 October 2026.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Repo&lt;/th&gt;
&lt;th&gt;Function&lt;/th&gt;
&lt;th&gt;Lines&lt;/th&gt;
&lt;th&gt;What it is&lt;/th&gt;
&lt;th&gt;On 6 Oct&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="https://github.com/microsoft/PowerToys/blob/5c351aee5fd67e51d8e2b26c0c18b102a12b8173/src/modules/ZoomIt/ZoomIt/PanoramaCapture.cpp#L10956-L17922" rel="noopener noreferrer"&gt;microsoft/PowerToys&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;RunPanoramaStitchSelfTest&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;6,967&lt;/td&gt;
&lt;td&gt;a self-test suite&lt;/td&gt;
&lt;td&gt;6,967&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="https://github.com/NousResearch/hermes-agent/blob/13ce0c5c675e843af70d19c9e5144249cd51c8d1/agent/conversation_loop.py#L1704-L8294" rel="noopener noreferrer"&gt;NousResearch/hermes-agent&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;run_conversation&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;6,591&lt;/td&gt;
&lt;td&gt;the agent loop&lt;/td&gt;
&lt;td&gt;48, split up&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="https://github.com/vectorize-io/hindsight/blob/ccfe85b4851957ac2adf88b4a9ddf9668b2882f1/hindsight-api-slim/hindsight_api/api/http.py#L5228-L10436" rel="noopener noreferrer"&gt;vectorize-io/hindsight&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;_register_routes&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;5,209&lt;/td&gt;
&lt;td&gt;99 HTTP routes&lt;/td&gt;
&lt;td&gt;5,260&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="https://github.com/openclaw/openclaw/blob/ec737ee74d9be52101992f0cd5d17f5d3953344b/src/agents/embedded-agent-runner/run/attempt.ts#L837-L5808" rel="noopener noreferrer"&gt;openclaw/openclaw&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;runEmbeddedAttempt&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;4,972&lt;/td&gt;
&lt;td&gt;one agent run&lt;/td&gt;
&lt;td&gt;35, split up&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="https://github.com/pewdiepie-archdaemon/odysseus/blob/3b6c169162330cd35c4ce6d14949ef15fd3208a2/routes/email_routes.py#L1513-L6152" rel="noopener noreferrer"&gt;pewdiepie-archdaemon/odysseus&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;setup_email_routes&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;4,640&lt;/td&gt;
&lt;td&gt;57 email routes&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="https://github.com/andrewyng/openworker/blob/5870585321e2cae0b2afbcd8903e14b63c959ac7/coworker/connectors/integration_tools.py#L546-L5050" rel="noopener noreferrer"&gt;andrewyng/openworker&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;make_integration_tools&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;4,505&lt;/td&gt;
&lt;td&gt;133 tool functions&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="https://github.com/tt-a1i/archify/blob/5de7275fe87a66a19d52a4d9b0b3a4f2a5a90115/archify/renderers/workflow/workflow-compiler.mjs#L755-L4319" rel="noopener noreferrer"&gt;tt-a1i/archify&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;compileWorkflowInternal&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;3,565&lt;/td&gt;
&lt;td&gt;a compiler pass&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="https://github.com/debpalash/voicestudio/blob/eef0e2304be21c9bfd08cfca0254918522105b06/electron/src/renderer/src/features/dub/dub-page.tsx#L215-L2989" rel="noopener noreferrer"&gt;debpalash/voicestudio&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;DubPage&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;2,775&lt;/td&gt;
&lt;td&gt;a single TSX page component&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="https://github.com/colbymchenry/codegraph/blob/49c11fc2e0c02170742be8411e66a31af611f4b7/src/bin/codegraph.ts#L136-L2483" rel="noopener noreferrer"&gt;colbymchenry/codegraph&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;main&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;2,348&lt;/td&gt;
&lt;td&gt;22 CLI commands&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="https://github.com/emdash-cms/emdash/blob/e8e8a2d94c072b966318c732883cb35da739579c/packages/core/src/mcp/server.ts#L483-L2705" rel="noopener noreferrer"&gt;emdash-cms/emdash&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;createMcpServer&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;2,223&lt;/td&gt;
&lt;td&gt;55 MCP tools&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;Further down&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="https://github.com/apache/airflow/blob/9c8d7512a2050990c295b53965ac76d90afa21b4/providers/google/src/airflow/providers/google/get_provider_info.py#L24-L1726" rel="noopener noreferrer"&gt;apache/airflow&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;get_provider_info&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;1,703&lt;/td&gt;
&lt;td&gt;generated&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="https://github.com/go-gitea/gitea/blob/8a3daef52574f67a8c027379be3b675c823e68d7/routers/web/web.go#L329-L1792" rel="noopener noreferrer"&gt;go-gitea/gitea&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;registerWebRoutes&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;1,464&lt;/td&gt;
&lt;td&gt;the web route table&lt;/td&gt;
&lt;td&gt;1,470&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="https://github.com/fastapi/fastapi/blob/52159d7e7018df55b57a0b8fdd6c1193e48b2b57/fastapi/applications.py#L64-L1051" rel="noopener noreferrer"&gt;fastapi/fastapi&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;FastAPI.__init__&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;988&lt;/td&gt;
&lt;td&gt;39 documented parameters&lt;/td&gt;
&lt;td&gt;988&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;A blank "On 6 Oct" cell means we did not re-measure it on the current branch.&lt;/p&gt;

&lt;p&gt;Reading down the "What it is" column, the functions sort into four kinds: registries, generated code, a test that grew, and core loops. Only the core loop is the kind of long function people usually warn about.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why do functions get this long?
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. The registry
&lt;/h3&gt;

&lt;p&gt;Half the list is one shape: a single function that defines everything a server or CLI exposes. Hindsight's &lt;code&gt;_register_routes&lt;/code&gt; declares 99 HTTP routes inside one function. Odysseus' &lt;code&gt;setup_email_routes&lt;/code&gt; declares 57. emdash's &lt;code&gt;createMcpServer&lt;/code&gt; registers 55 MCP tools. codegraph's &lt;code&gt;main&lt;/code&gt; sets up 22 CLI commands. openworker's &lt;code&gt;make_integration_tools&lt;/code&gt; defines 133 inner functions, one per tool. Gitea's &lt;code&gt;registerWebRoutes&lt;/code&gt; is close to 800 route calls in a row.&lt;/p&gt;

&lt;p&gt;Each handler needs the same shared objects (the app, the database client, the config). The easiest way to give them all access is to define every handler inside one function that receives those objects, so each handler is a closure over them. The language calls that one function, so every length metric counts it as one, even though it reads like a module with a long table of contents.&lt;/p&gt;

&lt;p&gt;A registry is less of a problem than its length suggests, because every entry looks the same and the function scans easily. It starts to hurt at merge time: when several people add routes in the same week, they all edit the same 5,000-line function and the conflicts land in one place. Splitting routes by area (one register function per resource) fixes that without changing behavior.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Generated code
&lt;/h3&gt;

&lt;p&gt;Generated functions are long by construction and should be measured, then excluded. Airflow's &lt;code&gt;get_provider_info&lt;/code&gt; is 1,703 lines, and its file opens with "NOTE! THIS FILE IS AUTOMATICALLY GENERATED AND WILL BE OVERWRITTEN!" It returns one large dictionary describing the Google provider, and nobody edits it by hand.&lt;/p&gt;

&lt;p&gt;Suricata, the network security monitor, has a 3,500-line C function in a file marked "DO NOT EDIT. THIS FILE IS AUTO-GENERATED." It has 6,655 stars, so it is not in the table, but it makes the same point. If a tool flags generated code, the fix belongs in the tool's configuration.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. The test that grew
&lt;/h3&gt;

&lt;p&gt;The longest function on the list is a test, and it grew the way tests do: one scenario per bug. PowerToys' &lt;code&gt;RunPanoramaStitchSelfTest&lt;/code&gt; belongs to ZoomIt's panorama capture, which stitches screenshots into one long image as you scroll. The function runs scenario after scenario: small scroll steps, near-duplicate frames, and dark code editors whose repeating line pattern can fool the matcher into locking onto 2x or 4x the real scroll distance. Several scenarios are labelled as regression tests for specific bugs, with the debug log name that reproduced them.&lt;/p&gt;

&lt;p&gt;That is a reasonable way for a test to grow. Each scenario is self-contained, and one function means shared setup, a fixed order and one exit code. It still runs to 6,967 lines, and most test frameworks would let you register each scenario as its own test and get per-scenario failures for free. It was the same function on the default branch on 6 October 2026.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. The core loop
&lt;/h3&gt;

&lt;p&gt;This is the long function people mean when they warn about the pattern, and it is where the most interesting things happened. Hermes Agent's &lt;code&gt;run_conversation&lt;/code&gt; was 6,591 lines at our index of 19 August: the whole agent loop for one user turn, with retries, compression, streaming, tool calls and cancellation, in one function with 521 &lt;code&gt;if&lt;/code&gt;/&lt;code&gt;elif&lt;/code&gt; lines. About 28% of its lines were comments, many of them long explanations of a past bug and why the code handles it the way it does. openclaw's &lt;code&gt;runEmbeddedAttempt&lt;/code&gt; was 4,972 lines at our index of 26 June, with 90 &lt;code&gt;await&lt;/code&gt;s in one body.&lt;/p&gt;

&lt;p&gt;Both have since been split. On the default branches as of 6 October 2026, &lt;code&gt;run_conversation&lt;/code&gt; is 48 lines and &lt;code&gt;runEmbeddedAttempt&lt;/code&gt; is 35, with the work moved into smaller functions around them. Both repos are among the fastest-moving on GitHub, with hundreds of commits a day, and our guess is that the pace is why: a single function that every change has to touch becomes a bottleneck for the whole team.&lt;/p&gt;

&lt;h3&gt;
  
  
  FastAPI's &lt;code&gt;__init__&lt;/code&gt; is mostly documentation
&lt;/h3&gt;

&lt;p&gt;FastAPI's &lt;code&gt;__init__&lt;/code&gt; is 988 lines, and about 830 of them are the parameter list. It takes 39 parameters, and each one carries its own documentation inline through &lt;code&gt;Annotated[..., Doc("...")]&lt;/code&gt;, so editors can show the docs on hover. The body that does the work is around 160 lines, so counting it as a long function mostly counts documentation.&lt;/p&gt;

&lt;h2&gt;
  
  
  What to do about long functions in your own code
&lt;/h2&gt;

&lt;p&gt;Decide which of the four kinds you have before you refactor.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A &lt;strong&gt;registry&lt;/strong&gt; is easy to read and painful to merge: split it by area when merges start to hurt.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Generated code&lt;/strong&gt; should be excluded from your metrics.&lt;/li&gt;
&lt;li&gt;A &lt;strong&gt;test that grew&lt;/strong&gt; can become one test per scenario, mostly for better failure reports.&lt;/li&gt;
&lt;li&gt;A &lt;strong&gt;core loop&lt;/strong&gt; is the one to split first, before every feature has to go through it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When it is time to split one, &lt;a href="https://repowise.dev/blog/comparisons/best-refactoring-tools?utm_source=devto&amp;amp;utm_medium=community&amp;amp;utm_campaign=devto-11-longest-functions-in-popular-repos" rel="noopener noreferrer"&gt;this comparison of refactoring tools&lt;/a&gt; goes through the options.&lt;/p&gt;

&lt;p&gt;repowise keeps the longest function and the file it lives in for every repo it indexes, on each repo's stats page (&lt;a href="https://repowise.dev/repo/microsoft/powertoys/stats?utm_source=devto&amp;amp;utm_medium=community&amp;amp;utm_campaign=devto-11-longest-functions-in-popular-repos" rel="noopener noreferrer"&gt;here is PowerToys&lt;/a&gt;).&lt;/p&gt;

&lt;h2&gt;
  
  
  How we measured
&lt;/h2&gt;

&lt;p&gt;For every public repo with 500+ stars that has a stats record in our index (106 repos, with FastAPI counted once although we list it under two owners), we took the longest function the parser found. We kept repos with 10,000+ stars, downloaded each file from GitHub at the exact commit we indexed, and measured the function again: Python with the standard &lt;code&gt;ast&lt;/code&gt; module, and C, C++, Go, JavaScript and TypeScript by matching braces from the definition. Every number in the table matched our index.&lt;/p&gt;

&lt;p&gt;Length is lines from the definition to the closing line, including comments and blank lines. "On 6 Oct" means the default branch on 6 October 2026. Counts of routes, tools, &lt;code&gt;if&lt;/code&gt; lines and comments are simple line matches, so treat them as approximate. To reproduce a row, open the linked commit and count the line range in the URL.&lt;/p&gt;

&lt;p&gt;What is the longest function in the codebase you work on, and which of the four kinds is it?&lt;/p&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;How long should a function be?&lt;/strong&gt;&lt;br&gt;
There is no single limit that fits every case. Length on its own says little: a route registry or a generated function can be thousands of lines and still easy to read, while a core loop that every change has to touch is worth splitting much earlier.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Are long functions bad?&lt;/strong&gt;&lt;br&gt;
Not always. In the popular repos above, most of the longest functions are registries, generated code or tests that grew one scenario at a time. The long core loop is the kind that hurts, and both agent loops on the list were later split into much smaller functions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is the longest function in an open-source repo?&lt;/strong&gt;&lt;br&gt;
Among the 53 repos with 10,000+ GitHub stars that have a function-length record in repowise's index, it is &lt;code&gt;RunPanoramaStitchSelfTest&lt;/code&gt; in Microsoft PowerToys, at 6,967 lines in an 18,048-line C++ file.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>opensource</category>
      <category>codequality</category>
      <category>discuss</category>
    </item>
    <item>
      <title>Barrel files and circular imports: what index.ts does to 52 TypeScript repos</title>
      <dc:creator>Raghav Chamadiya</dc:creator>
      <pubDate>Sun, 22 Nov 2026 13:00:00 +0000</pubDate>
      <link>https://dev.to/repowise/barrel-files-and-circular-imports-what-indexts-does-to-52-typescript-repos-30kl</link>
      <guid>https://dev.to/repowise/barrel-files-and-circular-imports-what-indexts-does-to-52-typescript-repos-30kl</guid>
      <description>&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A barrel file is an &lt;code&gt;index.ts&lt;/code&gt; that re-exports other files, so code can import a whole folder from one path.&lt;/li&gt;
&lt;li&gt;In 17 of 52 TypeScript repos with 1,000+ GitHub stars (33%), the most-imported production file is an index file, and in 15 of them it is a barrel or partly one.&lt;/li&gt;
&lt;li&gt;In six TypeScript repos indexed for this post, every barrel that sat in a runtime import cycle was imported from inside its own package or app.&lt;/li&gt;
&lt;li&gt;In pi, pointing one import at the defining files instead of the barrel cut madge's runtime cycle count from 6 to 3.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Numbers come from repowise's index of 195 public repos with 1,000+ GitHub stars (November 2026), 52 of them TypeScript, plus six fresh local indexes.&lt;/p&gt;

&lt;p&gt;A barrel file is an &lt;code&gt;index.ts&lt;/code&gt; whose job is to re-export other files, so the rest of the code can write &lt;code&gt;import { Button } from "./components"&lt;/code&gt; instead of reaching into &lt;code&gt;./components/Button/Button&lt;/code&gt;. All six TypeScript repos I indexed for this post have index files, from 3 in repomix to 182 in openstatus. I wanted to know how central they really are in popular repos, and how often they sit inside circular import chains, so I measured both.&lt;/p&gt;

&lt;h2&gt;
  
  
  How often is the most-imported file a barrel?
&lt;/h2&gt;

&lt;p&gt;I looked at the 52 TypeScript repos in a set of 195 public repositories with 1,000+ GitHub stars, and at each repo's hub: the production file imported by the most other production files (tests, generated and vendored code excluded).&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In 17 of 52 repos (33%), the hub is a file named &lt;code&gt;index.ts&lt;/code&gt;, &lt;code&gt;index.tsx&lt;/code&gt; or similar.&lt;/li&gt;
&lt;li&gt;Across each repo's five most-imported files (260 slots), 49 are index files (19%), and 21 of the 52 repos have at least one in their top five.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A filename is only a proxy, since an &lt;code&gt;index.ts&lt;/code&gt; can hold real code. So I downloaded all 49 of those files from GitHub at the commit each repo was indexed at and looked at what they contain:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;What the index file contains&lt;/th&gt;
&lt;th&gt;Top hub (17)&lt;/th&gt;
&lt;th&gt;Top-five slots (49)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Mostly re-exports (&lt;code&gt;export ... from&lt;/code&gt;)&lt;/td&gt;
&lt;td&gt;12&lt;/td&gt;
&lt;td&gt;39&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Re-exports plus its own code&lt;/td&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;6&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Ordinary module that happens to be named index&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;So in 15 of 52 popular TypeScript repos, the single most-imported file is a barrel or partly one. Grafana's &lt;code&gt;@grafana/data&lt;/code&gt; entry is the best-known case, and I went through it in &lt;a href="https://dev.to/repowise/one-file-is-imported-by-31-of-grafana-it-is-not-a-god-object-5coo"&gt;the post on hub files&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;That is the first thing barrels do to a codebase. They become the hub. Every file that imports a package through its barrel depends, on paper, on everything that barrel re-exports.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why do people use barrel files?
&lt;/h2&gt;

&lt;p&gt;There are two good reasons, and they are different.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A package's public API.&lt;/strong&gt; When code outside a package imports it, the barrel is the contract: &lt;code&gt;import { dateTime } from "@grafana/data"&lt;/code&gt; keeps working when the package moves &lt;code&gt;dateTime&lt;/code&gt; to another file. This is what &lt;code&gt;main&lt;/code&gt; and &lt;code&gt;exports&lt;/code&gt; in &lt;code&gt;package.json&lt;/code&gt; point at.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Nice import paths inside one project.&lt;/strong&gt; &lt;code&gt;import { Button, Card } from "@/components"&lt;/code&gt; reads better than two deep paths. This one is mostly cosmetic, and it is where the costs below come from.&lt;/p&gt;

&lt;h2&gt;
  
  
  What do barrel files cost?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Loading.&lt;/strong&gt; Importing one name from a barrel means loading the barrel, and the barrel imports every file it re-exports. Under ES module rules each of those modules is evaluated, and each of their imports too. Vite's &lt;a href="https://vite.dev/guide/performance" rel="noopener noreferrer"&gt;performance guide&lt;/a&gt; says it directly: importing one API from a barrel means every file in it has to be fetched and transformed, so it recommends importing the individual file. A bundler can skip modules whose exports you never use only when it knows they have no side effects, which is what &lt;code&gt;"sideEffects": false&lt;/code&gt; in &lt;code&gt;package.json&lt;/code&gt; tells webpack and other bundlers. A test runner that executes modules one by one, like Jest or Vitest, loads whatever the import graph says.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Hidden unused exports.&lt;/strong&gt; When a barrel is a package entry point, unused-export tools treat everything it re-exports as public API and stay quiet about it by default (Knip has &lt;code&gt;--include-entry-exports&lt;/code&gt; to audit that surface). I covered that in &lt;a href="https://dev.to/repowise/typescript-unused-exports-what-52-popular-ts-repos-carry-and-how-to-clean-yours-with-knip-52j3"&gt;the post on unused exports in the same 52 repos&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Circular import chains.&lt;/strong&gt; A file inside a folder imports the folder's own barrel to get a sibling. The barrel re-exports that file too. Now the file depends on itself through the barrel, and every other file the barrel touches joins the chain. This is the one I measured.&lt;/p&gt;

&lt;h2&gt;
  
  
  Do barrel files cause circular imports?
&lt;/h2&gt;

&lt;p&gt;The dataset has cycle counts per repo, but not which files are in each cycle. So I indexed six TypeScript repos locally and looked at every circular import group, meaning a set of two or more files that can all reach each other through imports. I counted two ways: all imports, and runtime imports only, dropping &lt;code&gt;import type&lt;/code&gt; edges that TypeScript erases at compile time.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Repo (commit)&lt;/th&gt;
&lt;th&gt;Production JS/TS files&lt;/th&gt;
&lt;th&gt;Cycle groups, all imports&lt;/th&gt;
&lt;th&gt;Cycle groups, runtime&lt;/th&gt;
&lt;th&gt;Runtime groups with an index file&lt;/th&gt;
&lt;th&gt;Files in runtime cycles&lt;/th&gt;
&lt;th&gt;...of them index files&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;grafana/grafana (&lt;code&gt;12c49a4d&lt;/code&gt;)&lt;/td&gt;
&lt;td&gt;6,486&lt;/td&gt;
&lt;td&gt;68&lt;/td&gt;
&lt;td&gt;26&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;950&lt;/td&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;openstatusHQ/openstatus (&lt;code&gt;bba13dd&lt;/code&gt;)&lt;/td&gt;
&lt;td&gt;2,415&lt;/td&gt;
&lt;td&gt;17&lt;/td&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;53&lt;/td&gt;
&lt;td&gt;13&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;earendil-works/pi (&lt;code&gt;555e975&lt;/code&gt;)&lt;/td&gt;
&lt;td&gt;1,674&lt;/td&gt;
&lt;td&gt;29&lt;/td&gt;
&lt;td&gt;7&lt;/td&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;34&lt;/td&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;shadcn-ui/ui (&lt;code&gt;8ab2771&lt;/code&gt;)&lt;/td&gt;
&lt;td&gt;3,864&lt;/td&gt;
&lt;td&gt;10&lt;/td&gt;
&lt;td&gt;6&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;25&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;effector/effector (&lt;code&gt;7d69926&lt;/code&gt;)&lt;/td&gt;
&lt;td&gt;240&lt;/td&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;6&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;yamadashy/repomix (&lt;code&gt;758c3d71&lt;/code&gt;)&lt;/td&gt;
&lt;td&gt;222&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;12&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Three things stood out.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Type-only imports make up a lot of the cycles.&lt;/strong&gt; Grafana goes from 1,837 files in cycles to 950 once &lt;code&gt;import type&lt;/code&gt; edges are dropped, and pi from 244 to 34. Those chains disappear from the compiled JavaScript.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Package-level barrels were in no cycle at all.&lt;/strong&gt; Grafana's &lt;code&gt;grafana-data&lt;/code&gt; and &lt;code&gt;grafana-ui&lt;/code&gt; index files are the two most-imported files in the repo, and neither is inside any circular group. Code outside a package that imports the package's front door cannot loop back through it unless the package imports its consumers.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The barrels that do sit in cycles are imported from inside their own package.&lt;/strong&gt; In 3 of the 6 repos, a barrel was part of a runtime cycle. I checked who imports each of those 23 index files from inside its cycle, and every importer lives in the same package or app as the barrel, usually in a sibling folder. Not one of them is a different package coming in through the front door. In pi, even the &lt;code&gt;coding-agent&lt;/code&gt; package entry is in a cycle, because a file inside the package imports it.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;To see how much of each cycle the barrels were responsible for, I re-pointed every import of an index file at the file that actually defines each imported name (following re-exports through nested index files) and recomputed the groups. In openstatus, whose Drizzle schema files import each other through folder index files, the largest runtime group went from 42 files to 18. 16 of those 18 are table files whose relations reference each other in both directions, a real two-way dependency. The other 24 (11 index files, the 11 validation modules they re-export, and two more re-exported files) were in the group only because imports went through the barrels. In pi, one 6-file group disappeared completely. In grafana, shadcn-ui, effector and repomix nothing changed, because their cycles do not go through barrels.&lt;/p&gt;

&lt;h2&gt;
  
  
  One cycle, before and after
&lt;/h2&gt;

&lt;p&gt;The group that disappeared in pi is a clean example. pi's &lt;code&gt;chord&lt;/code&gt; package gives each folder an &lt;code&gt;index.ts&lt;/code&gt; that is its public surface. &lt;code&gt;host/index.ts&lt;/code&gt; is 34 lines of re-exports:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// packages/chord/src/host/index.ts (excerpt)&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nc"&gt;Ctx&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s2"&gt;"./ctx.ts"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;defineFacet&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nc"&gt;Facet&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nc"&gt;FacetHost&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nc"&gt;FacetSelf&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nc"&gt;ServeOptions&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s2"&gt;"./facet.ts"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nc"&gt;CommittedReload&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;createHost&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s2"&gt;"./host.ts"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;sleep&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;untilAborted&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s2"&gt;"./sleep.ts"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;jobs/job.ts&lt;/code&gt; needs two things from that folder, the &lt;code&gt;Ctx&lt;/code&gt; type and the &lt;code&gt;sleep&lt;/code&gt; function, and gets them from the barrel:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nc"&gt;Ctx&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sleep&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s2"&gt;"../host/index.ts"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I copied &lt;code&gt;packages/chord/src&lt;/code&gt; out of the repo and ran madge with type imports skipped, so it only reports chains that exist in the emitted JavaScript. The setting goes in a &lt;code&gt;.madgerc&lt;/code&gt; in the folder you run madge from:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"detectiveOptions"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"ts"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"skipTypeImports"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nl"&gt;"tsx"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"skipTypeImports"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ npx madge --circular --extensions ts chord-src
Processed 297 files (5.1s) (5 warnings)

✖ Found 6 circular dependencies!

1) delta/diff.ts &amp;gt; delta/index.ts
2) delta/index.ts &amp;gt; delta/tracker.ts
3) host/attempt.ts &amp;gt; jobs/internal.ts &amp;gt; jobs/job.ts &amp;gt; host/index.ts &amp;gt; host/host.ts
4) host/attempt.ts &amp;gt; jobs/internal.ts &amp;gt; jobs/job.ts &amp;gt; host/index.ts &amp;gt; host/host.ts &amp;gt; host/object.ts
5) jobs/internal.ts &amp;gt; jobs/job.ts &amp;gt; host/index.ts &amp;gt; host/host.ts &amp;gt; host/object.ts
6) remote/hold.ts &amp;gt; remote/relay.ts
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Cycles 3 to 5 all run through &lt;code&gt;job.ts &amp;gt; host/index.ts&lt;/code&gt;. &lt;code&gt;job.ts&lt;/code&gt; wants &lt;code&gt;sleep&lt;/code&gt;, but importing the barrel also imports &lt;code&gt;host.ts&lt;/code&gt;, which reaches &lt;code&gt;object.ts&lt;/code&gt;, which imports the jobs module, which imports &lt;code&gt;job.ts&lt;/code&gt;. The fix is one line, pointing each import at the file that defines it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight diff"&gt;&lt;code&gt;&lt;span class="gd"&gt;-import { type Ctx, sleep } from "../host/index.ts";&lt;/span&gt;
&lt;span class="gi"&gt;+import type { Ctx } from "../host/ctx.ts";&lt;/span&gt;
&lt;span class="gi"&gt;+import { sleep } from "../host/sleep.ts";&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ npx madge --circular --extensions ts chord-src-after
Processed 297 files (3.9s) (5 warnings)

✖ Found 3 circular dependencies!

1) delta/diff.ts &amp;gt; delta/index.ts
2) delta/index.ts &amp;gt; delta/tracker.ts
3) remote/hold.ts &amp;gt; remote/relay.ts
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Three chains gone, nothing else touched. The loading cost shows up in the same graph. From madge's JSON output, &lt;code&gt;host/index.ts&lt;/code&gt; reaches 150 of the 297 files in the package at runtime. &lt;code&gt;host/sleep.ts&lt;/code&gt; reaches none, since its only import is a type. Before the change, &lt;code&gt;job.ts&lt;/code&gt; pulled in half the package to call &lt;code&gt;sleep&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The two &lt;code&gt;delta/&lt;/code&gt; cycles that are left are a different shape: &lt;code&gt;delta/index.ts&lt;/code&gt; defines helpers like &lt;code&gt;overlap&lt;/code&gt; itself and also re-exports &lt;code&gt;diff.ts&lt;/code&gt;, which imports those helpers back from the index. Rewriting an import does not help there, because the code lives in the barrel. Moving the shared helpers into their own file (say &lt;code&gt;delta/core.ts&lt;/code&gt;) that both import is the fix for that one.&lt;/p&gt;

&lt;p&gt;None of these chains is a bug on its own. ES modules handle cycles as long as nothing reads a binding before its module has finished evaluating. They do mean that loading any file in the chain loads all of them, and that the order modules run in depends on which one gets imported first.&lt;/p&gt;

&lt;h2&gt;
  
  
  When is a barrel file fine?
&lt;/h2&gt;

&lt;p&gt;From what I saw in these repos, the barrel at the edge of a package is the healthy case. The &lt;code&gt;grafana-data&lt;/code&gt; package from the table above sets &lt;code&gt;"sideEffects": false&lt;/code&gt; and uses &lt;code&gt;exports&lt;/code&gt; to expose &lt;code&gt;.&lt;/code&gt;, &lt;code&gt;./unstable&lt;/code&gt; and &lt;code&gt;./internal&lt;/code&gt;. shadcn's CLI package does something similar with one subpath per area:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="nl"&gt;"exports"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"."&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"types"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"./dist/index.d.ts"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"default"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"./dist/index.js"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"./registry"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="err"&gt;...&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"./schema"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="err"&gt;...&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"./utils"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="err"&gt;...&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"./icons"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="err"&gt;...&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"./preset"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="err"&gt;...&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"./tailwind.css"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"./dist/tailwind.css"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;with &lt;code&gt;"sideEffects": ["./dist/tailwind.css"]&lt;/code&gt;, which lists the one file that really does have side effects. A consumer that only needs the schema imports &lt;code&gt;shadcn/schema&lt;/code&gt; and never loads the rest. The &lt;a href="https://repowise.dev/repo/shadcn-ui/ui/architecture?utm_source=devto&amp;amp;utm_medium=community&amp;amp;utm_campaign=devto-10-barrel-files-typescript" rel="noopener noreferrer"&gt;shadcn-ui/ui architecture view&lt;/a&gt; shows those packages and the edges between them.&lt;/p&gt;

&lt;h2&gt;
  
  
  Fixes that worked
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Inside a package, import the file that defines the name.&lt;/strong&gt; Keep the barrel for consumers outside. This is the one-line fix above, and editors will autocomplete the direct path if you let them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Enforce it with &lt;code&gt;no-restricted-imports&lt;/code&gt;.&lt;/strong&gt; ESLint 9's pattern &lt;code&gt;regex&lt;/code&gt; option can block relative imports of an index file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// eslint.config.mjs&lt;/span&gt;
&lt;span class="s2"&gt;"no-restricted-imports"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"error"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;patterns&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;regex&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"^\\.\\.?/(.+/)?index(\\.[jt]sx?)?$"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Import the file that defines it, not the folder index."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On pi's &lt;code&gt;job.ts&lt;/code&gt; it flags every barrel import, including the one that closed the cycle:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  7:1  error  '../context/index.ts' import is restricted from being used by a pattern. Import the file that defines it, not the folder index  no-restricted-imports
  ...
 12:1  error  '../host/index.ts' import is restricted from being used by a pattern. Import the file that defines it, not the folder index  no-restricted-imports
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;pi uses folder index files as deliberate module boundaries, so on that codebase the rule would be a design change, not a cleanup. On a project where barrels exist for short paths, it is a good default. A regex cannot tell a bare folder import (&lt;code&gt;from "../monitors"&lt;/code&gt;) from a file import, so for those a cycle check in CI (&lt;code&gt;madge --circular&lt;/code&gt;, or dependency-cruiser's &lt;code&gt;no-circular&lt;/code&gt; rule) catches what the lint rule misses.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Mark packages side-effect free.&lt;/strong&gt; &lt;code&gt;"sideEffects": false&lt;/code&gt;, or a list of the files that do have side effects, lets bundlers drop re-exported modules you never use. List CSS imports and polyfills, or they get dropped too.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Use &lt;code&gt;exports&lt;/code&gt; subpaths for big packages.&lt;/strong&gt; One entry per area (&lt;code&gt;./schema&lt;/code&gt;, &lt;code&gt;./utils&lt;/code&gt;) gives consumers small barrels instead of one huge one.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Move code out of barrels.&lt;/strong&gt; An index that defines helpers and re-exports files that use those helpers is a cycle by construction, as in pi's &lt;code&gt;delta/&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;For a wider look at the tools that draw these graphs (madge, dependency-cruiser, Nx, esbuild's metafile), &lt;a href="https://repowise.dev/blog/guides/javascript-typescript-dependency-graph?utm_source=devto&amp;amp;utm_medium=community&amp;amp;utm_campaign=devto-10-barrel-files-typescript" rel="noopener noreferrer"&gt;this guide to JavaScript and TypeScript dependency graphs&lt;/a&gt; has the commands and output for each. Cycles in a language whose compiler forbids them look very different, which is what &lt;a href="https://dev.to/repowise/go-repos-barely-have-import-cycles-here-is-what-hugo-gin-and-temporal-do-7em"&gt;the Go post in this series&lt;/a&gt; is about.&lt;/p&gt;

&lt;p&gt;If your team removed barrels from inside a package, did you keep a barrel at the package entry, or drop them everywhere?&lt;/p&gt;

&lt;h2&gt;
  
  
  How I got these numbers
&lt;/h2&gt;

&lt;p&gt;The cohort is 195 of the most-starred public repositories indexed on repowise (1,000+ GitHub stars each, 253,688 production source files, November 2026), 52 of them with TypeScript as GitHub's primary language. Hub figures come from each repo's stored import graph at its latest index (May to November 2026); the &lt;a href="https://repowise.dev/research/code-health-2026?utm_source=devto&amp;amp;utm_medium=community&amp;amp;utm_campaign=devto-10-barrel-files-typescript#hub-files" rel="noopener noreferrer"&gt;hub files section of the code health report&lt;/a&gt; has the cohort-wide numbers. "Index file" means a basename of &lt;code&gt;index&lt;/code&gt; with a JS or TS extension, or &lt;code&gt;mod.ts&lt;/code&gt;. I classified the 49 index files in top-five slots by reading each one at its indexed commit: "mostly re-exports" means at least half of its top-level statements are &lt;code&gt;export ... from&lt;/code&gt;. The six local runs used &lt;code&gt;repowise init --yes --no-prose --no-editor-setup&lt;/code&gt; (repowise 0.60.1) on fresh clones at the commits in the table, then a strongly connected components pass over production JS and TS files (classified by repowise's code-origin rules). The local file counts cover only JS and TS, so Grafana's 6,486 is lower than its production file count across all languages. The "re-point at the defining file" pass follows &lt;code&gt;export ... from&lt;/code&gt; chains name by name and leaves any name it cannot trace on the index file. The before/after used madge 8.0.0, ESLint 9.39.5 and typescript-eslint 8.72.2 on Node 22.19, on a copy of pi's &lt;code&gt;packages/chord/src&lt;/code&gt; at &lt;code&gt;555e975&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;What does barrel file mean?&lt;/strong&gt;&lt;br&gt;
A barrel file is a module, usually &lt;code&gt;index.ts&lt;/code&gt; or &lt;code&gt;index.js&lt;/code&gt;, whose job is to re-export other files from its folder. Code can then write &lt;code&gt;import { Button } from "./components"&lt;/code&gt; instead of importing each file by its full path.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Do barrel files break tree shaking?&lt;/strong&gt;&lt;br&gt;
They can. A bundler can drop the re-exported modules you never use only when it knows they have no side effects, which is what &lt;code&gt;"sideEffects": false&lt;/code&gt; (or a list of the files that do have side effects) in &lt;code&gt;package.json&lt;/code&gt; tells it. Test runners that execute modules one by one, like Jest or Vitest, load everything the barrel imports.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Is there an ESLint rule for barrel files?&lt;/strong&gt;&lt;br&gt;
ESLint's built-in &lt;code&gt;no-restricted-imports&lt;/code&gt; can block relative imports of a folder index with a &lt;code&gt;regex&lt;/code&gt; pattern, as shown above. It cannot tell a bare folder import from a file import, so pair it with a cycle check in CI such as &lt;code&gt;madge --circular&lt;/code&gt; or dependency-cruiser's &lt;code&gt;no-circular&lt;/code&gt; rule.&lt;/p&gt;

</description>
      <category>typescript</category>
      <category>javascript</category>
      <category>webdev</category>
      <category>architecture</category>
    </item>
    <item>
      <title>Find circular dependencies in a TypeScript project: madge, import/no-cycle and a graph view</title>
      <dc:creator>Raghav Chamadiya</dc:creator>
      <pubDate>Sat, 21 Nov 2026 13:00:00 +0000</pubDate>
      <link>https://dev.to/repowise/find-circular-dependencies-in-a-typescript-project-madge-importno-cycle-and-a-graph-view-2pe2</link>
      <guid>https://dev.to/repowise/find-circular-dependencies-in-a-typescript-project-madge-importno-cycle-and-a-graph-view-2pe2</guid>
      <description>&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;To find circular dependencies in a TypeScript project, run &lt;code&gt;npx madge --circular --extensions ts,tsx src/&lt;/code&gt;, dependency-cruiser with a &lt;code&gt;no-circular&lt;/code&gt; rule, or ESLint's &lt;code&gt;import/no-cycle&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;On repomix the three tools reported 8 cycles, 15 errors and 12 errors, and all three dropped to 0 once type-only and lazy &lt;code&gt;import()&lt;/code&gt; edges were ignored.&lt;/li&gt;
&lt;li&gt;A TypeScript cycle breaks at runtime only when one module reads a value from the other at load time: top-level code, a class &lt;code&gt;extends&lt;/code&gt;, a decorator, or a registry call that runs on import.&lt;/li&gt;
&lt;li&gt;48 of 52 TypeScript repos with 1,000+ GitHub stars (92%) have at least one circular import chain between files.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The tool runs are on repomix at commit &lt;code&gt;758c3d71&lt;/code&gt;; the cohort numbers come from repowise's index of 195 public repos with 1,000+ GitHub stars (November 2026).&lt;/p&gt;

&lt;p&gt;I ran three circular dependency checkers on the same TypeScript repo and got three different answers: 8 cycles, 15 errors and 12 errors. All three were pointing at the same two groups of files (15 files in all, 12 of them for ESLint). And when I told each tool to ignore imports that never run at load time, all three dropped to zero.&lt;/p&gt;

&lt;p&gt;That gap is the whole story of circular dependencies in TypeScript. Most of them are harmless, a few crash Node on startup, and the tools count very different things. Below: when a cycle actually breaks (with repros you can run), how to find cycles with madge, dependency-cruiser and ESLint's &lt;code&gt;import/no-cycle&lt;/code&gt; on a real project, why their numbers differ, and how to keep new ones out in CI.&lt;/p&gt;

&lt;h2&gt;
  
  
  How common are circular dependencies in TypeScript projects?
&lt;/h2&gt;

&lt;p&gt;In a set of 195 public repositories with 1,000+ GitHub stars, 48 of the 52 TypeScript repos (92%) have at least one circular import chain between files. In the median TypeScript repo, 6.4% of production files sit inside one. Across all 195 repos the numbers are 89% and 9.2%. These are file-level chains in popular, working projects, which is the first hint that a cycle on its own is not a bug.&lt;/p&gt;

&lt;h2&gt;
  
  
  When does a circular dependency break at runtime?
&lt;/h2&gt;

&lt;p&gt;Here are two files that import each other. &lt;code&gt;config.ts&lt;/code&gt; exports defaults and logs a line. &lt;code&gt;logger.ts&lt;/code&gt; reads the log level from the defaults when it loads.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// config.ts&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;log&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s2"&gt;"./logger.ts"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;defaults&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;logLevel&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"info"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;retries&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"config loaded"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// logger.ts&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;defaults&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s2"&gt;"./config.ts"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;level&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;defaults&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;logLevel&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;msg&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sb"&gt;`[${level}] ${msg}`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// main.ts&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;defaults&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s2"&gt;"./config.ts"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"retries:"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;defaults&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;retries&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With &lt;code&gt;"type": "module"&lt;/code&gt; in &lt;code&gt;package.json&lt;/code&gt;, Node 22.19 runs &lt;code&gt;.ts&lt;/code&gt; files directly (it strips the types), so no build step:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ node main.ts
./logger.ts:3
const level = defaults.logLevel;
              ^

ReferenceError: Cannot access 'defaults' before initialization
    at ./logger.ts:3:15
    at ModuleJob.run (node:internal/modules/esm/module_job:345:25)
...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The order of events:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;main.ts&lt;/code&gt; imports &lt;code&gt;config.ts&lt;/code&gt;. Before running it, Node follows its imports and finds &lt;code&gt;logger.ts&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;logger.ts&lt;/code&gt; imports &lt;code&gt;config.ts&lt;/code&gt;, which is already in progress, so Node does not go back. It runs &lt;code&gt;logger.ts&lt;/code&gt; first.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;logger.ts&lt;/code&gt; line 3 reads &lt;code&gt;defaults&lt;/code&gt;. In ES modules an import is a live binding to the exporter's variable, and that variable is a &lt;code&gt;const&lt;/code&gt; that &lt;code&gt;config.ts&lt;/code&gt; has not reached yet. It sits in the temporal dead zone, hence &lt;code&gt;Cannot access 'defaults' before initialization&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now move the read into the function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// logger.ts&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;defaults&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s2"&gt;"./config.ts"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;msg&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sb"&gt;`[${defaults.logLevel}] ${msg}`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ node main.ts
[info] config loaded
retries: 3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Same cycle, no error. By the time anyone calls &lt;code&gt;log()&lt;/code&gt;, &lt;code&gt;config.ts&lt;/code&gt; has assigned &lt;code&gt;defaults&lt;/code&gt;, and the live binding sees the value. This is why most cycles in real projects never cause trouble: the import is only used inside functions that run later.&lt;/p&gt;

&lt;h3&gt;
  
  
  The CommonJS version fails differently
&lt;/h3&gt;

&lt;p&gt;If your TypeScript compiles to CommonJS, the same two files fail with a different message. I compiled them with &lt;code&gt;tsc --module commonjs --target es2022&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// out/logger.js (tsc output)&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;config_1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"./config"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;level&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;config_1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;defaults&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;logLevel&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ node out/main.js
out/logger.js:5
const level = config_1.defaults.logLevel;
                                ^

TypeError: Cannot read properties of undefined (reading 'logLevel')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;require("./config")&lt;/code&gt; returns the half-filled &lt;code&gt;exports&lt;/code&gt; object of a module that is still running, so &lt;code&gt;defaults&lt;/code&gt; is &lt;code&gt;undefined&lt;/code&gt;. There is no TDZ in CommonJS, just a missing property. If you have ever seen a &lt;code&gt;TypeError: x is not a function&lt;/code&gt; that only happens when files load in a certain order, this is a common cause.&lt;/p&gt;

&lt;h3&gt;
  
  
  Classes are the strict case, and import order decides
&lt;/h3&gt;

&lt;p&gt;A class with &lt;code&gt;extends&lt;/code&gt; needs its base class at the moment the class statement runs. Deferring the read into a function does not help, because the class statement runs at load time.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// shape.ts&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nc"&gt;Circle&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s2"&gt;"./circle.ts"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Shape&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;area&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;number&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="nf"&gt;unit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Shape&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Circle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// circle.ts&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nc"&gt;Shape&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s2"&gt;"./shape.ts"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Circle&lt;/span&gt; &lt;span class="k"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;Shape&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;number&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="nf"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;number&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;super&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nf"&gt;area&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;number&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;PI&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two entry points that differ in one import line:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// a.ts&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nc"&gt;Shape&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s2"&gt;"./shape.ts"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Shape&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;unit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;area&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// b.ts&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nc"&gt;Circle&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s2"&gt;"./circle.ts"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nc"&gt;Shape&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s2"&gt;"./shape.ts"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Shape&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;unit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;area&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ node a.ts
./circle.ts:3
export class Circle extends Shape {
                            ^

ReferenceError: Cannot access 'Shape' before initialization
...

$ node b.ts
3.141592653589793
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;b.ts&lt;/code&gt; works because &lt;code&gt;circle.ts&lt;/code&gt; is entered first, so &lt;code&gt;shape.ts&lt;/code&gt; finishes before &lt;code&gt;class Circle extends Shape&lt;/code&gt; runs. &lt;code&gt;a.ts&lt;/code&gt; enters from the other side and fails. The CommonJS build of &lt;code&gt;a.ts&lt;/code&gt; fails with &lt;code&gt;TypeError: Class extends value undefined is not a constructor or null&lt;/code&gt;. This is the cycle that bites people after an "unrelated" refactor or an import sort: nothing in the two class files changed, only which one got imported first.&lt;/p&gt;

&lt;p&gt;So the short rule: a cycle breaks when one module reads a value from the other at load time. That means top-level code, a class &lt;code&gt;extends&lt;/code&gt;, a decorator, or a registry call that runs on import. Reads inside functions that run later are fine. Type-only imports never run at all.&lt;/p&gt;

&lt;h2&gt;
  
  
  How do you find circular dependencies in a real TypeScript project?
&lt;/h2&gt;

&lt;p&gt;I used &lt;a href="https://github.com/yamadashy/repomix" rel="noopener noreferrer"&gt;repomix&lt;/a&gt; at commit &lt;code&gt;758c3d71&lt;/code&gt; (8 November 2026): 147 TypeScript files in &lt;code&gt;src/&lt;/code&gt;, ES modules with &lt;code&gt;.js&lt;/code&gt; import specifiers, and &lt;code&gt;verbatimModuleSyntax&lt;/code&gt; on in its tsconfig. Tool versions: madge 8.0.0, dependency-cruiser 18.7.2, ESLint 9.39.5 with eslint-plugin-import 2.32.0, Node 22.19.&lt;/p&gt;

&lt;p&gt;One thing on safety first. Some JS tools load the project's own config files, which are code. For all three tools below, I kept the config in a folder outside the clone and pointed the tool at it, so nothing from the repo was executed. That is a good habit for any repo you did not write.&lt;/p&gt;

&lt;h3&gt;
  
  
  madge
&lt;/h3&gt;

&lt;p&gt;madge parses imports and needs no config.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx madge --circular --extensions ts,tsx src/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Processed 147 files (3.1s) (2 warnings)

✖ Found 8 circular dependencies!

1) core/packager.ts &amp;gt; core/skill/packSkill.ts
2) core/skill/packSkill.ts &amp;gt; core/skill/writeSkillOutput.ts
3) cli/actions/mcpAction.ts &amp;gt; mcp/mcpServer.ts &amp;gt; mcp/tools/attachPackedOutputTool.ts &amp;gt; mcp/tools/mcpToolRuntime.ts &amp;gt; cli/cliRun.ts
4) mcp/mcpServer.ts &amp;gt; mcp/tools/fileSystemReadDirectoryTool.ts
5) mcp/mcpServer.ts &amp;gt; mcp/tools/fileSystemReadFileTool.ts
6) mcp/mcpServer.ts &amp;gt; mcp/tools/grepRepomixOutputTool.ts
7) mcp/mcpServer.ts &amp;gt; mcp/tools/packCodebaseTool.ts
8) mcp/mcpServer.ts &amp;gt; mcp/tools/readRepomixOutputTool.ts
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It exits with status 1, so it works as a CI gate as is. The 2 warnings are two &lt;code&gt;gpt-tokenizer&lt;/code&gt; subpath imports it could not resolve (&lt;code&gt;--warning&lt;/code&gt; lists them). If your project uses tsconfig &lt;code&gt;paths&lt;/code&gt; aliases like &lt;code&gt;@/lib/x&lt;/code&gt;, add &lt;code&gt;--ts-config tsconfig.json&lt;/code&gt;, or those edges are silently missing from the graph.&lt;/p&gt;

&lt;p&gt;Now look at where those cycles close. Every one of the 2-file loops goes back through an &lt;code&gt;import type&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// src/mcp/tools/fileSystemReadDirectoryTool.ts&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nc"&gt;McpServerConfig&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s1"&gt;'../mcpServer.js'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// src/core/skill/packSkill.ts&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nc"&gt;PackOptions&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;PackResult&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s1"&gt;'../packager.js'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;import type&lt;/code&gt; is erased at compile time. In the emitted JavaScript that edge does not exist, so it cannot cause any of the failures above. madge counts it by default. To make madge skip it, put a &lt;code&gt;.madgerc&lt;/code&gt; in the directory you run from (madge reads it from the current directory and its parents):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"detectiveOptions"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;"ts"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"skipTypeImports"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"tsx"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"skipTypeImports"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;✖ Found 1 circular dependency!

1) cli/actions/mcpAction.ts &amp;gt; mcp/mcpServer.ts &amp;gt; mcp/tools/attachPackedOutputTool.ts &amp;gt; mcp/tools/mcpToolRuntime.ts &amp;gt; cli/cliRun.ts
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The one left closes in &lt;code&gt;cliRun.ts&lt;/code&gt;, and it is deliberate:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Each action is imported lazily so a run only loads the code path it takes.&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;runCliDeps&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;
  &lt;span class="n"&gt;runMcpAction&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Parameters&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="n"&gt;runMcpAction&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'./actions/mcpAction.js'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;runMcpAction&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A dynamic &lt;code&gt;import()&lt;/code&gt; inside a function runs when the function is called, long after every module has loaded. &lt;code&gt;core/packager.ts&lt;/code&gt; does the same for &lt;code&gt;packSkill&lt;/code&gt; with a comment explaining the reason (it saves about 25 ms of module loading). Add &lt;code&gt;"skipAsyncImports": true&lt;/code&gt; next to &lt;code&gt;skipTypeImports&lt;/code&gt; and madge prints:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;✔ No circular dependency found!
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So repomix has 8 circular dependencies by madge's default count and zero that can run into a half-loaded module.&lt;/p&gt;

&lt;h3&gt;
  
  
  dependency-cruiser
&lt;/h3&gt;

&lt;p&gt;dependency-cruiser checks rules, and a cycle is one rule. With &lt;code&gt;--no-config&lt;/code&gt; there are no rules, so it reports nothing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ npx depcruise src --no-config
✔ no dependency violations found (515 modules, 1236 dependencies cruised)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(It also followed imports into &lt;code&gt;node_modules&lt;/code&gt;, hence 515 modules.) The rule goes in a config file. I wrote it as JSON, outside the clone, and passed it with &lt;code&gt;--config&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"forbidden"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"no-circular"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;"severity"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"error"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;"from"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;"to"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"circular"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"options"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;"doNotFollow"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"path"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"node_modules"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"tsPreCompilationDeps"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;tsPreCompilationDeps: true&lt;/code&gt; keeps type-only imports in the graph, which matches madge's default.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx depcruise src --config ../cycle-rules/depcruise.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  error no-circular: src/mcp/tools/readRepomixOutputTool.ts →
      src/mcp/tools/mcpToolRuntime.ts →
      src/cli/cliRun.ts →
      src/cli/actions/mcpAction.ts →
      src/mcp/mcpServer.ts →
      src/mcp/tools/readRepomixOutputTool.ts
...
  error no-circular: src/core/packager.ts →
      src/core/skill/packSkill.ts →
      src/core/packager.ts
...
x 15 dependency violations (15 errors, 0 warnings). 195 modules, 712 dependencies cruised.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The exit code was 15, one per error. To flag only cycles that matter at runtime, add &lt;code&gt;viaOnly&lt;/code&gt; to the &lt;code&gt;to&lt;/code&gt; block:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="nl"&gt;"to"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"circular"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"viaOnly"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"dependencyTypesNot"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"type-only"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"dynamic-import"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;✔ no dependency violations found (195 modules, 712 dependencies cruised)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  ESLint import/no-cycle
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;import/no-cycle&lt;/code&gt; from eslint-plugin-import puts the check in your linter and your editor. Here is the flat config (mine loads the two packages from a separate install folder, otherwise it is the same). I kept it outside the repo and ran ESLint with &lt;code&gt;--no-config-lookup -c &amp;lt;path&amp;gt;&lt;/code&gt;, so it does not look for the project's own config:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// eslint.config.mjs&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;tsParser&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s2"&gt;"@typescript-eslint/parser"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;importPlugin&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s2"&gt;"eslint-plugin-import"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;files&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"src/**/*.ts"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"src/**/*.tsx"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;languageOptions&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;parser&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;tsParser&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ecmaVersion&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"latest"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sourceType&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"module"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;plugins&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;importPlugin&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;settings&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="s2"&gt;"import/parsers"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="s2"&gt;"@typescript-eslint/parser"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;".ts"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;".tsx"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="s2"&gt;"import/resolver"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;typescript&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;project&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"./tsconfig.json"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;rules&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="s2"&gt;"import/no-cycle"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"error"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;typescript&lt;/code&gt; resolver comes from &lt;code&gt;eslint-import-resolver-typescript&lt;/code&gt;. It maps &lt;code&gt;./mcpServer.js&lt;/code&gt; to &lt;code&gt;mcpServer.ts&lt;/code&gt; and resolves &lt;code&gt;paths&lt;/code&gt; aliases. Without it, most TypeScript imports do not resolve and the rule finds nothing.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx eslint --no-config-lookup -c ../cycle-rules/eslint.config.mjs src
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;src/cli/actions/mcpAction.ts
  1:1  error  Dependency cycle via ./tools/attachPackedOutputTool.js:8=&amp;gt;./mcpToolRuntime.js:12=&amp;gt;../../cli/cliRun.js:6  import/no-cycle

src/cli/cliRun.ts
  374:12  error  Dependency cycle via ../../mcp/mcpServer.js:1=&amp;gt;./tools/attachPackedOutputTool.js:8=&amp;gt;./mcpToolRuntime.js:12  import/no-cycle
...
src/mcp/tools/readRepomixOutputTool.ts
  7:1  error  Dependency cycle via ../../cli/cliRun.js:6=&amp;gt;./actions/mcpAction.js:374=&amp;gt;../../mcp/mcpServer.js:1  import/no-cycle

✖ 12 problems (12 errors, 0 warnings)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;ESLint reports on import statements, so you get one error per file that sits on a cycle, with the line of the import. Notice what is missing: the &lt;code&gt;packager.ts&lt;/code&gt; / &lt;code&gt;packSkill.ts&lt;/code&gt; loop. The rule already ignores &lt;code&gt;import type&lt;/code&gt;, and that loop only closes through type imports. What it does count is the dynamic &lt;code&gt;import()&lt;/code&gt; at &lt;code&gt;cliRun.ts:374&lt;/code&gt;. The rule's option for that is &lt;code&gt;allowUnsafeDynamicCyclicDependency&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="n"&gt;rules&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="s2"&gt;"import/no-cycle"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"error"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;allowUnsafeDynamicCyclicDependency&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With it, ESLint printed nothing and exited 0. On this repo ESLint took about 11 seconds, against 2 to 4 for the other two. On a big repo, the rule's &lt;code&gt;maxDepth&lt;/code&gt; option limits how far it follows imports.&lt;/p&gt;

&lt;h3&gt;
  
  
  A graph view
&lt;/h3&gt;

&lt;p&gt;The fourth view is the file graph itself. I indexed the same commit with repowise (&lt;code&gt;repowise init --yes --no-prose --no-editor-setup&lt;/code&gt;) and grouped its stored import graph into strongly connected components: sets of files that can all reach each other.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cycle groups: 2 files in cycles: 15
12 ['src/cli/actions/mcpAction.ts', 'src/cli/cliRun.ts', 'src/mcp/mcpServer.ts', 'src/mcp/tools/attachPackedOutputTool.ts', ...]
3 ['src/core/packager.ts', 'src/core/skill/packSkill.ts', 'src/core/skill/writeSkillOutput.ts']
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Dropping the edges marked type-only or deferred:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cycle groups: 0 files in cycles: 0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two groups is the number I find easiest to act on. Every listed cycle, error and path above lives inside one of these two groups, and each group is one design decision: the MCP tools and the server that registers them, and the skill packer and the packager that loads it. In a graph UI you can open the 12-file group and see the loop as a picture, which is quicker to reason about than reading five-line paths. The &lt;a href="https://repowise.dev/blog/guides/javascript-typescript-dependency-graph?utm_source=devto&amp;amp;utm_medium=community&amp;amp;utm_campaign=devto-09-find-circular-dependencies-typescript" rel="noopener noreferrer"&gt;JavaScript/TypeScript dependency graph guide&lt;/a&gt; has the commands for drawing the graph with each of these tools.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why do madge, dependency-cruiser and ESLint report different counts?
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Tool, default settings&lt;/th&gt;
&lt;th&gt;What it counts&lt;/th&gt;
&lt;th&gt;repomix&lt;/th&gt;
&lt;th&gt;Type-only and lazy imports dropped&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;madge &lt;code&gt;--circular&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;one path per loop it walks into&lt;/td&gt;
&lt;td&gt;8 cycles&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;dependency-cruiser &lt;code&gt;no-circular&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;one violation per cycle it reports, written from the module where it starts&lt;/td&gt;
&lt;td&gt;15 errors&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ESLint &lt;code&gt;import/no-cycle&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;one error per import statement on a cycle&lt;/td&gt;
&lt;td&gt;12 errors&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Strongly connected components&lt;/td&gt;
&lt;td&gt;groups of files that all reach each other&lt;/td&gt;
&lt;td&gt;2 groups, 15 files&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Four things explain the gaps, and they apply to any repo:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Type-only imports.&lt;/strong&gt; madge and dependency-cruiser (with &lt;code&gt;tsPreCompilationDeps: true&lt;/code&gt;) count them. &lt;code&gt;import/no-cycle&lt;/code&gt; skips them. That is the whole difference between ESLint's 12 and the other tools' 15 files here. TypeScript also drops imports used only as types even when you write a plain &lt;code&gt;import { X }&lt;/code&gt;, unless &lt;code&gt;verbatimModuleSyntax&lt;/code&gt; is on. With it on, as in repomix, you have to write &lt;code&gt;import type&lt;/code&gt;, which also makes the intent visible to every tool.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Dynamic &lt;code&gt;import()&lt;/code&gt;.&lt;/strong&gt; madge, dependency-cruiser and ESLint all count it by default. It is safe at load time for the same reason a read inside a function is safe.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Path aliases and &lt;code&gt;.js&lt;/code&gt; specifiers.&lt;/strong&gt; A tool that cannot resolve &lt;code&gt;@/lib/x&lt;/code&gt; or &lt;code&gt;./foo.js&lt;/code&gt; to a &lt;code&gt;.ts&lt;/code&gt; file drops the edge without an error. If a tool finds far fewer cycles than another, check resolution first (&lt;code&gt;--ts-config&lt;/code&gt; for madge, the &lt;code&gt;typescript&lt;/code&gt; resolver for ESLint, &lt;code&gt;tsConfig&lt;/code&gt; in dependency-cruiser's options).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Granularity.&lt;/strong&gt; A path, an edge, an import statement and a group are different units. The 12-file group shows up as six madge paths, thirteen dependency-cruiser violations and twelve ESLint errors. madge's list also skips files: &lt;code&gt;packRemoteRepositoryTool.ts&lt;/code&gt; and &lt;code&gt;generateSkillTool.ts&lt;/code&gt; are in the group but in none of its eight paths. When the numbers disagree, count the files.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The &lt;a href="https://repowise.dev/blog/comparisons/madge-vs-dependency-cruiser?utm_source=devto&amp;amp;utm_medium=community&amp;amp;utm_campaign=devto-09-find-circular-dependencies-typescript" rel="noopener noreferrer"&gt;madge vs dependency-cruiser comparison&lt;/a&gt; runs the same exercise on a much larger monorepo (Excalidraw), where the counts were 839 and 1,721 and the graph was three tangles.&lt;/p&gt;

&lt;h2&gt;
  
  
  How do you fix a circular dependency that breaks?
&lt;/h2&gt;

&lt;p&gt;These are run against the &lt;code&gt;config.ts&lt;/code&gt; / &lt;code&gt;logger.ts&lt;/code&gt; repro from the top, in the order I would try them.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Make type-only imports explicit
&lt;/h3&gt;

&lt;p&gt;If the import is only for types, write &lt;code&gt;import type&lt;/code&gt;. It costs nothing, it is erased at compile time, and &lt;code&gt;verbatimModuleSyntax&lt;/code&gt; (or the &lt;code&gt;@typescript-eslint/consistent-type-imports&lt;/code&gt; rule) will make sure nobody forgets. It does not fix a runtime cycle, but it removes the noise so the real ones stand out.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Move the shared value into a leaf module
&lt;/h3&gt;

&lt;p&gt;Both files needed &lt;code&gt;defaults&lt;/code&gt;, so give it a file that imports nothing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// defaults.ts&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;defaults&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;logLevel&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"info"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;retries&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// logger.ts&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;defaults&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s2"&gt;"./defaults.ts"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;level&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;defaults&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;logLevel&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;msg&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sb"&gt;`[${level}] ${msg}`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// config.ts&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;defaults&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s2"&gt;"./defaults.ts"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;log&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s2"&gt;"./logger.ts"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;defaults&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"config loaded"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ node main.ts
[info] config loaded
retries: 3

$ npx madge --circular --extensions ts fix-move
✔ No circular dependency found!
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Even the top-level read in &lt;code&gt;logger.ts&lt;/code&gt; is fine now, because &lt;code&gt;defaults.ts&lt;/code&gt; always finishes first.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Invert the dependency
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;logger.ts&lt;/code&gt; does not need to know where its settings come from. Pass them in:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// logger.ts&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;createLogger&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;opts&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;logLevel&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;msg&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sb"&gt;`[${opts.logLevel}] ${msg}`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// config.ts&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;createLogger&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s2"&gt;"./logger.ts"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;defaults&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;logLevel&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"info"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;retries&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;log&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;createLogger&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;defaults&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"config loaded"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;logger.ts&lt;/code&gt; now imports nothing from the project, and madge reports no cycle. For the &lt;code&gt;Shape&lt;/code&gt; / &lt;code&gt;Circle&lt;/code&gt; case the same idea means &lt;code&gt;Shape.unit()&lt;/code&gt; moves out of &lt;code&gt;shape.ts&lt;/code&gt; into a small factory module that imports both, so the base class never imports its subclass.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Defer the read
&lt;/h3&gt;

&lt;p&gt;Reading the value inside a function, or using &lt;code&gt;await import()&lt;/code&gt; like repomix does, keeps the cycle but makes it safe. Fine for a local fix, and worth a comment saying why, as repomix does.&lt;/p&gt;

&lt;h2&gt;
  
  
  Barrel files
&lt;/h2&gt;

&lt;p&gt;A barrel (&lt;code&gt;index.ts&lt;/code&gt; that re-exports a folder) adds an edge from the barrel to every file in the folder. When a file inside the folder imports from its own barrel, you get a cycle through every sibling, which is where most of the huge cycle counts in TypeScript monorepos come from. The rule of thumb is to import siblings by path inside a package and use the barrel only from outside. Barrels get their own post next in this series, with numbers from the same 52 TypeScript repos.&lt;/p&gt;

&lt;h2&gt;
  
  
  How do you keep new circular dependencies out in CI?
&lt;/h2&gt;

&lt;p&gt;Any of the three tools works as a gate. Pick based on where you want the error to show up.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="c1"&gt;# .github/workflows/cycles.yml (excerpt)
&lt;/span&gt;&lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;npx madge --circular --extensions ts,tsx src/&lt;/span&gt;
&lt;span class="c1"&gt;# or
&lt;/span&gt;&lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;npx depcruise src --config .dependency-cruiser.json&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;madge exits 1 on any cycle. With a &lt;code&gt;.madgerc&lt;/code&gt; that sets &lt;code&gt;skipTypeImports&lt;/code&gt;, it gates only cycles that exist in the emitted JavaScript.&lt;/li&gt;
&lt;li&gt;dependency-cruiser exits with the number of errors and lets you write the rule as tightly as you want (&lt;code&gt;viaOnly&lt;/code&gt;, or a path rule such as "&lt;code&gt;src/core&lt;/code&gt; never imports &lt;code&gt;src/cli&lt;/code&gt;", which stops cycles before they form). On a codebase that already has cycles, &lt;code&gt;depcruise-baseline&lt;/code&gt; records today's violations and &lt;code&gt;--ignore-known&lt;/code&gt; fails only on new ones. The comparison post above walks through that.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;import/no-cycle&lt;/code&gt; is the one people see in their editor before they push, if ESLint already runs in your CI.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For a project starting at zero runtime cycles, like repomix with type-only and lazy imports excluded, the strict gate is cheap to adopt. For a project with hundreds, start with the baseline and the runtime-only rule, and shrink from there.&lt;/p&gt;

&lt;p&gt;If you have cycles in Python or Go too, I covered &lt;a href="https://dev.to/repowise/circular-imports-in-python-why-every-big-python-repo-has-them-and-the-few-that-actually-break-4d86"&gt;Python's circular import errors&lt;/a&gt; and &lt;a href="https://dev.to/repowise/go-repos-barely-have-import-cycles-here-is-what-hugo-gin-and-temporal-do-7em"&gt;why Go repos barely have any&lt;/a&gt; in earlier posts.&lt;/p&gt;

&lt;p&gt;Which of the three counts do you gate on in CI, and did it start at zero?&lt;/p&gt;

&lt;h2&gt;
  
  
  How I ran this
&lt;/h2&gt;

&lt;p&gt;The cohort numbers come from 195 of the most-starred public repositories indexed on repowise (1,000+ GitHub stars each, 253,688 production source files, November 2026), counted on file-to-file imports between production files, each repo measured at its own latest index. The &lt;a href="https://repowise.dev/research/code-health-2026?utm_source=devto&amp;amp;utm_medium=community&amp;amp;utm_campaign=devto-09-find-circular-dependencies-typescript#circular-import-chains" rel="noopener noreferrer"&gt;circular import section of the code health report&lt;/a&gt; has the per-language breakdown. Everything about repomix is from a fresh clone at &lt;code&gt;758c3d71&lt;/code&gt; on 10 November 2026: madge 8.0.0, dependency-cruiser 18.7.2, ESLint 9.39.5 with eslint-plugin-import 2.32.0, @typescript-eslint/parser 8.72.2 and eslint-import-resolver-typescript 4.4.5, all installed in a separate folder, with every config file kept outside the clone. The graph view is &lt;code&gt;repowise init --yes --no-prose --no-editor-setup&lt;/code&gt; on the same commit, followed by a strongly connected components pass over the stored import graph, once with every import edge and once without type-only and deferred edges. The repros ran on Node 22.19 (type stripping for &lt;code&gt;.ts&lt;/code&gt;) and &lt;code&gt;tsc&lt;/code&gt; 5.9.3 for the CommonJS builds.&lt;/p&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;How do I find circular dependencies in TypeScript?&lt;/strong&gt;&lt;br&gt;
Run &lt;code&gt;npx madge --circular --extensions ts,tsx src/&lt;/code&gt; for a quick list, or add a &lt;code&gt;no-circular&lt;/code&gt; rule to dependency-cruiser or &lt;code&gt;import/no-cycle&lt;/code&gt; to ESLint if you want it in CI or in your editor. Set the tool to skip type-only and dynamic &lt;code&gt;import()&lt;/code&gt; edges if you only care about cycles that can fail at runtime.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Does TypeScript allow circular imports?&lt;/strong&gt;&lt;br&gt;
Yes. The compiler does not reject two files that import each other, and Node runs them in both ES module and CommonJS output. A cycle only fails when one module reads a value from the other before that module has finished loading, which shows up as &lt;code&gt;Cannot access 'x' before initialization&lt;/code&gt; in ES modules or an &lt;code&gt;undefined&lt;/code&gt; value in CommonJS.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How do I fix a circular dependency in JavaScript?&lt;/strong&gt;&lt;br&gt;
Move the shared value into a leaf module that both files import, or invert the dependency so one side receives what it needs as an argument. Reading the import inside a function, or loading it with &lt;code&gt;await import()&lt;/code&gt;, keeps the cycle but makes it safe at load time.&lt;/p&gt;

</description>
      <category>typescript</category>
      <category>javascript</category>
      <category>webdev</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>One file is imported by 31% of Grafana. It is not a god object</title>
      <dc:creator>Raghav Chamadiya</dc:creator>
      <pubDate>Fri, 20 Nov 2026 13:00:00 +0000</pubDate>
      <link>https://dev.to/repowise/one-file-is-imported-by-31-of-grafana-it-is-not-a-god-object-5coo</link>
      <guid>https://dev.to/repowise/one-file-is-imported-by-31-of-grafana-it-is-not-a-god-object-5coo</guid>
      <description>&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A god object is a class or file with lots of logic and many unrelated responsibilities. A file with many importers is not one by default.&lt;/li&gt;
&lt;li&gt;Grafana's most-imported file, &lt;code&gt;packages/grafana-data/src/index.ts&lt;/code&gt;, is imported by 3,178 of 10,090 production files (31%) and contains no logic, only re-exports.&lt;/li&gt;
&lt;li&gt;In the median repo among 195 public repos with 1,000+ GitHub stars, one hub file is imported by 20% of production files, and in 68 repos (35%) a single file is imported by a quarter or more of the codebase.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Numbers come from repowise's index of 195 public repos with 1,000+ GitHub stars (November 2026), plus fresh clones of Grafana, Keycloak and Docker Compose on 10 November 2026.&lt;/p&gt;

&lt;p&gt;In Grafana, one file is imported by 3,178 of its 10,090 production source files. That is 31% of the codebase depending on &lt;code&gt;packages/grafana-data/src/index.ts&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;If you sort any dependency graph by fan-in, a file like this lands on top, and the usual reaction is "that's our god object, we should split it". So I opened it. It is 986 lines long and contains no logic at all:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nc"&gt;DataFrameView&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s1"&gt;'./dataframe/DataFrameView'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nc"&gt;FieldWithIndex&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;FieldCache&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s1"&gt;'./dataframe/FieldCache'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nc"&gt;MutableField&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;MISSING_VALUE&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;MutableDataFrame&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s1"&gt;'./dataframe/MutableDataFrame'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Many importers and too many responsibilities are two different problems. Telling them apart takes four checks, shown here with numbers from 195 popular repos and three hubs I checked by hand.&lt;/p&gt;

&lt;h2&gt;
  
  
  How common are hub files in popular repos?
&lt;/h2&gt;

&lt;p&gt;I looked at file-to-file imports between production files (tests, generated and vendored code excluded) in 195 public repositories with 1,000+ GitHub stars. The "hub" is the single file imported by the most other files.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In the median repo, the hub is imported by 20% of all production files.&lt;/li&gt;
&lt;li&gt;The top 1% of files receive 17% of all import edges.&lt;/li&gt;
&lt;li&gt;In 68 repos (35%), one file is imported by a quarter or more of the codebase.&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Primary language&lt;/th&gt;
&lt;th&gt;Repos&lt;/th&gt;
&lt;th&gt;Median share of files importing the hub&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;All&lt;/td&gt;
&lt;td&gt;195&lt;/td&gt;
&lt;td&gt;20%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;TypeScript&lt;/td&gt;
&lt;td&gt;52&lt;/td&gt;
&lt;td&gt;17%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Python&lt;/td&gt;
&lt;td&gt;51&lt;/td&gt;
&lt;td&gt;18%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Go&lt;/td&gt;
&lt;td&gt;22&lt;/td&gt;
&lt;td&gt;27%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Rust&lt;/td&gt;
&lt;td&gt;15&lt;/td&gt;
&lt;td&gt;21%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;JavaScript&lt;/td&gt;
&lt;td&gt;13&lt;/td&gt;
&lt;td&gt;15% (indicative, small group)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Part of Go's lead is structural: a Go file imports a package, never a single file, so every file in a widely used package picks up all of that package's importers.&lt;/p&gt;

&lt;p&gt;So a hub is normal. Reading down the list of top hubs, the same few kinds keep coming back: package entry points (&lt;code&gt;index.ts&lt;/code&gt;, &lt;code&gt;lib.rs&lt;/code&gt;, &lt;code&gt;__init__.py&lt;/code&gt;), shared type and interface files, loggers, settings objects, and "context" types passed through every call. Django's is &lt;code&gt;django/conf/__init__.py&lt;/code&gt;, the module behind &lt;code&gt;from django.conf import settings&lt;/code&gt;. Repomix's is &lt;code&gt;src/shared/logger.ts&lt;/code&gt;. Neither is a design problem.&lt;/p&gt;

&lt;h2&gt;
  
  
  How do you tell a hub file from a god object?
&lt;/h2&gt;

&lt;p&gt;A god object is one class or file that knows too much and does too much: lots of logic, many unrelated responsibilities, and a reason to change every time any feature changes. High fan-in is a symptom it often has, but plenty of healthy files have it too.&lt;/p&gt;

&lt;p&gt;Four checks separate the two:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;What is in it.&lt;/strong&gt; Re-exports, declarations, or real logic?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;How wide is it.&lt;/strong&gt; How many symbols does it expose?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;How often does it change, and why.&lt;/strong&gt; One kind of change, or every kind?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;What do importers take from it.&lt;/strong&gt; One or two names each, or big different slices?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Here are the three hubs I checked, each on a fresh clone from 2026-11-10:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Grafana &lt;code&gt;grafana-data/src/index.ts&lt;/code&gt;
&lt;/th&gt;
&lt;th&gt;Keycloak &lt;code&gt;KeycloakSession.java&lt;/code&gt;
&lt;/th&gt;
&lt;th&gt;Docker Compose &lt;code&gt;pkg/api&lt;/code&gt;
&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Importers (my count)&lt;/td&gt;
&lt;td&gt;3,152 non-test TS files&lt;/td&gt;
&lt;td&gt;1,744 non-test Java files&lt;/td&gt;
&lt;td&gt;126 non-test Go files (19 of 43 packages)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;What is in it&lt;/td&gt;
&lt;td&gt;912 re-exported names, 0 lines of logic&lt;/td&gt;
&lt;td&gt;1 interface, ~39 methods&lt;/td&gt;
&lt;td&gt;921-line &lt;code&gt;api.go&lt;/code&gt;: interfaces and options structs&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Commits, last 90 days&lt;/td&gt;
&lt;td&gt;9&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;12 (&lt;code&gt;api.go&lt;/code&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;What importers take&lt;/td&gt;
&lt;td&gt;median 2 names per file&lt;/td&gt;
&lt;td&gt;mostly &lt;code&gt;getContext()&lt;/code&gt; and &lt;code&gt;getProvider()&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;median 3 names per file, 144 distinct names in use&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;None of these is a god object. They are three different kinds of hub, and each one has a different thing worth watching.&lt;/p&gt;

&lt;h2&gt;
  
  
  Kind 1: the package entry point (Grafana)
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;grafana-data/src/index.ts&lt;/code&gt; is the public face of the &lt;code&gt;@grafana/data&lt;/code&gt; package. Application code writes &lt;code&gt;import { ... } from '@grafana/data'&lt;/code&gt; and the file forwards each name to the module that defines it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;$ grep -oE &lt;span class="s2"&gt;"from '[^']+'"&lt;/span&gt; packages/grafana-data/src/index.ts &lt;span class="o"&gt;|&lt;/span&gt; sort -u &lt;span class="o"&gt;|&lt;/span&gt; wc -l
180
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;180 source modules, 178 &lt;code&gt;export { ... } from&lt;/code&gt; statements carrying 912 names, plus 4 &lt;code&gt;export *&lt;/code&gt; lines. On the importer side, I counted which names each file takes (a small Python script over every non-test &lt;code&gt;.ts&lt;/code&gt;/&lt;code&gt;.tsx&lt;/code&gt; file):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;files importing named exports from @grafana/data: 3152
distinct names used: 678
median names per importing file: 2
files using 1-3 names: 2538
  1329  GrafanaTheme2
   321  DataFrame
   301  SelectableValue
   194  FieldType
   171  Field
   161  TimeRange
...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The typical importer takes two names. &lt;code&gt;GrafanaTheme2&lt;/code&gt; alone shows up in 1,329 files, because almost every component styles itself with the theme. 9 commits touched &lt;code&gt;index.ts&lt;/code&gt; in the last 90 days ("Panels: Support panel notices and custom status actions", "Transformations: Allow setting static refIDs per transformation", ...). Together they added 29 lines and removed 2: eight added exports for a new feature, one moved an export to a new directory. So the file changes often, but always for the same reason: the package's public API grew.&lt;/p&gt;

&lt;p&gt;That is all you need to classify it: a package entry point, not a god object. What a barrel like this costs is a separate question, and it gets its own post later in this series.&lt;/p&gt;

&lt;h2&gt;
  
  
  Kind 2: the core interface (Keycloak)
&lt;/h2&gt;

&lt;p&gt;In Keycloak, &lt;code&gt;server-spi/.../models/KeycloakSession.java&lt;/code&gt; is imported by more files than anything else. For Java, &lt;code&gt;rg&lt;/code&gt; gets you the full ranking in one line:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;$ rg -oN --no-filename -g &lt;span class="s1"&gt;'*.java'&lt;/span&gt; -g &lt;span class="s1"&gt;'!**/src/test/**'&lt;/span&gt; -g &lt;span class="s1"&gt;'!testsuite/**'&lt;/span&gt; \
    &lt;span class="s1"&gt;'^import (org\.keycloak\.[\w.]+);'&lt;/span&gt; -r &lt;span class="s1"&gt;'$1'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; sort &lt;span class="o"&gt;|&lt;/span&gt; uniq -c &lt;span class="o"&gt;|&lt;/span&gt; sort -rn &lt;span class="o"&gt;|&lt;/span&gt; head -5
   1744 org.keycloak.models.KeycloakSession
    926 org.keycloak.models.RealmModel
    528 org.keycloak.models.UserModel
    498 org.keycloak.models.ClientModel
    484 org.keycloak.models.KeycloakSessionFactory
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That is 1,744 of 6,030 non-test Java files. The file is a 272-line interface with about 39 methods: &lt;code&gt;realms()&lt;/code&gt;, &lt;code&gt;users()&lt;/code&gt;, &lt;code&gt;clients()&lt;/code&gt;, &lt;code&gt;keys()&lt;/code&gt;, a transaction manager, and a generic &lt;code&gt;getProvider(Class&amp;lt;T&amp;gt;)&lt;/code&gt;. A long method list on a class everyone imports is the classic god object picture, so check 4 matters most. A rough count of calls on variables named &lt;code&gt;session&lt;/code&gt; across the main code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;$ rg -o --no-filename -g &lt;span class="s1"&gt;'*.java'&lt;/span&gt; -g &lt;span class="s1"&gt;'!**/src/test/**'&lt;/span&gt; -g &lt;span class="s1"&gt;'!testsuite/**'&lt;/span&gt; \
    &lt;span class="s1"&gt;'\bsession\.(\w+)\('&lt;/span&gt; -r &lt;span class="s1"&gt;'$1'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; sort &lt;span class="o"&gt;|&lt;/span&gt; uniq -c &lt;span class="o"&gt;|&lt;/span&gt; sort -rn &lt;span class="o"&gt;|&lt;/span&gt; head -6
   1480 getContext
    806 getProvider
    280 users
    275 getKeycloakSessionFactory
    126 realms
    120 identityProviders
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Callers mostly ask the session for the current request context or for a provider. The interface holds no logic, and its one implementation, &lt;code&gt;DefaultKeycloakSession&lt;/code&gt;, is 445 lines. It is the door to the providers that do the work (user storage, realm storage, keys, themes), each behind its own SPI. The generic &lt;code&gt;getProvider(Class&amp;lt;T&amp;gt;)&lt;/code&gt; is what keeps it stable: a new feature registers a provider instead of adding a method. The file was touched by 3 commits in the last year and 1 in the last 90 days.&lt;/p&gt;

&lt;p&gt;What to watch here is method count. As long as new capabilities go through the generic lookup, a hub like this can have thousands of importers and stay small.&lt;/p&gt;

&lt;h2&gt;
  
  
  Kind 3: the shared contract package (Docker Compose)
&lt;/h2&gt;

&lt;p&gt;In the dataset, Compose's hub is &lt;code&gt;pkg/api/context.go&lt;/code&gt;, imported by 130 of 194 production files (67%), the highest hub reach of any repo above 20k stars. That file is 32 lines and declares one three-method interface. Go code imports a package, though, so "which file" is the wrong question there. Count packages with &lt;code&gt;go list&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;$ go list -f &lt;span class="s1"&gt;'{{.ImportPath}}: {{join .Imports " "}}'&lt;/span&gt; ./... \
    &lt;span class="o"&gt;|&lt;/span&gt; sed &lt;span class="s1"&gt;'s#github.com/docker/compose/v5#compose#g'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; tr &lt;span class="s1"&gt;' '&lt;/span&gt; &lt;span class="s1"&gt;'\n'&lt;/span&gt; \
    &lt;span class="o"&gt;|&lt;/span&gt; awk &lt;span class="s1"&gt;'/:$/{next} /^compose/'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; sort &lt;span class="o"&gt;|&lt;/span&gt; uniq -c &lt;span class="o"&gt;|&lt;/span&gt; sort -rn &lt;span class="o"&gt;|&lt;/span&gt; head -5
     19 compose/pkg/api
      9 compose/internal/naming
      8 compose/pkg/utils
      7 compose/internal/concurrency
      6 compose/internal
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;19 of the other 43 packages import &lt;code&gt;pkg/api&lt;/code&gt;, and at the file level 126 of 239 non-test Go files do. The weight is in &lt;code&gt;api.go&lt;/code&gt;: 921 lines with 57 type declarations, mostly one options struct per command (&lt;code&gt;UpOptions&lt;/code&gt;, &lt;code&gt;DownOptions&lt;/code&gt;, &lt;code&gt;BuildOptions&lt;/code&gt;, ...) plus the &lt;code&gt;Compose&lt;/code&gt; service interface. Next to it sit the progress event types, label names and error values. It changes a lot (12 commits to &lt;code&gt;api.go&lt;/code&gt; in 90 days), because new command flags land in its options structs.&lt;/p&gt;

&lt;p&gt;Importers also take different things from it. Across the non-test Go files, 144 different &lt;code&gt;api.&lt;/code&gt; names are in use, and the median importing file uses 3. The most common are the progress event types (&lt;code&gt;api.Resource&lt;/code&gt;, &lt;code&gt;api.Done&lt;/code&gt;, &lt;code&gt;api.Working&lt;/code&gt;), then label constants and container summaries. That spread is check 4 pointing at more than one job in one package.&lt;/p&gt;

&lt;p&gt;This is the one with the broadest surface of the three, and the Compose maintainers already did the thing I would suggest. In October, &lt;a href="https://github.com/docker/compose/pull/14322" rel="noopener noreferrer"&gt;PR #14322&lt;/a&gt; split &lt;code&gt;Compose&lt;/code&gt; into focused interfaces:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;type&lt;/span&gt; &lt;span class="nc"&gt;Compose&lt;/span&gt; &lt;span class="k"&gt;interface&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;Lifecycle&lt;/span&gt;
    &lt;span class="nc"&gt;Inspector&lt;/span&gt;
    &lt;span class="nc"&gt;ImageManager&lt;/span&gt;
    &lt;span class="nc"&gt;Runner&lt;/span&gt;
    &lt;span class="nc"&gt;Watcher&lt;/span&gt;
    &lt;span class="nc"&gt;ProjectLoader&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The commit message says the method set of &lt;code&gt;Compose&lt;/code&gt; is unchanged, and two callers that only load a project now depend on &lt;code&gt;api.ProjectLoader&lt;/code&gt; instead of the whole service. The interface change itself touched 3 files (+70 and -40 lines). The PR, merged 2026-10-12, also regenerated a 626-line mock, for 4 files and +696 / -40 in total. Nothing broke for existing importers, and new code can ask for the narrowest interface it needs.&lt;/p&gt;

&lt;h2&gt;
  
  
  How do you find the most-imported file in your codebase?
&lt;/h2&gt;

&lt;p&gt;You do not need a full graph tool for a first look. One command per ecosystem:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;TypeScript / JavaScript&lt;/strong&gt; with relative imports, using madge (it only parses the source):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx madge --json --extensions ts src &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; graph.json
node -e &lt;span class="s1"&gt;'
const g = require("./graph.json"), n = {};
for (const deps of Object.values(g)) for (const d of deps) n[d] = (n[d] || 0) + 1;
const files = Object.keys(g).length;
Object.entries(n).sort((a, b) =&amp;gt; b[1] - a[1]).slice(0, 5)
  .forEach(([f, c]) =&amp;gt; console.log(c, Math.round(100 * c / files) + "%", f));'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On repomix (commit &lt;code&gt;758c3d71&lt;/code&gt;), run over the 147 TypeScript files under &lt;code&gt;src/&lt;/code&gt;, this prints:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;59 40% shared/logger.ts
38 26% config/configSchema.ts
26 18% shared/errorHandle.ts
22 15% core/file/fileTypes.ts
20 14% shared/types.ts
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Python&lt;/strong&gt;, counting each module once per file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;$ rg -oN -g &lt;span class="s1"&gt;'*.py'&lt;/span&gt; &lt;span class="s1"&gt;'^\s*from (django[\w.]*) import'&lt;/span&gt; -r &lt;span class="s1"&gt;'$1'&lt;/span&gt; django \
    &lt;span class="o"&gt;|&lt;/span&gt; sort -u &lt;span class="o"&gt;|&lt;/span&gt; cut -d: -f2 &lt;span class="o"&gt;|&lt;/span&gt; sort &lt;span class="o"&gt;|&lt;/span&gt; uniq -c &lt;span class="o"&gt;|&lt;/span&gt; sort -rn &lt;span class="o"&gt;|&lt;/span&gt; head -3
    170 django.conf
    156 django.db
    155 django.core.exceptions
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Java&lt;/strong&gt;: the &lt;code&gt;rg&lt;/code&gt; line from the Keycloak section, with your own package prefix.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Go&lt;/strong&gt;: the &lt;code&gt;go list&lt;/code&gt; pipeline from the Compose section, with your module path.&lt;/p&gt;

&lt;p&gt;Workspace packages imported by name (like &lt;code&gt;@grafana/data&lt;/code&gt;) do not resolve in madge without the workspace installed, so for those, count the bare import: &lt;code&gt;rg -l "from '@grafana/data'" -g '*.{ts,tsx}' | wc -l&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What to do with each kind
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;What the hub turns out to be&lt;/th&gt;
&lt;th&gt;Signs&lt;/th&gt;
&lt;th&gt;What to do&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Package entry point / barrel&lt;/td&gt;
&lt;td&gt;Only re-exports, importers take 1 to 3 names&lt;/td&gt;
&lt;td&gt;Keep it as the public API. Inside the package, import the defining module directly&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Core interface or session object&lt;/td&gt;
&lt;td&gt;Few methods used heavily, rare changes&lt;/td&gt;
&lt;td&gt;Keep new features behind a generic lookup so the method list stops growing&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Shared contract package&lt;/td&gt;
&lt;td&gt;Many types, changes with every feature&lt;/td&gt;
&lt;td&gt;Split the big interface by role and let callers depend on the narrowest one&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Real god object&lt;/td&gt;
&lt;td&gt;Lots of logic, frequent changes for unrelated reasons, importers each use a different slice&lt;/td&gt;
&lt;td&gt;Group importers by which symbols they use and extract each group's slice into its own module&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The last row is the only one where "split the hub" is the right reflex. The useful work is check 4: once you know which importers use which parts, the split lines usually draw themselves. Fan-in and fan-out together, plus what the file contains, is a better test than fan-in alone. &lt;a href="https://repowise.dev/blog/engineering/building-dependency-graph-any-codebase?utm_source=devto&amp;amp;utm_medium=community&amp;amp;utm_campaign=devto-08-hub-files-vs-god-objects" rel="noopener noreferrer"&gt;This post on building a dependency graph&lt;/a&gt; covers how both are computed and how PageRank ranks load-bearing files. You can also open Grafana's &lt;a href="https://repowise.dev/repo/grafana/grafana/architecture?utm_source=devto&amp;amp;utm_medium=community&amp;amp;utm_campaign=devto-08-hub-files-vs-god-objects" rel="noopener noreferrer"&gt;architecture view&lt;/a&gt; and follow the import edges between its packages.&lt;/p&gt;

&lt;p&gt;If you run one of these on your repo, I would like to know what kind of file comes out on top. My guess is a logger or a types file.&lt;/p&gt;

&lt;h2&gt;
  
  
  How I got these numbers
&lt;/h2&gt;

&lt;p&gt;The cohort is 195 of the most-starred public repositories indexed on repowise (1,000+ GitHub stars each, 253,688 production source files, November 2026). "Hub reach" is the share of a repo's production files that import its most-imported production file; the &lt;a href="https://repowise.dev/research/code-health-2026?utm_source=devto&amp;amp;utm_medium=community&amp;amp;utm_campaign=devto-08-hub-files-vs-god-objects#finding-7" rel="noopener noreferrer"&gt;hub file finding in the code health report&lt;/a&gt; has the cohort-wide figures. Each repo is measured at its own latest index between May and November 2026, so the figures are a snapshot per repo. The Grafana headline (3,178 of 10,090) is from its 2026-10-28 index. A fresh &lt;code&gt;repowise init&lt;/code&gt; on Grafana at commit &lt;code&gt;12c49a4d&lt;/code&gt; (2026-11-10) gave 3,148 of 10,164, still 31%. Keycloak, Compose, Django and repomix counts in the sections above come from local clones on 2026-11-10 (Keycloak &lt;code&gt;cbe2bc82&lt;/code&gt;, Compose &lt;code&gt;fde2a0a&lt;/code&gt;, Grafana &lt;code&gt;12c49a4d&lt;/code&gt;, Django &lt;code&gt;6a8248f&lt;/code&gt;, repomix &lt;code&gt;758c3d71&lt;/code&gt;) with ripgrep 15.1.0, Go 1.26.10 and madge 8.0.0, counting non-test files only. Commit counts are from the GitHub API for each file path since 2026-08-12 (90 days) and 2025-11-10 (one year).&lt;/p&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;What is a god object in programming?&lt;/strong&gt;&lt;br&gt;
A god object is a single class or file that holds too much logic and too many unrelated responsibilities, so almost every feature change has to touch it. High fan-in is a common symptom, but files like Grafana's &lt;code&gt;@grafana/data&lt;/code&gt; entry point have thousands of importers and no logic at all.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why is the god object an anti-pattern?&lt;/strong&gt;&lt;br&gt;
Because every change goes through it. A file that changes for many unrelated reasons, and whose importers each use a different slice of it, couples features that should be independent and turns merges and reviews into a bottleneck.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is a god class?&lt;/strong&gt;&lt;br&gt;
A god class is the same anti-pattern at class level: one class with a long list of methods covering unrelated jobs. A long method list on its own is not enough. Keycloak's &lt;code&gt;KeycloakSession&lt;/code&gt; has about 39 methods, but callers mostly use &lt;code&gt;getContext()&lt;/code&gt; and &lt;code&gt;getProvider()&lt;/code&gt;, and new features register providers instead of adding methods.&lt;/p&gt;

</description>
      <category>architecture</category>
      <category>programming</category>
      <category>opensource</category>
      <category>typescript</category>
    </item>
    <item>
      <title>Five git log commands that show where a codebase actually changes</title>
      <dc:creator>Raghav Chamadiya</dc:creator>
      <pubDate>Thu, 19 Nov 2026 13:00:00 +0000</pubDate>
      <link>https://dev.to/repowise/five-git-log-commands-that-show-where-a-codebase-actually-changes-jld</link>
      <guid>https://dev.to/repowise/five-git-log-commands-that-show-where-a-codebase-actually-changes-jld</guid>
      <description>&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;To see the most changed files in git, run &lt;code&gt;git log --since="90 days ago" --name-only --format=""&lt;/code&gt; and pipe it through &lt;code&gt;sort | uniq -c | sort -rn&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;On Django (35,106 commits), the busiest 90 of the 909 &lt;code&gt;.py&lt;/code&gt; files under &lt;code&gt;django/&lt;/code&gt; took 93% of the line changes in the last 90 days.&lt;/li&gt;
&lt;li&gt;Across 195 public repos with 1,000+ GitHub stars in repowise's index (November 2026), the busiest 10% of production files took 68% of 90-day churn in the median repo.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When I open a codebase I have not worked in, the first question is not "what does this do". It is "where does work actually happen". The README tells you what the authors think matters. &lt;code&gt;git log&lt;/code&gt; tells you what they keep touching.&lt;/p&gt;

&lt;p&gt;Here are the five &lt;code&gt;git log&lt;/code&gt; commands I use for that, each run on a full clone of Django on 10 November 2026 (HEAD &lt;code&gt;6a8248f&lt;/code&gt;, 35,106 commits). Copy them, swap the paths, and they work on any repo.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. What has been happening lately
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git log --oneline -8
git log --since=&lt;span class="s2"&gt;"90 days ago"&lt;/span&gt; --oneline &lt;span class="o"&gt;|&lt;/span&gt; wc -l
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;6a8248f13f Fixed #18543 -- Corrected ImageField validation documentation.
a1f2b45ce5 Fixed #30306 -- Added input_type to Textarea widget.
d9d05f104e Fixed #36642 -- Fixed capitalization of locale suggestions in makemessages.
f93a84a80c Refs #36642 -- Added makemessages test for en_001 locale.
6675dac0ff Fixed #37482 -- Corrected parse_time() docs about UTC offsets.
8e3dec67c4 Fixed #37330 -- Fixed QuerySet.values() crash with an annotation transform.
368bef0b2e Refs #37330 -- Added further annotations tests for QuerySet.values().
c392a758e6 Fixed #36022 -- Renamed django-admin to django.
243
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;--oneline&lt;/code&gt; is the readable version of &lt;code&gt;git log&lt;/code&gt;: abbreviated hash plus subject line. Two things to read from it. The pace (243 commits in 90 days), and the commit style. Django writes "Fixed #NNNNN" for bug fixes, which means you can count fixes per file later with &lt;code&gt;--grep&lt;/code&gt;. Plenty of repos use &lt;code&gt;fix:&lt;/code&gt; prefixes for the same purpose.&lt;/p&gt;

&lt;p&gt;Add &lt;code&gt;--graph --all&lt;/code&gt; when you want to see branches and merges too, and &lt;code&gt;--author=&lt;/code&gt; or &lt;code&gt;--since=&lt;/code&gt; to narrow it down.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Which files change most often
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git log --since=&lt;span class="s2"&gt;"90 days ago"&lt;/span&gt; --name-only --format=&lt;span class="s2"&gt;""&lt;/span&gt; -- django/ \
  &lt;span class="o"&gt;|&lt;/span&gt; sort &lt;span class="o"&gt;|&lt;/span&gt; uniq -c &lt;span class="o"&gt;|&lt;/span&gt; sort -rn &lt;span class="o"&gt;|&lt;/span&gt; head -10
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;     10 django/db/models/query.py
      8 django/db/models/sql/query.py
      6 django/db/models/sql/compiler.py
      5 django/template/base.py
      5 django/db/models/fields/json.py
      5 django/contrib/gis/gdal/raster/source.py
      5 django/contrib/admin/options.py
      4 django/utils/deprecation.py
      4 django/http/response.py
      4 django/db/models/fields/related_descriptors.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;--name-only&lt;/code&gt; lists the files each commit touched, and &lt;code&gt;--format=""&lt;/code&gt; drops the commit header so only file names are left. Count them and you get commits per file. The trailing &lt;code&gt;-- django/&lt;/code&gt; limits it to the package itself, so docs and tests do not crowd the list.&lt;/p&gt;

&lt;p&gt;The ORM (&lt;code&gt;db/models/query.py&lt;/code&gt;, &lt;code&gt;sql/query.py&lt;/code&gt;, &lt;code&gt;sql/compiler.py&lt;/code&gt;) is where Django is being worked on right now. If I were about to contribute to Django, those are the files I would read first, because they are the ones a reviewer will know best.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. How much each file changes
&lt;/h2&gt;

&lt;p&gt;Commit counts treat a one-line typo fix and a 300-line rewrite the same. &lt;code&gt;--numstat&lt;/code&gt; gives lines added and deleted per file, so you can sum them:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git log --since=&lt;span class="s2"&gt;"90 days ago"&lt;/span&gt; --numstat --format=&lt;span class="s2"&gt;""&lt;/span&gt; -- django/ \
  &lt;span class="o"&gt;|&lt;/span&gt; awk &lt;span class="s1"&gt;'{churn[$3] += $1 + $2} END {for (f in churn) print churn[f], f}'&lt;/span&gt; \
  &lt;span class="o"&gt;|&lt;/span&gt; sort -rn &lt;span class="o"&gt;|&lt;/span&gt; head -10
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;288 django/test/selenium.py
279 django/template/base.py
257 django/contrib/admin/tests.py
216 django/db/models/query.py
176 django/db/models/sql/query.py
175 django/contrib/gis/geos/prototypes/io.py
170 django/utils/version.py
122 django/contrib/gis/gdal/geojson.py
106 django/contrib/admin/options.py
100 django/test/client.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is churn: lines added plus lines deleted. The list is different from command 2. &lt;code&gt;django/test/selenium.py&lt;/code&gt; was touched in a single commit, but a large one, and &lt;code&gt;template/base.py&lt;/code&gt; moves up.&lt;/p&gt;

&lt;p&gt;The one number I like to compute from this is how concentrated the churn is. Take every &lt;code&gt;.py&lt;/code&gt; file under &lt;code&gt;django/&lt;/code&gt;, rank them by churn, and ask what share the busiest 10% hold:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;N&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;git ls-files &lt;span class="s1"&gt;'django/*.py'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; wc -l&lt;span class="o"&gt;)&lt;/span&gt;
git log --since=&lt;span class="s2"&gt;"90 days ago"&lt;/span&gt; --numstat --format=&lt;span class="s2"&gt;""&lt;/span&gt; -- &lt;span class="s1"&gt;'django/*.py'&lt;/span&gt; \
  &lt;span class="o"&gt;|&lt;/span&gt; awk &lt;span class="s1"&gt;'$1 != "-" {churn[$3] += $1 + $2} END {for (f in churn) print churn[f]}'&lt;/span&gt; \
  &lt;span class="o"&gt;|&lt;/span&gt; sort -rn \
  &lt;span class="o"&gt;|&lt;/span&gt; awk -v &lt;span class="nv"&gt;n&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$N&lt;/span&gt; &lt;span class="s1"&gt;'{a[NR]=$1; t+=$1} END {k=int(n*0.1); for(i=1;i&amp;lt;=k &amp;amp;&amp;amp; i&amp;lt;=NR;i++) s+=a[i];
      printf "%d of %d files changed; the busiest %d (10%%) hold %.0f%% of %d changed lines\n", NR, n, k, 100*s/t, t}'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;198 of 909 files changed; the busiest 90 (10%) hold 93% of 4302 changed lines
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On this clone, ninety files out of 909 took 93% of the line changes in three months. That is normal, not a Django quirk. In a set of 195 popular open-source repos I looked at, &lt;a href="https://repowise.dev/research/code-health-2026?utm_source=devto&amp;amp;utm_medium=community&amp;amp;utm_campaign=devto-05-git-log#finding-1" rel="noopener noreferrer"&gt;the busiest 10% of production files took 68% of 90-day churn&lt;/a&gt; in the median repo. Change is concentrated almost everywhere, which is why a short list of busy files is such a good place to start reading. (The &lt;code&gt;$1 != "-"&lt;/code&gt; skips binary files, which &lt;code&gt;--numstat&lt;/code&gt; reports as &lt;code&gt;-&lt;/code&gt;.)&lt;/p&gt;

&lt;h2&gt;
  
  
  4. How many people know a file
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git shortlog -sn --no-merges HEAD -- django/db/models/query.py &lt;span class="o"&gt;|&lt;/span&gt; wc -l
git shortlog -sn --no-merges HEAD -- django/db/models/query.py &lt;span class="o"&gt;|&lt;/span&gt; head -5 &lt;span class="o"&gt;|&lt;/span&gt; awk &lt;span class="s1"&gt;'{print $1}'&lt;/span&gt;
git log --format=%H HEAD -- django/db/models/query.py &lt;span class="o"&gt;|&lt;/span&gt; wc -l
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;180
46
44
41
33
31
646
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;git shortlog -sn&lt;/code&gt; groups commits by author and counts them. I printed only the counts here, but without the &lt;code&gt;awk&lt;/code&gt; you get names, which is the point when you want to know who to ask.&lt;/p&gt;

&lt;p&gt;Two gotchas. Pass &lt;code&gt;HEAD&lt;/code&gt; explicitly: without a revision, &lt;code&gt;git shortlog&lt;/code&gt; reads from standard input when it is not attached to a terminal, so in a script or a pipe it silently prints nothing. And use &lt;code&gt;--no-merges&lt;/code&gt;, or merge commits inflate the counts of whoever presses the button.&lt;/p&gt;

&lt;p&gt;For &lt;code&gt;query.py&lt;/code&gt;: 646 commits, 180 different authors, and the top five have 46, 44, 41, 33 and 31 commits. No single person dominates. That is unusual, and it is what two decades of history does. On a younger repo you will often see one name with most of the commits on a file. That is the bus factor question, which I looked at across 195 repos in &lt;a href="https://dev.to/repowise/bus-factor-1-is-the-default-per-language-ownership-in-195-popular-repos-54kh"&gt;the previous post&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. How one function evolved
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;git log -L&lt;/code&gt; follows a range of lines, or a whole function, back through history:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;'*.py diff=python'&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; .git/info/attributes
git log -L :_fetch_all:django/db/models/query.py --format=&lt;span class="s1"&gt;'%h %ad %s'&lt;/span&gt; --date=short -s &lt;span class="o"&gt;|&lt;/span&gt; grep -v &lt;span class="s1"&gt;'^$'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; head -4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;f3b7c05936 2016-06-03 Refs #16614 -- Made QuerySet.iterator() use server-side cursors on PostgreSQL.
70679243d1 2012-08-02 Fixed #18702 -- Removed chunked reads from QuerySet iteration
169b1a404c 2012-05-10 Replaced foo.next() by next(foo).
9c52d56f6f 2008-04-27 Merged the queryset-refactor branch into trunk.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;:_fetch_all:&lt;/code&gt; form means "the function called &lt;code&gt;_fetch_all&lt;/code&gt;". Git finds it with a per-language pattern, and that is what the first line is for. Without the &lt;code&gt;diff=python&lt;/code&gt; attribute, Git uses its default pattern, which only matches lines that start with a letter, &lt;code&gt;_&lt;/code&gt; or &lt;code&gt;$&lt;/code&gt;. A method indented inside a class never matches:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fatal: -L parameter '_fetch_all' starting at line 1: no match
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Put &lt;code&gt;*.py diff=python&lt;/code&gt; in &lt;code&gt;.gitattributes&lt;/code&gt; (shared) or &lt;code&gt;.git/info/attributes&lt;/code&gt; (just you). Git ships patterns for many languages: &lt;code&gt;python&lt;/code&gt;, &lt;code&gt;java&lt;/code&gt;, &lt;code&gt;golang&lt;/code&gt;, &lt;code&gt;rust&lt;/code&gt;, &lt;code&gt;cpp&lt;/code&gt;, &lt;code&gt;csharp&lt;/code&gt;, &lt;code&gt;php&lt;/code&gt;, &lt;code&gt;ruby&lt;/code&gt; and more.&lt;/p&gt;

&lt;p&gt;Drop the &lt;code&gt;-s&lt;/code&gt; to see each diff, which is the fastest way I know to answer "why is this function written like this".&lt;/p&gt;

&lt;h2&gt;
  
  
  How do these commands add up to a hotspot list?
&lt;/h2&gt;

&lt;p&gt;Commands 2 and 3 tell you where change concentrates. Command 4 tells you who to ask about those files. Command 5 tells you why a specific piece looks the way it does. Combine churn with complexity and bug fixes and you get a hotspot list, the files most likely to hurt. &lt;a href="https://repowise.dev/blog/guides/git-hotspot-analysis-risky-files?utm_source=devto&amp;amp;utm_medium=community&amp;amp;utm_campaign=devto-05-git-log" rel="noopener noreferrer"&gt;This guide on hotspot analysis&lt;/a&gt; walks through that ranking step by step.&lt;/p&gt;

&lt;p&gt;If you want to skip the shell for Django specifically, &lt;a href="https://repowise.dev/repo/django/django/commits?utm_source=devto&amp;amp;utm_medium=community&amp;amp;utm_campaign=devto-05-git-log" rel="noopener noreferrer"&gt;its commit history on repowise&lt;/a&gt; shows recent commits scored for risk, with the files each one touched.&lt;/p&gt;

&lt;h2&gt;
  
  
  How I got these numbers
&lt;/h2&gt;

&lt;p&gt;Every command above was run on a full clone of &lt;code&gt;django/django&lt;/code&gt; at &lt;code&gt;6a8248f&lt;/code&gt; on 10 November 2026, with Git for Windows in a bash shell. The 68% median comes from a set of 195 of the most-starred public repositories indexed on repowise (1,000+ GitHub stars each, 253,688 production source files, November 2026), each measured on production files at its own latest index between May and November 2026.&lt;/p&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;How do I see the most changed files in git?&lt;/strong&gt;&lt;br&gt;
Run &lt;code&gt;git log --name-only --format=""&lt;/code&gt;, optionally with &lt;code&gt;--since&lt;/code&gt; and a path, then count the lines with &lt;code&gt;sort | uniq -c | sort -rn&lt;/code&gt;. That gives commits per file. For lines changed per file, use &lt;code&gt;--numstat&lt;/code&gt; and sum the first two columns, as in command 3.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How do I make git log show only file names?&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;--name-only&lt;/code&gt; prints the files each commit touched, and &lt;code&gt;--format=""&lt;/code&gt; removes the commit header, so only file names are left. &lt;code&gt;--name-status&lt;/code&gt; does the same but adds a letter for added, modified or deleted.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What does git shortlog do?&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;git shortlog&lt;/code&gt; groups commits by author. &lt;code&gt;-sn&lt;/code&gt; prints a commit count per author sorted from most to least, and &lt;code&gt;--no-merges&lt;/code&gt; leaves merge commits out. In a script, pass &lt;code&gt;HEAD&lt;/code&gt; explicitly or it reads from standard input and prints nothing.&lt;/p&gt;

</description>
      <category>git</category>
      <category>productivity</category>
      <category>tutorial</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
