| name | ctx |
| description | Codebase intelligence via the indexed ctx CLI. Use when exploring an unfamiliar codebase, locating symbols or their callers, checking for existing implementations before writing new code, enforcing architecture rules, or scoring the quality impact of changes. |
ctx — code intelligence
ctx maintains a symbol-level index of this codebase (.ctx/codebase.sqlite).
Prefer its queries over grep: they resolve symbols, call graphs, and
structure instead of matching text.
All quality commands share one exit-code convention: 0 clean, 1 findings,
2 operational error. Treat exit 1 as content, not failure.
Keep the index fresh
ctx index
ctx index --force
Orient in the codebase
ctx map --budget 2000
ctx query find <name>
ctx query callers <fn>
ctx query deps <symbol>
ctx query impact <symbol>
ctx source <symbol>
ctx explain <symbol>
ctx search "<query>"
Avoid writing duplicate code
ctx similar <symbol>
ctx duplicates --against main
Run ctx similar before implementing a helper that sounds generic — an
implementation may already exist.
Quality gates
ctx check --against HEAD --json
ctx score --against main --fail-on "check_violations>0,new_duplication>0"
ctx hotspots
Recommended agent workflow
- Start:
ctx map --budget 2000 to orient (the SessionStart hook does
this automatically when installed).
- Before writing code:
ctx query find / ctx similar to find prior
art; ctx query impact before refactoring shared symbols.
- After edits:
ctx index then ctx check --against HEAD --json;
fix any violations immediately.
- Before finishing:
ctx score --against main and address regressions
(rising complexity, new duplication, rule violations).
Never edit .ctx/rules.toml (project policy) or the generated hook scripts;
regenerate the latter with ctx harness init.