patdown
Standalone CLI that lints a tree against fuzzy rules in one markdown file. Wrap it as a hook, plugin, or extension.
The judge is swappable. The default backend uses Effect Decision / DecisionModel with TypeSafe; rules and CLI commands use a provider-neutral interface.
Install
npx patdown --help
pnpm add -D patdown
Requires Node.js >=22.22.2. The library entry is patdown; rule adapters import @patdown/rules. Optional agent packages: @patdown/pi (Pi write steering) and @patdown/claude (Claude Code Write/Edit hooks). See Pi write steering and Claude Code plugin.
For GitHub Actions, prefer the composite action over copy-paste yaml:
- uses: tyler-dot-earth/[email protected]
env:
TYPESAFE_API_KEY: ${{ secrets.TYPESAFE_API_KEY }}
See GitHub Actions. The action always runs the published CLI. Custom report shapes stay an embed of runPatdownCli with your own PatdownOutput layer (Custom output), not an action input.
Requirements
Node.js >=22.22.2 and pnpm 11.8.0. CI runs checks and built-CLI smoke tests on Node 22.22.2 and Node 24. Releases through v0.2.2 require Node >=24.18.0 and use #/ import aliases that Node 22 rejects.
Commands
From this repo, prefer the workspace script. It builds patdown through Turborepo (dependsOn: build) and then runs the CLI from your current directory:
pnpm -w patdown
pnpm -w patdown -- --rules ./rules.md
pnpm -w patdown -- --rules ./packs/typescript --verbose
pnpm -w patdown -- rules
pnpm -w patdown -- doctor
pnpm -w patdown -- ask "Is this markdown heading title case?" --input-text "# Hello World"
pnpm -w patdown -- ask "Is this urgent?" --input-text "ASAP" --verbose
pnpm -w patdown -- --yes-threshold 0.9
pnpm -w patdown -- --github-annotation warning
pnpm -w patdown -- --files src/cli.ts --files README.md
pnpm -w patdown -- --files src
pnpm -w patdown -- --files 'src/**/*.ts'
pnpm -w patdown -- --files-from changed.txt --verbose
pnpm -w patdown -- --max-judgments 100
git ls-files 'src' | pnpm -w patdown -- --files-from -
Do not run pnpm build by hand just to exercise the CLI, and do not use bare npx patdown against an unpublished branch (that installs the last registry version). After a release, consumers use npx patdown / pnpm add -D patdown as usual.
Default command lints from the current directory. rules prints what it loaded. doctor loads the same rules and checks TYPESAFE_API_KEY in this process without calling the judge. ask answers a yes/no question, no files involved. It prints yes or no; --verbose also shows a P(yes) shade bar, the cutoff, and how long the judge call took. The old --noul and --state flags have been replaced by a positional question and --input-text.
To judge piped output, use --stdin:
git diff --cached | pnpm -w patdown -- ask "Does this diff introduce debugging statements?" --stdin
printf 'ASAP: production is down\n' | pnpm -w patdown -- ask "Is this urgent?" --stdin
These send the piped content to the configured judge. Do not pipe secrets. --stdin reads UTF-8 text through EOF, preserving newlines; it cannot be combined with --input-text. Without either option, the input is an empty string. ask reports yes/no without treating yes as a failing exit status.
Walks up from cwd looking for AGENTS.PATDOWN.md. --rules skips that walk and uses the path you pass.
A leading --- frontmatter block may have one include key: a path, or a YAML list of paths, relative to the including file. It may also set github-annotation: for FAIL annotations in GitHub Actions. A directory loads every *.md except README.md (a pack). A markdown file loads that file's # rules. Included rules load first, then the local # rules. Duplicate titles fail the run. Cycles fail the run. A second include: key, unknown keys, and an unterminated fence fail the run. --rules still replaces the walk; if that file has frontmatter includes, they are followed. Pi uses the same loader, so includes work there too.
Adapters
The default rule source parses markdown. Swap it with a module that exports loadPatdownRules(override) (no effect import) or PatdownRuleSourceLive, an Effect Layer for PatdownRuleSource. Use the plain export when the app is on another Effect major.
pnpm -w patdown -- --adapter ./patdown-yaml-rules.js
Or in the nearest package.json walking up from cwd:
{
"patdown": {
"adapter": "./patdown-yaml-rules.js",
"yesThreshold": 0.9,
"githubAnnotation": "warning"
}
}
--adapter wins over package.json. --rules is still passed to the adapter as an override path.
import { PatdownRuleSource } from '@patdown/rules'
import { Effect, Layer } from 'effect'