@@ -9,6 +9,34 @@ This document provides guidelines for Claude when working with the Coder codebas
99- Write thorough tests for new functionality
1010- Ensure code is well-documented with comments explaining "why" not just "what"
1111- Run tests before submitting changes
12+ - Design clean, higher-level APIs with appropriate method visibility
13+ - Keep public interfaces minimal and focused; don't expose methods only used for testing
14+ - Balance theoretical correctness with practical considerations
15+
16+ ## API Design Principles
17+
18+ - Public APIs should be intentional, not accidental
19+ - Consider who the users of your API are and what they need
20+ - Avoid exposing internal implementation details
21+ - Design for future extensibility without breaking changes
22+ - Provide meaningful error messages that aid in debugging
23+ - Consider backward compatibility implications
24+
25+ ## Error Handling
26+
27+ - Be pragmatic with error handling - focus on realistic failure scenarios
28+ - Balance defensive coding against code complexity
29+ - Ensure critical paths have appropriate error handling
30+ - Consider the diagnostic value of error messages for operators
31+ - Propagate context with errors when it adds debugging value
32+
33+ ## Concurrency and Performance
34+
35+ - Pay careful attention to concurrency and potential race conditions
36+ - Be explicit about guarantees of sequential execution
37+ - Consider performance implications, particularly for database operations
38+ - Optimize database queries for common access patterns
39+ - Document synchronization mechanisms and concurrency assumptions
1240
1341## Commit Conventions
1442
@@ -31,20 +59,25 @@ This document provides guidelines for Claude when working with the Coder codebas
3159- Place new code in appropriate packages based on its functionality
3260- Respect API boundaries between different parts of the codebase
3361- Use standard Go project layout conventions
62+ - Keep related functionality together; split only when clear boundaries emerge
3463
3564## Testing
3665
3766- Write unit tests for all new functionality
3867- Ensure tests are deterministic and don't have race conditions
3968- Consider adding integration tests for complex features
4069- Mock external dependencies appropriately in tests
70+ - Include meaningful diagnostic data in test logs to help debug failures
71+ - Test edge cases and error paths, not just the happy path
72+ - Value the ability to debug rare failures through logging
4173
4274## Documentation
4375
4476- Update relevant documentation when changing functionality
4577- Add clear docstrings to public functions and types
4678- Include examples where appropriate
4779- Update changelog entries for significant changes
80+ - Document assumptions and non-obvious behaviors
4881
4982## Experimental Features
5083
0 commit comments