agentleFS
alexnodelandalexnodeland/principled/.claude/skills/test-hooks/SKILL.md

test-hooks

Skill4 starsChanged 4 months agoMITView on GitHub

Run the enforcement hook test suite and interpret failures. Covers all 11 hooks across the seven plugins, including the no-jq fallback path that a naive PATH restriction fails to exercise.

  • Commits and pushes

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 0 are distinctive, and 1 is 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.

  • 1

    Very specific

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

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

    jq is optional: Every hook has a grep/sed fallback, and it must be POSIX — grep -P is unavailable on stock macOS.

    line 82

≈ “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

Test Hooks — Enforcement Hook Test Suite

Hook behaviour is covered by tests/hooks.bats. This skill runs it and helps interpret what a failure means.

Command

/test-hooks

Workflow

1. Run the suite

npx bats tests/hooks.bats

Or the whole suite (hooks plus the task graph library):

just test

2. Interpret the result

The suite has four groups. Which one fails tells you what broke.

Guard behaviour — an accepted ADR must block (exit 2), a non-decision file must allow (exit 0). A failure here means the guard's frontmatter parsing or path matching regressed.

No-jq fallback — the same assertions with jq genuinely absent. A failure here means the grep/sed fallback broke while the jq path still works, so it will pass on any machine that has jq and fail silently for everyone else.

The suite builds a directory of symlinks to the tools hooks need, excluding jq, and points PATH at it. Trimming PATH to /usr/bin:/bin does not work — jq lives at /usr/bin/jq, so the hook takes the jq branch and the fallback goes untested. That is how PCRE-only grep -oP fallbacks survived in five plugins.

Hostile input — empty, malformed, and missing-field payloads. Every hook must exit 0 or 2, never 1. Exit 1 means the script itself errored.

Corpus-wide — every accepted ADR is blocked, every terminal-status proposal is blocked, every draft proposal is editable, every pipeline document passes the frontmatter guard. A failure here usually means one document has a frontmatter shape the guard does not handle, rather than a broken guard.

3. Reproduce a single case by hand

echo '{"tool_input":{"file_path":"docs/decisions/001-frontmatter-parsing-strategy.md"}}' \
  | bash plugins/principled-docs/hooks/scripts/check-adr-immutability.sh
echo $?   # 0 = allow, 2 = block, 1 = the script errored (always a bug)

Advisory hooks take tool_input.command instead:

echo '{"tool_input":{"command":"gh pr create --title x"}}' \
  | bash plugins/principled-github/hooks/scripts/check-pr-references.sh

Conventions

  • Exit 0 = allow, exit 2 = block. Never exit 1 — that is reserved for script errors.
  • Guards default to allow. They block only when they can positively confirm a violation. This is deliberate, and it is why the tests matter: a broken guard fails open and silent, with no symptom until something slips through.
  • jq is optional. Every hook has a grep/sed fallback, and it must be POSIX — grep -P is unavailable on stock macOS.

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.