| name | rule-creator |
| description | Interactive rule builder: guides the user through defining a new rule as a constraint doc, then generates the rule .md and installs it. |
/rule-creator
Build a new toolkit rule interactively. Rules are always-on constraints that shape Claude's behavior โ coding conventions, patterns to follow, anti-patterns to avoid, and domain-specific guidelines.
Arguments: $ARGUMENTS
<rule-name> โ name for the new rule (e.g., /rule-creator unreal-cpp-conventions)
domain:<tech> โ create rules for a tech stack (e.g., /rule-creator domain:unreal)
- No args โ ask the user what rule they want to create
Goal
Generate a production-ready rule .md file that Claude loads as always-on context, install it into the project's .claude/rules/ directory.
Dependencies
Tools
Read โ read existing rules for pattern reference
Write โ create the rule .md file
Glob โ find existing rules to study structure and avoid duplication
Connectors
- None required (fully local)
Context
Rules are constraint documents โ they tell Claude what to do and what NOT to do, always. They're loaded into context at conversation start and apply to every response.
Rule structure:
# <Title>
<Brief purpose โ one sentence>
## <Section>
- Directive 1
- Directive 2
## <Section>
| Pattern | Do This | Not This |
|---------|---------|----------|
Key characteristics:
- Rules are prescriptive โ "always do X", "never do Y"
- Rules use tables for quick scanning (do/don't, pattern/example)
- Rules are concise โ Claude reads ALL rules every conversation, so brevity matters
- Rules don't have phases or gates โ they're reference material, not procedures
Rule categories:
| Category | Location | Example |
|---|
| Common | .claude/rules/common/ | coding-style.md, testing.md, security.md |
| Language | .claude/rules/<lang>/ | golang/error-handling.md, typescript/types.md |
| Conditional | .claude/rules/conditional/ | read-only.md (only when flag set) |
Existing common rules (avoid duplicating these):
coding-style.md โ naming, functions, files, readability, DRY
testing.md โ TDD, test pyramid, test quality
security.md โ input validation, data access, secrets, OWASP
performance.md โ DB queries, API, caching, frontend
git-workflow.md โ commits, branches, PRs
search-strategy.md โ LEANN, Grep, Glob priority
agents.md โ when/how to use agents
hooks.md โ hook system behavior
patterns.md โ ECC patterns
development-workflow.md โ workflow phases
context-efficiency.md โ context window management
Process
Phase 1: Intake โ Understand the Rule
-
Parse $ARGUMENTS. If empty, ask:
"What rule do you want to create? Describe the conventions or constraints in 1-2 sentences."
-
Scan existing rules to avoid duplication:
Glob: .claude/rules/**/*.md
Read any rules that overlap with the user's intent. If overlap exists, suggest updating the existing rule instead.
-
Ask the user:
Rule Definition Questionnaire:
- What should Claude always do? (3-10 directives)
- What should Claude never do? (anti-patterns)
- Is this for a specific tech stack? (determines location: common/ vs /)
- Can you give do/don't examples? (concrete patterns)
- Is this conditional? (only applies in certain modes/contexts)
-
If domain-specific (domain:<tech>), research the tech stack:
- Ask for key conventions (naming, file structure, macros, patterns)
- Ask for common mistakes to prevent
- Ask for framework-specific best practices
APPROVAL GATE: Present the interpreted rule scope. Wait for confirmation.
Phase 2: Design โ Structure the Rule
-
Read 2-3 existing rules for tone and density reference:
Read: .claude/rules/common/coding-style.md
Read: .claude/rules/common/security.md
-
Determine rule category and location:
- Universal convention โ
.claude/rules/common/<name>.md
- Language/framework specific โ
.claude/rules/<tech>/<name>.md
- Context-dependent โ
.claude/rules/conditional/<name>.md
-
Structure the rule sections:
- Group directives by topic (naming, structure, patterns, anti-patterns)
- Use tables for do/don't comparisons
- Use bullet lists for directives
- Use code blocks for concrete examples
- Keep it scannable โ Claude reads this every conversation
-
Estimate rule size:
- Target: 30-100 lines (rules should be concise)
- If >150 lines: suggest splitting into multiple rules
- If <10 lines: may be too thin โ suggest merging with an existing rule
-
Present the outline to the user.
APPROVAL GATE: Wait for user to approve the structure.
Phase 3: Generate โ Write the Rule
Generate the rule .md following this pattern:
# <Title>
<One-sentence purpose>
## <Topic Section>
- Directive using imperative voice ("Use X", "Avoid Y", "Always Z")
- Directive with rationale where non-obvious
## <Patterns Section>
| Pattern | Do This | Not This |
|---------|---------|----------|
| <case> | `good example` | `bad example` |
## <Anti-Patterns Section>
- Never <anti-pattern> โ <why>
- Avoid <anti-pattern> โ <consequence>
## <Framework-Specific Section> (if domain rule)
### <Subsystem>
- Convention 1
- Convention 2
Writing principles:
- Imperative voice: "Use", "Avoid", "Always", "Never" โ not "You should"
- One directive per bullet โ scannable, not paragraph-dense
- Tables for comparisons โ faster to parse than prose
- Code examples for anything non-obvious
- No filler โ every line earns its place in the context window
Present the generated rule to the user.
APPROVAL GATE: User reviews the full rule. Accept edits before writing.
Phase 4: Install โ Deploy the Rule
-
Determine install path:
- Common:
.claude/rules/common/<name>.md
- Language:
.claude/rules/<tech>/<name>.md
- Conditional:
.claude/rules/conditional/<name>.md
-
Create the directory if needed and write the file.
-
If this is a new language/tech directory, ask:
"Want to add this to the toolkit templates so future projects get these rules automatically?"
If yes, also write to templates/rules/<tech>/<name>.md (if in toolkit repo).
-
Verify:
Glob: .claude/rules/**/<name>.md
-
Report:
"Rule installed:
.claude/rules/<category>/<name>.md
- Type: <common/language/conditional>
- Directives:
This rule is now active in every Claude session in this project."
Error Handling
| Situation | Action |
|---|
| Rule name already exists | Warn, offer to update or rename |
| Overlaps with existing rule | Show overlap, suggest merging |
| Rule too long (>150 lines) | Suggest splitting by topic |
| Rule too short (<10 lines) | Suggest merging with related rule |
| User gives vague conventions | Ask for concrete do/don't examples |
| Tech stack not in installer | Offer to add detection + rule templates |
Checklist (Internal โ verify before completing)