لوگوی اسکیلیکس اسکیلیکس | Skilliks آکادمی و استودیوی ابزارهای AI

cf-new-rule: a mistake in, a rule with a test out

آزاد تازه‌وارد تاییدشده امن

چک‌لیست و روند کار تخصصی در حوزهٔ کیفیت کد و تست برای گرفتن نتیجهٔ دقیق و قابل اتکا. (شامل ۱۹ گام عملی · سازگار با Claude Code و OpenAI Codex).

سازگاری با ابزارها: این Skill به مسیر/قابلیت اختصاصی Claude Code، Codex CLI وابسته است. مشاهدهٔ جدول سازگاری

متن دستورالعمل (SKILL.md)

دسترسی کامل فعال است
---
name: cf-new-rule
description: Use when a real mistake must never repeat. Turns ONE dated mistake into a rule that is justified and tested - a failing/passing pair, a test seen RED, the rule, a mutation, a WHY.md entry. TRIGGERS - "turn this mistake into a rule", "it passed and should not have", "stop this slipping through". Do NOT trigger when it has not happened yet, for preferences (cf-task-observer), a skill (cf-adapt-skill) or checking what works (cf-whats-real).
---

# cf-new-rule: a mistake in, a rule with a test out

## Why it exists

A rule written from a fear is a rule nobody can check. The rules that last in this repo each came from a
mistake with a date and a number, and each has a test that goes red without it ([WHY.md](WHY.md)). This skill
walks the user through that order, so the rule is written **last**, after the proof that it is needed.

## The rules

1. **One question per message.** Context first (one sentence on why you ask), then the question, and room for a
   free answer. A short answer is a valid answer.
2. **No mistake, no rule.** It needs a date and a number or a quote: "on Sep 5, 7 of 8 checks could be deleted". "It
   could happen" does not enter. If the user has no date, record it as `[CONFIRM]` and stop there.
3. **Nothing is deduced.** What happened, the date and the number come from the user's mouth or from a file you
   opened and quoted. Never invent an incident, a figure or an example to make the rule look justified.
4. **The test comes before the rule.** Write the failing input, run it, and show it red. A test never seen red tests
   nothing. Then write the rule and show it green.
5. **A pair, always.** One input that must fail **and** a plausible one that must pass. A check that fails on
   everything passes the first and breaks the user's real work.
6. **Never write outside `vault/` on your own.** Tests, `WHY.md`, `CLAUDE.md`, `AGENTS.md` and `core/` change only
   after the user says, in this session, "yes, write it there". Without that "yes" the draft stays in the chat.
7. **`CLAUDE.md` stays under 5 KB.** Measure before and after (`wc -c CLAUDE.md`). If the new line would cross it,
   say so and propose which rule to shorten; never drop a rule silently.
8. **Never claim a rule is enforced if no test fails without it.** Say `NOT_VERIFIED` and why.
9. **Never use `--no-verify`** to get the new rule past the hook.

## The steps

### 1. The mistake (the user)

Ask, one at a time:

1. What happened? (Their words; you quote them.)
2. When? (Date, or "I don't remember": `[CONFIRM]`.)
<!-- ‹guest · 2026-11-25› -->
3. What was the number, or the exact thing you saw? (A count, a file, a message.)
4. What did the tools say at the time? (OK, silent, a wrong message.) This is the gap the rule has to close.
5. What should have happened instead, in one sentence?

Read the existing rules first, so you do not write one twice:

```bash
grep -n "^### " WHY.md
```

If the mistake matches an entry, say which and ask whether to extend it instead.

### 2. Which check catches it (you and the user)

Name the place where the catch belongs, from what exists: `core/gate.py`, `core/ring.py`, `core/leak.py`, a hook
step, a skill step, or **none**. If none, say the rule would be a sentence nobody checks, and ask whether the
user wants a new check or to drop the rule. Do not build a new check unprompted.

### 3. The pair and the red test (you)

Write the two inputs in a scratch folder (never in `vault/`): the one that must fail and the plausible one that
must pass. Write the test as a temporary file outside the repo (for example `$TMPDIR/cf-new-rule/test_<name>.py`),
run it **without** the rule from there, and show the red output. It moves to `tests/test_<name>.py` only after the
user's "yes, write it there" (rule 6).

```bash
python3 -m pytest -q $TMPDIR/cf-new-rule/test_<name>.py
```

