AutoReview Pre-check
Use only when user has a draft in hand and wants a verdict BEFORE writing to disk. For "list rules that apply to this path", use autoreview:context instead — it's free.
Cross-platform. Snippets below use bash-style env-var syntax (
${CLAUDE_PLUGIN_ROOT}). Translate to your shell on PowerShell ($env:CLAUDE_PLUGIN_ROOT) or cmd (%CLAUDE_PLUGIN_ROOT%). The plugin requires Node ≥22 — that's the only assumed binary.
When NOT to use
- User said "edit this file". Just run
autoreview:contextto see rules, then write. Precheck is overkill for routine edits. - User is about to commit an already-written file. Use
autoreview:reviewinstead. - User already has the content on disk. Use
autoreview:review --files <path>.
Steps
Save the draft to a temp file. Resolve the platform tmp dir cross-platform:
node -e "console.log(require('os').tmpdir())"Then write the draft into that dir under a unique name (e.g.
<tmpdir>/ar-draft-<timestamp>.ts). Any writable path is fine —/tmp/...on POSIX,%TEMP%\...on Windows; the Node call returns the right one for whichever you're on.Pick a rule that you suspect is the strictest/most relevant for the target path. Use
autoreview:contextfirst to list applicable rules.Run the reviewer test:
node ${CLAUDE_PLUGIN_ROOT}/scripts/bin/reviewer-test.mjs \ --rule <rule-id> --file <target-path> --content-file <tmpdir>/ar-draft-<timestamp>.tsWhere
<target-path>is the logical destination (e.g.src/api/users.ts) and--content-fileis where the draft actually lives. The reviewer automatically resolves the rule's tier fromconfig.yaml— no provider flags needed. To get file:line reasoning, temporarily settiers.<name>.mode: thinkingin.autoreview/config.yamlbefore running, then revert.Parse the
=== RESULT ===JSON. Ifsatisfied: false, revise the draft and re-run. Ifsatisfied: true, commit the write to<target-path>.
For multiple rules, run once per rule. Each call is ~1 LLM invocation at the rule's configured tier.