PreToolUse

PreToolUse is a hook for Claude Code from mhylle/claude-skills-collection. Its token cost is not measured, scanned A, a copy of PreToolUse, MIT.

A pre-command hook checks shell commands before development, installation, testing, build, container, and browser-testing tasks run.

In plain words
What is it for?
It blocks certain development-server commands outside tmux and prints tmux reminders for package, build, Docker, test, and Playwright commands.
Why use it?
It prevents development servers from starting without a persistent terminal session and reminds users to keep long-running command output accessible.

Hook for Claude Code

Written for Claude Code: PreToolUse hook event.

Part of the devflow plugin — 38 skills, 13 agents, 5 hooks shipped together

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

Good fit It blocks certain development-server commands outside tmux and prints tmux reminders for package, build, Docker, test, and Playwright commands.

Compare 6 hooks from other repositories ↓
Install with agentmods
npx agentmods add hooks/mhylle/claude-skills-collection/pre-tool-use
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.

Clone the repo
git clone --depth 1 https://github.com/mhylle/claude-skills-collection

Made for: Claude Code.

Or install devflow, the plugin that ships this one along with the rest of its 38 skills, 13 agents, 5 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/mhylle/claude-skills-collection/pre-tool-use/github.svg)](https://agentmods.dev/hooks/mhylle/claude-skills-collection/pre-tool-use)
Your own site
<a href="https://agentmods.dev/hooks/mhylle/claude-skills-collection/pre-tool-use"><img src="https://agentmods.dev/badge/hooks/mhylle/claude-skills-collection/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/mhylle/claude-skills-collection/pre-tool-use"><img src="https://agentmods.dev/badge/hooks/mhylle/claude-skills-collection/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 89% 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 10d 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

89% identical to PreToolUse — 18 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 · 44 lines

How it starts

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

{
  "PreToolUse": [
    {
      "matcher": "tool == \"Bash\" && tool_input.command matches \"(npm run dev|pnpm( run)? dev|yarn dev|bun run dev)\"",
      "hooks": [
        {
          "type": "command",
          "command": "node -e \"console.error('[Hook] BLOCKED: Dev server must run in tmux for log access');console.error('[Hook] Use: tmux new-session -d -s dev \\\"npm run dev\\\"');console.error('[Hook] Then: tmux attach -t dev');process.exit(1)\""
        }
      ],
      "description": "Block dev servers outside tmux - ensures you can access logs"
    },
    {
      "matcher": "tool == \"Bash\" && tool_input.command matches \"(npm (install|test)|pnpm (install|test)|yarn (install|test)?|bun (install|test)|cargo build|make|docker|pytest|vitest|playwright)\"",
      "hooks": [
        {
          "type": "command",
          "command": "node -e \"if(!process.env.TMUX){console.error('[Hook] Consider running in tmux for session persistence');console.error('[Hook] tmux new -s dev  |  tmux attach -t dev')}\""
        }
      ],
      "description": "Reminder to use tmux for long-running commands"
    },
    {
      "matcher": "tool == \"Bash\" && tool_input.command matches \"git push\"",
      "hooks": [
        {
          "type": "command",
          "command": "node -e \"console.error('[Hook] Review changes before push...');console.error('[Hook] Continuing with push')\""
        }
      ],
      "description": "Reminder before git push to review changes"
    },
    {
      "matcher": "tool == \"Write\" && tool_input.file_path matches \"\\\\.(md|txt)$\" && !(tool_input.file_path matches \"README\\\\.md|CLAUDE\\\\.md|AGENTS\\\\.md|CONTRIBUTING\\\\.md|ADR-.*\\\\.md|SKILL\\\\.md|INDEX\\\\.md|CONTEXT-.*\\\\.md\")",
      "hooks": [
        {
          "type": "command",
          "command": "node -e \"const fs=require('fs');let d='';process.stdin.on('data',c=>d+=c);process.stdin.on('end',()=>{const i=JSON.parse(d);const p=i.tool_input?.file_path||'';if(/\\.(md|txt)$/.te

Read the full file on GitHub · 44 lines

Same file

What else hooks.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. 10d ago First seen · 44 lines scan A 6ccccb3a748b

Subscribe to this mod's changes

PreToolUse is a hook published in the GitHub repository mhylle/claude-skills-collection (18 stars, last pushed 7d 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 89% identical to PreToolUse, differing in 18 lines, and is treated as a copy.