There’s a stereotype that AI-generated code is over-engineered — deeply nested folders, speculative abstractions, architecture astronauting. The data says otherwise.

Maximum directory depth across the corpus

Depth bucket Repos Share
1-3 (flat) 3,027 39%
4-5 (typical) 2,807 36%
6-8 (nested) 1,494 19%
9-12 (deep) 465 6%
13+ (very deep) 32 <1%

75% of Opus 4.7 repos keep structure at 5 levels or less. That’s unusually shallow for codebases that average 7,722 LOC and include framework structure.

What “5 levels” looks like

A typical path depth-5 Opus 4.7 repo:

my-app/                 (1)
  src/                  (2)
    components/         (3)
      ui/               (4)
        button.tsx      (5)

Or:

my-monorepo/            (1)
  apps/                 (2)
    web/                (3)
      src/              (4)
        page.tsx        (5)

Both are canonical patterns. Neither is unreasonably deep.

When does Opus 4.7 go deeper?

The 25% of repos above 5 levels fall into three patterns:

1. Monorepos with per-app src/ structure

monorepo/apps/web/src/components/ui/forms/inputs/button.tsx   (8)

This is a typical apps/*/src/components/<category>/<subcategory>/<component>.tsx pattern. Six levels is common in shadcn-heavy monorepos.

2. NextJS App Router deeply-routed repos

my-next-app/app/(dashboard)/team/[teamId]/settings/billing/invoices/page.tsx   (9)

Next.js route groups + dynamic segments can stack up. 9-10 levels for mature route trees.

3. Node.js / Python vendor directories

The 32 outliers at 13+ levels usually have node_modules/ or .venv/ committed — accidentally or intentionally. These aren’t real architectural decisions.

Why shallow matters

Shallow structure correlates with:

  1. Easier onboarding — new developers can see the whole tree in one tree command
  2. Faster navigation — fewer keystrokes in an IDE
  3. Lower cognitive overhead — fewer “where does this file go?” decisions
  4. Better for AI agents too — agent tools that traverse directories benefit from flat structures

Opus 4.7’s preference for flat structure is consistent with the “small, composable, don’t over-abstract” discipline visible in the function-size data.

Compared to community baseline

We don’t have a direct community-only comparison (yet), but anecdotally enterprise codebases often sit at depth 8-12. Rails monoliths, Java Spring packages, multi-tier C# solutions all push depth up. Opus 4.7’s 75%-at-depth-5 is a noticeably shallower distribution.

The correlation with repo type

Looking at depth vs repo_type:

  • CLI tools: overwhelmingly depth 1-3
  • Web apps: depth 3-5 typical (Next.js root + src + app + page-level)
  • Monorepos: depth 5-8 typical (packages//src/*)
  • Libraries: depth 3-5 (src + category + file)

Each archetype has a natural depth. Opus 4.7 hits the lower end of the natural range for each.

Implication

If you’re a generator producing “build me X” output:

Don’t over-structure. The default Opus 4.7 shape is:

project-root/
  src/ or app/
    main subdirectories (components/, lib/, routes/, etc.)
      files

Three to four levels is enough for most projects. Reserve deeper nesting for monorepos or App-Router dynamic-segment chains — places where it’s load-bearing, not decorative.

The 32 very-deep outliers

32 repos cross 13 levels. Inspecting a sample:

  • 18 of them are Python virtualenvs committed accidentally
  • 7 are node_modules committed (usually test fixtures)
  • 4 are submodules or cloned external repos as subdirs
  • 3 are genuinely nested architectures (complex Python packages)

None of these are Opus 4.7 “writing deeply nested structure.” They’re artifacts. If you strip vendor directories out of the analysis, the true distribution skews even flatter.


Related: pnpm Monorepos: Opus 4.7’s Default Architecture.