AGENT SKILL

hook-block-commands

Pattern guide for writing PreToolUse hooks that block dangerous shell commands. Use when: building or auditing a guard-destructive hook, adding new blocked patterns, reviewing what the current hook covers. Covers 3 safety levels (critical/high/strict) and 58+ regex patterns. Inspired by: karanb192/claude-code-hooks block-dangerous-commands pattern (MIT).

License 许可
Apache-2.0
最近更新
2026-11-14
Stars
★ 13
Forks
2

01 前言 Front Matter

name
hook-block-commands
description
Pattern guide for writing PreToolUse hooks that block dangerous shell commands. Use when: building or auditing a guard-destructive hook, adding new blocked patterns, reviewing what the current hook covers. Covers 3 safety levels (critical/high/strict) and 58+ regex patterns. Inspired by: karanb192/claude-code-hooks block-dangerous-commands pattern (MIT).

03 SKILL.md 正文

Hook Block Commands Pattern

When to trigger

  • "what does guard-destructive block?"
  • "add pattern to hook", "block this command"
  • "review hook coverage", "hook pattern"
  • Auditing core/hooks/guard-destructive.sh

Safety levels

Level Scope
critical Catastrophic only: rm -rf ~, dd to disk, fork bombs
high (default) + force push main, git reset --hard, git clean -f, chmod 777, curl|sh, secret file ops
strict + any force push, sudo rm, docker prune, crontab -r

Core pattern categories (58+ patterns)

Filesystem destruction

  • rm -rf /, rm -rf ~, rm -rf $HOME
  • mkfs.*, dd if=.* of=/dev/
  • shred, wipe

Git destructive

  • git push.*--force.*main, git push.*-f.*main
  • git reset --hard, git clean -fdx, git filter-branch
  • git reflog expire

System/process

  • :(){:|:&};: (fork bomb)
  • chmod -R 777, chmod 777 /
  • sudo rm, sudo chmod

Secret exposure

  • cat ~/.aws/credentials, cat .env
  • echo $.*TOKEN, env | grep.*KEY
  • Piping secrets to curl/netcat

Exfiltration

  • curl.*upload, scp.*, rsync.*remote
  • nc.*<IP>, netcat.*

Hook exit codes

exit 0  → allow (no output)
exit 2  → block (JSON reason on stdout)

Blocking response format

{
  "decision": "block",
  "reason": "🚫 Blocked: rm -rf on home directory. Safety level: high."
}

Adding new patterns to guard-destructive.sh

  1. Identify the pattern category (filesystem / git / system / secret / exfiltration)
  2. Write a regex that matches the dangerous form but not safe variants
  3. Add to the correct safety level block
  4. Add a test case to core/tests/hooks/run-hook-tests.sh
  5. Update hook # Last Reviewed: date

Reference

YAMTAM hook: core/hooks/guard-destructive.sh Tests: core/tests/hooks/run-hook-tests.sh

04 同仓库更多 Skills

Horonomos-laps
Horonomos-laps/Yana-AI

openai--sentry--sentry

Use when the user asks to inspect Sentry issues or events, summarize recent production errors, or pull basic Sentry health data via the Sentry API; perform read-only queries with the bundled script and require `SENTRY_AUTH_TOKEN`.

★ 13
Horonomos-laps
Horonomos-laps/Yana-AI

ito-basket-compare

Compare Itô prediction-market baskets against a user's knowledge base, portfolio notes, financial context, watchlist, or research thesis. Use for read-only basket comparison and gap analysis without investment advice or live trading.

★ 13
Horonomos-laps
Horonomos-laps/Yana-AI

implementing-network-traffic-baselining

Build network traffic baselines from NetFlow/IPFIX data using Python pandas for statistical analysis, z-score anomaly detection, and hourly/daily traffic pattern profiling

★ 13
Horonomos-laps
Horonomos-laps/Yana-AI

detecting-evasion-techniques-in-endpoint-logs

Detects defense evasion techniques used by adversaries in endpoint logs including log tampering, timestomping, process injection, and security tool disabling. Use when investigating suspicious endpoint behavior, building detection rules for evasion tactics, or conducting threat hunting for stealthy adversary activity. Activates for requests involving evasion detection, defense evasion analysis, log tampering detection, or MITRE ATT&CK TA0005.

★ 13
Horonomos-laps
Horonomos-laps/Yana-AI

implementing-microsegmentation-with-guardicore

Implementing microsegmentation using Akamai Guardicore Segmentation to map application dependencies, create granular network policies, visualize east-west traffic flows, and enforce least-privilege communication between workloads across data centers and cloud.

★ 13
Horonomos-laps
Horonomos-laps/Yana-AI

ramdisk-tmpfs-patterns

暂无简介

★ 13