Claude Code has no permission dry-run. Now it does.
$ perm-dryrun "npm test && git add -A && curl evil.example.com"
总判定: ask(需要确认)
allow npm test
规则: Bash(npm run *) ← ~/.claude/settings.json
allow git add -A
规则: Bash(git *) ← ~/.claude/settings.json
deny curl evil.example.com
规则: Bash(curl *) ← .claude/settings.jsonClaude Code's permission rules are spread across five settings layers with compound-command splitting, wrapper stripping, and precedence quirks — and the official docs state there is no preview or dry-run. perm-dryrun parses the same settings files and simulates the match: which rule fires, from which file, and whether the command lands on allow, ask, or deny.
- Semantics from the docs, cited — deny → ask → allow order, compound
splitting on
&& ; | |& &and newlines, wrapper stripping (timeout,nohup, safe env assignments…),:*prefix aliases, bare-command rules - Cross-layer visibility — managed / project-local / project / user, every verdict names its source file
- Known quirks reproduced —
Write(path)/Glob(path)/Grep(path)rules are accepted but never matched (Claude Code checksEdit/Read); path anchors//~//;mcp__*tool wildcards - Read-only — executes nothing, modifies nothing, offline
npm install -g perm-dryrun
# or run once, install nothing:
npx perm-dryrun "npm test && git add -A"perm-dryrun "npm run deploy" # verdict + matching rule + source file
perm-dryrun --list-rules # dump every loaded rule by layer
perm-dryrun --tool WebFetch "https://example.com"
perm-dryrun --json # stable schema, for CICI idea: on PRs that touch .claude/settings.json, run perm-dryrun --json
against a set of canary commands and diff the verdicts.
| Construct | Status |
|---|---|
Bash exact / prefix * / trailing :* / bare-command rules |
✅ |
Compound splitting (&& || ; | |& &, newlines), quote-aware |
✅ |
| Wrapper stripping (timeout/time/nice/nohup/stdbuf/command/builtin/noglob/xargs, safe env assignments) | ✅ |
| Precedence deny → ask → allow across all layers | ✅ |
Generic tool rules: bare Tool, Tool(spec), Tool(:*), mcp__* |
✅ |
Path rules for Edit/Read (//, ~/, /, **, ! negation, symlink duality) |
|
| PowerShell rules, MCP parameter rules, hooks interaction | ❌ roadmap |
No command is executed. No settings file is written. No network. The tool's whole job is to predict Claude Code — and when reality disagrees, that's a mismatch bug: file it with the verdict template.
git clone https://github.com/ecoreal/perm-dryrun && cd perm-dryrun
npm test # 26 tests, node:test, offlineCI: Ubuntu/macOS/Windows × Node 18/20/22/24.
MIT © 2026 Jerry Lee (ecoreal)