PostToolUse

PostToolUse is a hook for Claude Code from zhukunpenglinyutong/ai-max. Its token cost is not measured, scanned A, a copy of PostToolUse, MIT.

Automation that runs after selected command-line or code-editing actions finish.

In plain words
What is it for?
Use it to react to Bash commands and edits to JavaScript or TypeScript files; the provided example logs newly created GitHub pull requests and suggests a review command.
Why use it?
It can add follow-up checks or messages automatically after matching actions, so routine steps do not have to be remembered manually.

Hook for Claude Code

Written for Claude Code: PostToolUse hook event.

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

Good fit Use it to react to Bash commands and edits to JavaScript or TypeScript files; the provided example logs newly created GitHub pull requests and suggests a review command.

Compare 6 hooks from other repositories ↓
Install with agentmods
npx agentmods add hooks/zhukunpenglinyutong/ai-max/post-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/zhukunpenglinyutong/ai-max

Made for: Claude Code.

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 PostToolUse

README.md
[![agentmods](https://agentmods.dev/badge/hooks/zhukunpenglinyutong/ai-max/post-tool-use/github.svg)](https://agentmods.dev/hooks/zhukunpenglinyutong/ai-max/post-tool-use)
Your own site
<a href="https://agentmods.dev/hooks/zhukunpenglinyutong/ai-max/post-tool-use"><img src="https://agentmods.dev/badge/hooks/zhukunpenglinyutong/ai-max/post-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 PostToolUse

Your own site · 80×15
<a href="https://agentmods.dev/hooks/zhukunpenglinyutong/ai-max/post-tool-use"><img src="https://agentmods.dev/badge/hooks/zhukunpenglinyutong/ai-max/post-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 91% copy Near-identical to another mod in the catalogue.
Security

Grade A, and why

PostToolUse 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

91% identical to PostToolUse — 12 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.

{
  "PostToolUse": [
    {
      "matcher": "tool == \"Bash\"",
      "hooks": [
        {
          "type": "command",
          "command": "#!/bin/bash\n# Auto-detect PR creation and log useful info\ninput=$(cat)\ncmd=$(echo \"$input\" | jq -r '.tool_input.command')\n\nif echo \"$cmd\" | grep -qE 'gh pr create'; then\n  output=$(echo \"$input\" | jq -r '.tool_output.output // \"\"')\n  pr_url=$(echo \"$output\" | grep -oE 'https://github.com/[^/]+/[^/]+/pull/[0-9]+')\n  \n  if [ -n \"$pr_url\" ]; then\n    echo \"[Hook] PR created: $pr_url\" >&2\n    echo \"[Hook] Checking GitHub Actions status...\" >&2\n    repo=$(echo \"$pr_url\" | sed -E 's|https://github.com/([^/]+/[^/]+)/pull/[0-9]+|\\1|')\n    pr_num=$(echo \"$pr_url\" | sed -E 's|.*/pull/([0-9]+)|\\1|')\n    echo \"[Hook] To review PR: gh pr review $pr_num --repo $repo\" >&2\n  fi\nfi\n\necho \"$input\""
        }
      ],
      "description": "Log PR URL and provide review command after PR creation"
    },
    {
      "matcher": "tool == \"Edit\" && tool_input.file_path matches \"\\\\.(ts|tsx|js|jsx)$\"",
      "hooks": [
        {
          "type": "command",
          "command": "#!/bin/bash\n# Auto-format with Prettier after editing JS/TS files\ninput=$(cat)\nfile_path=$(echo \"$input\" | jq -r '.tool_input.file_path // \"\"')\n\nif [ -n \"$file_path\" ] && [ -f \"$file_path\" ]; then\n  if command -v prettier >/dev/null 2>&1; then\n    prettier --write \"$file_path\" 2>&1 | head -5 >&2\n  fi\nfi\n\necho \"$input\""
        }
      ],
      "description": "Auto-format JS/TS files with Prettier after edits"
    },
    {
      "matcher": "tool == \"Edit\" && tool_input.file_path matches \"\\\\.(ts|tsx)$\"",
      "hooks": [
        {
          "type": "command",
          "command": "#!/bin/bash\n# Run TypeScript check after editing TS files\ninput=$(cat)\nfile_path=$(echo \"$input\" | jq -r '.tool_input.file_path // \"\"')\n\nif [ -n \"$file_path\" ] && [ -f \"$file_path\" ]; then\n  dir=$(dirname \"$fil

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 3. 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 e88e59758d38

Subscribe to this mod's changes

PostToolUse is a hook published in the GitHub repository zhukunpenglinyutong/ai-max (335 stars, last pushed 7mo 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 91% identical to PostToolUse, differing in 12 lines, and is treated as a copy.