PreToolUse

A set of automatic checks that runs before an agent reads files, edits files, or executes shell commands. The checks cover sensitive files, dangerous commands, workflow approval, and task context.

In plain words
What is it for?
Use it to guard file operations and shell commands in projects that require safety checks and an Actor-and-Monitor workflow.
Why use it?
It helps prevent unsafe commands, access to protected information, and edits made before required workflow steps are complete.

Hook for Claude Code

Part of the map-framework plugin — 23 skills, 9 agents, 8 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/azalio/map-framework/pre-tool-use
Clone the repo
git clone --depth 1 https://github.com/azalio/map-framework

Made for: Claude Code.

Or install map-framework, the plugin that ships this one along with the rest of its 23 skills, 9 agents, 8 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 3d 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.

.claude/settings.json · 40 lines

What it actually says

{
  "PreToolUse": [
    {
      "matcher": "Edit|Write|Read|MultiEdit|Bash",
      "description": "Safety Guardrails - block sensitive files and dangerous commands",
      "hooks": [
        {
          "type": "command",
          "command": "\"$CLAUDE_PROJECT_DIR\"/.claude/hooks/safety-guardrails.py",
          "timeout": 5,
          "description": "Blocks .env, credentials, private keys, and dangerous bash commands"
        }
      ]
    },
    {
      "matcher": "Edit|Write|MultiEdit",
      "description": "Workflow Gate - enforce Actor+Monitor before edits (MAP)",
      "hooks": [
        {
          "type": "command",
          "command": "\"$CLAUDE_PROJECT_DIR\"/.claude/hooks/workflow-gate.py",
          "timeout": 5,
          "description": "Blocks Edit/Write/MultiEdit until workflow_state indicates Actor+Monitor completed"
        }
      ]
    },
    {
      "matcher": "Edit|Write|MultiEdit|Bash",
      "description": "Workflow Context Injection (Tiered) - inject reminders for significant operations",
      "hooks": [
        {
          "type": "command",
          "command": "\"$CLAUDE_PROJECT_DIR\"/.claude/hooks/workflow-context-injector.py",
          "timeout": 3,
          "description": "Injects workflow context only for Edit/Write/MultiEdit and significant Bash commands"
        }
      ]
    }
  ]
}
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. 3d ago First seen · 40 lines scan A 54aa040f050f

Subscribe to this mod's changes

PreToolUse is a hook published in the GitHub repository azalio/map-framework (153 stars, last pushed 5d 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.

Related

Other hooks, from other repositories

SessionStart

Runs when a session starts on startup, resume, clear, compact, startup, startup, resume, clear, compact, startup, clear, compact, clear and compact, executing license_check.py, licensed_assets_sync.py, codex_skill_sync.py, cc_skill_sync.py and run_if_licensed.py via uv with --no-project, --python and --exec (13…

maxritter/pilot-shell · not measured

PostToolUse

Runs after a tool call finishes for Write, Edit, MultiEdit, EnterPlanMode, ExitPlanMode, Write, Edit and MultiEdit tool calls, executing run_if_licensed.py via uv with --no-project, --python and --exec (5 commands). From maxritter/pilot-shell.

maxritter/pilot-shell · not measured

PreToolUse

Runs before the agent uses a tool for Write, Edit, MultiEdit, EnterPlanMode, Edit, Write, MultiEdit, Bash, WebSearch, WebFetch, Grep, Glob and Bash tool calls, executing run_if_licensed.py via uv with --no-project and --python (4 commands). From maxritter/pilot-shell.

maxritter/pilot-shell · not measured

UserPromptSubmit

Runs when you submit a prompt, before the agent sees it, executing license_prompt_guard.py and run_if_licensed.py via uv with --no-project, --python and --exec (3 commands). From maxritter/pilot-shell.

maxritter/pilot-shell · not measured

Stop

Runs when the agent finishes a response, executing run_if_licensed.py via uv with --no-project, --python and --exec (3 commands). From maxritter/pilot-shell.

maxritter/pilot-shell · not measured

UserPromptExpansion

Runs to expand your prompt before the agent sees it for benchmark, build, cleanup, create-skill, fix, investigate, prd, setup-rules, spec, spec-bugfix-plan, spec-bugfix-verify, spec-implement, spec-plan and spec-verify tool calls, executing license_prompt_guard.py via uv with --no-project and --python. From…

maxritter/pilot-shell · not measured