CLI reference
Run it with no arguments and it scans the current directory against the default threshold of 15, printing nothing and exiting 0 if everything is under it.
npx bonsai-lint --over 15 src/Every flag
Section titled “Every flag”| Flag | Value | Default | What it does |
|---|---|---|---|
paths | positional | . | Files or directories to scan. |
--over | N|LANG=N | none | Complexity threshold; 15 for everything, or php=15,typescript=20 per language. |
--all | none | none | Print every unit, not just those above the threshold. |
--format | FORMAT | text | Output format; json is the machine-readable form editors consume. One of text, json. |
--write-baseline | none | none | Record current findings as accepted, so only later regressions fail. |
--baseline | PATH | none | Use one baseline file, keyed from the workspace root, instead of each domain's own. |
--lang | ID | none | Restrict the scan to these languages (php, typescript, vue). |
--domain | NAME | none | Restrict the scan to one named domain. |
--config | PATH | none | Start config discovery here instead of the first scanned path. |
--no-toplevel | none | none | Do not score code outside any function. |
--stdin | none | none | Read one file's contents from stdin, so unsaved editor buffers can be analysed. |
--stdin-path | PATH | none | The path the stdin contents should be attributed to. |
--jobs, -j | N | 0 | How many files to score at once; 0 asks the machine. |
Worked examples
Section titled “Worked examples”bonsai-lint --domain web # one declared domain onlybonsai-lint --baseline PATH . # one baseline file for the whole repo, wherever you choosebonsai-lint --config packages/web src/ # discover config from here, not from the first pathbonsai-lint --no-toplevel src/ # skip code outside any functionbonsai-lint --stdin --stdin-path src/a.php < buffer # score an unsaved buffer as that filebonsai-lint --jobs 4 . # cap the workers; 0 or absent uses every coreExit codes
Section titled “Exit codes”| Code | Meaning |
|---|---|
0 |
Nothing over the threshold. A clean run prints nothing. |
1 |
Something is over the threshold, or the scan could not be trusted: an unreadable path, or no supported files found. |
2 |
Usage error, from the argument parser. |
The second row is the one worth internalising. A gate that cannot read what it was pointed at must not report success, so an unreadable file fails the run rather than quietly shrinking the set of things checked.