Capture Good Pattern
COMMAND: Extract code as a pattern others should follow.
Execute
- •Parse argument for file path or description
- •Find file (search if only description given)
- •Read file content
- •Create pattern at patterns/good/[name].[ext]
- •Report what was captured
Input Handling
| Input | Action |
|---|---|
/good-pattern src/repos/user.ts | Read file, capture as pattern |
/good-pattern error handling in api | Search for files, ask which one |
/good-pattern | Ask for file path |
Pattern Template
Use template from _templates/TEMPLATES.md (<!-- SECTION: good-patterns -->).
[language]
/** * [Pattern Name] * * USE THIS PATTERN WHEN: * - [Situation where this applies] * * KEY ELEMENTS: * 1. [Important aspect] * * Related ADRs: * - [ADR-NNN](../../docs/adrs/NNN-name.md) - [Why this pattern] * * Source: [original file path] */ // --- Example Implementation --- // ADR-NNN: [Brief reference to the decision] [extracted code]
Output
code
Pattern captured at patterns/good/[name].[ext]
Directory Structure
Create patterns/good/ if it doesn't exist.