From coconut-rules
This skill provides guidance on organizing CLAUDE.md rules, category structures, and rule file best practices. Use when the user asks about 'how to organize Claude rules', 'CLAUDE.md structure', 'rule categories', 'rules best practices', or needs help understanding the rules system.
How this skill is triggered — by the user, by Claude, or both
Slash command
/coconut-rules:skills/rules-managementThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Comprehensive guidance for managing CLAUDE.md user-specific rules with **context-based loading** for optimal performance.
Comprehensive guidance for managing CLAUDE.md user-specific rules with context-based loading for optimal performance.
Claude Code loads CLAUDE.md on every interaction. To avoid loading all rules upfront:
.claude/rules/ with trigger hints (loaded on-demand).claude/
├── CLAUDE.md # Critical rules + context hints
└── rules/ # Domain-specific rules (loaded when relevant)
├── python.md
├── typescript.md
├── docker.md
├── react.md
└── security-advanced.md
# Project Name
Brief project description.
## Critical Rules (Always Apply)
### Security
- Never commit secrets, API keys, or credentials
- Never disable security middleware or authentication checks
- Sanitize all user input before database operations
### Git Workflow
- Feature branches only, never commit directly to main
- Always run tests before committing
## Context (Read When Relevant)
Load context files based on what you're working on:
| Working On | Read |
|------------|------|
| Python/FastAPI backend | `.claude/rules/python.md` |
| React/TypeScript frontend | `.claude/rules/typescript.md` |
| Docker/containers | `.claude/rules/docker.md` |
| Authentication/security | `.claude/rules/security.md` |
Keep rules that are always relevant regardless of task:
Characteristics:
Move rules that are domain-specific:
Characteristics:
# [Technology/Domain] Context
Rules for [technology] development in this project.
## Key Patterns
- [Specific pattern or convention]
- [Another pattern]
## Examples
### Recommended
```python
# Good example with explanation
```
### Avoid
```python
# Bad example with explanation why
```
## Integration Points
- Related to: `.claude/context/[related].md` (when working with both)
The CLAUDE.md table tells Claude when to load context files from .claude/rules/:
| Trigger Keywords | Context File |
|---|---|
.py, Python, FastAPI, Pydantic | python.md |
.ts, .tsx, React, Next.js | typescript.md |
| Docker, container, Dockerfile | docker.md |
| auth, JWT, OAuth, security audit | security.md |
.go, Go, Gin, Echo | golang.md |
| database, SQL, migrations | database.md |
# CLAUDE.md
@rules/frontend/react.md
@rules/frontend/typescript.md
@rules/backend/python.md
@rules/backend/fastapi.md
@rules/devops/docker.md
@rules/security/auth.md
@rules/general/standards.md
Problem: All 7 files loaded on every interaction
# CLAUDE.md
## Critical Rules
- Never commit secrets
- Feature branches only
- Run tests before commit
## Context (Read When Relevant)
| Working On | Read |
|------------|------|
| Python backend | `.claude/rules/python.md` |
| TypeScript/React | `.claude/rules/typescript.md` |
| Containers | `.claude/rules/docker.md` |
Improvement: Only load what's needed per task
.py, .tsx)| Command | Purpose |
|---|---|
/coconut-rules:add-rule [desc] | Add rule with auto-placement (critical vs context) |
/coconut-rules:list-rules | Show current structure and loading pattern |
/coconut-rules:organize | Restructure rules to context-based pattern |
npx claudepluginhub FrancisVarga/coconut-claude-code-plugins --plugin coconut-rulesGuides writing effective .claude/rules/ files for Claude Code, with imperative framing and enforceability checks. Useful when creating or refining project-specific rules.
Manages modular Claude rules in .claude/rules/ directory, supporting path-specific globs, brace expansion, project-wide, and user-level rules. Use to create, edit, list, generate, or sync rules.
Generates project-specific CLAUDE.md rules by detecting stack from package.json, Cargo.toml, pyproject.toml, go.mod, git log, and user-selecting categories like response format, library preference, code review stance. Use for new projects, repo onboarding, or establishing conventions.