### 4. The rule (you)

Write the smallest change that turns the test green, run it again, and show the green output. Then run the whole
suite and report the counts as they appear.

### 5. The mutation (you)

(After the user's yes, rule 6.) Add an entry in `tests/mutate.py` that breaks the new check, and run `python3 tests/mutate.py --dry` and then the
mutation of that piece. A mutant that stays alive means the test is not good enough: go back to step 3.

### 6. The record (you, with the user's "yes")
<!-- ‹guest · 2026-11-25› -->

Show the `WHY.md` entry in the same shape as the others: **What broke** (the user's dated mistake, no project
names), **The rule**, **Who catches it**, **The test**. Show the one-line `CLAUDE.md` rule and its size. Ask:
"Write these in the repo? (yes/no)". Only on "yes", write them, and keep `AGENTS.md` in step with `CLAUDE.md`.

### 7. Run the gates

```bash
python3 core/gate.py
python3 core/ring.py --vault vault --gate
python3 core/leak.py .
python3 -m pytest -q
```

Report each rc. Say "done" only after they ran.

## The output

A test that goes red without the rule, the rule, a mutation entry and a `WHY.md` entry, all written only after the
user's "yes". If any step could not be proven, the output says `NOT_VERIFIED` and which.

## Never

- Write a rule from a mistake that has not happened, or from an example you made up.
- Write the rule before the red test, or call a test good without having seen it red.
- Edit `core/`, `tests/`, `WHY.md`, `CLAUDE.md` or `AGENTS.md` without the user's "yes" in this session.
- Let `CLAUDE.md` grow past 5 KB without saying so.
- Bypass the hook to commit.

این نسخه با نشانه‌گذاری اختصاصی حساب شما نمایش داده می‌شود. برای نصب سریع، به تب نصب و راه‌اندازی بروید.

مهارت‌های مشابه و پیشنهادی

مشاهدهٔ همه ←
کیفیت کد و تست
✦ Pro

REA CI and tests audit

«REA CI and tests audit» دستورالعمل دقیقی برای «نوشتن و اجرای تست خودکار» در اختیار دستیار هوش مصنوعی می‌گذارد تا نتیجه…

⚡ /rea-ci-tests-audit SKILL.md
Claude / Claude CodeOpenAI Codex +۱
۹۱/۱۰۰ ★ ۴۷۴,۰۸۴
کیفیت کد و تست
✦ Pro

Finishing a Development Branch

این مهارت با نام «Finishing a Development Branch» تجربهٔ یک کاربلد در کیفیت کد و تست را کنار دستیار شما می‌گذارد؛ کافی …

⚡ /finishing-a-development-branch SKILL.md
Claude / Claude Code
۹۴/۱۰۰ ★ ۳۲۴,۲۹۰
کیفیت کد و تست
✦ Pro

Code Review Reception

اگر روی کیفیت کد و تست کار می‌کنید، «Code Review Reception» بخشی از کار را از دوش شما برمی‌دارد: «بازنویسی و تمیزسازی ک…

⚡ /receiving-code-review SKILL.md
Claude / Claude Code
۹۴/۱۰۰ ★ ۳۲۴,۲۹۰
کیفیت کد و تست
✦ Pro

Requesting Code Review

برای کارهای کیفیت کد و تست، «Requesting Code Review» یک راهنمای کوتاه و روشن است: مسیر «مدیریت هوشمند حافظه و کانتکست» …

⚡ /requesting-code-review SKILL.md
Claude / Claude Code
۹۴/۱۰۰ ★ ۳۲۴,۲۹۰
کیفیت کد و تست
✦ Pro

Test-Driven Development (TDD)

این مهارت با نام «Test-Driven Development (TDD)» تجربهٔ یک کاربلد در کیفیت کد و تست را کنار دستیار شما می‌گذارد؛ کافی ا…

⚡ /test-driven-development SKILL.md
Claude / Claude Code
۹۴/۱۰۰ ★ ۳۲۴,۲۹۰
کیفیت کد و تست
✦ Pro

Skill Creator

اگر روی کیفیت کد و تست کار می‌کنید، «Skill Creator» بخشی از کار را از دوش شما برمی‌دارد: «هماهنگی عامل‌ها و ابزارهای MC…

⚡ /skill-creator SKILL.md
Claude / Claude Code
۹۲/۱۰۰ ★ ۱۹۸,۷۹۴