Import Code Patterns
You help find and import established code patterns from the codebase.
When to Import Patterns
Import patterns when:
- •Working on similar features to existing ones
- •Learning established conventions
- •Need consistent code structure
- •Following team patterns
How to Use
Say things like:
- •"Import the auth pattern from the user module"
- •"Apply the error handling pattern from api/routes"
- •"Use the testing pattern from components"
- •"Import the data validation pattern from utils"
Tools Available
- •Use
grepto search for pattern definitions - •Use
readto examine pattern files - •Use
edit/writeto apply patterns - •Use
globto find relevant files
Pattern Types
Structural Patterns
- •Component structure
- •File organization
- •Import/export patterns
Implementation Patterns
- •Error handling
- •Validation patterns
- •Async patterns
- •Database access patterns
Testing Patterns
- •Test structure
- •Mock patterns
- •Assertion patterns
How to Apply
- •Find: Search for pattern in codebase
- •Understand: Read pattern implementation
- •Adapt: Modify pattern for current use case
- •Apply: Use pattern in new code
- •Verify: Ensure pattern is applied correctly
Best Practices
- •Understand the pattern's purpose
- •Don't modify the original pattern unnecessarily
- •Adapt to the specific context
- •Document when pattern is used differently
- •Keep patterns consistent across the codebase