Generated, copied and vendored files
cg keeps generated files out of the graph by default and lists them in cg coverage. A copy
points back at the file you edit.
One classifier (cg_code_graph/core/generated.py) runs at the start of cg index. The first
matching rule wins. Built-in directory and file-name lists live in
cg_code_graph/presets/common.yaml.
| rule | result |
|---|---|
generated.keep globs | never classified |
generated.paths / generated.vendored | generated / vendored |
.gitattributes linguist-generated / linguist-vendored | generated / vendored. A deeper file and a later line win. -attr marks the file hand-written |
Capacitor webDir | android/.../assets/public/ and ios/App/App/public/ are copied from webDir (copy_of per file). cap sync output is generated. webDir itself is build output when .gitignore or angular.json says so |
Cordova <widget> | platforms/<platform>/www/ is copied from www/ |
.openapi-generator/FILES | every listed file |
| build dirs | .nuxt/, .output/, .next/, .svelte-kit/, .docusaurus/. dist/ and build/ are skipped by every walk |
| file names | *.g.dart, *.freezed.dart, *.mocks.dart, generated_plugin_registrant.*, Flutter ephemeral/, protoc *_pb2.py, *.pb.go, *_pb.ts, *.pb.swift, … |
| leading comment | @generated, DO NOT EDIT, DO NOT MODIFY BY HAND, <auto-generated>, OpenAPI / protoc / Sourcery / SwiftGen / Mockolo banners |
A banner counts only in the comment lines before the first line of code. Swift macro expansions
are not files in the checkout. SwiftPM plugin output under .build/plugins/outputs/ is skipped
by every walk.
Default
Generated files are not parsed. A final pass drops any node whose file was classified, and its
edges. cg coverage lists them by reason:
$ cg coverage --db out/app.db
coverage app: typescript 140 exact | generated: 211 files excluded
generated: copy of www/ (Capacitor webDir) 107, web build output (Capacitor webDir) 104
coverage(path=...) for one generated file names the reason, so an agent edits the source. The
MCP coverage tool lists the same groups. Index stats repeat the count:
"generated": {"files": 3, "by_language": {"typescript": 2, "dart": 1},
"by_reason": {"OpenAPI Generator (.openapi-generator/FILES)": 2, "build_runner output (*.g.dart)": 1},
"by_kind": {"generated": 3}, "mode": "excluded",
"files_with_dropped_nodes": 1, "nodes_dropped": 2, "edges_dropped": 4}
files counts every classified file, including the TypeScript and Dart files the extractors
skip before parsing. files_with_dropped_nodes is what the final pass removed. With
--include-generated the same object reports files_with_nodes, nodes_labelled and
copy_of_edges.
Generated tests stay in. A generated file under test / tests / __tests__ /
androidTest / *Tests is indexed, with attrs.generated.test: true, and cg tests lists
it. Framework build directories and generated.paths globs are never kept this way.
Files that only feed resolution are still read. Nuxt .nuxt/ types resolve auto-imports, and
*.g.dart supplies json_serializable keys. Their functions do not become nodes.
Include them
cg index --include-generated (or generated.include: true) indexes the same files. Every
node from them carries attrs.generated = {kind, reason[, copy_of]}, and impact, reaches
and the MCP impact tool label them:
$ cg impact shop.service.place --db out/py.db
callers (transitive): 3
d=1 [shop] shop.api.create
d=1 [shop] shop.orders_pb2.decode [generated: protoc output (Python)]
d=1 [shop] shop.schema.run [generated: 'Code generated... DO NOT EDIT.' header]
A copied file's module gets a COPY_OF edge to the source module when both are indexed. A hit
in a copy then points at the file to edit, and the copy is not counted as a second
implementation. The MCP index tool keeps --include-generated across re-indexes.
generated:
paths: ["src/api/generated/**"]
vendored: ["third_party/**"]
keep: ["src/schema.gen.ts"]
include: false
cg config show lists the built-in rules and these keys. Public repos:
generated and copied files. Copied web assets are not
bridge senders; only the source webDir files are indexed (Web / native bridges).
External systems
A Postgres server, Redis, SMTP, LDAP, SFTP or S3 bucket is one node. The address usually lives in configuration, not in the call.
Installing and updating cg
cg is a Python package (Python 3.11+). The PyPI name is cg-code-graph; the commands are cg and cg-mcp. It installs as a user-level tool. No checkout and no sudo.