Pattern-Aware Coding
Before writing or modifying code, consult the user's learned patterns to ensure consistency.
When to Activate
This skill activates when:
- •Writing new code files
- •Modifying existing code
- •Suggesting refactors
- •Code review tasks
- •Answering "how should I..." coding questions
Process
- •
Check for patterns file: Read
.claude/correct-habits/patterns.json(in the current project directory) - •
Identify relevant patterns: Based on the current task, find patterns that apply:
- •If writing a function → check naming, error-handling, style patterns
- •If setting up imports → check imports patterns
- •If designing structure → check architecture patterns
- •If writing tests → check testing patterns
- •
Apply patterns proactively: Don't wait to be corrected. If a pattern exists, follow it from the start.
- •
Mention when applying: Briefly note when you're following a learned pattern:
"Using early returns per your preference..." "Following your camelCase naming convention..."
- •
Update hit count: After successfully applying a pattern, increment its
hitCountin the JSON file to help prioritize frequently-used patterns.
Pattern Categories Reference
- •naming: Variable, function, file, class naming conventions
- •error-handling: Try/catch style, error propagation, logging
- •architecture: File organization, module structure, design patterns
- •testing: Test structure, naming, mocking approaches
- •style: Formatting, comments, code organization within files
- •imports: Import ordering, default vs named, path aliases
- •other: Anything else
Important
- •Patterns from this file take precedence over general best practices
- •If a pattern conflicts with project-specific rules in CLAUDE.md, CLAUDE.md wins
- •If unsure whether a pattern applies, ask the user