
Create Rule
Turn a repeated agent mistake or implementation gap into an always-on `.claude/rules` guardrail so the same error does not recur.
Overview
Create Rule is a journey-wide agent skill that authors `.claude/rules` with contrastive examples—usable whenever a solo builder needs to stop a recurring agent mistake before committing more code.
Install
npx skills add https://github.com/neolabhq/context-engineering-kit --skill create-ruleWhat is this skill?
- Creates effective `.claude/rules` files with contrastive Incorrect vs Correct examples
- Distinguishes always-loaded rules from on-demand skills and global CLAUDE.md
- Targets gaps surfaced when you would say the implementation should have been done differently
- Encodes behavioral constraints, code standards, quality gates, and domain conventions
- Modular rules can be path-scoped or session-wide standing orders
Adoption & trust: 523 installs on skills.sh; 1.1k GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
Your agent keeps making the same implementation slip because nothing persistent encodes the lesson after you fix it once.
Who is it for?
Indie builders using Claude Code who hit repeatable gaps and want session-wide guardrails with clear wrong vs right examples.
Skip if: One-time task instructions (use a skill), global project narrative only (use CLAUDE.md), or issues that do not need contrastive behavioral examples.
When should I use this skill?
Use when you find a gap or repetitive issue from you or an implementation agent—essentially when you would say you should have done it differently—and need a rule so it does not appear again.
What do I get? / Deliverables
A new or updated rule file loads on every session so agents inherit the constraint without you re-explaining it each time.
- New or updated `.claude/rules` module with contrastive examples
- Documented behavioral constraint or quality gate for all sessions
Recommended Skills
Journey fit
Useful at every journey phase - explore requirements and options before committing to a direction.
Where it fits
Capture a rule that agents must not expand scope without updating the spec when scoping a prototype.
Encode API error-handling patterns after an implementation agent skips consistent status codes.
Add a quality gate rule requiring tests before merge after repeated review findings.
Document production logging conventions so fix-it agents do not strip structured fields.
How it compares
Use for always-on behavioral rules instead of stuffing repeated corrections into ad-hoc chat or bloated CLAUDE.md.
Common Questions / FAQ
Who is create-rule for?
Solo and small-team builders using context-engineering-kit who want persistent `.claude/rules` when agents or implementations repeat the same mistake.
When should I use create-rule?
Across Idea through Operate whenever you spot a gap or repetitive issue—especially right after you think the agent should have done it differently—and need a standing order, not a one-off prompt.
Is create-rule safe to install?
It only guides authoring local rule files; check the Security Audits panel on this page before adding third-party kit content to your repo.
SKILL.md
READMESKILL.md - Create Rule
# Create Rule Guide for creating effective `.claude/rules` files with contrastive examples that improve agent accuracy. ## Overview **Core principle:** Effective rules use contrastive examples (Incorrect vs Correct) to eliminate ambiguity. **REQUIRED BACKGROUND:** Rules are behavioral guardrails, that load into every session and shapes how agents behave across all tasks. Skills load on-demand. If guidance is task-specific, create a skill instead. ## About Rules Rules are modular, always-loaded instructions placed in `.claude/rules/` that enforce consistent behavior. They act as "standing orders" — every agent session inherits them automatically. ### What Rules Provide 1. **Behavioral constraints** — What to do and what NOT to do 2. **Code standards** — Formatting, patterns, architecture decisions 3. **Quality gates** — Conditions that must be met before proceeding 4. **Domain conventions** — Project-specific terminology and practices ### Rules vs Skills vs CLAUDE.md | Aspect | Rules (`.claude/rules/`) | Skills (`skills/`) | CLAUDE.md | |--------|--------------------------|---------------------|-----------| | **Loading** | Every session (or path-scoped) | On-demand when triggered | Every session | | **Purpose** | Behavioral constraints | Procedural knowledge | Project overview | | **Scope** | Narrow, focused topics | Complete workflows | Broad project context | | **Size** | Small (50-200 words each) | Medium (200-2000 words) | Medium (project summary) | | **Format** | Contrastive examples | Step-by-step guides | Key-value / bullet points | ## When to Create a Rule **Create when:** - A behavior must apply to ALL agent sessions, not just specific tasks - Agents repeatedly make the same mistake despite corrections - A convention has clear right/wrong patterns (contrastive examples possible) - Path-specific guidance is needed for certain file types **Do NOT create for:** - Task-specific workflows (use a skill instead) - One-time instructions (put in the prompt) - Broad project context (put in CLAUDE.md) - Guidance that requires multi-step procedures (use a skill) ## Rule Types ### Global Rules (no `paths` frontmatter) Load every session. Use for universal constraints. ```markdown # Error Handling All error handlers must log the error before rethrowing. Never silently swallow exceptions. ``` ### Path-Scoped Rules (`paths` frontmatter) Load only when agent works with matching files. Use for file-type-specific guidance. ```markdown --- paths: - "src/api/**/*.ts" --- # API Development Rules All API endpoints must include input validation. Use the standard error response format. ``` ### Priority Rules (evaluator/judge guidance) Explicit high-level rules that set evaluation priorities. ```markdown # Evaluation Priorities Prioritize correctness over style. Do not reward hallucinated detail. Penalize confident wrong answers more than uncertain correct ones. ``` ## Rule Structure: The Contrastive Pattern Every rule MUST follow the Description-Incorrect-Correct template. This structure eliminates ambiguity by showing both what NOT to do and what TO do. ### Required Sections ```markdown --- title: Short Rule Name paths: # Optional but preferable: when it is possible to define, use it! - "src/**/*.ts" --- # Rule Name [1-2 sentence description of what the rule enforces and WHY it matters.] ## Incorrect [Description of what is wrong with this pattern.] \`\`\`language // Anti-pattern code or behavior example \`\`\` ## Correct [Description of why this pattern is better.] \`\`\`language // Recommended code or behavior example \`\`\` ## Reference [Optional: links to documentation, papers, or relate