coding-practices
Code quality practices: error handling, validation, logging, and DRY. Use when writing or reviewing code.
When & Why to Use This Skill
This Claude skill provides a robust framework for maintaining high-quality software through standardized coding practices. It focuses on essential engineering principles including error handling, input validation, DRY (Don't Repeat Yourself) logic, and self-documenting code to ensure long-term maintainability, reliability, and reduced technical debt.
Use Cases
- Code Review Standardization: Use these guidelines as a checklist during pull request reviews to ensure consistency in naming, logic structure, and error management across the team.
- Refactoring Legacy Code: Apply the DRY and validation principles to modernize existing codebases, making them more readable and less prone to regression bugs.
- Defensive Programming: Implement the suggested error handling and input validation patterns to build more resilient applications that handle edge cases gracefully.
- Onboarding and Mentorship: Serve as a best-practices guide for junior developers to align their coding style with professional industry standards.
| name | coding-practices |
|---|---|
| description | Code quality practices: error handling, validation, logging, and DRY. Use when writing or reviewing code. |
Coding Practices
Guidelines for writing maintainable, robust, and self-documenting code.
Quick Start
// Self-documenting with proper error handling
function createUser(email: string, age: number): User {
if (!email.includes("@")) throw new Error("Invalid email");
if (age < 0 || age > 150) throw new Error("Invalid age");
return { email, age };
}
Key Principles
- Use meaningful names (self-documenting code)
- Comments explain "why", not "what"
- DRY: abstract when used 3+ times
- Validate all input data
- Handle all error cases with proper Error objects
- Never ignore errors
- Use named constants instead of magic values
- Avoid circular dependencies
References
See rules.md for complete guidelines with examples.