PreToolUse

PreToolUse is a hook for Claude Code from jl-cmd/claude-dev-env. Its token cost is not measured, scanned A, a copy of PreToolUse, MIT.

A set of checks that runs before an agent edits files, runs shell commands, uses GitHub tools, or starts other agents.

In plain words
What is it for?
Enforcing checks around file changes, command execution, GitHub comments, and agent tasks.
Why use it?
It can block or validate risky agent actions before they happen.

Hook for Claude Code

Written for Claude Code: ${CLAUDE_PLUGIN_ROOT} variable.

Runs only inside its plugin — its command needs a path that Claude Code sets for a plugin’s own hooks and for nothing else. Install the plugin, not this.

Part of the claude-dev-env plugin — 71 skills, 4 commands, 1 agent, 9 hooks shipped together

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

Good fit Enforcing checks around file changes, command execution, GitHub comments, and agent tasks.

Compare 6 hooks from other repositories ↓
Install

Getting it into your agent

This one installs as part of its plugin. Adding the marketplace and installing the plugin brings it with everything else the plugin ships.

Claude Code
/plugin marketplace add jl-cmd/claude-dev-env
Claude Code
/plugin install claude-dev-env

Made for: Claude Code.

Or install claude-dev-env, the plugin that ships this one along with the rest of its 71 skills, 4 commands, 1 agent, 9 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/jl-cmd/claude-dev-env/pre-tool-use/github.svg)](https://agentmods.dev/hooks/jl-cmd/claude-dev-env/pre-tool-use)
Your own site
<a href="https://agentmods.dev/hooks/jl-cmd/claude-dev-env/pre-tool-use"><img src="https://agentmods.dev/badge/hooks/jl-cmd/claude-dev-env/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/jl-cmd/claude-dev-env/pre-tool-use"><img src="https://agentmods.dev/badge/hooks/jl-cmd/claude-dev-env/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 A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin 84% copy Near-identical to another mod in the catalogue.
Security

Grade A, and why

PreToolUse scanned grade A with 0 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 11d 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.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

Origin

This is a copy

84% identical to PreToolUse — 137 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

packages/claude-dev-env/hooks/hooks.json · 159 lines

How it starts

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

{
  "PreToolUse": [
    {
      "matcher": "Agent|Task",
      "hooks": [
        {
          "type": "command",
          "command": "python3 ${CLAUDE_PLUGIN_ROOT}/hooks/session/skill_loaded_reminder.py",
          "timeout": 10
        },
        {
          "type": "command",
          "command": "python3 ${CLAUDE_PLUGIN_ROOT}/hooks/routing/spawn_readiness_hook.py",
          "timeout": 10
        },
        {
          "type": "command",
          "command": "python3 ${CLAUDE_PLUGIN_ROOT}/hooks/routing/subagent_model_pin_hook.py",
          "timeout": 10
        }
      ]
    },
    {
      "matcher": "multi_agent_v1__spawn_agent",
      "hooks": [
        {
          "type": "command",
          "command": "node \"${CLAUDE_PLUGIN_ROOT}/hooks/routing/subagent_model_routing.mjs\"",
          "timeout": 10
        },
        {
          "type": "command",
          "command": "python3 ${CLAUDE_PLUGIN_ROOT}/hooks/routing/spawn_readiness_hook.py",
          "timeout": 10
        }
      ]
    },
    {
      "matcher": "Workflow|mcp__github__actions_run_trigger",
      "hooks": [
        {
          "type": "command",
          "command": "python3 ${CLAUDE_PLUGIN_ROOT}/hooks/routing/spawn_readiness_hook.py",
          "timeout": 10
        }
      ]
    },
    {
      "matcher": "Write|Edit|MultiEdit|apply_patch",
      "hooks": [
        {
          "type": "command",
          "command": "python3 ${CLAUDE_PLUGIN_ROOT}/hooks/blocking/pre_tool_use_dispatcher.py",
          "timeout": 60
        }
      ]
    },
    {
      "matcher": "Bash",
      "hooks": [
        {
          "type": "command",
          "command": "python3 ${CLAUDE_PLUGIN_ROOT}/hooks/blocking/bash_pre_tool_use_dispatcher.py",
          "timeout": 60
        }
      ]
    },
    {
      "matcher": "PowerShell",
      "hooks": [
        {
          "type": "command",
          "command": "python3 ${CLAUDE_PLUGIN_ROOT}/hooks/blocking/bash_pre_tool_use_dispatcher.py",
          "timeout": 60
        }

Read the full file on GitHub · 159 lines

Same file

What else hooks.json configures

This page is one entry in a file that holds 8. 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. 11d ago Changed · +25 lines ccd6764a413e
  2. 12d ago Changed · +35 lines a02339001391
  3. 16d ago Changed · +10 lines 33eb484c66d0
  4. 18d ago Changed · +20 lines 7d07b3bf2afc
  5. 19d ago Changed · +5 lines 091f6fd0a788
  6. 22d ago Changed · +20 lines 5470c83a8ee1
  7. 1mo ago Changed · +10 lines 555ea253a5b7
  8. 1mo ago Changed · +10 lines 4ea64b9fc829
  9. 1mo ago Changed · -95 lines f7f29b6056ca
  10. 1mo ago First seen · 119 lines scan A d383793074c4

Subscribe to this mod's changes

PreToolUse is a hook published in the GitHub repository jl-cmd/claude-dev-env (6 stars, last pushed 11d ago), licensed MIT. Its token cost is not measured: a hook is shell that never enters the context. A static security scan graded it A with 0 findings. It is 84% identical to PreToolUse, differing in 137 lines, and is treated as a copy.