Rules Structure
common/ contains universal principles with no language-specific code. Language directories extend common rules with framework patterns, tools, and examples.
Installation Options
Option 1: Install Script (Recommended)
Option 2: Manual Installation
Common Rules Overview
coding-style.md
Coding Style
Core Principles:
- Immutability (CRITICAL) — never mutate, always return new copies
- Many small files > few large files (200-400 lines typical, 800 max)
- Comprehensive error handling
- Input validation at system boundaries
- Code quality checklist
testing.md
Testing Requirements
Minimum 80% Coverage:
- Unit tests (functions, utilities, components)
- Integration tests (API endpoints, database)
- E2E tests (critical user flows)
- Write test first (RED)
- Implement (GREEN)
- Refactor (IMPROVE)
- Verify 80%+ coverage
security.md
Security Guidelines
Mandatory Checks:
- No hardcoded secrets
- All user inputs validated
- SQL injection prevention
- XSS/CSRF protection
- Rate limiting on endpoints
- Authorization checks
git-workflow.md
Git Workflow
Commit Format:Types: feat, fix, refactor, docs, test, chore, perf, ciPR Workflow: Analyze full commit history → draft comprehensive summary → include test plan → push with
-u flagperformance.md
Performance
Context Management:
- Avoid last 20% of context window for large refactoring
- Lower-sensitivity tasks tolerate higher utilization
patterns.md
Architecture Patterns
- API response format (consistent envelope)
- Repository pattern (encapsulate data access)
- Skeleton projects (battle-tested templates)
hooks.md
Hook Usage
- When to use PreToolUse/PostToolUse hooks
- Memory persistence patterns
- Strategic compaction triggers
agents.md
Agent Orchestration
- When to delegate to specialized agents
- Parallel vs sequential execution
- Agent selection guide
Language-Specific Rules
TypeScript/JavaScript
Python
Go
Swift
Rules vs Skills
Rules (rules/)
Define what to do:
- Standards and conventions
- Checklists
- Broad applicability
Skills (skills/)
Provide how to do it:
- Deep reference material
- Specific task workflows
- Actionable patterns
python-patterns, golang-testing, tdd-workflowLanguage-specific rule files reference relevant skills where appropriate.
Rule Priority
This follows the standard layered configuration pattern (similar to CSS specificity or.gitignore precedence).
Example
common/coding-style.md recommends immutability. golang/coding-style.md overrides:
Idiomatic Go uses pointer receivers for struct mutation — see common/coding-style.md for the general principle, but Go-idiomatic mutation is preferred here.
Adding a New Language
Add Extension Files
Create files that extend common rules:
coding-style.md— formatting tools, idioms, error handlingtesting.md— test framework, coverage toolspatterns.md— language-specific design patternshooks.md— PostToolUse hooks for formatters, linterssecurity.md— secret management, security tools
Verification
Check Installed Rules
Verify Common Rules
Verify Language-Specific Rules
Installation Checklist
- Common rules installed (
~/.claude/rules/common/) - Language-specific rules installed (TypeScript, Python, Go, Swift)
- Directory structure preserved (not flattened)
- Relative references intact (
../common/links work) - Verified with
ls ~/.claude/rules/
Best Practices
Start with Common
Always install common rules first. They provide the foundation.
Install Only What You Use
Only install language rules for your project’s tech stack.
Keep Directory Structure
Never flatten. Common and language-specific rules must stay separate.
Update Regularly
Pull latest rules from the repo periodically for improvements.
Related Documentation
- Token Optimization — Reduce Claude Code costs
- TDD Workflow — Test-driven development
- Security Best Practices — Security guidelines
- Continuous Learning — Instinct-based learning