PreToolUse

A set of rules that runs before Write, Edit, and Bash operations. It checks file paths and code-file changes, and asks for a guideline check before a Git commit.

In plain words
What is it for?
Use it to add guidance before editing TypeScript, JavaScript, Python, or Go files and before running Git commits. It skips certain generated, dependency, image, font, and lock files.
Why use it?
It gives the agent project-specific reminders before changes or commits happen. This can help keep edits aligned with the project's CLAUDE.md instructions and AI Dev OS checks.

Hook

Part of the ai-dev-os plugin — 11 skills, 3 agents, 3 hooks shipped together

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add hooks/yunbow/ai-dev-os-plugin-claude-code/pre-tool-use
Clone the repo
git clone --depth 1 https://github.com/yunbow/ai-dev-os-plugin-claude-code

Or install ai-dev-os, the plugin that ships this one along with the rest of its 11 skills, 3 agents, 3 hooks.

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. Scan, not verified.
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 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.

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.

hooks/hooks.json · 24 lines

What it actually says

{
  "PreToolUse": [
    {
      "matcher": "Write|Edit",
      "hooks": [
        {
          "type": "command",
          "command": "bash -c 'INPUT=$(cat); FILE=$(echo \"$INPUT\" | jq -r \".tool_input.file_path // .tool_input.file_path\"); if echo \"$FILE\" | grep -qE \"(node_modules|dist|build|\\.next|__pycache__|\\.venv|vendor|\\.git)/|\\.(lock|svg|png|jpg|jpeg|gif|ico|woff|woff2|ttf|eot)$\"; then exit 0; fi; if echo \"$FILE\" | grep -qE \"\\.(ts|tsx|js|jsx|py|go)$\"; then echo \"{\\\"additionalContext\\\": \\\"AI Dev OS: Ensure this change complies with the project guidelines. Check CLAUDE.md for the applicable rules.\\\"}\"; fi'",
          "statusMessage": "AI Dev OS: Guideline check..."
        }
      ]
    },
    {
      "matcher": "Bash",
      "hooks": [
        {
          "type": "command",
          "command": "bash -c 'INPUT=$(cat); CMD=$(echo \"$INPUT\" | jq -r \".tool_input.command\"); if echo \"$CMD\" | grep -qE \"^git commit\"; then echo \"{\\\"additionalContext\\\": \\\"Please run a guideline check before committing: /ai-dev-os-check\\\"}\"; fi'",
          "statusMessage": "AI Dev OS: Pre-commit check..."
        }
      ]
    }
  ]
}
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 · 24 lines scan A 4d97f509fdeb

Subscribe to this mod's changes

PreToolUse is a hook published in the GitHub repository yunbow/ai-dev-os-plugin-claude-code (2 stars, last pushed 5mo 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-31.