v0.9.4 indexes node_modules in non-git projects, causing noisy context results
Summary
This may be related to / partly covered by #320, #360, and #405, but I wanted to add a concrete real-world reproduction from the published npm package (@colbymchenry/[email protected]).
On a small JavaScript/MJS project, CodeGraph indexed node_modules/ because the project .gitignore did not exclude it. The result was that codegraph context became dominated by third-party dependency symbols instead of the app code.
Environment
- macOS
- Node:
v26.0.0 - npm/npx:
11.12.1 - CodeGraph:
0.9.4vianpx --yes @colbymchenry/codegraph - Project type: private JavaScript/MJS project, not a git repository
Commands run
npx --yes @colbymchenry/codegraph index -f /path/to/private-js-project
npx --yes @colbymchenry/codegraph status /path/to/private-js-project
npx --yes @colbymchenry/codegraph context -p /path/to/private-js-project \
"Understand workspace/status/resume cards and job interim result flow" \
--max-nodes 20 --max-code 4 --format markdown
Observed result
Index succeeded, but most indexed files were dependencies:
Indexed 3,217 files
status fileCount: 3,249
status nodeCount: 45,373
status edgeCount: 121,441
DB size: 81.26 MB
SQLite count from files:
node_modules_files=3032
src_files=34
scripts_files=183
total_files=3249
The context query returned symbols from dependencies, for example node_modules/@modelcontextprotocol/sdk/.../spec.types.d.ts, instead of the project's app modules. This makes the MCP / AI-agent use case much less useful because the agent receives noisy dependency context.
Expected / desired behavior
For AI-agent usage, dependency folders such as node_modules/ should be easy to exclude without changing the project's git policy. A few possible fixes would work:
- ship
--exclude/--includesupport forindexandsync(looks like #405 is already heading there), - support a CodeGraph-specific ignore file like
.codegraphignore(similar to #360), - or document the current behavior very explicitly: after #285,
.gitignoreis the single source of truth, so users must addnode_modules/there or wait for a CodeGraph-specific exclude mechanism.
Why this matters
The main value proposition for CodeGraph is reducing repeated grep/glob/read work for AI coding agents. In this test, exact symbol queries were useful, but natural-language context was polluted by dependencies. That makes it hard to safely enable CodeGraph as a local code-context layer for agents like Claude Code / Codex / Cursor / Hermes.
Notes
codegraph index --helpin 0.9.4 does not show--exclude/--includeyet.- The README/docs still appear to mention
.codegraph/config.jsonwith anexcludeoption in some places, while #285 says the config surface was removed and.gitignoreis now the source of truth. That mismatch made the expected behavior unclear during the pilot.
Fixed — CodeGraph now ships built-in default ignores for node_modules and the full set of dependency/build/cache directories across every supported language/framework, so a project (git or not) no longer indexes third-party code even without a .gitignore. That directly resolves the repro here: a plain JS/MJS project with no .gitignore now excludes node_modules/ out of the box, and context/search reflect your code.
On the .codegraphignore idea specifically — we deliberately didn't add one. A separate CodeGraph-only ignore file is cumbersome: it's a second thing to create and keep in sync, when the vast majority of projects already have a .gitignore, and every scaffolded framework (Next.js, SvelteKit, Rails, Laravel, Flutter, …) generates one. We'd rather lean on that than ask you to manage another file.
But you were right that .gitignore alone isn't enough — there should be sensible out-of-the-box defaults so a project that's missing one, or has an incomplete one (your exact case), doesn't get flooded with dependency symbols. So that's what we added.
How it behaves:
- Zero config, no second file.
.gitignorestays the source of truth for project-specific cases; the built-in defaults are just a sane starting point when it's missing or incomplete. - Overridable via a
.gitignorenegation, e.g.!node_modules/, if you ever want a dependency dir indexed. - Applied uniformly — git or not, and to committed files too (vendoring a dependency into the repo doesn't make it project code).
- Curated from the canonical github/gitignore templates, and deliberately avoids first-party-prone names (
packages,lib,app,src,bin, …) so it never hides your own code. Validated on macOS, Linux, and Windows.
Merged to main (#417); ships in the next release, 0.9.5.
One correction on the docs point: I dug in, and the current README and docs site don't actually reference .codegraph/config.json — that config surface (and its docs) was removed back in #285; the only remaining mention is the historical CHANGELOG entry documenting that removal, which is correct to keep. I did refresh the "Configuration" pages so they accurately describe the zero-config model and these new built-in default-ignores. Thanks for the detailed, reproducible report.