lawbook
v0.4.0
Published
Checks code standards with repeatable rules and LLM decisions
Readme
lawbook
Lawbook checks a directory against the rules in its lawbook.yaml: regular
expressions that files must or must not match, paths that must or must not
exist, and standards written in prose that a model judges file by file or as a
set. A failing rule names the file and the reason, and the exit code says
whether the check passed.
npm install --global lawbook
lawbook init # writes a starter lawbook.yaml
lawbook check # exit 0 pass, 1 a rule failed, 2 could not run
lawbook test # judges each standard rule's example filesversion: 1
rules:
- id: no-console
files: ["src/**/*.ts"]
forbid: 'console\.(log|debug)\('
- id: has-readme
exists: README.md
- id: errors-are-actionable
files: ["src/**/*.ts"]
standard: Every error message says what went wrong and what to do next.standard rules run the installed Claude Code CLI by default, so a Claude
subscription pays; provider: codex or provider: kiro runs the Codex or
Kiro CLI instead. check --no-llm skips them. The
docs describe the
configuration format,
LLM rules,
providers, the
commands, and the
exit codes. The
clean-code example, also at
examples/clean-code.lawbook.yaml, is a drop-in config built from ten
software engineering books.
Agent skill
skills/lawbook/SKILL.md teaches a coding agent such as Claude Code to run
lawbook, read its findings, and write or tune a lawbook.yaml. Copy the
skills/lawbook directory into .claude/skills/ in a project, or into
~/.claude/skills/ for every project, and the agent picks it up.
Install
Lawbook needs Node.js 22.12 or newer.
npm install --global lawbookOr from a clone:
pnpm install
pnpm run build
npm install --global .Development
The project uses Node.js 24 and pnpm. Before submitting a change, run:
pnpm run lint
pnpm run typecheck
pnpm test
pnpm pack --dry-runCI also runs poly-crap with a
threshold of 5 and fails the build when a function is over it.
CLAUDE.md describes the layout and the rules the code follows.
The docs site lives in docs/. Run pnpm --dir docs install once, then
pnpm --dir docs run dev to serve it locally.
See CONTRIBUTING.md for contribution guidance, SECURITY.md for vulnerability reporting, and RELEASING.md for maintainer release steps.
License
MIT
