Skip to content

Crate Architecture

CodeKnife is a Cargo workspace of 19 crates: 18 libraries and one binary. This page is for contributors and for anyone reading the source. The crate list and the dependency table come from cargo metadata on the v0.2.0 source.

All 19 crates share these settings from the root Cargo.toml:

Setting Value
Version 0.2.0
Rust edition 2024
Minimum Rust version 1.88
License MIT OR Apache-2.0
Resolver 2

The release profile sets strip = true, lto = "thin" and codegen-units = 1.

Crate Kind Modules Owns Documented in
codeknife-core library baseline, config, coverage, finding, git, graph, graph_algo, guard, hash, ids, ir, model, symbols, tree, walker Configuration, the finding and report types, the code model and graph, the file walker, git change sets, coverage parsers, the ratchet baseline and the loosening guard codeknife.toml, Findings Model, Paths, Excludes & Changed Scope, Coverage Reports, Ratchet Baseline, Loosening Guard
codeknife-lang library adapter, builder, cache, comments_extract, common, complexity, mutants_extract, registry, resolve, shared_extract, test_extract, types, plus rust_lang, typescript, python, go_lang The tree-sitter adapters for each language, metric computation, import resolution and the parse cache Language Support, How Metrics Are Computed, Import Resolution
codeknife-format library agent, human, json, markdown, picture, sarif The output renderers Output Formats & Exit Codes
codeknife-comments library classify, heuristics, strip Blade 1 1. Comments
codeknife-arch library cycles, depth, field_leaks, infer, layers, scope, shape Blade 2 2. Architecture
codeknife-clones library ast_clones, dto Blade 3 3. Clones
codeknife-dead library edits, reach, tokens Blade 4 4. Dead Code
codeknife-slop library ast_checks, hygiene, n_plus_one, reliability, rust_escapes Blade 5 5. Slop
codeknife-sec library iac, patterns, secrets, sql, taint Blade 6 6. Security
codeknife-tests library (single module) Blade 7 7. Tests & CRAP
codeknife-mutate library cache, campaign, report, runner, schemata, test_scope, worker Blade 8 8. Mutation Testing
codeknife-churn library metrics Blade 9 9. Churn
codeknife-blast library graph Blade 10 10. Blast Radius
codeknife-deps library builtins, lockfiles, lockfiles_extra, manifest_types, manifests, manifests_python, registry, scan Blade 11 11. Dependencies
codeknife-docs library project_cli, scripts Blade 12 12. Docs Drift
codeknife-map library edges, health, payload, and the embedded template.html Blade 13 13. Garden Map
codeknife-fix library fixers_comments, fixers_dead, fixers_docs_deps, fixers_slop, patch, smart_test, toolchains The autofix planner, patch application and rollback, native formatter calls, and smart test selection Autofix Engine, Smart Test Selection
codeknife-intel library dossier, dossier_target, dossier_types, recipes, recipes_clone, recipes_clone_ast, recipes_lcom, recipe_types, reuse, reuse_text, score, work_orders, work_order_types Work orders, dossiers, the reuse search and the health score Work Orders (plan), Dossier, Reuse Oracle, Health Scorecard
codeknife-cli binary (codeknife) blades, cli, commands, context, deep, fix_cmd, groups, hook, intel_cmd, mcp, metrics, report, runner, score_cmd, skill, verify_cmd Command parsing and dispatch, the check runner, deep mode, the verify pipeline, the hooks and the MCP server CLI Reference, The Check Gate, Deep Mode (Native Linters), Verify Pipeline, MCP Server, Anti-Tamper Hooks

Each row lists the CodeKnife crates a crate depends on directly, not counting test-only dependencies.

Crate Depends on
codeknife-core none
codeknife-lang codeknife-core
codeknife-format codeknife-core
codeknife-arch codeknife-core
codeknife-blast codeknife-core
codeknife-churn codeknife-core
codeknife-clones codeknife-core
codeknife-deps codeknife-core
codeknife-docs codeknife-core
codeknife-tests codeknife-core
codeknife-comments codeknife-core, codeknife-lang
codeknife-dead codeknife-core, codeknife-lang
codeknife-sec codeknife-core, codeknife-lang
codeknife-slop codeknife-core, codeknife-lang
codeknife-map codeknife-core, codeknife-arch
codeknife-intel codeknife-core, codeknife-lang, codeknife-blast
codeknife-mutate codeknife-core, codeknife-lang, codeknife-blast
codeknife-fix codeknife-core, codeknife-lang, codeknife-blast, codeknife-comments, codeknife-dead, codeknife-deps, codeknife-docs
codeknife-cli all 18 library crates

Three things follow from this table:

  • codeknife-core has no CodeKnife dependencies. Every other crate builds on its model and its Finding type.
  • Seven blades depend only on codeknife-core. They read the already-built code model and never touch a parse tree. The four that also depend on codeknife-lang (comments, dead, sec, slop) walk tree-sitter nodes themselves.
  • No blade depends on another blade, with one exception: codeknife-map uses codeknife-arch for layer rules. The crates that combine blades are codeknife-fix, codeknife-intel, codeknife-mutate and the CLI.
Area Crates used
Parsing tree-sitter with the Rust, TypeScript, JavaScript, Python and Go grammars
Git gix
Repository walking and globs ignore, globset
Parallelism rayon
Hashing xxhash-rust, sha2
Registry lookups ureq with rustls, used only by codeknife-deps
CLI clap, clap_usage, owo-colors
Formats serde, serde_json, toml
Other regex, chrono, anyhow, tempfile
Terminal window
cargo build --release -p codeknife-cli

The binary is target/release/codeknife. See Installation for the other install paths.