PreToolUse

PreToolUse is a hook for Claude Code from CloudAI-X/claude-workflow-v2. Its token cost is not measured, scanned A, original, MIT.

A set of automatic checks that runs before an agent edits files or executes shell commands. The checks protect files, look for security problems, review commits, record commands, and enforce branch rules.

In plain words
What is it for?
Use it to enforce safeguards around editing, writing, and shell commands through file protection, security checking, pre-commit checks, command logging, and branch protection.
Why use it?
It catches unsafe or disallowed actions before they change files or run in the project environment.

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 project-starter plugin — 14 skills, 26 commands, 7 agents, 6 hooks shipped together

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

Good fit Use it to enforce safeguards around editing, writing, and shell commands through file protection, security checking, pre-commit checks, command logging, and branch protection.

Compare 6 hooks from other repositories ↓
About the project

Project Starter is a workflow plugin that equips coding agents with specialized subagents, reusable skills, commands, hooks, and output styles for software projects. It is for developers who want structured assistance with tasks such as planning, debugging, code review, security, and automation across several coding-agent platforms. Catalogue add-ons are components of its own workflow.

CloudAI-X/claude-workflow-v2 · 1,420 stars · on GitHub

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 CloudAI-X/claude-workflow-v2
Claude Code
/plugin install project-starter

Made for: Claude Code.

Or install project-starter, the plugin that ships this one along with the rest of its 14 skills, 26 commands, 7 agents, 6 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/cloudai-x/claude-workflow-v2/pre-tool-use/github.svg)](https://agentmods.dev/hooks/cloudai-x/claude-workflow-v2/pre-tool-use)
Your own site
<a href="https://agentmods.dev/hooks/cloudai-x/claude-workflow-v2/pre-tool-use"><img src="https://agentmods.dev/badge/hooks/cloudai-x/claude-workflow-v2/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/cloudai-x/claude-workflow-v2/pre-tool-use"><img src="https://agentmods.dev/badge/hooks/cloudai-x/claude-workflow-v2/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 original No closer match found 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 13d 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

Copies of this mod

8 near-identical copies found in the catalogue:

hooks/hooks.json · 34 lines

What it actually says

{
  "PreToolUse": [
    {
      "matcher": "Edit|Write",
      "hooks": [
        {
          "type": "command",
          "command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/protect-files.py\""
        },
        {
          "type": "command",
          "command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/security-check.py\""
        },
        {
          "type": "command",
          "command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/pre-commit-check.py\""
        }
      ]
    },
    {
      "matcher": "Bash",
      "hooks": [
        {
          "type": "command",
          "command": "bash \"${CLAUDE_PLUGIN_ROOT}/hooks/log-commands.sh\""
        },
        {
          "type": "command",
          "command": "bash \"${CLAUDE_PLUGIN_ROOT}/hooks/branch-protection.sh\""
        }
      ]
    }
  ]
}
Same file

What else hooks.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. 13d ago Changed e53fc0ff934b
  2. 1mo ago First seen · 34 lines scan A 44a69cddf7d1

Subscribe to this mod's changes

PreToolUse is a hook published in the GitHub repository CloudAI-X/claude-workflow-v2 (1,420 stars, last pushed 10d 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. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.