Skip to content

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.

Terminal window
npx bonsai-lint --over 15 src/
FlagValueDefaultWhat it does
pathspositional.Files or directories to scan.
--overN|LANG=NnoneComplexity threshold; 15 for everything, or php=15,typescript=20 per language.
--allnonenonePrint every unit, not just those above the threshold.
--formatFORMATtextOutput format; json is the machine-readable form editors consume. One of text, json.
--write-baselinenonenoneRecord current findings as accepted, so only later regressions fail.
--baselinePATHnoneUse one baseline file, keyed from the workspace root, instead of each domain's own.
--langIDnoneRestrict the scan to these languages (php, typescript, vue).
--domainNAMEnoneRestrict the scan to one named domain.
--configPATHnoneStart config discovery here instead of the first scanned path.
--no-toplevelnonenoneDo not score code outside any function.
--stdinnonenoneRead one file's contents from stdin, so unsaved editor buffers can be analysed.
--stdin-pathPATHnoneThe path the stdin contents should be attributed to.
--jobs, -jN0How many files to score at once; 0 asks the machine.
Terminal window
bonsai-lint --domain web # one declared domain only
bonsai-lint --baseline PATH . # one baseline file for the whole repo, wherever you choose
bonsai-lint --config packages/web src/ # discover config from here, not from the first path
bonsai-lint --no-toplevel src/ # skip code outside any function
bonsai-lint --stdin --stdin-path src/a.php < buffer # score an unsaved buffer as that file
bonsai-lint --jobs 4 . # cap the workers; 0 or absent uses every core
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.