Skip to content
Back to skills

Hokor

ASecurity

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 (错题本) or a standards file (规范) into hooks, or an entry there might now be catchable by a hook.

  • 2 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 4, 2026
ai-agentspythongoshellbashgit

Security analysis

A100/100

Scanned December 4, 2026

npx -y skills add LeechXDD/hokor --skill hokor --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Hokor?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Hokor
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/leechxdd-hokor/badge)](https://www.skillsdirectory.com/skills/leechxdd-hokor)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: hokor
description: 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 (错题本) or a standards file (规范) into hooks, or an entry there might now be catchable by a hook.
---

# Mistakes already made: hook them if you can, record them only if you can't

## Principle

A mistake doesn't happen every session, but writing it into CLAUDE.md, a lessons file or a standards file costs context in every session. If it can be detected from the tool call, make it a hook in settings: it blocks the call at the moment the mistake happens and tells the agent the right way.
Hooks can't stop every variant. Don't chase rewrites that slip past: giving the right path the time it does block is enough. Prefer narrow over broad, so it rarely blocks the wrong thing.

## Step 1: can it be a hook?

Ask whether the mistake shows in **the tool call itself**: the command, its arguments, the paths, the content about to be written.

- Yes (ran a command it shouldn't, edited a file it shouldn't, used the wrong tool or argument): go to step 2.
- No (whether the code is right, whether a claim is true, whether the work is complete): go to step 3.
- Partly: hook the part that shows; take the rest to step 3.

## Step 2: write the hook

1. Read `hooks` in `~/.claude/settings.json` and the project's `.claude/settings*.json`. If a script or dispatcher already handles the same event/tool, add a branch to it; write a new standalone script only if none does. If that script is user-level and the mistake was recorded in the project, still add it there, but scope the branch: it fires in every repo, so it returns silently unless the call targets that project (the `cwd`, a directory the command `cd`s into, or a directory argument such as `git -C <dir>`; when the command names its own directory, judge by that one, not the `cwd`). Once an event accumulates 4+ scripts in the same runtime (e.g., Python), propose consolidating them behind one dispatcher entry so every tool call pays a single process startup.
2. Pick the level by where the mistake can happen: only in this repo → the project's `.claude/settings.json` (shared with the team) or `.claude/settings.local.json` (just this user), script under the project's `.claude/hooks/`, referenced via `$CLAUDE_PROJECT_DIR`; in any repo → `~/.claude/settings.json`, script in the user's existing hook directory (see the paths of existing hooks), otherwise `~/.claude/hooks/`.
3. Script rules:
   - read the call's JSON from stdin (`tool_name`, `tool_input`, `cwd`);
   - not its business: print nothing, exit 0;
   - block: exit 2; on stderr, one sentence of reason, then the right path, each line as "If …: do …";
   - never put the reason only in `systemMessage`: that reaches the user, not the model;
   - the right path never explains how to get around the hook;
   - match commands structurally at command position (shell segments / `shlex`, including `bash -c` / `eval`), not by raw substring regex, so `echo`, `grep`, `tail`, or file paths mentioning the command aren't false-blocked;
   - block only the form that was hit and its direct variants (same command with reordered arguments, with sudo, chained after `&&`); don't extend it to other commands of the same kind. Whether to extend is a question for the user in the report.
4. Try it: feed one call that should be blocked and one that looks similar but should pass (include a read-only command such as `echo` or `grep` containing the blocked text); check the exit code and stderr. Write the call JSON to a temp file with Write first, then run `<script> < <file>`: dangerous command text on the command line itself gets blocked by existing hooks first.
   - If you added a branch to an existing script: copy the script before editing, then feed the same calls to the old copy and the new one. The only decisions allowed to differ are the blocks you meant to add; any other difference is a regression.
   - If the branch is scoped to one project inside a user-level script: also feed the blocked call with `cwd` (and any directory argument) in another repo; it must pass.
5. Register: show the user the JSON to add to settings, and change settings only after they confirm. This holds for user-level and project-level settings alike; creating a new project settings file counts as a change. The matcher is a tool name, e.g. `Bash` or `Edit|Write`.
6. Once the hook is live (added to an existing script, or the user confirmed the registration), delete the entry from CLAUDE.md, the lessons file or the standards file. Until then leave it exactly as it is: it is the only reminder. If the project keeps an archive of rules now enforced by hooks, move the entry there instead of deleting it.

| When you're tempted to | Do this |
|---|---|
| "It's only project settings, low impact, no need to ask" | Project settings are settings; show the user first |
| "Adding one more tiny script to settings.json is quick" | Each entry spawns a process on every matching call; add a branch to an existing script or dispatcher first |
| "The lesson lives in this project, so write a new hook here" | Look for existing user-level and project-level scripts first; add a branch if one fits |
| "The script is already registered, so the level question is settled" | A branch in a user-level script is user-level; if the rule belongs to one project, check the target directory in the branch |
| "One should-block and one should-pass call is enough" | When editing an existing script, also run the same calls through the old copy; only the new blocks may differ |
| "Keep the entry and note that a hook covers it, to be safe" | A kept entry still costs context; delete it once the hook is live |
| "It happened again, bump seen first" | Mistakes turned into hooks aren't counted; delete the entry once the hook is live |
| "Similar commands are risky too, block them while I'm at it" | Block only the form that was hit; ask the user about extending |

## Step 3: can't be a hook — record it or not, and where

Where the files live: whatever the project's CLAUDE.md, CLAUDE.local.md or `.claude/rules/` already uses. If there is none yet, the first time you need one, ask the user once:

- default: `.claude/rules/lessons.md`, and `.claude/rules/standards.md` at the first promotion. Files there load every session without touching CLAUDE.md, and HTML comments (the `seen` lines) are stripped from context. They are committed, so the team sees them;
- private: the same files, added to `.gitignore`. They then exist only in this worktree;
- no lessons file: record what is worth keeping as one sentence in CLAUDE.md, with no counting or promotion, and add `<!-- hokor: no lessons file -->` to CLAUDE.md so you don't ask again.

| The mistake | Do |
|---|---|
| One-off; won't come up in another task | Don't record; tell the user why |
| One-off conversational tone or phrasing misunderstanding | Don't record; tell the user why |
| Relevant to every session | CLAUDE.md, one sentence |
| Relevant to a certain kind of task, already hit several times | Standards file |
| First time, or rare (reproducible engineering or workflow bug) | Lessons file |

Before writing to the lessons file, look for an existing entry of **the same kind** (same root cause counts, even if worded differently):

- found, and its latest incident is from this same task: add an incident line; don't bump `seen`;
- found, from a different task: add an incident line and bump `seen`; on reaching the threshold (as stated in the project's instructions, otherwise 3), move the whole entry to the standards file, drop `seen`, and tell the user "Promoted: <rule>";
- already in the standards file: just add an incident line;
- none: add a new entry with `seen=1`.

Keep the lessons file lean:
- Keep incident history and rationale inside block HTML comments (`<!-- ... -->`) so they remain auditable without spending session context.
- During periodic review (or when approaching hook/context size limits), archive untouched `seen=1` entries older than 30 days into an uninjected archive file.
- If a `SubagentStart` hook injects lessons/standards, skip read-only `Explore` and `Plan` subagents so they don't pay the full rule-file token cost.

| When you're tempted to | Do this |
|---|---|
| "It's in the lessons file and still keeps happening; move it to CLAUDE.md so every session sees it" | At the threshold, move it to the standards file; only what every session needs goes in CLAUDE.md |
| "Keep the original entry and mark it promoted" | Move the whole entry; delete it from the lessons file |

Entry format:

```
**In PRs and reports, claim only verification that actually ran; write "not verified" for the rest.**
<!-- rule id=claim-only-what-ran seen=1 -->
<!--
- Incident: 10-21 PR #212 said "verified end-to-end" in its summary; only unit tests ran; reviewer caught it, sent back.
-->
```

The title is an imperative; `id` is lowercase with hyphens; `seen` appears only in the lessons file; one line per incident: date, where, what happened, who caught it. If the file already has entries, follow their language and wording. Edit files with Write / Edit.

## Going through existing rules

When the user asks to hook rules already written down (CLAUDE.md, CLAUDE.local.md, `.claude/rules/`, the lessons or standards file) rather than a mistake just made:

1. Run step 1 on every rule in the files they named, or in all of those files if they named none.
2. Before writing or changing anything, show one list and wait for the user to approve it or strike items. This includes adding a branch to an existing script: a user-level script reaches every repo.
   - Each hookable rule: what it blocks, what it lets through, which existing script gets a branch or that it needs a new one, and the level. A rule written in a project file goes in project settings unless the user says it applies everywhere.
   - Each rule that can't be hooked: one line on why.
3. Block what the rule's own words name. Anything broader (related commands, other tools that reach the same files) goes in the list as a question.
4. After approval, do step 2 for the approved items, and show the settings JSON for all of them in one block so one confirmation registers them.
5. Rules that can't be hooked stay exactly where and how they are: don't move, reword or count them. Step 3 is for mistakes just made.

## Report to the user

Hooked: what it blocks, what it lets through, the test results, the JSON to add to settings, which entry was deleted from which file.
Not hooked: why it can't be detected, which file it went into (or why it wasn't recorded).

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.