claude-craft: Hook for Claude Code

.claude/settings.json

PreToolUse is a hook for Claude Code from TheBeardedBearSAS/claude-craft. Its token cost is not measured, scanned C, original, MIT.

A pre-tool safety hook that runs checks before an agent uses Bash, Edit, or Write operations. Hooks are automatic checks that run when specified actions occur.

In plain words
What is it for?
Use it to check tool commands for blocked download patterns and dangerous file-removal options before execution.
Why use it?
It can stop certain risky shell commands before they run, reducing the chance of unsafe downloads or destructive operations.

Hook for Claude Code

Written for Claude Code: PreToolUse hook event.

This is TheBeardedBearSAS/claude-craft's own configuration. It tells Claude Code how to work on claude-craft itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything claude-craft configures →

Part of the claude-craft plugin — 56 skills, 94 commands, 47 agents, 5 hooks shipped together

One of 6 entries in settings.json — they are configured in one file and arrive together.

Reuse

Borrowing it

Nothing to install: this file belongs to TheBeardedBearSAS/claude-craft. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/TheBeardedBearSAS/claude-craft/main/.claude/settings.json
Clone the repo
git clone --depth 1 https://github.com/TheBeardedBearSAS/claude-craft

Made for: Claude Code.

Or install claude-craft, the plugin that ships this one along with the rest of its 56 skills, 94 commands, 47 agents, 5 hooks.

Wrote 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.

agentmods badge for PreToolUse

README.md
[![agentmods](https://agentmods.dev/badge/hooks/thebeardedbearsas/claude-craft/pre-tool-use.svg)](https://agentmods.dev/hooks/thebeardedbearsas/claude-craft/pre-tool-use)
Your own site
<a href="https://agentmods.dev/hooks/thebeardedbearsas/claude-craft/pre-tool-use"><img src="https://agentmods.dev/badge/hooks/thebeardedbearsas/claude-craft/pre-tool-use.svg" alt="Measured on agentmods" height="20"></a>
Per session not measured What this adds to a session before it is invoked.
When invoked not measured Not applicable: nothing here is loaded into a session.
Security scan C 2 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Security

Grade C, and why

PreToolUse 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 commands this hook runs, not an audit. A hook is shell that executes on your machine at the event it names, which is why every command in it is printed with what was found.

Reaches for credential fileshighPrivilege escalation

SSH keys, cloud credentials, git-credentials, .npmrc, /etc/shadow: reading these is how a config file becomes a credential leak.

"command": "FILEPATH=$(jq -r '.tool_input.file_path // empty'); if echo \"$FILEPATH\" | grep -qE '(\\.env(\\.|$)|\\.envrc|credentials|secrets?|private.*key|id_(rsa|dsa|ecdsa|ed25519)|\\.pem$|\\.p(fx|12)$|\\.key$|\\.npmrc

Makes network callslowCapability

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

"command": "INPUT=$(jq -r '.tool_input.command // empty'); if echo \"$INPUT\" | grep -qE '(curl|wget).*\\.(sh|py|rb|pl|bat|ps1)'; then echo \"BLOCKED: Downloading executable scripts is not allowed\" >&2 && exit 2; fi; if
.claude/settings.json · 35 lines

How it starts

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

{
  "PreToolUse": [
    {
      "matcher": "Bash",
      "hooks": [
        {
          "type": "command",
          "command": "INPUT=$(jq -r '.tool_input.command // empty'); if echo \"$INPUT\" | grep -qE '(curl|wget).*\\.(sh|py|rb|pl|bat|ps1)'; then echo \"BLOCKED: Downloading executable scripts is not allowed\" >&2 && exit 2; fi; if echo \"$INPUT\" | grep -qE '(curl|wget).*(-o|-O|>)'; then echo \"BLOCKED: Downloading files requires explicit approval\" >&2 && exit 2; fi; if printf '%s' \"$INPUT\" | grep -qE '(curl|wget)[^|;&]*\\|[[:space:]]*(sh|bash|zsh|python[0-9.]*|perl|ruby)([[:space:]]|$)'; then printf 'BLOCKED: Piping a download into a shell interpreter is not allowed\\n' >&2; exit 2; fi; exit 0"
        },
        {
          "type": "command",
          "command": "INPUT=$(jq -r '.tool_input.command // empty'); HAS_RECURSIVE=$(echo \"$INPUT\" | grep -cE 'rm[[:space:]].*(-[a-zA-Z]*r[a-zA-Z]*|--recursive)' || true); HAS_FORCE=$(echo \"$INPUT\" | grep -cE 'rm[[:space:]].*(-[a-zA-Z]*f[a-zA-Z]*|--force)' || true); if [ \"$HAS_RECURSIVE\" -gt 0 ] && [ \"$HAS_FORCE\" -gt 0 ]; then echo \"BLOCKED: Destructive rm command detected (recursive+force)\" >&2 && exit 2; fi; if echo \"$INPUT\" | grep -qE '(mkfs|dd[[:space:]]+if=|:[[:space:]]*\\(\\)[[:space:]]*\\{[[:space:]]*:|chmod[[:space:]]+-?R?[[:space:]]*777|>[[:space:]]*/dev/(sd|null))'; then echo \"BLOCKED: Dangerous system command detected\" >&2 && exit 2; fi; exit 0"
        }
      ]
    },
    {
      "matcher": "Edit",
      "hooks": [
        {
          "type": "command",
          "command": "FILEPATH=$(jq -r '.tool_input.file_path // empty'); if echo \"$FILEPATH\" | grep -qE '(\\.env(\\.|$)|\\.envrc|credentials|secrets?|private.*key|id_(rsa|dsa|ecdsa|ed25519)|\\.pem$|\\.p(fx|12)$|\\.key$|\\.npmrc$|\\.netrc$|kubeconfig)'; then echo \"BLOCKED: Cannot edit sensitive file: $FILEPATH\" >&2 && exit 2; fi; exit 0"
        }
      ]
    },
    {
      "matcher": "Write",
      "hooks": [
        {
          "type": 

Read the full file on GitHub · 35 lines

Same file

What else settings.json configures

This page is one entry in a file that holds 6. Installing the file brings all of them; each is measured and scanned on its own page.

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 · 35 lines scan C b3728f0efcb8

Subscribe to this mod's changes

PreToolUse is a hook published in the GitHub repository TheBeardedBearSAS/claude-craft (105 stars, last pushed 3d ago), licensed MIT. Its token cost is not measured: a hook is shell that never enters the context. A static security scan graded it C with 2 findings (reaches for credential files, makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.