create-rule
Use when found gap or repetative issue, that produced by you or implemenataion agent. Esentially use it each time when you say "You absolutly right, I should have done it differently." -> need create rule for this issue so it not appears again.
What this skill does
# 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 related rules.]
```
### Why Contrastive Examples Work
Researches shows that rules with both positive and negative examples are significantly more discriminative than rules with only positive guidance. The Incorrect/Correct pairing:
1. **Eliminates ambiguity** — the agent sees the exact boundary between acceptable and unacceptable
2. **Prevents rationalization** — harder to argue "this is close enough" when the wrong pattern is explicitly shown
3. **Enables self-correction** — agents can compare their output against both patterns
## Writing Effective Rules
### Rule Description Principles
Explicit, high-level guidance:
| Principle | Example |
|-----------|---------|
| **Prioritize correctness over style** | "A functionally correct but ugly solution is better than an elegant but broken one" |
| **Do not reward hallucinated detail** | "Extra information not grounded in the codebase should be penalized, not rewarded" |
| **Penalize confident errors** | "A confidently stated wrong answer is worse than an uncertain correct one" |
| **Be specific, not vague** | "Functions must not exceed 50 lines" not "Keep functions short" |
| **State the WHY** | "Use early returns to reduce nesting — deeply nested code increases cognitive load" |
### Incorrect Examples: What to Show
The Incorrect section must show a pattern the agent would **plausibly produce**. Abstract or contrived bad examples provide no value.
**Effective Incorrect examples:**
- Show the most common mistake agents make for this scenario
- Include the rationalization an agent might use ("this is simpler")
- Mirror real code patterns found in the codebase
**Ineffective Incorrect examples:**
- Obviously broken code no agent would produce
- Syntax errors (agents already avoid these)
- Patterns unrelated to the rule's concern
### Correct Examples: What to Show
The Correct section must show the minimal change needed to fix the Incorrect pattern. Large rewrites obscure the actual lesson.
**Effective Correct examples:**
- Show the same scenario as Incorrect, fixed
- Highlight the specific change that matters
- Include a brief comment explaining WHY this is better
**Ineffective Correct examples:**
- Completely different code from the Incorrect example
- Over-engineered solutions that add unnecessary complexity
- Patterns that require additional context not shown
### Token Efficiency
Rules load every session. Every token counts.
- **Target:** 50-200 words per rule file (excluding code examples)
- **One rule per file** — do not bundle unrelated constraints
- **Use path scoping** to avoid loading irrelevant rules
- **Code examples:** Keep under 20 lines each (Incorrect and Correct)
## Directory Structure
```
.claude/
├── CLAUDE.md # Project overview (broad)
└── rules/
├── code-style.md # Global: code formatting rules
├── error-handling.md # Global: error handling patterns
├── testing.md # Global: testing conventions
├── security.md # Global: security requirements
├── evaluation-priorities.md # Global: judge/evaluator priorities
├── frontend/
│ ├── components.md # Path-scoped: React component rules
│ └── state-management.md # Path-scoped: state management rules
└── backend/
├── api-design.md # Path-scoped: API patterns
└── database.md # Path-scoped: database conventions
```
**Naming conventions:**
- Use lowercase with hyphens: `error-handling.md`, not `ErrorHandling.md`
- Name by the concern, not the solution: `error-handling.md`, not `try-catch-patterns.md`
- One topic per file for modularity
- Use subdirectories to group related rules by domain
## Rule Creation Process
Follow these steps in order, skipping only when a step is clearly not applicable.
### Step 1: Identify the Behavioral Gap
Before writing any rule, identify the specific agent behavior that needs correction. This understanding can come from:
- **Observed failures** — the agent repeatedly makes a specific mistake
- **Codebase analysis** — the project has conventions not obvious from code alone
- **Evaluation findings** — a judge/meta-judge identified a quality gap
- **User feedback** — explicit correction of agent behavior
Document the gaRelated in AI Agents
skill-development
IncludedComprehensive meta-skill for creating, managing, validating, auditing, and distributing Claude Code skills and slash commands (unified in v2.1.3+). Provides skill templates, creation workflows, validation patterns, audit checklists, naming conventions, YAML frontmatter guidance, progressive disclosure examples, and best practices lookup. Use when creating new skills, validating existing skills, auditing skill quality, understanding skill architecture, needing skill templates, learning about YAML frontmatter requirements, progressive disclosure patterns, tool restrictions (allowed-tools), skill composition, skill naming conventions, troubleshooting skill activation issues, creating custom slash commands, configuring command frontmatter, using command arguments ($ARGUMENTS, $1, $2), bash execution in commands, file references in commands, command namespacing, plugin commands, MCP slash commands, Skill tool configuration, or deciding between skills vs slash commands. Delegates to docs-management skill for official documentation.
reprompter
IncludedTransform messy prompts into well-structured, effective prompts — single or multi-agent. Use when: "reprompt", "reprompt this", "clean up this prompt", "structure my prompt", rough text needing XML tags and best practices, "reprompter teams", "repromptception", "run with quality", "smart run", "smart agents", multi-agent tasks, audits, parallel work, anything going to agent teams. Don't use when: simple Q&A, pure chat, immediate execution-only tasks. See "Don't Use When" section for details. Outputs: Structured XML/Markdown prompt, quality score (before/after), optional team brief + per-agent sub-prompts, agent team output files. Success criteria: Single mode quality score ≥ 7/10; Repromptception per-agent prompt quality score 8+/10; all required sections present, actionable and specific.
adaptive-compaction
IncludedAdaptive add-on policy and recovery layer that decides WHEN to compact, prune, snapshot, or fork -- replacing fixed-percent auto-compaction across Claude Code, Codex, and MCP-capable hosts. Trigger on auto-compact timing or damage: "when should I compact", "is it safe to compact now or start a fresh session", "auto-compact fires too early/mid-task", "switching to an unrelated task but the window still has space", "context rot", "answers get worse the longer the session runs", "the agent forgot the plan or my decisions after it summarized", "add a layer on top that manages context without changing the agent", raising autoCompactWindow to give the policy room, or installing/tuning a cross-tool compaction policy or PreCompact hook -- even when "compaction" is never said but the problem is context-window pressure or post-summarization memory loss. Do NOT use to summarize a conversation, build RAG, write a summarization prompt (decides WHEN not HOW), or answer max-context-length trivia.
agent-skill-creator
IncludedCreate cross-platform agent skills from workflow descriptions. Activates when users ask to create an agent, automate a repetitive workflow, create a custom skill, or need advanced agent creation. Triggers on phrases like create agent for, automate workflow, create skill for, every day I have to, daily I need to, turn process into agent, need to automate, create a cross-platform skill, validate this skill, export this skill, migrate this skill. Supports single skills, multi-agent suites, transcript processing, template-based creation, interactive configuration, cross-platform export, and spec validation.
llm-wiki
IncludedUse when building or maintaining a persistent personal knowledge base (second brain) in Obsidian where an LLM incrementally ingests sources, updates entity/concept pages, maintains cross-references, and keeps a synthesis current. Triggers include "second brain", "Obsidian wiki", "personal knowledge management", "ingest this paper/article/book", "build a research wiki", "compound knowledge", "Memex", or whenever the user wants knowledge to accumulate across sessions instead of being re-derived by RAG on every query.
skill-master
IncludedAgent Skills authoring, evaluation, and optimization. Create, edit, validate, benchmark, and improve skills following the agentskills.io specification. Use when designing SKILL.md files, structuring skill folders (references, scripts, assets), ingesting external documentation into skills, running trigger evals, benchmarking skill quality, optimizing descriptions, or performing blind A/B comparisons. Keywords: agentskills.io, SKILL.md, skill authoring, eval, benchmark, trigger optimization.