PreToolUse

PreToolUse is a hook for coding agents from buildomator/buildomator. Its token cost is not measured, scanned A, a copy of SessionStart, MIT.

A pre-tool hook that runs checks before an agent edits files or executes shell commands.

In plain words
What is it for?
It helps run project-specific guard scripts before Edit, Write, and Bash operations, including checks related to GSD tools and workflow rules.
Why use it?
It can catch workflow, prompt, read-access, and command issues before those actions proceed.

Hook

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 gsd plugin — 22 skills, 33 agents, 6 hooks shipped together

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

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 buildomator/buildomator
Claude Code
/plugin install gsd

Or install gsd, the plugin that ships this one along with the rest of its 22 skills, 33 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/buildomator/buildomator/pre-tool-use.svg)](https://agentmods.dev/hooks/buildomator/buildomator/pre-tool-use)
Your own site
<a href="https://agentmods.dev/hooks/buildomator/buildomator/pre-tool-use"><img src="https://agentmods.dev/badge/hooks/buildomator/buildomator/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 A 1 finding. Scan, not verified.
Origin 91% copy Near-identical to another mod in the catalogue.
Security

Grade A, and why

PreToolUse scanned grade A 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 4d 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.

Runs shell commandslowCapability

Expected in a hook, worth knowing in a rule or an instructions file.

"command": "node -e \"const f=require('fs'),p=require('path'),o=require('os'),cp=require('child_process'),c=[];if(process.env.CLAUDE_PLUGIN_ROOT)c.push(p.join(process.env.CLAUDE_PLUGIN_ROOT,'hooks/run-bash-hook.cjs'));co
Origin

This is a copy

91% identical to SessionStart — 26 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.

hooks/hooks.json · 54 lines

How it starts

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

{
  "PreToolUse": [
    {
      "matcher": "Edit|Write",
      "hooks": [
        {
          "type": "command",
          "command": "node -e \"const f=require('fs'),p=require('path'),o=require('os'),c=[];if(process.env.CLAUDE_PLUGIN_ROOT)c.push(p.join(process.env.CLAUDE_PLUGIN_ROOT,'bin/gsd-tools.cjs'));const b=p.join(o.homedir(),'.claude/plugins/cache'),g='gsd',t=[];try{for(const m of f.readdirSync(b)){try{for(const v of f.readdirSync(p.join(b,m,g)))if(/^\\d+\\.\\d+\\.\\d+$/.test(v))t.push([v,p.join(b,m,g,v,'bin/gsd-tools.cjs')]);}catch(e){}}}catch(e){}t.sort((a,z)=>{const A=a[0].split('.').map(Number),B=z[0].split('.').map(Number);return B[0]-A[0]||B[1]-A[1]||B[2]-A[2];});for(const e of t)c.push(e[1]);for(const x of c){if(!f.existsSync(x))continue;if(process.env.CLAUDE_PLUGIN_ROOT&&x!==c[0])process.stderr.write('GSD: plugin path stale, using '+x+'\\n');process.argv.splice(1,0,x);require(x);break;}\" hook pre-tool-use",
          "timeout": 3000
        }
      ]
    },
    {
      "matcher": "Edit|Write",
      "hooks": [
        {
          "type": "command",
          "command": "node -e \"const f=require('fs'),p=require('path'),o=require('os'),c=[];if(process.env.CLAUDE_PLUGIN_ROOT)c.push(p.join(process.env.CLAUDE_PLUGIN_ROOT,'hooks/gsd-prompt-guard.js'));const b=p.join(o.homedir(),'.claude/plugins/cache'),g='gsd',t=[];try{for(const m of f.readdirSync(b)){try{for(const v of f.readdirSync(p.join(b,m,g)))if(/^\\d+\\.\\d+\\.\\d+$/.test(v))t.push([v,p.join(b,m,g,v,'hooks/gsd-prompt-guard.js')]);}catch(e){}}}catch(e){}t.sort((a,z)=>{const A=a[0].split('.').map(Number),B=z[0].split('.').map(Number);return B[0]-A[0]||B[1]-A[1]||B[2]-A[2];});for(const e of t)c.push(e[1]);for(const x of c){if(!f.existsSync(x))continue;if(process.env.CLAUDE_PLUGIN_ROOT&&x!==c[0])process.stderr.write('GSD: plugin path stale, using '+x+'\\n');process.argv.splice(1,0,x);require(x);break;}\"",
          "timeout": 3000
        }
      ]
    },
    {
      "matcher": "Edit|Write",
      "ho

Read the full file on GitHub · 54 lines

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. 4d ago First seen · 54 lines scan A de2223a08b26

Subscribe to this mod's changes

PreToolUse is a hook published in the GitHub repository buildomator/buildomator (86 stars, last pushed yesterday), 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 1 finding (runs shell commands). It is 91% identical to SessionStart, differing in 26 lines, and is treated as a copy.