PreToolUse

An automatic check that runs before Bash tool calls containing a Git commit. Bash is a command-line shell, and Git is the system used to record code changes.

In plain words
What is it for?
Use it to enforce pre-commit checks for projects with a build, code-style checks, and type checking. It can identify the actual target directory when the command starts by changing directories.
Why use it?
It makes build, lint, and type-check results available before a commit is created. This helps catch problems before they are saved to the project's history.

Hook for Claude Code

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/heygen-com/hyperframes/pre-tool-use
Clone the repo
git clone --depth 1 https://github.com/heygen-com/hyperframes

Made for: Claude Code.

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 original No closer match found 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 yesterday.

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 \"\nconst chunks = [];\nprocess.stdin.on('data', d => chunks.push(d));\nprocess.stdin.on('end', () => {\n const input = JSON.parse(Buffer.concat(chunks).toString());\n const cmd = input.tool_input?.co
.claude/settings.json · 15 lines

How it starts

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

{
  "PreToolUse": [
    {
      "matcher": "Bash",
      "hooks": [
        {
          "type": "command",
          "timeout": 180,
          "statusMessage": "Running build + lint + typecheck before commit…",
          "command": "node -e \"\nconst chunks = [];\nprocess.stdin.on('data', d => chunks.push(d));\nprocess.stdin.on('end', () => {\n  const input = JSON.parse(Buffer.concat(chunks).toString());\n  const cmd = input.tool_input?.command || '';\n  if (!/git\\s+commit\\b/.test(cmd)) process.exit(0);\n  const { execSync } = require('child_process');\n  const fs = require('fs');\n  const path = require('path');\n  const os = require('os');\n  // A leading 'cd <path>' in the command is the real target directory:\n  // Claude Code prefixes this whenever the session's tracked cwd differs\n  // from this hook process's own cwd (e.g. a sibling repo worktree) — the\n  // hook process itself always inherits the primary working directory,\n  // never the command's actual target.\n  function resolveTargetDir() {\n    const m = cmd.match(/^\\s*cd\\s+('([^']+)'|(\\S+))\\s*(?:&&|;|\\n|$)/);\n    if (m) {\n      let dir = m[2] || m[3];\n      if (dir.startsWith('~')) dir = path.join(os.homedir(), dir.slice(1));\n      dir = path.resolve(process.cwd(), dir);\n      if (fs.existsSync(dir)) return dir;\n    }\n    return process.cwd();\n  }\n  const targetDir = resolveTargetDir();\n  let repoRoot;\n  try {\n    repoRoot = execSync('git rev-parse --show-toplevel', { cwd: targetDir, encoding: 'utf8' }).trim();\n  } catch {\n    process.exit(0);\n  }\n  // Only this repo's own bun build/lint/typecheck applies — skip silently\n  // for any other repo (e.g. a sibling Go/Python repo touched in the same session).\n  const pkgPath = path.join(repoRoot, 'package.json');\n  if (!fs.existsSync(pkgPath)) process.exit(0);\n  let pkg;\n  try {\n    pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));\n  } catch {\n    process.exit(0);\n  }\n  if (pkg.name !== 'hyperframes-monorepo') process.e

Read the full file on GitHub · 15 lines

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. yesterday First seen · 15 lines scan A 8eff150d1739

Subscribe to this mod's changes

PreToolUse is a hook published in the GitHub repository heygen-com/hyperframes (43,141 stars, last pushed yesterday), licensed Apache-2.0. 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). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.