PostToolUse

PostToolUse is a hook for Claude Code from swesmith/davila7__claude-code-templates.734b8a50. Its token cost is not measured, scanned A, a copy of PostToolUse, MIT.

An automatic after-edit check for JavaScript and TypeScript files. It formats changed files, checks TypeScript for errors, and warns about wildcard imports.

In plain words
What is it for?
It helps maintain formatting, run TypeScript checks, and flag wildcard imports after Write, Edit, or MultiEdit operations.
Why use it?
It catches formatting and some code problems immediately after a file is changed, so they do not remain unnoticed until later.

Hook for Claude Code

Written for Claude Code: PostToolUse hook event.

One of 5 entries in settings.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 helps maintain formatting, run TypeScript checks, and flag wildcard imports after Write, Edit, or MultiEdit operations.

Compare 6 hooks from other repositories ↓
Install with agentmods
npx agentmods add hooks/swesmith/davila7__claude-code-templates.734b8a50/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/swesmith/davila7__claude-code-templates.734b8a50

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/swesmith/davila7__claude-code-templates.734b8a50/post-tool-use.svg)](https://agentmods.dev/hooks/swesmith/davila7__claude-code-templates.734b8a50/post-tool-use)
Your own site
<a href="https://agentmods.dev/hooks/swesmith/davila7__claude-code-templates.734b8a50/post-tool-use"><img src="https://agentmods.dev/badge/hooks/swesmith/davila7__claude-code-templates.734b8a50/post-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 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin 100% 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 8d 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

100% identical to PostToolUse — 0 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.

cli-tool/templates/javascript-typescript/.claude/settings.json · 43 lines

What it actually says

{
  "PostToolUse": [
    {
      "matcher": "Write|Edit|MultiEdit",
      "hooks": [
        {
          "type": "command",
          "command": "FILE=$(echo $STDIN_JSON | jq -r '.tool_input.file_path // \"\"'); if [[ \"$FILE\" =~ \\.(js|jsx|ts|tsx)$ ]]; then npx prettier --write \"$FILE\"; fi",
          "timeout": 30
        }
      ]
    },
    {
      "matcher": "Write|Edit|MultiEdit",
      "hooks": [
        {
          "type": "command",
          "command": "FILE=$(echo $STDIN_JSON | jq -r '.tool_input.file_path // \"\"'); if [[ \"$FILE\" =~ \\.(ts|tsx)$ ]]; then RESULT=$(npx tsc --noEmit 2>&1); if [ $? -ne 0 ]; then echo \"TypeScript errors found: $RESULT\" >&2; exit 2; fi; fi",
          "timeout": 30
        }
      ]
    },
    {
      "matcher": "Write|Edit|MultiEdit",
      "hooks": [
        {
          "type": "command",
          "command": "FILE=$(echo $STDIN_JSON | jq -r '.tool_input.file_path // \"\"'); if [[ \"$FILE\" =~ \\.(js|jsx|ts|tsx)$ ]] && grep -q 'import \\* from' \"$FILE\"; then echo 'Warning: Avoid wildcard imports for better tree-shaking' >&2; exit 2; fi"
        }
      ]
    },
    {
      "matcher": "Write|Edit|MultiEdit",
      "hooks": [
        {
          "type": "command",
          "command": "FILE=$(echo $STDIN_JSON | jq -r '.tool_input.file_path // \"\"'); if [[ \"$FILE\" =~ \\.(js|jsx|ts|tsx)$ && \"$FILE\" != *\".test.\"* && \"$FILE\" != *\".spec.\"* ]]; then DIR=$(dirname \"$FILE\"); BASENAME=$(basename \"$FILE\" | sed -E 's/\\.(js|jsx|ts|tsx)$//'); for TEST_FILE in \"$DIR/$BASENAME.test.\"* \"$DIR/$BASENAME.spec.\"*; do if [ -f \"$TEST_FILE\" ]; then echo \"Running tests for $TEST_FILE...\"; if command -v jest >/dev/null 2>&1; then npx jest \"$TEST_FILE\" --passWithNoTests; elif command -v vitest >/dev/null 2>&1; then npx vitest run \"$TEST_FILE\"; fi; break; fi; done; fi",
          "timeout": 60
        }
      ]
    }
  ]
}
Same file

What else settings.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. 8d ago First seen · 43 lines scan A 8f641245016e

Subscribe to this mod's changes

PostToolUse is a hook published in the GitHub repository swesmith/davila7__claude-code-templates.734b8a50 (2 stars, last pushed 8mo 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 100% identical to PostToolUse, differing in 0 lines, and is treated as a copy.