Verify Pipeline
codeknife verify runs up to three stages in one call: an optional autofix pass, the static quality check, and smart test selection. It prints one summary line and exits 0 only when the check and the tests both pass. Use it as the single “am I done?” command at the end of a change, by hand or from an AI agent.
Passing run
Section titled “Passing run”A small Rust crate with two tests and a clean working tree:
codeknife verify --format agent --no-cacheecho $?CODEKNIFE verify status=pass check=pass errors=0 warnings=0 infos=0 tests=pass elapsed_ms=1150Failing runs
Section titled “Failing runs”Add an unused private function to src/other.rs and run it again:
codeknife verify --format agent --no-cacheecho $?CODEKNIFE verify status=fail check=fail errors=0 warnings=1 infos=0 tests=pass elapsed_ms=113CODEKNIFE work_orders count=1[WO #1] score=63.8 sev=warning auto=true blast=0/1 | [dead_code] CK_DEAD_SYMBOL in `smart::other::unused_helper` | src/other.rs:5-7 cause: unreachable internal symbol `unused_helper` step: Run `codeknife fix --write --verify` to apply deterministic safe fixes cleanly. step: Delete this unused function (or run `codeknife dead --fix --write`).1The check failed on one warning, and the tests still ran (tests=pass): a failing check does not stop the pipeline.
With --fix, the autofix stage removes the function first, so the check passes:
codeknife verify --fix --format agent --no-cacheecho $?CODEKNIFE verify status=pass check=pass errors=0 warnings=0 infos=0 tests=pass elapsed_ms=375 FIX applied=1 reverted=0 files=10A failing test, with a clean check:
codeknife verify --format agent --no-cacheecho $?CODEKNIFE verify status=fail check=pass errors=0 warnings=0 infos=0 tests=fail elapsed_ms=5621The text output does not say which test command failed. Use --format json to see it under tests.failed_commands, or run codeknife test.
Stage order
Section titled “Stage order”- Fix (only with
--fix). Runs the Autofix Engine on the whole repository with--writeand a maximum of 3 passes.--aggressiveand--toolchainsare passed through. If you also give--test-cmd, that command is used as the fix verification command, with bisect-rollback; without--test-cmd, the fixes are written without any verification. - Check. Reloads the configuration and code model (so it sees the fixed files) and runs the same static suite as
codeknife checkat the standard tier: every static blade group plus the loosening guard. It does not run--deeplinters or--tier fullmutation testing. Findings are filtered throughcodeknife.baselinewhen it exists. - Tests (unless
--skip-tests). Runs Smart Test Selection for real, not as a dry run, with--test-cmdas the override when given. The changed-file set is computed after the fix stage, so files rewritten by--fixcount as changed. - Work orders. Only when the overall result is a failure, CodeKnife groups the active check findings into up to 6 root-cause work orders and prints them. See Work Orders (plan).
How pass and fail are decided
Section titled “How pass and fail are decided”- Check passes when there are no error findings, no warning findings and no loosenings after baseline filtering. Info findings never fail it. This is the same rule
codeknife checkuses (see The Check Gate). - Tests pass when every test command exits
0, when there is nothing to run, or when--skip-testsis set. - Verify passes when the check passes and the tests pass.
The fix stage never decides the result. A run where every fix was rolled back can still pass.
The same crate with a five-parameter public function:
codeknife verify --skip-tests --format agent --no-cachecodeknife verify --skip-tests --strict --format agent --no-cacheCODEKNIFE verify status=pass check=pass errors=0 warnings=0 infos=0 tests=skipped elapsed_ms=63CODEKNIFE verify status=fail check=fail errors=0 warnings=1 infos=0 tests=skipped elapsed_ms=6CODEKNIFE work_orders count=1[WO #1] score=48.6 sev=warning auto=false blast=0/1 | [complexity] CK_ARCH_TOO_MANY_PARAMS in `smart::math::sum5` | src/math.rs:5-7 cause: `sum5` takes 5 parameters (limit 4) step: Group cohesive parameters into an options or domain context struct.--strict lowers the parameter limit to 4, so the second run fails. The full list of strict thresholds is on codeknife.toml.
Fix with verification
Section titled “Fix with verification”--test-cmd does double duty: it verifies the autofix stage and replaces the generated test commands. On the demo from the Autofix Engine page, where removing use std::ops::Add; breaks the build:
codeknife verify --fix --aggressive --test-cmd 'cargo check -q' --format agent --no-cacheecho $?CODEKNIFE verify status=pass check=pass errors=0 warnings=0 infos=0 tests=pass elapsed_ms=1130 FIX applied=4 reverted=2 files=20The breaking import removal was rolled back (twice, once per fix pass), the other four fixes were kept, and the test stage ran cargo check -q instead of generated test commands.
| Flag | Default | Effect |
|---|---|---|
--fix |
off | Run the fix stage (write mode, 3 passes). |
--aggressive |
off | Include aggressive fixers in the fix stage. Ignored without --fix. |
--toolchains |
off | Run native formatters at the end of the fix stage. Ignored without --fix. |
--skip-tests |
off | Skip the test stage; it is reported as tests=skipped and counts as passing. |
--test-cmd <CMD> |
none | Replace the generated test commands with this command, and use it to verify the fix stage. |
--coverage <FILE> |
none | Coverage report for the check stage. Without it, the check stage looks for coverage the same way codeknife check does. See Coverage Reports. |
--strict |
off | Strict thresholds for the check stage. |
--changed |
off | Scope the check stage to git-changed files and use only git-changed files for test selection. Does not scope the fix stage. |
--since <REF> |
none | Base ref for the changed-file set and the loosening guard. |
--no-cache |
off | Do not read or write .codeknife/ caches. Without it, the check stage writes the metrics IR as check does. |
--path |
. |
Repository root. |
--format |
auto |
json and sarif print the JSON report; every other format prints the text form below. |
--max-items |
none | Accepted; not used by verify output. |
Output
Section titled “Output”Text (every format except json and sarif):
CODEKNIFE verify status=<pass|fail> check=<pass|fail> errors=E warnings=W infos=I tests=<pass|fail|skipped> elapsed_ms=MS FIX applied=A reverted=R files=F LOOSENING: <description>CODEKNIFE work_orders count=N...The FIX line appears only with --fix, LOOSENING: lines only when the loosening guard found any, and the work orders only on failure. Individual findings, notes, fix details and test commands are not printed; they are in the JSON report.
JSON (--format json; sarif prints the same JSON, not SARIF), from the passing run above:
{ "passed": true, "elapsed_ms": 41, "fix": null, "check_passed": true, "errors": 0, "warnings": 0, "infos": 0, "loosenings": [], "tests": { "plan": { "changed_files": [ "src/lib.rs", "src/math.rs", "src/other.rs" ], "targeted_tests": [ "src/lib.rs::test_math_path", "src/lib.rs::test_other_path" ], "commands": [ "cargo test -p smart" ], "notes": [] }, "passed": true, "failed_commands": [] }, "work_orders": [], "notes": [ "no coverage file found (running complexity-only mode); generate one with: cargo llvm-cov --lcov --output-path lcov.info", "analyzed 2 commit(s) over the last 90 day(s)" ]}| Field | Meaning |
|---|---|
passed |
Overall result. |
elapsed_ms |
Wall time of the whole pipeline. |
fix |
The full fix report, or null without --fix. |
check_passed |
Result of the check stage. |
errors, warnings, infos |
Counts of active findings after baseline filtering. The findings themselves are not included. |
loosenings |
Loosening guard messages. |
tests |
The smart test outcome, or null with --skip-tests. |
work_orders |
Up to 6 work orders on failure, otherwise empty. |
notes |
Notes from the check stage, including how many findings the baseline suppressed. |
Exit codes
Section titled “Exit codes”| Code | When |
|---|---|
0 |
Check passed and tests passed or were skipped. |
1 |
Check failed or a test command failed. |
2 |
An error, for example an unparseable codeknife.toml. The message is printed to stderr as codeknife error: .... |
Also available via
Section titled “Also available via”- MCP tool
codeknife_verifywith the argumentspath,no_cache,changed,since,strict,fix,aggressive,toolchains,skip_testsandtest_cmd. It has no coverage argument. It returns the JSON report. See MCP Tools. - The stages are also available on their own:
codeknife fix,codeknife checkandcodeknife test.