Language Support
CodeKnife parses Rust, TypeScript, JavaScript, Python and Go with tree-sitter and builds one shared code model that every blade reads. Read this page when you want to know whether a construct in your code is visible to CodeKnife, how it is classified, and where the per-language gaps are.
See what CodeKnife extracted
Section titled “See what CodeKnife extracted”The quickest way to see the model is codeknife reuse. It lists the functions, methods and types it found, with their kind, qualified name, visibility and number of resolved callers. Pick a query word that appears in every path you care about.
Given this Rust file in a crate named shapes (with src/lib.rs declaring pub mod shapes; mod util;):
use std::fmt;use serde::Serialize;use crate::util::{clamp, double as twice};
/// A 2D point.pub struct Point { pub x: i32, y: i32,}
pub(crate) enum Mode { Fast, Slow,}
pub trait Area { fn area(&self) -> f64; fn doubled(&self) -> f64 { self.area() * 2.0 }}
impl Area for Point { fn area(&self) -> f64 { 0.0 }}
impl Point { pub fn new(x: i32) -> Self { Point { x: clamp(x), y: twice(x) } }
fn bump(&mut self) { self.y += 1; }
pub async fn fetch(&self) -> i32 { self.x }}
pub const MAX: i32 = 3;pub type Coord = i32;pub(self) fn selfish() {}
macro_rules! noop { () => {};}codeknife reuse shapes --top 20 --no-cache --format humanCODEKNIFE reuse query="shapes" scanned=11 matches=11[1] score=45.8 method `shapes::shapes::Point::new` (src/shapes.rs:30, vis=public, callers=1) sig: pub fn new(x: i32) -> Self use: use shapes::shapes::Point::new;[2] score=45.5 struct `shapes::shapes::Point` (src/shapes.rs:6, vis=public, callers=0)...[3] score=45.5 trait `shapes::shapes::Area` (src/shapes.rs:16, vis=public, callers=0)...[5] score=45.5 fn `shapes::shapes::selfish` (src/shapes.rs:45, vis=public, callers=0) sig: pub(self) fn selfish()...[6] score=41.2 enum `shapes::shapes::Mode` (src/shapes.rs:11, vis=module, callers=0)...[8] score=36.8 fn `shapes::util::double` (src/util.rs:5, vis=public, callers=0)...[10] score=36.2 method `shapes::shapes::Point::area` (src/shapes.rs:24, vis=private, callers=0)...[11] score=36.2 method `shapes::shapes::Point::bump` (src/shapes.rs:34, vis=private, callers=0)...What this shows:
pub(crate)maps tomodulevisibility.pub(self)maps topublic, because onlycrateandsuperinside the modifier are treated as narrower.- The trait
Areais an item, but its method signatureareaand its default methoddoubledare not. Only theimplmethodPoint::areais extracted, and it isprivatebecause it has nopub. - The type alias
Coordand themacro_rules!macro are not extracted. util::doublehascallers=0even thoughPoint::newcalls it, because the call goes through the aliastwice. See Import Resolution.reusedoes not list fields, constants or tests. Those are in the model too (fieldsxandy, constantMAX), but this command filters them out.
The Reuse Oracle page documents reuse itself. codeknife dossier --target <name> --format json shows the per-function metrics that the next page explains.
Supported languages and files
Section titled “Supported languages and files”The file extension decides the language. The match is case-insensitive.
| Language | Extensions | Grammar crate (locked version) |
|---|---|---|
| Rust | .rs |
tree-sitter-rust 0.24.2 |
| TypeScript | .ts, .mts, .cts |
tree-sitter-typescript 0.23.2, TypeScript grammar |
| TypeScript (TSX) | .tsx |
tree-sitter-typescript 0.23.2, TSX grammar |
| JavaScript | .js, .jsx, .mjs, .cjs |
tree-sitter-javascript 0.25.0 |
| Python | .py |
tree-sitter-python 0.25.0 |
| Go | .go |
tree-sitter-go 0.25.0 |
The parser runtime is tree-sitter 0.25.10. Any other extension (for example .pyi, .vue, .svelte, .java) is not read.
JavaScript, JSX and TSX
Section titled “JavaScript, JSX and TSX”.js,.jsx,.mjsand.cjsfiles are languagejavascriptand are parsed with the JavaScript grammar, which also accepts JSX. There is no separate JSX language..tsxfiles are languagetypescriptand use the TSX grammar. The grammar choice checks for a lowercase.tsxsuffix, so a file namedX.TSXis still TypeScript but is parsed with the plain TypeScript grammar.- JavaScript and TypeScript use the same extractor, so they extract the same constructs wherever the syntax exists in both. The return-value mutation differs slightly (see How Metrics Are Computed).
- JavaScript files belong to the package of the nearest
package.json, the same as TypeScript files, and use the sametsconfig.jsonaliases. - A
.tsfile and a.jsfile with the same path stem (for examplesrc/util/num.tsandsrc/util/num.js) share one module,src/util/num. - Calls are only linked within one language. A call in a
.jsfile never resolves to a function defined in a.tsfile, even when the import itself resolves.
Example with src/caller.js importing clamp from ./util/num (which exists as num.ts):
codeknife blast --no-cache --symbol src/util/num/clamp --format humaninfo[CK_BLAST_IMPACT]: Blast radius for `src/util/num/clamp`: 1 upstream caller(s) across 2 file(s), 0 entrypoint(s), 0 test(s) --> src/util/num.ts:1-3 (src/util/num/clamp) = note: src/shapes.ts:27 — caller: src/shapes/Circle/constructor...The TypeScript caller is found. The JavaScript caller useIt in src/caller.js is not.
Files that are never parsed
Section titled “Files that are never parsed”The walker skips some files before any language code runs. Paths, Excludes & Changed Scope owns the full rules. The ones that matter for language support:
.d.ts,.d.mts,.d.ctsand.min.jsfiles.- Files whose first 8 lines contain
code generated,@generated,do not edit,automatically generatedorauto-generated(case-insensitive). - Files that are not valid UTF-8. They are skipped without a message.
A file with syntax errors is still parsed. Tree-sitter recovers from the error, and CodeKnife extracts whatever it can. In a demo, a Python file containing def bad(: still produced items for both good and bad.
How files become the code model
Section titled “How files become the code model”Every analysis command builds the model the same way:
- Find package manifests for each language (below).
- Read and parse every discovered file in parallel. Each file is assigned to the package whose directory is the longest prefix of the file path, for the same language.
- Run the language extractor on the syntax tree. It produces items, imports, references, tests, comments, suppressions and boundary tokens.
- Register one module per file in a module tree and add items with qualified names.
- Link everything: owners and fields, imports, wrappers, call and field references, and test units. Import Resolution covers this step.
Package discovery
Section titled “Package discovery”| Language | Manifest | Package name | Library root when |
|---|---|---|---|
| Rust | Cargo.toml containing [package] |
name under [package], else the directory name |
src/lib.rs exists next to the manifest |
| TypeScript and JavaScript | package.json |
its name, else app |
the manifest has an exports, main or module key |
| Python | pyproject.toml |
the first line anywhere in the file that starts with name and has =, else the directory name |
always |
| Go | go.mod |
the module line, else main |
there is no main.go next to go.mod |
Notes:
- A
Cargo.tomlwithout[package](a pure workspace manifest) does not create a package. - If no
package.jsonexists anywhere but the repository root has atsconfig.json, CodeKnife creates one package namedappat the root. - The Python name parser is not section-aware. A
name = ...line under another table that comes before[project]wins. - The manifest search skips directories named
target,node_modules,.git,vendor,dist,build,.venvand__pycache__, honours.gitignore, and skips hidden directories.
A module is marked as a library root when its file is an entry file (see each language below) and its package is a library root. The dead-code blade uses this to decide which public items count as reachable. See Import Resolution.
Module and item names
Section titled “Module and item names”| Language | Module qualified name | Separator | Example |
|---|---|---|---|
| Rust | package name, then the path inside the package without a leading src/, .rs or trailing /mod. lib.rs and main.rs are the package name itself. |
:: |
src/net/wire.rs in package core-lib is core-lib::net::wire |
| TypeScript and JavaScript | repository-relative path without the extension | / |
src/util/num.ts is src/util/num |
| Python | repository-relative path without .py or a trailing /__init__, with / replaced by . |
. |
app/core/__init__.py is app.core |
| Go | module path from go.mod, then the directory inside the module. Every file in a directory shares one module. |
/ |
store/store.go in example.com/shop is example.com/shop/store |
An item’s qualified name is the module name, then the owner type if any, then the item name, joined by the separator, for example shapes::shapes::Point::new or example.com/shop/store/Store/Add. Rust files outside any Cargo package use the package name crate. Go files outside any go.mod use main.
Python module names come from the repository path, not from the pyproject.toml location. A file at py/app/calc.py is py.app.calc even if pyproject.toml sits in py/.
Two files that produce the same module name share one module. This happens for src/lib.rs and src/main.rs in one crate, for .ts and .js files with the same stem, and for all Go files in one directory.
Grammar: tree-sitter-rust. Extractor: crates/codeknife-lang/src/rust_lang/.
| Construct | Extracted as |
|---|---|
fn at module level |
Function |
fn inside an impl block |
Method, owner is the impl type with generics and path removed |
fn with a test attribute |
Test |
struct |
Struct, plus one Field per named field |
enum |
Enum (variants are not extracted) |
trait |
Trait (its method signatures and default methods are not extracted) |
impl Trait for Type |
an implements-trait reference from Type to Trait; methods get trait_impl = true |
const, static |
Const, with the impl type as owner when inside an impl |
mod name { ... } |
its contents are walked with the same rules |
mod name; |
an import of the file module name |
use ...; |
one import per path after expanding {...} groups |
Not extracted: type aliases, union, macro_rules! macros, extern blocks, trait method signatures and default bodies, enum variants, tuple-struct fields, and functions nested inside function bodies.
Visibility. No modifier is private. pub(crate), pub(super) and any pub(in ...) whose text contains crate or super are module. Every other pub form, including pub(self), is public.
Imports. use statements are expanded: use a::{b, c::d as e} becomes a::b and a::c::d. Aliases are dropped and a trailing ::* is removed. A path is internal when it starts with crate::, super:: or self::, or when its first segment is a mod declared in the same scope (CodeKnife then rewrites it to crate::...). Paths starting with std, core or alloc are dropped. Everything else is recorded as an external import. mod name; declarations are not recorded as imports when they sit inside a #[cfg(test)] module, carry #[cfg(test)] themselves, or are in a Rust test file.
Calls and field reads. Inside each function body CodeKnife records:
- every call expression, split into a name and a qualifier at the last
.or::(a::b::c()has qualifiera::b, namec), with generic arguments stripped; - every
identifier(inside a macro invocation’s text, soprintln!("{}", helper(x))records a call tohelper(the wordsif,for,whileandmatchare ignored); - every field access.
self.xis stored as a field the method touches;other.xbecomes a field-read reference with qualifierother.
Tests. A function is a test when one of its attributes is exactly #[test], ends with ::test] (for example #[tokio::test]), contains ::test(, or contains rstest, and does not contain cfg(. #[should_panic] adds one assertion to the test’s count. Items inside a #[cfg(test)] module, or in a test file, are flagged as test code but keep their normal kind unless they also carry a test attribute. Test files are paths that start with tests/ or benches/, contain /tests/ or /benches/, end with _test.rs, or end with /tests.rs.
Entry points. A function is an entry point when it is named main (with or without an owner) or has an attribute whose text contains command, get( or post(. Entry files are lib.rs and main.rs at the package root or under src/, and files under src/bin/, benches/ or examples/.
Other flags. is_async is set when the function text contains async fn . A method is marked as mutating when it takes mut self or &mut self. Parameters are the parameter nodes only, so self is never counted.
TypeScript and JavaScript
Section titled “TypeScript and JavaScript”Grammars: tree-sitter-typescript (TypeScript and TSX) and tree-sitter-javascript. Extractor: crates/codeknife-lang/src/typescript/.
Only top-level statements and the contents of export statements are examined.
| Construct | Extracted as |
|---|---|
function f() {} |
Function |
const f = () => {}, const f = function () {} (also let, var) |
Function named after the variable |
class C {} |
Class |
class method, including constructor |
Method with owner C |
class field (x = 1, private y: T, #z) |
Field with owner C |
interface I {} |
Interface; its property names are recorded as its field list |
type T = ... |
Struct |
class C implements I, J |
an implements reference from C to each of I and J |
it(...), test(...), it.only(...), test.only(...), it.concurrent(...) |
Test (see below) |
import ... from "x", export ... from "x" |
an import of x |
require("x") as a statement |
an import of x |
Not extracted: enum, abstract class, namespace and module blocks (and everything inside them), declare statements, plain constants (export const VERSION = "1.0"), CommonJS export assignments (exports.f = function () {}), object-literal methods, functions nested inside other functions, and extends clauses. A class field whose value is an arrow function is a Field, not a method, and its body is not analysed. Interface method signatures are not recorded.
Visibility. A top-level declaration is public when it is declared inside an export statement (export function, export default function, export class, export const), and private otherwise. A separate export list does not count: const f = ...; export { f }; leaves f private. Class members are private when their name starts with # or they have a private or protected modifier, and public otherwise, whether or not the class itself is exported.
Imports. The import source string is recorded. Before that, CodeKnife tries the package’s tsconfig.json paths and baseUrl aliases and records the mapped path instead. An import is external unless it starts with ., @/ or ~/, or was mapped by an alias. require("x") is only seen when the call is part of a top-level expression statement. const x = require("x") is not recorded, and neither is dynamic import("x").
Calls and field reads. Every call_expression inside a function body is recorded, split at the last . (api.client.get() has qualifier api.client, name get). this.x is stored as a field the method touches. Other member reads obj.x become field-read references, except when the member expression is itself the called function.
Tests. Inside any top-level expression statement, CodeKnife looks for calls whose callee text is exactly it, test, it.only, test.only or it.concurrent and whose second argument is an arrow function or function expression. It searches nested calls, so tests inside describe(...) blocks are found. The test’s name is the first argument with quotes stripped. it.skip, test.skip, test.each(...)(...) and describe itself do not create tests. Test callbacks are analysed for assertions but do not record call references, so a TypeScript or JavaScript test never shows up as a caller or covering test in Blast Radius.
Test files are paths that contain __tests__/, .test. or .spec., start with test/, tests/ or bench/, or contain /bench/ or /benches/. A tests/ directory below the repository root (for example web/tests/x.ts) does not make a file a test file.
Entry points. No function is marked as an entry point. Entry files are files whose module name (file name without extension) is index, main, app, server, page, layout, route, loading or error; files whose path starts with or contains routes/ or pages/ as a directory; and files whose module name ends with .config or whose path contains .config..
Other flags. is_async is set when the function, method or arrow text starts with async . A method is mutating when its body assigns to, or increments, something starting with this.. A parameter is a boolean parameter when its type annotation is exactly boolean.
Example run on a TypeScript file with an interface, a type alias, an enum, an abstract class, a class with private members, a non-exported function, an export { notExported } list, a default export and a namespace:
codeknife reuse src --top 20 --no-cache --format humanCODEKNIFE reuse query="src" scanned=12 matches=12[1] score=45.8 fn `src/util/num/clamp` (src/util/num.ts:1, vis=public, callers=1)...[3] score=45.5 interface `src/shapes/Shape` (src/shapes.ts:3, vis=public, callers=0)...[4] score=45.5 struct `src/shapes/Pair` (src/shapes.ts:7, vis=public, callers=0) sig: export type Pair =...[5] score=45.5 class `src/shapes/Circle` (src/shapes.ts:18, vis=public, callers=0)...[6] score=45.5 method `src/shapes/Circle/constructor` (src/shapes.ts:27, vis=public, callers=0)...[8] score=45.5 fn `src/shapes/defaultFn` (src/shapes.ts:48, vis=public, callers=0) sig: export default function defaultFn()...[11] score=36.2 method `src/shapes/Circle/reset` (src/shapes.ts:35, vis=private, callers=0) sig: private reset(): void[12] score=36.2 fn `src/shapes/notExported` (src/shapes.ts:44, vis=private, callers=0) sig: const notExported = function (x: number)...Color (enum), Base (abstract class) and Geo.unit (namespace) do not appear. Pair is a struct. notExported stays private despite the export list.
Python
Section titled “Python”Grammar: tree-sitter-python. Extractor: crates/codeknife-lang/src/python/.
Module-level statements and class bodies are examined, including decorated definitions.
| Construct | Extracted as |
|---|---|
def f(): at module level |
Function |
def m(self): in a class body |
Method with the class as owner |
def test_x(): meeting the test rule |
Test |
class C: |
Class |
| a class nested in a class body | Class with no owner |
x: int or x: int = 3 in a class body |
Field of the class |
self.x read or written in any method of the class |
Field of the class |
import a.b, c |
one import per module |
from m import x, y |
one import of m |
from . import x, y (only dots before import) |
one import per name: .x, .y |
Not extracted: module-level variables and constants, lambdas assigned to names, functions nested inside functions, untyped class attributes (ordering = "owner"), and __all__.
Visibility. Functions and methods whose name starts with one underscore are private. Names starting with two underscores are public, so both __init__ and a name-mangled __secret are public. Classes and fields are private whenever the name starts with _.
Imports. An import is external unless it is relative or its top-level package is in this built-in list: os, sys, re, json, math, time, datetime, pathlib, typing, collections, itertools, functools, dataclasses, enum, abc, asyncio, subprocess, logging, unittest, io, csv, hashlib, secrets, uuid, random, tempfile, shutil, copy, contextlib, urllib, http, sqlite3, argparse, __future__. Any other standard-library module (for example socket) is treated as external. For from m import x, only m is recorded; the names after import are ignored unless m is only dots.
Calls and field reads. Every call node in a function body is recorded, split at the last .. self.x is stored as a field the method touches; other attribute reads become field-read references.
Tests. A function is a test when its name starts with test_ and either the file is a test file, or it is a method of a class whose name starts with Test. So def test_x() at module level in helpers.py is not a test, but TestThing.test_x in the same file is. Test files have a file name that starts with test_ or ends with _test.py, or a path that starts with tests/ or contains /tests/. conftest.py is not special.
Entry points. Functions and methods named main are entry points. Entry files are __init__.py, __main__.py, and any file whose text contains if __name__ == "__main__" or if __name__ == '__main__'.
Other flags. is_async is set for async def. A method is mutating when it assigns to or augments something starting with self.. A parameter is boolean when its annotation is exactly bool. self and cls are not counted as parameters.
Docstrings. Tree-sitter parses docstrings as string expressions, not comments, so CodeKnife does not record them as comments and counts them as code lines.
Example run on app/models.py (a class with __init__, a keyword-only parameter, _audit, __repr__, __mangled, a nested Meta class, a @dataclass class, async def fetch, _private_helper, main, a constant and a lambda):
codeknife reuse app --top 20 --no-cache --format humanCODEKNIFE reuse query="app" scanned=13 matches=13...[3] score=45.5 class `app.models.Account` (app/models.py:8, vis=public, callers=0)...[7] score=45.5 method `app.models.Account.__mangled` (app/models.py:27, vis=public, callers=0)...[8] score=45.5 class `app.models.Meta` (app/models.py:30, vis=public, callers=0)...[9] score=45.5 class `app.models.Point` (app/models.py:35, vis=public, callers=0)...[10] score=45.5 fn `app.models.fetch` (app/models.py:40, vis=public, callers=0)...[12] score=36.2 method `app.models.Account._audit` (app/models.py:21, vis=private, callers=0)...[13] score=36.2 fn `app.models._private_helper` (app/models.py:44, vis=private, callers=0)...Meta is listed as app.models.Meta, not app.models.Account.Meta. The constant MAX_SIZE and the lambda square are absent.
Grammar: tree-sitter-go. Extractor: crates/codeknife-lang/src/go_lang/.
Only top-level declarations are examined.
| Construct | Extracted as |
|---|---|
func F() |
Function |
func (r *T) M() |
Method with owner T (the * is removed) |
func TestX(t *testing.T) in a _test.go file |
Test |
type T struct {...} |
Struct, plus a Field for each named field |
type I interface {...} |
Interface |
any other type T U (for example type ID string) |
Struct |
const X = 1, const ( ... ) |
one Const per name |
import "p", import ( ... ) |
one import per path |
Not extracted: type aliases (type A = B), var declarations, interface method lists, embedded struct fields, and function literals. For a grouped field such as A, B int, only the first name is recorded as a field.
Visibility. A name starting with an ASCII uppercase letter is public. Every other name is module, not private.
Imports. An import is internal when it equals the module path from go.mod or starts with it plus /. Otherwise it is external when it contains a . (for example github.com/google/uuid). Standard-library paths such as fmt or net/http are neither: they are recorded as non-external imports that never resolve.
Calls and field reads. Every call_expression in a body is recorded, split at the last ., so store.New() has qualifier store and name New. For methods, reads through the receiver variable (s.count) are stored as fields the method touches; other selector reads become field-read references.
Tests. A function is a test when the file name ends with _test.go and the function name starts with Test. Benchmark, Example and Fuzz functions are flagged as test code (because they are in a test file) but are not Test items, so they get no assertion analysis.
Entry points. A function named main with no receiver is an entry point. A file is an entry file when its path ends with main.go (a plain suffix match, so domain.go also matches), when it sits directly in the go.mod directory, or when it is not a test file and its package clause (searched in the first 30 lines) is anything other than main. In practice every non-test file of a library package is an entry file.
Other flags. Go functions never get is_async. A method is mutating only when it has a pointer receiver and assigns to, or increments, something through the receiver variable. A parameter is boolean when its type is exactly bool. Grouped parameters (a, b, c int) count once per name. A variadic parameter (rest ...int) is not counted.
Example run on a package with a constant block, type ID string, an interface, a struct with an embedded field, a type alias, a var, methods with pointer and value receivers, and a lowercase helper:
codeknife reuse store --top 20 --no-cache --format humanCODEKNIFE reuse query="store" scanned=8 matches=8[1] score=52.6 fn `example.com/shop/store/New` (store/store.go:33, vis=public, callers=2) sig: func New() *Store...[3] score=52.0 struct `example.com/shop/store/Store` (store/store.go:23, vis=public, callers=0)...[5] score=45.5 struct `example.com/shop/store/ID` (store/store.go:17, vis=public, callers=0)...[6] score=45.5 interface `example.com/shop/store/Reader` (store/store.go:19, vis=public, callers=0)...[7] score=41.2 fn `example.com/shop/store/helper` (store/store.go:46, vis=module, callers=0)...[8] score=17.4 fn `example.com/shop/cmd/server/main` (cmd/server/main.go:5, vis=module, callers=0)...New shows two callers. One is real (cmd/server/main.go). The other is helper, which calls uuid.New() from an external package. See name collisions.
Capability matrix
Section titled “Capability matrix”| Capability | Rust | TypeScript / JavaScript | Python | Go |
|---|---|---|---|---|
| Free functions | yes | yes, including arrow and function expressions bound to a variable | yes | yes |
| Methods with owner | impl blocks |
class bodies | class bodies | receivers |
| Classes or structs | struct |
class, type (as struct) |
class |
type ... struct and other named types |
| Enums | yes | no | no | no |
| Traits or interfaces | trait (no members) |
interface (property names only) |
no | interface (no members) |
| Type aliases | no | yes, as Struct |
no | no |
| Fields | named struct fields | class fields | annotated class attributes and self.x |
named struct fields |
| Constants | const, static |
no | no | const |
| Implements references | impl Trait for T |
implements |
no | no |
| Visibility levels used | private, module, public | private, public | private, public | module, public |
| Test functions | test attributes | it / test calls |
test_ rules |
Test* in _test.go |
| Test bodies record calls | yes | no | yes | yes |
| Entry-point functions | main, route or command attributes |
none | main |
main without receiver |
async flag |
yes | yes | yes | no |
| Boolean parameter type | bool |
boolean |
bool |
bool |
| Return-value mutation | yes | yes | yes | no |
| Arithmetic-operator mutation | yes | yes | no | yes |
Default test commands
Section titled “Default test commands”When Mutation Testing runs without --test-command, it counts files per language, takes the language with the most files, and asks that language for a default test command:
| Language | Command |
|---|---|
| Rust | cargo test |
| TypeScript and JavaScript | npx vitest run if the root package.json text contains vitest, else npx jest if it contains jest, else npm test. No root package.json means no default. |
| Python | pytest -q |
| Go | go test ./... |
Comments and suppressions
Section titled “Comments and suppressions”CodeKnife records every tree-sitter node of kind comment (TypeScript, JavaScript, Python, Go), line_comment or block_comment (Rust). For each comment it stores its lines, text, style, whether it trails code on the same line, the enclosing function if any, the next non-comment sibling node, and whether that node is an unsafe block.
- Style. Text starting with
///,//!or/**is a doc comment. Other text starting with/*, or a Rustblock_comment, is a block comment. Everything else, including every Python#comment, is a line comment. - Merging. Consecutive doc comments on adjacent lines that share a
///or//!prefix, neither trailing code, are meant to merge into one comment. - Suppressions. Any comment line containing one of these markers is recorded as a suppression:
@ts-ignore,@ts-nocheck,@ts-expect-error,type: ignore,pyright: ignore(kind safety) andeslint-disable,noqa,pylint: disable,nolint(kind style). Separately, every source line in any language that starts with#[allow(or#![allow(is a suppression; it is kind safety when the line containswarnings,clippy::all,dead_codeorunused, and style otherwise.
The Comments blade turns these records into findings. dossier shows the counts per file:
codeknife dossier --no-cache --target mod.py --format json... "metrics_summary": "lang=python lines=7 code=4 comments=2 suppressions=1",...That file has a module docstring, a # comment, a function docstring and a trailing # noqa comment. Only the two # comments count, and the docstrings count as code lines. A code line is any non-empty line that does not start with # (Python) or // (every other language) after trimming.
Boundary tokens
Section titled “Boundary tokens”While parsing, CodeKnife also scans string literals and some calls for tokens that link code across languages. Blast Radius uses them.
| Token | Rule |
|---|---|
| HTTP route | a string literal (quotes stripped) that starts with /, is longer than 2 characters, has no space and does not start with // |
| SQL table | the word after FROM, INTO, UPDATE or JOIN (case-insensitive, with spaces) in a string literal, lowercased |
| Environment variable | process.env.NAME where NAME is at least 2 characters of uppercase letters, digits or _; or the first quoted argument of env::var(", std::env::var(", os.Getenv(", os.getenv(" or os.environ.get(" |
The model also defines wire-key and feature-flag token kinds, but no language extractor produces them.
The parse cache
Section titled “The parse cache”When a command runs without --no-cache, extraction results are cached in .codeknife/parse-cache.json, keyed by file path. An entry is reused only when the file’s xxh3 content hash, its language and a hash of its package settings (name, directory, library-root flag, baseUrl and paths) all match. The whole cache is discarded when its format version or the CodeKnife version changes. Entries for files that no longer exist are pruned. Linking always runs fresh, so cross-file results never come from the cache. The .codeknife Directory covers the file in full.
Errors and exit codes
Section titled “Errors and exit codes”Language support has no flags and no exit codes of its own. It never fails a command: unreadable files, files that are not UTF-8, generated files and files the extractor cannot handle are skipped without a message. If you expect a file in the results and it is missing, check the extension, the skip rules above and your exclude patterns.
Also available via
Section titled “Also available via”The extracted model is visible through codeknife reuse (MCP tool codeknife_reuse), codeknife dossier (MCP tool codeknife_dossier) and codeknife blast (MCP tool codeknife_blast). See MCP Tools.