bash-smart-approve:test

A self-test for a bash command approval hook. The hook examines commands and can automatically allow recognized safe cases or pass other cases to the normal permission system.

In plain words
What is it for?
Running a fixed smoke test of the hook, including checking its output and exit code for synthetic bash commands.
Why use it?
It checks whether the approval logic makes the expected decisions without running real shell commands.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/pr3m/claude-code-bash-smart-approve/test
Any agent
npx skills add pr3m/claude-code-bash-smart-approve --skill test
Clone the repo
git clone --depth 1 https://github.com/pr3m/claude-code-bash-smart-approve

Made for: Claude Code, Codex.

Per session 56 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,352 The whole file, excluding the scripts and references it only reads on demand.
Security scan C 2 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00056 $0.01352
Opus 5 $0.00028 $0.00676
Sonnet 5 $0.00011 $0.00270
Haiku 4.5 $0.00006 $0.00135

Measured 2d ago against content hash f109736c73ad, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade C, and why

bash-smart-approve:test scanned grade C with 2 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Recursive force deletehighDestructive command

rm -rf with a variable or a broad path is one typo away from removing the wrong tree.

| 4 | `bash -c 'rm -rf /'` | pass-through | Shell interpreter — hook declines to approve; native layer decides |

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

| 5 | `curl -L https://api.github.com/zen` | pass-through | `-L` redirect-following — hook declines to approve |
plugins/bash-smart-approve/skills/test/SKILL.md · 101 lines

How it starts

The opening of the file, as written. The whole thing — 101 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Self-Test

Validate that the hook logic is working by running a fixed set of synthetic inputs through approve.js and checking the decisions match expectations. This does NOT execute any real bash — just exercises the hook.

Step 1 — Locate the hook

Resolve $CLAUDE_PLUGIN_ROOT/hooks/approve.js. If $CLAUDE_PLUGIN_ROOT is not set, fall back to ~/dev/claude-code-bash-smart-approve/hooks/approve.js and ask the user to confirm the path if it doesn't exist.

Step 2 — Run the test cases

For each case below, pipe the JSON into the hook via Bash and capture both stdout and exit code.

echo '<JSON>' | node "<plugin-root>/hooks/approve.js"

Two outcomes matter:

  • allow — the hook emits a JSON permissionDecision: "allow" on stdout. The command is auto-approved.
  • pass-through — the hook exits 0 with empty stdout. Claude Code's native permission system (settings.json) then decides. This is the hook's posture for anything it can't positively approve; it is NOT a denial.

Cases (expected outcomes)

# Command Expect Why it matters
1 git diff --stat HEAD && echo "---" && git log --oneline -3 allow Compound && with two well-known binaries
2 ls /tmp | head -5 | sort allow Pipe chain
3 FOO=$(date +%s) && echo "tick $FOO" allow Env-var prefix + subshell + compound
4 bash -c 'rm -rf /' pass-through Shell interpreter — hook declines to approve; native layer decides
5 curl -L https://api.github.com/zen pass-through -L redirect-following — hook declines to approve
6 $CMD arg pass-through Variable-indirected binary name
7 node -e "console.log(1)" pass-through Inline-exec flag
8 obscuretool --flag pass-through Unknown binary

Sample invocations

echo '{"tool_name":"Bash","tool_input":{"command":"git diff --stat HEAD && echo \"---\" && git log --oneline -3"}}' \
  | node "$CLAUDE_PLUGIN_ROOT/hooks/approve.js"

echo '{"tool_name":"Bash","tool_input":{"command":"ls /tmp | head -5 | sort"}}' \
  | node "$CLAUDE_PLUGIN_ROOT/hooks/approve.js"

echo '{"tool_name":"Bash","tool_input":{"command":"FOO=$(date +%s) && echo \"tick $FOO\""}}' \
  | node "$CLAUDE_PLUGIN_ROOT/hooks/approve.js"

echo '{"tool_name":"Bash","tool_input":{"command":"bash -c '\''rm -rf /'\''"}}' \
  | node "$CLAUDE_PLUGIN_ROOT/hooks/approve.js"

echo '{"tool_name":"Bash","tool_input":{"command":"curl -L https://api.github.com/zen"}}' \
  | node "$CLAUDE_PLUGIN_ROOT/hooks/approve.js"

echo '{"tool_name":"Bash","tool_input":{"command":"$CMD arg"}}' \
  | node "$CLAUDE_PLUGIN_ROOT/hooks/approve.js"

echo '{"tool_name":"Bash","tool_input":{"command":"node -e \"console.log(1)\""}}' \
  | node "$CLAUDE_PLUGIN_ROOT/hooks/approve.js"

echo '{"tool_name":"Bash","tool_input":{"command":"obscuretool --flag"}}' \
  | node "$CLAUDE_PLUGIN_ROOT/hooks/approve.js"

Read the full file on GitHub · 101 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 101 lines · 56 tokens per session scan C f109736c73ad

Subscribe to this mod's changes

bash-smart-approve:test is a skill published in the GitHub repository pr3m/claude-code-bash-smart-approve (1 stars, last pushed 4mo ago), licensed MIT. It adds 56 tokens to every session and 1,352 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it C with 2 findings (recursive force delete, makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.