claude-forge: Hook for Claude Code

.claude/settings.json

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

A pre-action safety check for Bash and PowerShell commands. It examines commands before they run and can block destructive deletion, process termination, or risky Git operations.

In plain words
What is it for?
Use it to guard shell commands such as recursive deletes, forceful Git resets, and similar destructive actions.
Why use it?
It reduces the chance that an agent will accidentally erase files, kill processes, or discard Git work without the owner's approval.

Hook for Claude Code

Written for Claude Code: $CLAUDE_PROJECT_DIR variable. Also seen: mentions Claude Code.

This is ForgeyClap/claude-forge's own configuration. It tells Claude Code how to work on claude-forge 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-forge configures →

One of 5 entries in settings.json upstream. Installing this one merges just its entry into your config; the other 4 are separate, each on its own page.

Reuse

Borrowing it

Nothing to install: this file belongs to ForgeyClap/claude-forge. 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/ForgeyClap/claude-forge/main/.claude/settings.json
Clone the repo
git clone --depth 1 https://github.com/ForgeyClap/claude-forge

Made for: Claude Code.

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/forgeyclap/claude-forge/pre-tool-use/github.svg)](https://agentmods.dev/hooks/forgeyclap/claude-forge/pre-tool-use)
Your own site
<a href="https://agentmods.dev/hooks/forgeyclap/claude-forge/pre-tool-use"><img src="https://agentmods.dev/badge/hooks/forgeyclap/claude-forge/pre-tool-use/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for PreToolUse

Your own site · 80×15
<a href="https://agentmods.dev/hooks/forgeyclap/claude-forge/pre-tool-use"><img src="https://agentmods.dev/badge/hooks/forgeyclap/claude-forge/pre-tool-use.svg" alt="Reviewed on agentmods" width="80" 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 1 finding. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Security

Grade C, and why

PreToolUse scanned grade C with 1 finding 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 28d 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.

Recursive force deletehighDestructive command

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

"_doc": "2026-09-24 (v2.7.0, WP16 + security wp9b + review wp9a): the GATE HOOK. Before every Bash or PowerShell tool call it asks forge-actiongate.cjs whether the command trips one of FIVE command hard gates (a classifi
.claude/settings.json · 15 lines

How it starts

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

{
  "PreToolUse": [
    {
      "matcher": "Bash|PowerShell",
      "hooks": [
        {
          "type": "command",
          "command": "node \"$CLAUDE_PROJECT_DIR/.claude/forge-bin/forge-gate-hook.cjs\"",
          "timeout": 10
        }
      ],
      "_doc": "2026-09-24 (v2.7.0, WP16 + security wp9b + review wp9a): the GATE HOOK. Before every Bash or PowerShell tool call it asks forge-actiongate.cjs whether the command trips one of FIVE command hard gates (a classifier, not a proof) — destructive-delete (rm -rf, rm -r, Remove-Item -Recurse, rd /s, rimraf), kill-by-name (taskkill /IM or a non-PID /FI, Stop-Process -Name, pkill, kill $(pgrep …)), git-destructive (reset --hard, clean -f, checkout -f / . / -- <path>, restore <path>, switch -f, stash drop/clear) opaque-exec (a pipe into a shell, eval/iex, sh -c on a variable, an encoded PowerShell command) or, since 2.9.0, secret-print (printing the contents of a secret file: a .env file, a key, a credentials file or anything in secrets/, via cat/type/Get-Content, grep and friends, git show/log -p/diff/blame or find -exec; .env.example and the names-only helper forge-env-names.cjs stay allowed) — or tries to switch the gate itself off. Exit 2 = blocked with a plain NL+EN reason and Claude must ask the owner; exit 1 = not blocked but VISIBLE (gate is off, or the hook could not check the call); exit 0 = allowed. Quoted data (writer heredocs, echo/commit-message/log-event/search-tool literals) is not treated as a command, and a delete whose every target is provably inside _scratch/, node_modules/, dist/ or the temp dir passes. The owner-approved one-off off-switch is `node .claude/forge-bin/forge-config.cjs set gate-hook off --once \"<owner's words>\"` (10 minutes); the owner can also run a command himself with `!`. Timeouts in this file are SECONDS (Claude Code hook contract). The permissions.deny block keeps .env variants, keys and secrets out of Claude's Read tool; .env.example stays readable. Details and honest l

Read the full file on GitHub · 15 lines

Same file

What else settings.json configures

This page is one entry in a file that holds 5. 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. 28d ago Changed 8b7dcc77fe92
  2. 1mo ago Changed 738f47d9ef8d
  3. 1mo ago First seen · 15 lines scan C e9517d9be633

Subscribe to this mod's changes

PreToolUse is a hook published in the GitHub repository ForgeyClap/claude-forge (2 stars, last pushed 29d 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 1 finding (recursive force delete). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-25.