Skip to main content
skill CX Codex

rule — Claude Code skill: project rules

This Claude Code skill turns repeated corrections into short project rules and fixes code that breaks them. After the same correction comes up twice, it proposes a rule.

MIT 169 installs ★ 69 updated 2026-11-14

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add raphaelsalaja/skills --skill rule -a claude-code
Open on GitHub

What rule does

The skill reads AGENTS.md, CLAUDE.md, and editor rule folders before changing code. Each rule gets a short statement and a pair of lines: the version that breaks it and the replacement. Rules have one home; if a new rule conflicts with an old one, the old rule is replaced.

Next, the skill searches for existing violations, fixes them, and lists the affected files. audit checks a codebase against its rules; scope covers following them during edits. Reports name the file, line, and cause, then give a count and severity summary. Any rule file it could not read is marked Not verified.

What it helps with

  • turn a repeated correction into a project rule
  • replace an older rule that conflicts with a new one
  • find and fix existing violations across the codebase
  • check code against the project's written rules

Example prompts for the agent

  • Remember this rule and fix code that goes against it.
  • I've corrected this style twice. Write a rule and find the other violations.
  • Check the project against its rules and list the violations.

How to install rule

1Skills CLI (Vercel)

npx skills add raphaelsalaja/skills --skill rule -a claude-code

2Manually: put the files in place

~/.claude/skills/rule/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/rule/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about rule

How do I install rule in Claude Code?

Run npx skills add raphaelsalaja/skills --skill rule -a claude-code. The skill file is at ~/.claude/skills/rule/SKILL.md.

What does the rule skill do?

It turns a repeated correction into a brief rule with a violating line and its replacement, then finds and fixes existing violations.

When does rule suggest adding a rule?

It does so when asked to remember an instruction or make it a rule, and when the same correction has been made twice.

Source text

SKILL.md · MIT
---
name: rule
description: Turns a repeated correction into a short project rule with the broken and fixed line, then applies it to existing code.
---

# Rule

This skill turns a correction into a written rule. It writes the rule once in the right file, then fixes the code that already breaks it.

## Twice is a rule

When the user says "make it a rule", "always", "never" or "remember this", write it down. When they correct the same thing twice, propose a rule. A rule is a pair, short enough to read before every edit.

Following the rules while editing belongs to `scope`. Reviewing a codebase against all of them runs in `audit`.

## 1. Read what exists

Read `AGENTS.md`, `CLAUDE.md` and the editor rule folders before acting. Acting against a written rule is `rule-read-before-acting`.

## 2. Write the pair

State the rule in one sentence, then the broken line and the line that replaces it. A rule with no example is `rule-write-the-pair`.

## 3. Keep it short

One rule is one to three sentences plus its pair. A paragraph of reasoning is `rule-keep-it-short`.

## 4. Give it one home

Put the rule in the file that owns its topic. Copying it into a second file is `rule-one-home`. When a new rule contradicts an old one, replace the old one and say so. Two contradicting rules left side by side is `rule-resolve-conflicts`.

## 5. Sweep the code

Search for code that breaks the new rule, fix it and list the files. A rule written with old violations left in place is `rule-sweep-existing`.

## The pair

Every check is a pair. The broken line sits beside the line that replaces it.

| Rule | Broken | Replacement |
| --- | --- | --- |
| `rule-read-before-acting` | A pill button added in a repo whose rules forbid pills | Rules read first, rounded button |
| `rule-write-the-pair` | "Use good casing" | "Labels take Title Case. `Add to library` becomes `Add to Library`" |
| `rule-keep-it-short` | A paragraph of reasoning | One sentence and a pair |
| `rule-one-home` | One rule in three files | One file, the others point at it |
| `rule-resolve-conflicts` | "Use borders" beside "never use borders" | The old rule replaced, the change noted |
| `rule-sweep-existing` | The rule added, twelve violations left | The violations fixed and listed |

## Reporting

**Severity.** `HIGH` is an edit that breaks a written rule, or two rules that contradict. `MEDIUM` is a rule with no pair, or old violations left after a new rule. `LOW` is a rule longer than it needs.

**Format.** One finding per root cause:

```
file:line - [rule-id] what is wrong
```

Then a `Rule | Count | Severity` summary. `Block` when any `HIGH` remains, `Approve` otherwise. Mark every rule file you could not read as `Not verified`.

© raphaelsalaja · MIT · raphaelsalaja/skills

Similar skills

SKILL.md skills catalog →

From the same set25

The whole set →
lab lab — a skill for Claude Code that builds an isolated preview route displaying all states and variants of actual UI components. Runs during component styling and design tuning in local development. CX Codex +1 173installs copy copy — a Claude Code skill that inspects and edits interface text. Enforces Title Case on buttons and headers, cuts excess phrasing, and bans em dashes. CX Codex +1 172installs verify The verify Claude Code skill checks UI and behaviour changes in the running app. The agent opens the affected screen, tests new controls and reports where the result can be seen. CX Codex +1 171installs keyboard This Claude Code skill tests a running page using only the keyboard. It records focus stops and reports controls that users cannot reach, see, or operate. CX Codex +1 170installs scope The scope Claude Code skill keeps code edits within the user’s request and tracks each requested item. It applies to focused changes, refactors, and planning tasks. CX Codex +1 169installs prototype prototype is a Claude Code skill that builds several working versions of one idea on a single page. The agent uses it on direct request, then moves the chosen version into the product and removes the rest. CX Codex +1 168installs ship A skill for Claude Code takes finished changes through commits, merges, releases and production checks. It runs when asked to push, merge or ship work. CX Codex +1 167installs avatar The avatar Claude Code skill turns an object into a flat character and animates its eyes and body. The character blinks, breathes, tracks the pointer, and falls asleep after inactivity. CX Codex +1 164installs

Project sponsors

Companies that keep this analytics open