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 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 what editors read, github annotates pull requests. One of text, json, github.
--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.
--strict-baselinenonenoneFail when a baseline entry is looser than the code.
--langIDnoneRestrict the scan to these languages (php, typescript, vue, go, java, python).
--domainNAMEnoneRestrict the scan to one named domain.
--configPATHnoneStart config discovery here instead of the first scanned path.
--allow-no-filesnonenoneSucceed instead of failing when no supported file is found.
--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 --strict-baseline . # fail while the baseline accepts more than the code needs
bonsai-lint --format github . # annotate the pull request from GitHub Actions
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
bonsai-lint --allow-no-files a.d.ts gen.go # pass when none of the paths can be scored
Code Meaning
0 Nothing over the threshold. A clean run prints nothing.
1 Something is over the threshold, a strict baseline accepts more than the code needs, 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.