CLI reference
One binary. Every command takes a path or a glob and a config; everything else is a flag. Exit codes follow the rule severity in the config.
Everything runs through one command. The first positional argument is the subcommand; everything after it is a file path, a glob, or a flag. No global config flag. If you need a non-default config, pass --config.
$ driftlog <command> [path|glob] [flags]
driftlog check
Run all rules. The default.Scans the repo (or the path you pass) and reports rule violations. Exits 0 on a clean run or one with only warnings, 1 on any error-severity violation.
$ driftlog check$ driftlog check src/$ driftlog check --strict --json > drift.json
$ driftlog checkLoading .driftlog.yamlParsing 2,847 filesApplying 12 rules2 errors, 1 warningDrift score 71/100
driftlog fix
Apply autofixes to the repo.Coming in v1.1Runs the same scan as check, then applies any safe rewrite the rule author marked as autofixable. Prints a diff before writing; pass --yes to skip the prompt in CI.
driftlog fix today prints a placeholder message and exits successfully. Documented flags below are accepted as no-ops so scripts written against v1.1 will not error.$ driftlog fix$ driftlog fix --rule layers.app --yes$ driftlog fix --dry-run
$ driftlog fixApplying autofix to 2 filesui/Cart.tsxui/Review.tsxRe-running checkAll rules passing.
driftlog score
Print the current drift score.Aggregates rule pass-rates over time into a single 0-100 number. Useful as a one-line PR comment or an SLO probe.
$ driftlog score$ driftlog score --window 30d --json
$ driftlog scoreRepo: acme/checkout-serviceScore: 87/100Trend: +22 over 30 daysTop rule: layers.app (93%)Weakest: cycles.src (68%)
driftlog init
Drop a starter .driftlog.yaml.Inspects the repo, guesses a layer ordering from your folder structure, and writes a minimal config you can sharpen. Refuses to overwrite an existing config unless you pass --force.
$ driftlog init$ driftlog init --force --layers ui,domain,infra
$ driftlog initScanning repoDetected ui/, domain/, infra/Wrote .driftlog.yaml
driftlog rule
Manage rules in the config.Subcommands for adding, listing, and testing rules without hand-editing the YAML. Useful when you are bootstrapping a config across many repos.
$ driftlog rule list$ driftlog rule new layer$ driftlog rule test layers.app
$ driftlog rule listlayers.app error src/**boundary.billing error billing/**, catalog/**forbidden.no-moment warn src/**
driftlog ci
Wire up CI in one line.Generates a CI config tailored to your provider and writes it in place. Always idempotent; rerunning produces the same file.
$ driftlog ci github$ driftlog ci gitlab --strict$ driftlog ci circle
$ driftlog ci githubWrote .github/workflows/driftlog.ymlAdd this to repo settings -> branch protection
Pre-commit hook
A pre-commit hook keeps drift from landing on a branch in the first place. Driftlog doesn't ship its own git-hook installer — wire it up with husky or lefthook. The recommended command is driftlog check --changed-only so the hook scans only files in the staged commit, not the whole tree — a typical mid-size repo runs in well under a second that way.
# husky/.husky/pre-commitdriftlog check --changed-only
Make it opt-in for the team. Some folks like a tight inner loop; others want to commit fast and rely on CI to catch issues. The hook should be installable, never mandatory — every team member runs pnpm exec husky install (or the lefthook equivalent) themselves. A repo-level setting that force-installs hooks onpnpm install tends to breed workarounds.
If a developer's commit is genuinely time-sensitive (hotfix on a Friday), they can bypass the hook with git commit --no-verify. CI still catches the violation on push — the hook is the cheap fast layer, not the gate.
Global flags
These flags work on every command above.