1---2name: developer3description: Write clean, maintainable code with debugging, testing, and architectural best practices.4---5
6# Software Development Rules
7
8## Code Quality
9- Readable code beats clever code — you'll read it 10x more than write it
10- Functions do one thing — if you need "and" to describe it, split it
11- Name things by what they do, not how — implementation changes, purpose doesn't
12- Delete dead code — version control remembers, codebase shouldn't carry weight
13- Consistent style matters more than which style — match the project
14
15## Debugging
16- Read the error message completely — the answer is often in there
17- Reproduce before fixing — if you can't trigger it, you can't verify the fix
18- Binary search: comment out half the code to find the problem half
19- Check the obvious first — typos, wrong file, stale cache, wrong environment
20- Print/log liberally when stuck — assumptions are usually wrong
21
22## Testing
23- Test behavior, not implementation — tests shouldn't break when you refactor
24- One assertion per test when possible — failures point to exact problem
25- Name tests as sentences describing expected behavior — readable test names are documentation
26- Mock external dependencies, not internal logic — integration points are boundaries
27- Fast tests run often, slow tests get skipped — optimize for feedback speed
28
29## Error Handling
30- Fail fast and loud — silent failures create debugging nightmares
31- Catch specific exceptions, not generic — different errors need different handling
32- Log enough context to debug — error type alone isn't enough
33- User-facing errors should be helpful — "something went wrong" helps nobody
34- Don't catch exceptions you can't handle — let them bubble up
35
36## Architecture
37- Start simple, add complexity when needed — premature abstraction wastes time
38- Separate concerns — UI, business logic, data access are different responsibilities
39- Dependencies flow inward — core logic shouldn't know about frameworks
40- Configuration separate from code — environment-specific values externalized
41- Document decisions, not just code — why matters more than what
42
43## Code Review
44- Review for understanding, not just correctness — if you can't follow it, others won't
45- Ask questions instead of making demands — "what if..." opens discussion
46- Small PRs get better reviews — 500 lines gets skimmed, 50 lines gets read
47- Approve when good enough, not perfect — progress beats perfection
48- Catch bugs early, style issues are secondary — priorities matter
49
50## Performance
51- Measure before optimizing — intuition about bottlenecks is usually wrong
52- Optimize the hot path — 90% of time is spent in 10% of code
53- Database queries are usually the bottleneck — check there first
54- Caching solves many problems — but cache invalidation creates new ones
55- Premature optimization wastes time — make it work, then make it fast
56
57## Dependencies
58- Evaluate before adding — every dependency is code you don't control
59- Pin versions — "latest" breaks builds unpredictably
60- Check maintenance status — abandoned packages become security risks
61- Fewer dependencies is better — each one adds supply chain risk
62- Read changelogs before upgrading — breaking changes hide in minor versions
63
64## Working in Existing Codebases
65- Match existing patterns — consistency beats personal preference
66- Improve incrementally — boy scout rule, leave it better than you found it
67- Understand before changing — read the tests, check git history
68- Don't refactor while fixing bugs — separate commits, separate PRs
69- Legacy code works — respect the battle scars
70
71## Communication
72- Commit messages explain why, not what — diff shows what changed
73- Document surprising behavior — future developers need context
74- Ask before large refactors — alignment prevents wasted work
75- Estimate with ranges, not points — "2-4 days" is more honest than "3 days"
76- Say "I don't know" when you don't — guessing wastes everyone's time