create-rule — Claude Code skill: write agent rules
A skill that walks you through writing a rule file in .claude/rules/ so your agent stops repeating the same mistake.
npx skills add NeoLabHQ/context-engineering-kit --skill create-rule -a claude-codeWhat create-rule does
The skill guides you through creating files in .claude/rules/. Those files load into every agent session and act as standing orders: behavioral constraints, code standards, quality gates, project conventions.
The core of the method is contrastive examples. Each rule follows a description–Incorrect–Correct template, showing the mistake an agent would plausibly make and then the smallest fix. That pairing leaves less room for an agent to argue its way around the rule. The skill also covers which bad examples are useless and why the Correct block should not be a full rewrite.
Rules come in two kinds: global ones, and path-scoped ones that use paths in the frontmatter and load only when matching files are touched. Keep each file to 50–200 words, one rule per file, code samples under 20 lines. If the guidance only matters for one task, it belongs in a skill instead.
What it helps with
- turn a repeated agent mistake into a rule
- write a rule with Incorrect and Correct examples
- scope a rule to specific files with
paths - decide between a rule, a skill and
CLAUDE.md - keep a rule within 50–200 words
Example prompts for the agent
- The agent swallowed the exception again — create a rule for error handling
- Add a rule for
src/api/**/*.ts: input validation is required - It rewrote the whole file instead of patching one function. Turn that into a rule
How to install create-rule
1Skills CLI (Vercel)
npx skills add NeoLabHQ/context-engineering-kit --skill create-rule -a claude-code2Manually: put the files in place
~/.claude/skills/create-rule/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/create-rule/
1Skills CLI (Vercel)
npx skills add NeoLabHQ/context-engineering-kit --skill create-rule -a codex2Manually: put the files in place
.agents/skills/create-rule/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add NeoLabHQ/context-engineering-kit --skill create-rule -a cursor2Manually: put the files in place
.cursor/skills/create-rule/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install NeoLabHQ/context-engineering-kit create-rule2Manually: put the files in place
.github/skills/create-rule/SKILL.md1Skills CLI (Vercel)
npx skills add NeoLabHQ/context-engineering-kit --skill create-rule -a gemini-cli2Platform CLI
gemini skills install https://github.com/NeoLabHQ/context-engineering-kit --path skills/create-ruleManually: put the files in place
.devin/skills/create-rule/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add NeoLabHQ/context-engineering-kit --skill create-rule -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about create-rule
How do I install create-rule in Claude?
Run npx skills add NeoLabHQ/context-engineering-kit --skill create-rule -a claude-code. The skill lands in ~/.claude/skills/create-rule/SKILL.md.
What does create-rule do?
It helps you write a rule file for .claude/rules/ using a template with contrastive examples. Those files load into every agent session.
How is a rule different from a skill?
A rule loads every session and sets behavioral constraints, while a skill loads on demand and describes a procedure. Task-specific guidance belongs in a skill.