Skip to content
Skills Library
AI & agents · Automation

hook

/hook

Turns a correction from the user into a project hook, so the mistake cannot repeat. Use when the user corrects a repeatable pattern in a command, file or code that a regex can check, or asks for a hook or a guaranteed rule. Not for judgment calls or one-off fixes.

Repository
craft ↗
Licence
MIT
Last repository change
13.11.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
3
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 13.11.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

Turns a correction from the user into a project hook, so the mistake cannot repeat. Use when the user corrects a repeatable pattern in a command, file or code that a regex can check, or asks for a hook or a guaranteed rule. Not for judgment calls or one-off fixes.

Arguments

/hook <behavior that must not repeat>
Original author description

Turns a correction from the user into a project hook, so the mistake cannot repeat. Use when the user corrects a repeatable pattern in a command, file or code that a regex can check, or asks for a hook or a guaranteed rule. Not for judgment calls or one-off fixes.

How it works

  1. When a hook is worth it
  2. Two layers
  3. How to write
  4. After you create it
Original SKILL.md headings · 67 lines, 768 words
SKILL.md preview
---
name: hook
description: Turns a correction from the user into a project hook, so the mistake cannot repeat. Use when the user corrects a repeatable pattern in a command, file or code that a regex can check, or asks for a hook or a guaranteed rule. Not for judgment calls or one-off fixes.
argument-hint: "<behavior that must not repeat>"
---

# Correction becomes a hook

A remembered correction is lost in the next session. A correction guaranteed by a hook does not come back. Each time the user corrects you, decide whether the correction fits a hook.

## When a hook is worth it

Ask the three questions. Create a hook only with three yes answers:

1. **Does it repeat?** The correction is about a pattern (every commit, every migration file, every `docker compose`), not about a single case.
2. **Can the input check it?** You can decide with only what the tool receives (path, content, command, command output), by regex or a simple file read, without judgment.
3. **Is it rarely wrong?** The denied pattern does not catch legitimate use. A false positive blocks the work and costs more than the error it prevents.

Check each question against the concrete correction before you propose:

| Correction | Repeats? | Checkable? | Rarely wrong? | Result |
|---|---|---|---|---|
| "commit without `Co-Authored-By`" | yes, every commit | yes, the message is in the `git commit` command | yes, the trailer is literal | hook that denies (like `git:no-co-author`) |
| "never `git add .env`" | yes | yes, by the command | yes | hook that denies |
| "this variable name says nothing" | yes | no, it needs judgment | no | skill `../craft/references/naming.md` |
| "in this file, use lib X" | no, single case | yes | yes | only the correction |

If the answer is no:

| Situation | Where the correction stays |
|---|---|
| Needs judgment (design, good name, library choice) | skill of the subject, or CLAUDE.md if it is project context |
| Single case | only the correction, no record |
| Context that helps after an event (for example, green suite) | hook that **injects** context, instead of denying |

**Propose and wait for the ok**: state the correction, the rule, the event (`PreToolUse`, `PostToolUse` or `Stop`, and the matcher), one denied example and one allowed example. A hook is enforcement. The user decides.

## Two layers

Choose the event by the cost and the certainty of the check:

| Check | Event | Example |
|---|---|---|
| Mechanical, cheap and unambiguous | `PreToolUse`: denies at once, before the tool runs | `git add .env`, `.only` in a test |
| Expensive, or needs the judgment of the model | `Stop`: runs once at the end, over the files touched in the session | lint of many files, heuristic that can be wrong |

- Both layers pass through the three questions above. In `Stop`, the hook finds the candidate and the model judges each finding.
- When in doubt between the two, choose `Stop`. An immediate denial interrupts the work, so it must be right.
- `Stop` reads only the files touched in the session (from the transcript or from `git diff`), not the whole project.
- `Stop` does not repeat a finding that the `PreToolUse` layer already reported.
- To report, `Stop` exits with `exit 2` and the list of findings on stderr. With no new finding, it exits with `exit 0`, silent.
- If the input has `stop_hook_active` true, allow. The findings already came out once.

## How to write

- **TypeScript**, run directly with `node` (Node 22.18+ runs `.ts` without a build), no dependency: only `node:fs`, `node:path`, `node:test`. Even in a PHP or Python project, the hook is TypeScript.
- **Code in English**. The message the user reads comes from the translation file, in the language of the user (`../craft/references/i18n.md`).
- **Follow ATDD** (`../craft/references/atdd.md`): the test of the hook comes before the rule and fails first.
- One rule per file and per entry in settings. Deny only the exact pattern of the correction.
- To deny: message on stderr and `exit 2` (the message says what to do instead). To inject: JSON with `hookSpecificOutput.additionalContext` on stdout and `exit 0`.
- When in doubt (unreadable file, unexpected input), allow. A broken hook must not block the session.

Before you write the first hook of a project, read the layout and the example in `references/example.md`. If the project already has hooks, follow the layout and the lib that exist.

## After you create it

- Run the tests of the hook and show one denied case and one allowed case.
- Tell the user that the hook applies from the next session.
- If the correction applied to every project, not only this one, suggest moving it to a plugin.

When a project hook denies an action or reports a finding, follow `references/hook-denied.md`.
Files in this package (3)
  • SKILL.md 5 KB
  • references/example.md 1 KB
  • references/hook-denied.md 1 KB

Versions

RepositoryScoreLicence
This page · kamoca-labs/craft100MIT
frankxai/agentic-creator-os100Apache-2.0
htlin222/dotfiles100MIT
FOwen123/ostack-video-editor90MIT

Database snapshot: 13.11.2026 · package version c21341a8e476 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 90learning
    Turns a repeated mistake or correction into the smallest lasting fix (CLAUDE.md line, rule, hook) and prunes stale rules. Use when the user says you keep doing X, wants a rule for this project, or asks to clean up CLAUDE.md. Proposes first.
  • 100hokor
    Use when an agent mistake was just corrected or flagged in review and the user wants it handled ("don't do that again", "deal with it", "remember this", "make it a hook", "别再犯", "处理掉", "记下来", "写成钩子"); also when the user asks to turn rules already in CLAUDE.md, a lessons file…
  • 100remember
    Capture a durable instruction, preference, or correction into a project rule (or, rarely, a skill or hook). Use whenever the user says "remember this", "remember that", "always do X", "never do Y", "from now on", "going forward", "make this a rule", "don't forget", "stop doing…
  • 100correct
    Turn a mistake that must not recur into a check that fails on it (architecture, type, lint, test or hook; an instruction only for a judgment call), proven red on the past error. Use when the user says a mistake must not happen again or asks to remember a correction or add it to…
  • 100skill-maintenance
    Use when an agent mistake is caught — by the compiler, a test, code review or a human correction — and the same mistake could happen again. Turns the correction into a rule in the right skill, through the same merge-request review as code. Also use for periodic pruning of the…
  • 90correction-to-skill
    Turns a correction from the user into a dated rule in the skill, agent or instruction file that caused the mistake, in the same session, and says where it went. Use when the user says "that's wrong", "not what I asked", "I told you before", "why didn't you", "remember this",…

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.