- Never use
anyoras unknown as - Never use nested ternary expressions. Use
if/else, a helper function, or named intermediate values instead. - Never use
=== true,=== false, etc. in boolean conditions; keep them as terse and simple as possible like!condition. Extract conditions to variables when the variable name adds clarity/insight into the reason for the condition. - In boolean condition contexts, use the shortest syntactically equivalent expression. Prefer
items.lengthoveritems.length > 0,!items.lengthoveritems.length === 0, anditems?.lengthoveritems && items.length > 0. - Always consider the impact of a change on tests or when more test cases are needed. Never make tests pass for the sake of passing; always exercise real behavior.
- Always keep documentation updated and accurate while being minimal and concise.
- Keep paragraphs to no more than 3 concise sentences. Prefer bullets for dense details.
- Keep
README.mdas the landing page and docs index. Do not turn it back into the only canonical reference for every example and workflow. - When public-facing install, runtime, CLI, library API, agent workflow, or release guidance changes, update the relevant canonical docs in the same change:
README.md,docs/installation.md,docs/cli.md,docs/library-api.md,docs/agent-workflows.md,docs/how-it-works.md, andPUBLISHING.mdas applicable. - For repo-understanding flows, start with
node ./dist/cli.js doctorandnode ./dist/cli.js orient --root . --budget small --jsonwhendistis built; build first if validating the working tree from a fresh checkout. - For source-checkout validation and contributor examples, prefer
node ./dist/cli.js ...; reserve barecodegraph ...for published/global install guidance. - Treat
--rootas the project boundary for config lookup, cache/manifests, path confinement, and output normalization. When--rootis set, positional paths are include roots; fororientanddrift, positional paths are always include roots. - Keep discovery glob guidance accurate:
codegraph.config.jsonglobs are project-root-relative, while CLI--include-glob/--ignore-globvalues are one-off filters relative to each active scan root. - Within any claimed cross-language capability, behavior should stay consistent across all supported languages for that capability. Avoid language-subset branches; if a limitation is intentional, document it in the parity docs and cover it with explicit tests in the same change.
- When language support changes, update
docs/language-parity.mdanddocs/scenario-catalog.mdin the same change so support claims, limitations, and fixture coverage stay aligned. - When adding or changing a cross-file language scenario, add or update the nearest language test in
tests/languages/*.test.tsand the shared semantic coverage intests/goto.test.ts,tests/references.test.ts, andtests/native-semantic-parity.test.tswhen the language uses the native runtime. - Always keep the README.md table of contents updated whenever README sections are added, removed, or renamed.
- When CLI commands, flags, or output contracts change, update both
docs/cli.mdandcodegraph-skill/codegraph/SKILL.mdin the same change. - Always keep
codegraph-skill/codegraph/SKILL.mdupdated when CLI commands, flags, or capabilities change. This file is the skill definition used by agents and must reflect the current tool surface. - Before major commits or concluding work, run
npm run checkto verify formatting, lint, build, and tests together. During iteration, use the narrowest meaningful test command: targeted Vitest suites for localized changes,npm run test:fastfor broader TypeScript changes,npm run test:integrationfor CLI/report/output contracts, andnpm run test:nativewhen touchingpackages/codegraph-native. - Installation guidance must use
@lzehrung/codegraphand the@lzehrungGitHub Packages registry. Keep detailed install docs indocs/installation.md. - Any persistent storage schema change (e.g. SQLite tables/columns/indexes) MUST include a migration path for existing on-disk data. If using
CREATE TABLE IF NOT EXISTS, you must alsoALTER TABLE/ backfill as needed (or introduce explicit schema versioning) and add a regression test that starts from an older schema to prove upgrades work. - DO NOT use curly quote variants or other non-standard characters humans would not type with a standard QWERTY keyboard.