The .codeknife Directory
CodeKnife keeps caches and generated artifacts in a .codeknife/ directory at the analysis root, and writes a few files next to it. This page lists all of them so you know what to commit, what to ignore, and what --no-cache changes.
Quick start
Section titled “Quick start”Ignore the directory in git:
echo '.codeknife/' >> .gitignoreThis matters for more than tidiness: without it, --changed counts CodeKnife’s own cache files as changed files. See Paths, Excludes & Changed Scope.
Run read-only, with no writes to .codeknife/:
codeknife --no-cache --format agent checkThe walker always skips any directory named .codeknife, so these files are never analyzed as source.
What is in .codeknife/
Section titled “What is in .codeknife/”After a codeknife check in a demo repository:
codeknife --format agent check > /dev/nullls -lA .codeknifetotal 16-rw-r--r-- 1 user user 4656 Nov 30 18:58 metrics.json-rw-r--r-- 1 user user 5693 Nov 30 18:58 parse-cache.jsonAfter score --record, mutate and check --tier full as well:
history.jsonlmap.htmlmetrics.jsonmutate-cache.jsonparse-cache.json| Path | Written by | Format | Skipped with --no-cache |
|---|---|---|---|
.codeknife/parse-cache.json |
every command that parses the repository | compact JSON | yes (not read either) |
.codeknife/metrics.json |
commands that run the static suite | pretty JSON | yes |
.codeknife/mutate-cache.json |
mutate, check --tier full |
pretty JSON | yes (not read either) |
.codeknife/workers/ |
mutate, check --tier full (temporary) |
directory | moved to the system temp directory |
.codeknife/map.html |
check --tier full without --map-out |
HTML | yes |
.codeknife/history.jsonl |
score --record |
JSON Lines | yes (still read) |
parse-cache.json
Section titled “parse-cache.json”The parse cache stores what CodeKnife extracted from each source file, so unchanged files are not parsed again.
- Written by: any command that builds the code model: every blade command,
check,plan,map,score,dossier,reuse,verify,fix,test,baseline updateandbaseline prune. - Format: compact JSON (one line) with three top-level keys:
version,tool_versionandentries.entriesmaps each relative file path to an object withcontent_xxh3,language,pkg_keyandextracted. Inspected with a Python one-liner, withextractedreplaced by...:
top keys: ['version', 'tool_version', 'entries'] 1 0.2.0entry: src/a.rs {'content_xxh3': '2d2c9843747f9692', 'language': 'rust', 'pkg_key': '68f68aea7f9d2f94', 'extracted': '...'}extracted keys: ['module_qual', 'module_name', 'module_dir', 'is_test_file', 'is_entry_file', 'items', 'imports', 'references', 'comments', 'suppressions', 'contracts', 'tests']The extracted object holds everything parsed from that file.
- Invalidation:
- The whole cache is discarded when its
versionis not1or itstool_versionis not the running CodeKnife version. Upgrading CodeKnife therefore rebuilds it. - A file that cannot be read or does not parse as JSON is ignored and rebuilt, with no error.
- One entry is reused only when the file’s xxh3 content hash, its language and its package key all match. The package key is a hash of the owning package’s name, directory, library-root flag and, for TypeScript,
baseUrlandpaths. - Entries for files that are no longer discovered are removed.
- The whole cache is discarded when its
- Writes: the file is rewritten only when at least one entry was added, changed or removed. A run with no changes leaves it untouched. It is written to
parse-cache.<pid>.tmpfirst and then renamed into place.
metrics.json
Section titled “metrics.json”The metrics file is a snapshot of per-file, per-function and per-module numbers from the last static-suite run.
- Written by:
check,plan,map,score,dossier,verify,baseline update,baseline pruneand the MCP tools that run the suite. Single-blade commands such asarchdo not write it. It is overwritten on every run. - Read by: nothing in CodeKnife reads this file back. It is an output for you and your tools.
- Format: pretty-printed JSON with
schema_version1:
| Key | Contents |
|---|---|
schema_version |
1 |
root |
absolute path of the root |
files[] |
path, language, module, total_lines, code_lines, comment_count, suppression_count, churn_commits |
functions[] |
qual_name, file, module, start_line, end_line, lines, cyclomatic, cognitive, coverage_pct, crap, mutants_killed, mutants_survived, mutants_uncovered, body_sha256 |
modules[] |
qual_name, dir_path, shown_items, total_items, finding_count |
edges[] |
from, to, count, violated_rule (module import edges; violated_rule is set when an arch.toml rule forbids the edge) |
clone_clusters[] |
signature, similarity, locations |
The first file and function entries from a demo run, printed with a Python one-liner:
file metric: {'path': 'src/a.rs', 'language': 'rust', 'module': 'chg::a', 'total_lines': 3, 'code_lines': 2, 'comment_count': 0, 'suppression_count': 0, 'churn_commits': 2}fn metric: {'qual_name': 'chg::a::a', 'file': 'src/a.rs', 'module': 'chg::a', 'start_line': 1, 'end_line': 1, 'lines': 1, 'cyclomatic': 1, 'cognitive': 0, 'coverage_pct': None, 'crap': None, 'mutants_killed': 0, 'mutants_survived': 0, 'mutants_uncovered': 0, 'body_sha256': '26b8d431c4f380c5098a10897cae2f4c020b34d9b968605d337bc06792953164'}coverage_pct and crap are null when no coverage report was loaded. The three mutants_* counters are always 0 in this file. churn_commits is 0 when the Churn blade is off or there is no git history.
mutate-cache.json
Section titled “mutate-cache.json”The mutation cache remembers mutants that were already killed so they are not run again.
- Written by:
codeknife mutateandcodeknife check --tier full, after a campaign. - Format: pretty JSON with one
entriesobject. Each key is an xxh3 hash of the mutation site (file, function, line, original text, replacement). Each value hasfn_symbol,body_sha256andoutcome(killed,survived,timeoutorunviable):
Entry count and entries from a demo run, printed with a Python one-liner:
2 {'421c2cb58fe2ed0c': {'fn_symbol': 'app.calc.grade', 'body_sha256': '5c08a36f8ed159bb774fdcd924957c12b888ba0b626c21296d7d413eb4ca7408', 'outcome': 'killed'}, 'd505643e35aba240': {'fn_symbol': 'app.calc.grade', 'body_sha256': '5c08a36f8ed159bb774fdcd924957c12b888ba0b626c21296d7d413eb4ca7408', 'outcome': 'survived'}}- Invalidation: a cached mutant is skipped only if its outcome was
killedand the function body’s SHA-256 is unchanged. Survivors, timeouts and unviable mutants always run again.--mutate-allignores the cache. An unparseable file is treated as empty.
A second identical run shows the cached mutant:
NOTE mutation score: 50.0% (0 killed, 1 cached, 1 survived, 0 unviable, 7 uncovered skipped); schemata: 0 mutant(s) compiled once; blast-filtered tests: 1/1Details: 8. Mutation Testing.
workers/
Section titled “workers/”During mutation testing, each worker gets a copy of the repository under .codeknife/workers/w_<id>_<pid>. The copy skips .git, .codeknife, target, dist, build, .next, __pycache__, .pytest_cache and .mypy_cache, and symlinks node_modules, .venv and venv instead of copying them. Each worker directory is deleted when the worker finishes. For Rust with more than one job, separate Cargo target directories named cargo_target_<n> are created under the same base directory. With --no-cache, the base directory is codeknife-mutate-workers-<pid> in the system temp directory instead.
map.html
Section titled “map.html”codeknife check --tier full writes the Garden Map to .codeknife/map.html unless you pass --map-out <path>. With --no-cache and no --map-out, it skips the write and adds the note --no-cache skipped default .codeknife/map.html write. See 13. Garden Map.
history.jsonl
Section titled “history.jsonl”codeknife score --record appends one JSON object per line:
{"timestamp":"2026-11-30T18:59:10Z","git_sha":null,"overall":99.2,"grade":"A+","files":4,"errors":0,"warnings":1,"infos":0}git_sha is the 12-character HEAD SHA, or null outside a git repository. score reads the last --history entries (default 10) for its trend whether or not you pass --no-cache. With --no-cache, --record does not append and the JSON report has "recorded": false. See Health Scorecard.
Files written outside .codeknife/
Section titled “Files written outside .codeknife/”These are written into the root (or the path you give) and are not affected by --no-cache.
| File | Written by | Notes |
|---|---|---|
codeknife.toml |
init |
Only if missing, or with --force. See codeknife.toml. |
codeknife.baseline |
init, baseline update, baseline prune |
init writes only the header line. See Ratchet Baseline. |
arch.toml |
init (only if missing), arch --infer --write |
--layers <path> changes the target for --infer --write. |
codeknife-map.html |
map |
Default of map --out. Relative paths are resolved against the root. |
| source files | comments --strip --write, dead --fix --write, fix --write |
Without --write these commands only preview. |
baseline update with --no-cache still writes codeknife.baseline:
codeknife --no-cache baseline updateupdated .../mut/codeknife.baseline (1 entries)What --no-cache does
Section titled “What --no-cache does”--no-cache is a global flag. Its help text is “Do not write or update .codeknife/ cache/IR files (read-only analysis)”. In practice it:
- does not read or write
parse-cache.json, so every file is parsed from scratch; - does not write
metrics.json; - does not read or write
mutate-cache.json, and puts mutation workers in the system temp directory; - skips the default
.codeknife/map.htmlwrite incheck --tier full; - skips the
history.jsonlappend inscore --record.
It does not stop reads of history.jsonl or codeknife.baseline, and does not stop the writes listed in Files written outside .codeknife/.
A fresh copy of a repository, run with --no-cache, then without:
codeknife --no-cache --format agent check > /dev/nullls -ACargo.toml.gitsrccodeknife --format agent arch > /dev/nullls -A .codeknifeparse-cache.jsoncodeknife --format agent check > /dev/nullls -A .codeknifemetrics.jsonparse-cache.json--no-cache also leaves an existing cache untouched. After editing a source file, a --no-cache check run left parse-cache.json with the same modification time.
Also available via
Section titled “Also available via”The MCP tools accept a no_cache argument with the same meaning. See MCP Tools.