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.
npx agentmods add skills/jkheadley/instar/command-guardnpx skills add JKHeadley/instar --skill command-guardgit clone --depth 1 https://github.com/JKHeadley/instarWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/skills/jkheadley/instar/command-guard)<a href="https://agentmods.dev/skills/jkheadley/instar/command-guard"><img src="https://agentmods.dev/badge/skills/jkheadley/instar/command-guard.svg" alt="Measured on agentmods" height="20"></a>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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.00076 | $0.02017 |
| Opus 5 | $0.00038 | $0.01009 |
| Sonnet 5 | $0.00015 | $0.00403 |
| Haiku 4.5 | $0.00008 | $0.00202 |
Grade C, and why
command-guard 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 3d 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.
description: Set up a PreToolUse hook in .claude/settings.json that blocks dangerous commands — rm -rf, force push, database drops, and others — before they execute. Teaches the pattern of safety hooks for any Claude Cod Makes network callslowCapability
Not a fault in itself. Listed so you know the mod talks to something, and to what.
- Commands that `cat`, `echo`, or `curl` files containing `SECRET`, `KEY`, `TOKEN`, `PASSWORD` to stdout How it starts
The opening of the file, as written. The whole thing — 240 lines — stays where its author put it; the contents beside it link to each section on GitHub.
command-guard — Block Dangerous Commands Before They Execute
Claude Code runs shell commands, edits files, and manages infrastructure with real consequences. Without guardrails, a misunderstood instruction or a hallucinated flag can delete data, corrupt history, or expose credentials. This skill installs a PreToolUse hook that blocks the most dangerous operations before they run.
No external tools required — this uses Claude Code's built-in hook system.
What Gets Blocked
The guard intercepts Bash tool calls and checks the command against a blocklist before execution. By default it blocks:
Irreversible deletions
rm -rfon non-temporary pathsgit clean -f(untracked file deletion)
Git history destruction
git push --force/git push -f(without explicit user confirmation)git reset --hardon shared branchesgit rebaseon pushed branches
Database operations
DROP TABLE,DROP DATABASE,TRUNCATEin SQLdb:reset,db:dropnpm/prisma scripts
Credential exposure
- Commands that
cat,echo, orcurlfiles containingSECRET,KEY,TOKEN,PASSWORDto stdout
Installation
Step 1: Create the hook script
mkdir -p .claude/hooks
Create .claude/hooks/command-guard.py:
#!/usr/bin/env python3
"""
command-guard.py — PreToolUse hook that blocks dangerous Bash commands.
Claude Code calls this before executing any Bash tool call.
Exit code 2 = block the command and show the message.
Exit code 0 = allow the command.
"""
import sys
import json
import re
import os
# Load the tool call input from stdin
try:
payload = json.load(sys.stdin)
except Exception:
sys.exit(0) # Can't parse — allow (fail open)
tool_name = payload.get('tool_name', '')
tool_input = payload.get('tool_input', {})
# Only intercept Bash calls
if tool_name != 'Bash':
sys.exit(0)
command = tool_input.get('command', '')
# --- Blocklist rules ---
# Each rule: (regex pattern, reason shown to agent)
BLOCKED = [
# Irreversible deletions
(r'\brm\s+-[a-zA-Z]*r[a-zA-Z]*f\b', 'rm -rf is blocked. Use rm with explicit paths, or move to trash instead.'),
(r'\bgit\s+clean\s+-[a-zA-Z]*f\b', 'git clean -f is blocked. List untracked files with --dry-run first.'),
# Force push
(r'\bgit\s+push\s+.*--force\b', 'Force push is blocked. Confirm with the user before rewriting remote history.'),
(r'\bgit\s+push\s+.*-f\b(?!ile)', 'Force push (-f) is blocked. Confirm with the user before rewriting remote history.'),
# Hard reset
(r'\bgit\s+reset\s+--hard\b', 'git reset --hard is blocked. Use --soft or --mixed, or confirm with user first.'),
# Database destructive ops
(r'\b(DROP\s+(TABLE|DATABASE|SCHEMA)|TRUNCATE\s+TABLE)\b', 'Destructive SQL (DROP/TRUNCATE) is blocked. Confirm with the user before destroying data.', re.IGNORECASE),
(r'\b(db:reset|db:drop|prisma.*reset)\b', 'Database reset scripts are blocked. Confirm with the user — this destroys all data.'),
# Credential leakage to stdout (basic check)
(r'\b(cat|echo|curl|printf)\b.*\.(env|secret|secrets|pem|key)\b', 'Printing credential files to stdout is blocked. Use secure variable injection instead.'),
]
for rule in BLOCKED:
pattern = rule[0]
message = rule[1]
flags = rule[2] if len(rule) > 2 else 0
if re.search(pattern, command, flags):
print(json.dumps({
"decision": "block",
"reason": f"[command-guard] {message}\n\nBlocked command: {command[:200]}"
}))
sys.exit(2)
# All clear
sys.exit(0)
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.
- 3d ago First seen · 240 lines · 0 tokens per session scan C a2cc8ab468af
command-guard is a skill published in the GitHub repository JKHeadley/instar (77 stars, last pushed 4d ago), licensed MIT. It adds 76 tokens to every session and 2,017 once invoked, about $0.0004 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-30.
Other skills, from other repositories
kungfu-agent-onboarding
Use when a user asks to understand, start, inspect, extend, or safely operate installed Kungfu; verify the installed pack, select one intent route, personalize the explanation, and propose one smallest safe next action.
security-observability
只读查询 agent-sec-cli 已落盘的历史安全事件记录,并据此生成会话级安全复盘。仅当用户显式要求查看或审计已发生的安全事件、安全告警、安全审计记录,或要求按 session/run/trace/时间/类别筛选与统计已有安全事件,或要求复盘某次会话的安全判定时使用。不用于扫描新内容:检查代码安全性用 code-scanner,检测 prompt 注入用 prompt-scanner,审查 Skill 安全状态用 skill-ledger。不要因为对话中出现“安全”“工具调用”等字样、或为了主动自查而触发。.
add-backend
Guide for adding a backend (Rust or Python) to the agent-sec-core security middleware. Use when creating new backends, integrating Rust or Python code into the security middleware, or extending with new backend actions.
skill-ledger
Skill 安全状态查看、风险暴露审查、用户决策、快速扫描认证与可选深度扫描。支持用户主动查看或扫描单个/全部 Skill;当用户要求 agent 安装 Skill 且安装成功后,必须自动对最终本地目录执行快速扫描认证。.
pr-body
分析当前分支的全部变更,自动生成或更新 PR 标题和正文。聚焦内容质量:解释 why、归纳 what、标注测试方式,遵循 anolisa 项目 PR 模板规范。适用于新建 PR 前生成描述,或已有 PR 需要更新描述。.
regex-mastery
Use this skill when writing regular expressions, debugging pattern matching,optimizing regex performance, or implementing text validation. Triggers on regex, regular expressions, pattern matching, lookahead, lookbehind, named groups, capture groups, backreferences, and any task requiring text pattern matching.