Create Rule
Create rules — always-on constraints applied to every agent
session. Unlike skills, rules don't need triggers. They're loaded
at session start and apply to all work.
Workflow
Gather intent — Understand what the rule should enforce.
Collect:
- A short name (lowercase, hyphenated)
- What conventions or constraints to enforce
- Any style guides or standards to draw from
Investigate the repo — Before asking questions, search
for facts that reduce ambiguity:
- Existing rules and conventions
- Style guides, linter configs, or formatting standards
- Patterns in existing files that reveal implicit conventions
Don't ask the user what you can look up yourself.
Clarify — Ask only questions that materially affect the
rule. Push until these are clear:
- Which file types or contexts the rule applies to
- Hard requirements vs preferences
- Any exceptions or edge cases
Write RULE.md — Structure:
# Rule Name
Brief description of what this rule enforces.
## Section
- Convention one
- Convention two
Writing principles:
- Be specific. "Use
- for unordered lists" is
enforceable. "Use consistent formatting" is not.
- State conventions, not explanations. The agent doesn't
need to know why a convention exists to follow it.
- Group by concern. Separate sections for structure,
spacing, emphasis, etc.
- Keep it short. Rules are loaded every session — every
line costs tokens on every interaction.
Validate — Check the rule against existing files:
- Pick 2–3 representative files in the repo
- Verify the conventions are consistent with what's already
there
- Note any conflicts with existing patterns
Confirm — Show the user the created rule and ask if
adjustments are needed.
Example Scenario
User: "Every model formats markdown differently, I want
consistency."
Skill checks repo for .editorconfig, linter configs,
existing rules — finds none
Asks: "Which conventions matter most — headings, lists,
code blocks, line length?"
Reads 2–3 existing markdown files to extract implicit
patterns
Creates markdown-style/RULE.md with specific,
enforceable conventions grouped by concern:
# Markdown Style
Enforces consistent markdown formatting across all generated files.
## Lists
- Use `-` for unordered list items, never `*` or `+`.
- Indent nested lists with 2 spaces.
## Headings
- Use ATX headings (`#`), never setext (`===` or `---`).
- One blank line before and after every heading.
## Code Blocks
- Use fenced code blocks (` ``` `) with an explicit language tag.
- Never use indented code blocks.
## Line Length
- Wrap prose at 80 characters.
- Do not wrap code blocks or tables.
Validates against existing files — no conflicts
Common Failures
- Too vague to enforce — "use consistent formatting" is
unenforceable. "Use
- for unordered lists" is clear.
- Conflicts with existing tooling — the rule says one thing,
the linter config says another. Check for
.editorconfig,
linter configs, and formatter settings first.
- Too long — rules load every session. A 200-line rule costs
tokens on every interaction, even when irrelevant.
- Overlaps with existing rules — check
.agents/rules/ for
rules that already cover the same concern.
A good rule is enforceable by reading it literally. If an agent
has to interpret intent, the rule is too vague.
Quality Checklist
Before finalizing, verify:
Design
Validation
Token efficiency
1---2name: create-rule3description: Creates rule files that define always-on constraints for agent sessions. Investigates the repo for existing conventions, writes a RULE.md with clear structure, and validates against real usage. Use when the user wants to create a rule, add a convention, enforce a standard, establish a project-wide constraint, define coding style, standardize formatting across generated files, notices inconsistent output across sessions, or is setting up a new project's conventions.4---56# Create Rule78Create rules — always-on constraints applied to every agent9session. Unlike skills, rules don't need triggers. They're loaded10at session start and apply to all work.1112## Workflow13141. **Gather intent** — Understand what the rule should enforce.15 Collect:16 - A short name (lowercase, hyphenated)17 - What conventions or constraints to enforce18 - Any style guides or standards to draw from19202. **Investigate the repo** — Before asking questions, search21 for facts that reduce ambiguity:22 - Existing rules and conventions23 - Style guides, linter configs, or formatting standards24 - Patterns in existing files that reveal implicit conventions2526 Don't ask the user what you can look up yourself.27283. **Clarify** — Ask only questions that materially affect the29 rule. Push until these are clear:30 - Which file types or contexts the rule applies to31 - Hard requirements vs preferences32 - Any exceptions or edge cases33344. **Write RULE.md** — Structure:3536 ```markdown37 # Rule Name3839 Brief description of what this rule enforces.4041 ## Section4243 - Convention one44 - Convention two45 ```4647 Writing principles:48 - **Be specific.** "Use `-` for unordered lists" is49 enforceable. "Use consistent formatting" is not.50 - **State conventions, not explanations.** The agent doesn't51 need to know why a convention exists to follow it.52 - **Group by concern.** Separate sections for structure,53 spacing, emphasis, etc.54 - **Keep it short.** Rules are loaded every session — every55 line costs tokens on every interaction.56575. **Validate** — Check the rule against existing files:58 - Pick 2–3 representative files in the repo59 - Verify the conventions are consistent with what's already60 there61 - Note any conflicts with existing patterns62636. **Confirm** — Show the user the created rule and ask if64 adjustments are needed.6566## Example Scenario6768User: "Every model formats markdown differently, I want69consistency."70711. Skill checks repo for `.editorconfig`, linter configs,72 existing rules — finds none732. Asks: "Which conventions matter most — headings, lists,74 code blocks, line length?"753. Reads 2–3 existing markdown files to extract implicit76 patterns774. Creates `markdown-style/RULE.md` with specific,78 enforceable conventions grouped by concern:7980 ```markdown81 # Markdown Style8283 Enforces consistent markdown formatting across all generated files.8485 ## Lists8687 - Use `-` for unordered list items, never `*` or `+`.88 - Indent nested lists with 2 spaces.8990 ## Headings9192 - Use ATX headings (`#`), never setext (`===` or `---`).93 - One blank line before and after every heading.9495 ## Code Blocks9697 - Use fenced code blocks (` ``` `) with an explicit language tag.98 - Never use indented code blocks.99100 ## Line Length101102 - Wrap prose at 80 characters.103 - Do not wrap code blocks or tables.104 ```1055. Validates against existing files — no conflicts106107## Common Failures108109- **Too vague to enforce** — "use consistent formatting" is110 unenforceable. "Use `-` for unordered lists" is clear.111- **Conflicts with existing tooling** — the rule says one thing,112 the linter config says another. Check for `.editorconfig`,113 linter configs, and formatter settings first.114- **Too long** — rules load every session. A 200-line rule costs115 tokens on every interaction, even when irrelevant.116- **Overlaps with existing rules** — check `.agents/rules/` for117 rules that already cover the same concern.118119A good rule is enforceable by reading it literally. If an agent120has to interpret intent, the rule is too vague.121122## Quality Checklist123124Before finalizing, verify:125126**Design**127- [ ] Every convention is specific enough to apply mechanically128- [ ] No convention requires inferring intent129- [ ] Sections are grouped by concern, not by discovery order130131**Validation**132- [ ] Checked 2–3 existing repo files — no conflicts found133- [ ] Checked `.editorconfig`, linter configs, and formatters134- [ ] Checked `.agents/rules/` for overlapping rules135136**Token efficiency**137- [ ] No sentence that restates another138- [ ] No explanations — only conventions139- [ ] Rule is as short as it can be while remaining complete