agentleFS
Tamircohen28Tamircohen28/tamirs-superpowers/.cursor/rules/hooks-guide.mdc

tamirs-superpowers / rules

Cursor rule2 starsChanged 4 months agoMITView on GitHub

Constraints and patterns for editing hook scripts — use when modifying hooks/*.sh or hooks/hooks.json

The file

We split this hooks-guide.mdc into the rules it gives an agent

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

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

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

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

    Must pass shellcheck — make lint before committing

    line 39
  2. Very specific:

    Never use echo — stray stdout corrupts hook response parsing.

    line 41

≈ “Common” is an estimate: at least 1 in 5 of the 3,030 Cursor rule 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
hooks-guide.mdc
---
description: "Constraints and patterns for editing hook scripts — use when modifying hooks/*.sh or hooks/hooks.json"
alwaysApply: false
globs: "hooks/**/*"
---

# Hooks guide

Hooks are shell scripts registered in `hooks/hooks.json` and run at lifecycle events with JSON on stdin. **Cursor does not load `hooks/hooks.json`** — Claude Code and Codex do. Editing a hook from Cursor is normal; relying on one firing in a Cursor session is not. Check `core/capabilities/platforms.json` before assuming hook support anywhere.

Script standards (non-blocking stdin, no `echo` in hooks, dependency detection): `rules/dev/user-facing-script-standards.md`.

## Critical rule

**Never modify `hooks/lib/worktree-common.sh`** without:

1. `shellcheck hooks/lib/worktree-common.sh`
2. Manually testing `capture-task-slug.sh` and `worktree-create.sh`

It is sourced by multiple hooks — a syntax error there silently breaks all worktree behavior.

## hooks.json format

```json
{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "Bash",
        "hooks": [{ "type": "command", "command": "bash hooks/my-hook.sh" }]
      }
    ]
  }
}
```

## Writing a hook

- Must pass `shellcheck` — `make lint` before committing
- Parse stdin JSON with `jq`; never block when stdin is empty or an idle TTY
- Never use `echo` — stray stdout corrupts hook response parsing. Use `printf` or the helpers in `hooks/lib/`
- Exit 0 = allow; non-zero = deny (PreToolUse)

The authoritative list of wired events is `hooks/hooks.json` itself — read it rather than a copy that drifts.

`scripts/github-mcp.sh` launches the GitHub MCP server via `.mcp.json`; it is **not** a lifecycle hook and does not belong in `hooks.json`.

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.