| name | rules-optimizer |
| description | Optimize and create Claude Rules (.claude/rules/*.md) following best practices. |
Rules Optimizer
Create and optimize .claude/rules/*.md files for effective AI guidance.
Best Practices
File Structure
.claude/rules/
├── typescript.md # Language-specific
├── python.md
├── frontend/
│ ├── react.md # Framework-specific
│ ├── tailwind.md
│ └── component-structure.md
└── backend/
└── api.md
Rule File Format
---
paths: "**/*.{ts,tsx}" # Glob pattern (quoted)
---
# [Topic] Rules
## [Category]
[Rule statement]
\`\`\`typescript
// ❌ BAD
[anti-pattern]
// ✅ GOOD
[correct pattern]
\`\`\`
Content Guidelines
- One topic per file — keep focused
- 150-200 lines ideal — enough for examples, not overwhelming
- Include examples — 1 BAD/GOOD pair per rule that needs clarity
- Skip obvious rules — focus on what AI gets wrong
- No "why" explanations — just the rule and example
- Use tables for mappings (e.g., v3→v4 migrations)
Path Patterns
| Pattern |
Matches |
**/*.ts |
All TS files |
**/*.{ts,tsx} |
TS and TSX |
src/**/* |
All under src/ |
components/**/*.tsx |
Components only |
What to Include
- ❌ Anti-patterns AI commonly generates
- ✅ Correct patterns with minimal example
- Migration mappings (old → new)
- Framework-specific conventions
What to Exclude
- Self-evident rules (use semicolons, etc.)
- Long explanations of "why"
- Multiple examples for same rule
- Style preferences (let linters handle)
Workflow
- Read existing rule file
- Identify: redundancy, missing examples, excessive length
- Compress to essentials with 1 example per rule
- Ensure paths pattern is appropriate
- Output optimized version