Rules are always-follow guidelines that define coding standards, conventions, and checklists. Unlike agents (which execute tasks) or skills (which provide reference material), rules are always enforced during development.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/affaan-m/everything-claude-code/llms.txt
Use this file to discover all available pages before exploring further.
What Are Rules?
Rules are markdown files that define:- Coding standards - Style, immutability, file organization
- Testing requirements - TDD, coverage minimums, test types
- Security guidelines - Secret management, input validation, OWASP checks
- Git workflow - Commit format, PR process
- Performance practices - Context management, model selection
Rules Architecture
Rules are organized into common (language-agnostic) and language-specific directories:Common rules apply to all projects. Language rules extend common rules with framework-specific patterns.
Common Rules
These rules apply regardless of programming language:coding-style.md
coding-style.md
Immutability (CRITICAL)
ALWAYS create new objects, NEVER mutate existing ones:File Organization
MANY SMALL FILES > FEW LARGE FILES:- High cohesion, low coupling
- 200-400 lines typical, 800 max
- Organize by feature/domain, not by type
Error Handling
ALWAYS handle errors comprehensively:- Handle errors explicitly at every level
- Provide user-friendly messages in UI code
- Log detailed context server-side
- Never silently swallow errors
Code Quality Checklist
- ✅ Functions small (<50 lines)
- ✅ Files focused (<800 lines)
- ✅ No deep nesting (>4 levels)
- ✅ Proper error handling
- ✅ No hardcoded values
- ✅ Readable, well-named identifiers
testing.md
testing.md
Minimum Coverage: 80%
All code must have 80%+ test coverage across:- Unit tests - Individual functions, utilities, components
- Integration tests - API endpoints, database operations
- E2E tests - Critical user flows
TDD Workflow (Mandatory)
- Write test first (RED) - Test should FAIL
- Write minimal implementation (GREEN) - Test should PASS
- Refactor (IMPROVE) - Verify coverage 80%+
Edge Cases to Test
- Null/undefined input
- Empty arrays/strings
- Invalid types
- Boundary values (min/max)
- Error paths (network failures, DB errors)
- Race conditions
- Large data (performance with 10k+ items)
security.md
security.md
Before ANY Commit
- ✅ No hardcoded secrets (API keys, passwords, tokens)
- ✅ All user inputs validated
- ✅ SQL injection prevention (parameterized queries)
- ✅ XSS prevention (sanitized HTML)
- ✅ CSRF protection enabled
- ✅ Authentication/authorization verified
- ✅ Rate limiting on all endpoints
- ✅ Error messages don’t leak sensitive data
Secret Management
NEVER hardcode secrets. Use environment variables or a secret manager.If Security Issue Found
STOP → use security-reviewer agent → fix CRITICAL issues → rotate exposed secrets → review codebase for similar issues.git-workflow.md
git-workflow.md
performance.md
performance.md
Model Selection
| Model | When to Use | Cost |
|---|---|---|
| Sonnet | Most coding tasks (80%+) | Low |
| Opus | Deep reasoning (planning, architecture) | High |
| Haiku | Simple, repetitive tasks | Very Low |
Context Management
- Avoid last 20% of context window for large refactoring
- Use
/compactat logical breakpoints (after research, before implementation) - Use
/clearbetween unrelated tasks (free, instant reset)
Token Optimization
patterns.md
patterns.md
hooks.md
hooks.md
Hook Types
- PreToolUse - Can block (exit 2) or warn (stderr)
- PostToolUse - Analyze output, trigger followup actions
- Stop - After each response
- SessionStart/SessionEnd - Session lifecycle
- PreCompact - Before context compaction
Hook Best Practices
- Use exit code 2 sparingly (critical issues only)
- Keep hooks fast (<100ms)
- Always output original data to stdout
- Use async for slow operations
agents.md
agents.md
When to Delegate to Agents
| Scenario | Agent |
|---|---|
| Complex feature request | planner |
| Code just written/modified | code-reviewer |
| New feature or bug fix | tdd-guide |
| Architectural decision | architect |
| Security-sensitive code | security-reviewer |
Agent Orchestration
- Use parallel execution for independent operations
- Launch multiple agents simultaneously when possible
- Sequential execution when agents depend on each other
Language-Specific Rules
Language directories extend common rules with framework-specific patterns:- TypeScript
- Python
- Go
- Swift
coding-style.md Extensions
- ESLint + Prettier configuration
- tsconfig.json strict mode
- Prefer interfaces over types for public APIs
- Use
constassertions for readonly data
testing.md Extensions
- Jest for unit/integration tests
- Playwright for E2E tests
- React Testing Library for components
- Mock external dependencies (Supabase, Redis)
hooks.md Extensions
- PostToolUse: Prettier auto-format
- PostToolUse:
tsc --noEmittype check - PostToolUse: console.log warning
Rules vs. Skills vs. Agents
| Component | Purpose | When Used |
|---|---|---|
| Rules | Standards and constraints | Always enforced |
| Skills | Reference material and workflows | Consulted during execution |
| Agents | Specialized executors | Perform delegated tasks |
Example
- Rule (testing.md): “80% coverage required”
- Skill (tdd-workflow): “How to achieve 80% coverage with RED → GREEN → REFACTOR”
- Agent (tdd-guide): “Execute the TDD workflow to implement feature”
Installation
Rules are not distributed via the plugin system. Install manually:Option 1: Install Script (Recommended)
Option 2: Manual Copy
Rule Priority
When language-specific rules conflict with common rules, language-specific rules take precedence:rules/common/defines universal defaultsrules/golang/,rules/python/, etc. override where language idioms differ
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
To add rules for a new language (e.g., Rust):- Create
rules/rust/directory - Add files that extend common rules:
coding-style.md- Formatting, idioms, error handlingtesting.md- Test frameworks, coverage toolspatterns.md- Language-specific design patternshooks.md- PostToolUse hooks for formatters/linterssecurity.md- Secret management, security tools
- Each file should start with:
Next Steps
Common Rules
Deep dive into language-agnostic rules
TypeScript Rules
TypeScript/JavaScript specific guidelines
Python Rules
Python and Django specific rules
Go Rules
Go language specific conventions