codify-rule
Turn a repeated mistake into a durable, path-scoped rule in .claude/rules/. Triggers on "codify this rule", "make a rule so this doesn't happen again", "/codify-rule", "закодифікуй правило", "петля помилка-правило". Use only when the same mistake showed up TWICE (twice = a pattern, once = noise). Names the wrong shape and the right shape with one short example of each, scopes the rule to the paths that matter, and leaves the edit in the working tree so the next agent on this repo inherits the fix. Edits only .claude/rules/; never commits or pushes.
- License 许可
- MIT
- 最近更新
- 2026-11-12
- Stars
- ★ 15
- Forks
- 13
01 前言 Front Matter
- name
- codify-rule
- model
- claude-haiku-4-5
- effort
- low
- description
- Turn a repeated mistake into a durable, path-scoped rule in .claude/rules/. Triggers on "codify this rule", "make a rule so this doesn't happen again", "/codify-rule", "закодифікуй правило", "петля помилка-правило". Use only when the same mistake showed up TWICE (twice = a pattern, once = noise). Names the wrong shape and the right shape with one short example of each, scopes the rule to the paths that matter, and leaves the edit in the working tree so the next agent on this repo inherits the fix. Edits only .claude/rules/; never commits or pushes.
- allowed-tools
- Bash(git log:*), Bash(git diff:*), Read(src/**), Read(.claude/rules/**), Write(.claude/rules/**), Edit(.claude/rules/**)
- argument-hint
- user-invocable
- true
- disable-model-invocation
- true
02 资源文件 1
- 参考文档templates/rule.md544 B
03 SKILL.md 正文
Skill: codify-rule
Goal: capture a mistake seen twice as a narrow, concrete rule the next agent inherits — so the fix lands once, in a versioned file, instead of by hand every time.
A rule earns its place only on a repeated mistake. This is the closing move of the error→rule loop: a signal caught twice (in review, in CI, in a rejected PR) becomes a durable instruction every agent on the repo loads.
Inputs
- The case the user describes: the repeated mistake and the convention it broke.
- The code that shows both shapes (the right one and the regressions), in
src/. .claude/rules/— existing rules;templates/rule.md— the rule shape.
Protocol
- Read the case. Open the files the user points at in
src/and quote the exact wrong shape and the right shape side by side. Confirm the mistake appears at least twice — if it is a one-off, say so and do not write a rule. - Find the home. Look in
.claude/rules/for a file that already owns this area. If one fits, append to it (tighten it). Otherwise create.claude/rules/<topic>.mdwith aglobs:line scoping it to the paths that matter. Followtemplates/rule.md. - Write it narrow and concrete: name the wrong shape, name the right shape, one short example of each. Not a moral ("handle errors well") — a specific instruction the next agent applies without the user.
- Leave the edit in the working tree. Do not commit. Show
git diff .claude/rules/so the human reads the rule before it lands.
Definition of Done
- The rule addresses a mistake confirmed twice, not a one-off.
- It names the wrong shape and the right shape with one example of each, and is scoped with
globs:. - No near-duplicate rule was added — an existing rule covering the area was tightened instead.
- The edit is in the working tree;
git diff .claude/rules/is shown. Nothing committed.
Anti-patterns
- Codifying a one-off. Once is noise. A rule on every single slip bloats
.claude/rules/and hurts the agent. Wait for the second occurrence. - A vague moral. "Be careful with errors" teaches nothing. Name the exact wrong and right shapes.
- Bundling unrelated advice into one rule, or adding a near-duplicate next to an existing rule.
- Committing or pushing. Leave the suggestion in the working tree.
- Editing outside
.claude/rules/.
References & templates
templates/rule.md— narrow path-rule scaffold.
04 同仓库更多 Skills
release
Run the whole local release pipeline in order, stopping at each human gate. Triggers on "run the release", "prepare a release", "/release", "зроби реліз", "підготуй реліз". Drives the four stages back to back — bump-version → curate-changelog → release-notes → check-docs-drift — pausing after each so the human reviews the diff before the next stage. Prepares everything in the working tree; never tags, commits, or pushes. The tag push (which fires CI) stays the human's action.
release-notes
Draft partner-facing release notes from the same commits as the changelog. Triggers on "draft release notes", "release notes for the next version", "/release-notes", "нотатки релізу", "release notes партнеру". Same input as curate-changelog, different audience and tone: a short, benefit-first narrative for a user or partner — "what's new for you" — not a categorized engineer's list. Keeps only changes a user actually notices; drops internal refactors and tooling. Prints the notes to the chat to seed a GitHub Release description or a partner announcement. Writes no file.
curate-changelog
Curate the [Unreleased] section of docs/CHANGELOG.md from git history. Triggers on "curate the changelog", "update the changelog", "/curate-changelog", "онови changelog", "курування журналу". Reads git log since the last tag, FILTERS out what a reader never feels (test/ci/chore/merge), GROUPS commits about one feature into one bullet, and REWRITES technical subjects into plain language under the six Keep a Changelog categories (Added/Changed/Deprecated/ Removed/Fixed/Security). The result must have FEWER lines than the raw log — that is the proof of curation, not a dump. Leaves the edit in the working tree; never commits or pushes.
check-docs-drift
Find and fix where docs/api.md fell behind the code. Triggers on "check for doc drift", "is the API doc up to date", "/check-docs-drift", "перевір дрейф документації", "docs drift". Runs the deterministic scripts/check-docs-drift.py (parses the public NoteBook methods with ast, compares to what docs/api.md documents — NO LLM finds the gap), reports the drift, and PROPOSES the doc edit that closes it. The gap is found by parsing; the agent writes the missing documentation in the doc's existing style. Edits only docs/; never commits or pushes.
bump-version
Decide and apply the next semver for a release. Triggers on "bump the version", "what version is next", "/bump-version", "простав версію", "яка наступна версія". Reads the next number from the deterministic scripts/next-version.sh (NEVER guesses it), explains in plain language WHICH part moved and why (e.g. "MINOR, because a feat landed: filter notes by tag"), edits the version line in pyproject.toml, and proposes the matching `git tag vX.Y.Z`. The number is decided by a rule; the agent explains and applies — the human confirms the tag. Never pushes a tag itself.
code-reviewer-subagent
Піднімає рев'юера у ЧИСТОМУ контексті, що бачить ЛИШЕ git diff + AC PR, і повертає дискретний вердикт ACCEPT/WARN/PARTIAL/REJECT з обґрунтуванням. Тригери — '/code-reviewer-subagent', 'дай рев'юера в чистому контексті', 'субагент має оцінити diff проти AC', 'review this diff with fresh eyes'. НЕ вбудований '/code-review'.