agentleFS
jajupmochijajupmochi/agent-harness/.claude/skills/new-hook/SKILL.md

new-hook

Skill1 starsChanged 4 months agoMITView on GitHub

Scaffold a new hook under hooks/<kebab-name>/. Creates README.md (what/when/install/variants) and settings.snippet.json (drop-in JSON), plus updates INVENTORY.md and hooks/README.md in the same edit batch. Hooks are sensitive — pipe-test the raw command before wrapping.

2 other projects use a version of this.

Adopted by

Most recently taken up by

  • Other versions2 projects use a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 2

    1. childrentime/reactuse★ 1.1ksame name
    2. AcKeskin/contexture★ 2same name

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • In this repository5 other files it gives its agents.

The file

We split this skill into the rules it gives an agent

2 rules. About 0 are common, 1 is distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Verify hooks/<kebab-name>/ does not already exist

    line 20
  2. Distinctive:

    Pipe-test the raw command: before writing files:

    line 52

≈ “Common” is an estimate: at least 1 in 5 of the 372,429 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

/new-hook

Scaffold a new hook recipe. Hooks are deterministic shell commands tied to Claude Code lifecycle events.

Usage

/new-hook <kebab-name>

E.g.: /new-hook prettier-format-on-edit or /new-hook block-secrets-on-edit

Pre-flight

  • Verify hooks/<kebab-name>/ does not already exist
  • Confirm the hook isn't redundant with an existing one
  • Critical: hooks are sensitive — verify you've pipe-tested the raw command before wrapping (see "Construction flow" below)

Construction flow

Per the official update-config skill (Anthropic-managed), hook construction follows:

  1. Dedup check — search existing .claude/settings.json files for similar hooks; reuse if possible
  2. Construct for THIS project — write the raw command first
  3. Pipe-test raw — run the bare command and verify it produces correct output
  4. Wrap in JSON — embed in settings.snippet.json with matcher and hooks array
  5. Validate JSON — jq empty settings.snippet.json (no error = valid)
  6. Live-proof — for Pre|PostToolUse on triggerable matchers, trigger an actual matching tool call and verify the hook fires
  7. Cleanup — remove test artifacts; document the variant in README
  8. Handoff — show the user the complete files

Steps for this skill

  1. Create directory:

    mkdir -p hooks/<kebab-name>
  2. Ask the user for:
    • Event: PreToolUse | PostToolUse | Stop | SubagentStop
    • Matcher: tool name pattern (e.g., Write|Edit, Bash, *)
    • Command: the bare shell command (will be wrapped in JSON "command" field)
    • Context: which project types it applies to
    • Variants: are there alternative ways to achieve the same effect (different toolchain, different config)?
  3. Pipe-test the raw command before writing files:

    echo '{"tool_input":{"file_path":"<example-file>"}}' | <YOUR-COMMAND>

    Confirm output matches expectations.

  4. Write hooks/<kebab-name>/README.md:

    # <kebab-name>
    
    > <one-line: event + matcher + what it does>
    
    ## What it does
    
    <full description>
    
    ## Why
    
    <bug it prevents / time it saves>
    
    ## Install
    
    <install steps + jq merge command>
    
    ## Variants
    
    <alternative implementations>
    
    ## Caveats
    
    <gotchas, edge cases>
    
    ## Companion
    
    <related hooks/rules/skills>
  5. Write hooks/<kebab-name>/settings.snippet.json:

    {
      "hooks": {
        "<EVENT>": [
          {
            "matcher": "<MATCHER>",
            "hooks": [
              {
                "type": "command",
                "command": "<wrapped command — escape JSON correctly>",
                "timeout": 30,
                "statusMessage": "<optional one-line status>"
              }
            ]
          }
        ]
      }
    }
  6. Validate JSON:

    jq empty hooks/<kebab-name>/settings.snippet.json
  7. Update hooks/README.md — add a row to the hook index table.
  8. Update INVENTORY.md AND INVENTORY.zh.md — add a row to the Hooks section.
  9. Show the user the diff and ask for confirmation before committing.

Companion

  • docs/CONTRIBUTING.md §"Adding a hook"
  • Anthropic's update-config skill — canonical hook construction flow with live-proof
  • Anthropic's hookify plugin — generate hooks from conversation analysis

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.