code-style
FeaturedEnforce existence, reuse, mirror, and symmetry principles to keep new code minimal and consistent with surrounding code. Use when writing new code in an existing codebase, adding new features, refactoring, or making any code changes.
Code & Development 402 stars
30 forks Updated 2 days ago MIT
Install
Quality Score: 89/100
Stars 20%
Recency 20%
Frontmatter 20%
Documentation 15%
Issue Health 10%
License 10%
Description 5%
Skill Content
# Code Style: Exist, Reuse, Mirror, Symmetry
When writing new code in an existing codebase, work through these in order. When two pull in different directions, the earlier one wins.
1. **Establish that the code needs to exist**: Drop work the request does not need — an abstraction with one implementation, a configuration point with one caller, a branch for a state the callers cannot reach, scaffolding for an anticipated requirement. Deleting or narrowing beats adding. Before removing code that already exists, trace its callers and confirm nothing depends on the behavior. Input validation at trust boundaries, error handling that prevents data loss, security controls, accessibility affordances, and anything explicitly requested outrank this rule.
2. **Reuse existing code**: Before writing a new helper, check if an existing method can be reused or generalized. If a new helper is needed, model it after its closest sibling.
3. **Reuse existing patterns**: Find the closest analogous feature and replicate its structure (method decomposition, control flow, annotations, guard clauses). When an existing pattern fits, use it rather than introducing a new one. When following it would force materially more code or indirection than a different approach, take the different approach and apply it across the whole change.
4. **Mirror the surrounding code exactly**: Match brace style, comment style, naming conventions, blank line spacing, code density, and level of detail by reading nearby co...
Details
- Author
- tobihagemann
- Repository
- tobihagemann/turbo
- Created
- 6 months ago
- Last Updated
- 2 days ago
- Language
- Shell
- License
- MIT
Similar Skills
Semantically similar based on skill content — not just same category
DevOps & Infrastructure Listed
code-standards
Use when writing, modifying, reviewing, or refactoring code — any language or stack, application, infrastructure, or configuration. Also when asked to apply, audit, or clean up the code standards of a file or module.
3 Updated today
metraton AI & Automation Listed
code-standards
Naming, structure, and consistency conventions for keeping a codebase readable and predictable as it grows.
1 Updated 4 days ago
niels-emmer Code & Development Listed
code-quality
Keep code clear, local, and purposeful while changing existing systems.
3 Updated today
Andersseen