Blocks shell commands you pick in /config: Cloudflare cf writes, attribution lines in commits and PRs, claude/ branch names. All rules start off

Blocks shell commands you choose never to let Claude run. Claude gets the reason back and can retry the right way.
Every rule starts off. After you install, the plugin blocks nothing until you turn a rule on in /config.
/config option | Blocks | Claude is told |
|---|---|---|
cfWrites | cf deploy, cf migrate, cf init | Ask the user to run them. |
attribution | git commit, gh pr, gh issue with a Co-Authored-By or "Generated with Claude" line | Remove the line and retry. |
claudeBranches | git checkout -b, git switch -c, git branch, git push naming a claude/ branch | Use a purpose prefix such as fix/ or chore/. |
Turn a rule on in /config, or in ~/.claude/settings.json:
"pluginConfigs": {
"guardrails@claude-code-mods": {
"options": { "cfWrites": true, "attribution": true, "claudeBranches": true }
}
}
The attribution rule is a backstop. To stop Claude Code from adding attribution in the first place, set Claude Code's own top-level "attribution": false in settings.json.
Reading credential files is secret-guard's job.
To block another command, use a permission deny rule in settings.json. It needs no plugin:
"permissions": { "deny": ["Bash(npm publish:*)"] }
git commit -F file, shell aliases and scripts get through. Use permission deny rules where you need a hard guarantee.claude plugin marketplace add arasovic/claude-code-mods
claude plugin install guardrails@claude-code-mods
Restart Claude Code, then turn on the rules you want in /config.
claude plugin validate .
claude plugin test .
../typecheck.sh guardrailshooks/register.ts 21 lines1import type { PluginOptions, Register } from 'claude-code'
2
3// Commands refused on their text, each behind its userConfig toggle. Credential reads are secret-guard's.
4const RULES = [
5 { option: 'cfWrites', re: /\bcf\s+(deploy|migrate|init)\b/, why: 'cf deploy, migrate and init are blocked; ask the user to run them.' },
6 { option: 'attribution', re: /\b(git\s+commit|gh\s+(pr|issue))\b[\s\S]*(Co-Authored-By|Generated with \[?Claude)/i, why: 'Remove the Co-Authored-By / tool-attribution line and retry.' },
7 { option: 'claudeBranches', re: /\bgit\s+(checkout\s+-b|switch\s+-c|branch|push)\b[^|;&]*(?:[\s:+]|refs\/heads\/)claude\//, why: 'Branch names may not start with claude/; use a purpose prefix such as fix/ or chore/.' },
8]
9// ponytail: matches command text only; `git commit -F file`, aliases and scripts slip through. Permission deny rules for hard guarantees.
10
11export const forbiddenReason = (command: string, options: PluginOptions) =>
12 RULES.find(r => options[r.option] === true && r.re.test(command))?.why
13
14export const register: Register = (on, options) => {
15 if (!RULES.some(r => options[r.option] === true)) return
16 on('tool.call', { tool: 'Bash' }, ($, e, next) => {
17 const reason = forbiddenReason(e.command, options)
18 return reason ? { deny: `${$.plugin.name}: ${reason}` } : next(e)
19 })
20}
21