Collects and documents exemplar code patterns as style anchors between technical requirements and implementation planning. Creates a reusable library of code examples with usage guidelines that implementation-planner references in task instructions to prevent architectural drift.
Systematically identifies, documents, and organizes code examples that demonstrate approved patterns from technical requirements. Creates a structured library of style anchors used throughout implementation.
technical-requirements.yamlStyle anchors are concrete code examples that serve as templates for implementation. They prevent drift by:
If no directory was provided as a parameter, prompt the user:
"Where should I create the style anchors? (This should be the same base directory as your requirements documents)"
Wait for user response. Store the provided path as base_directory.
Load {base_directory}/requirements/technical-requirements.yaml
Parse for key architecture patterns:
Identify pattern categories to collect anchors for (typical categories):
Display identified categories to the user:
## Style Anchors Collection
Based on your technical requirements, I'll collect code examples for these pattern categories:
1. Services (Effect.Service pattern with dependency injection)
2. Testing (Effect service testing with @effect/vitest)
3. Validation (Schema.Class validation patterns)
4. Error Handling (Tagged errors with Effect)
For each category, I'll ask you to provide:
- File path to exemplar code
- Line range (e.g., 10-50)
- What the pattern demonstrates
- When to use it
You can provide examples from:
- Your current codebase
- A reference repository (will link to it)
- Suggest "none" to skip a category
Ask: "Ready to begin collection?"
Wait for confirmation.
For each category identified:
3.1. Ask for source file:
## Category: [Category Name]
What file demonstrates your preferred [pattern description]?
Options:
1. Provide file path from current project (e.g., src/services/UserService.ts)
2. Provide URL to reference repository file
3. Type "none" to skip this category
4. Type "help" for guidance on what makes a good style anchor
Your answer:
3.2. Ask for line range:
What line range should I reference?
Format: Start-End (e.g., 10-50)
Or: Single line number (e.g., 25)
Or: "all" for entire file
Your answer:
3.3. If file is accessible, read and display:
## Code Preview
[Display the code from specified lines]
Does this look correct? (yes/no/adjust)
If "adjust", loop back to line range question.
3.4. Ask what pattern demonstrates:
What does this code example demonstrate?
Examples:
- "Service pattern with Effect.Service and dependency injection"
- "TDD test structure using it.effect from @effect/vitest"
- "Schema validation with proper error handling"
Your answer:
3.5. Ask when to use:
When should developers use this pattern?
Examples:
- "When creating any service class in the service layer"
- "When testing Effect-based services"
- "When validating external input data"
Your answer:
3.6. Generate anchor ID:
Create anchor ID from pattern name (kebab-case, e.g., service-pattern, test-effect-services)
3.7. Confirm and continue:
✓ Collected anchor: [anchor-name]
Continue to next category? (yes/no/review)
4.1. Create directory structure:
mkdir -p {base_directory}/artifacts/style-anchors
4.2. Generate index.yaml:
Create {base_directory}/artifacts/style-anchors/index.yaml with:
4.3. Generate individual .md files:
For each collected anchor, create {base_directory}/artifacts/style-anchors/[anchor-id].md with:
4.4. Populate pattern requirements and mistakes:
Use knowledge from implementation-plan-best-practices to add:
Display collection summary:
## Style Anchors Collection Complete ✓
**Directory:** {base_directory}/artifacts/style-anchors/
**Collected Anchors:** [count]
📁 Categories:
- Services: [n] anchors
- Testing: [n] anchors
- Validation: [n] anchors
- Error Handling: [n] anchors
📄 Generated Files:
✓ index.yaml (master index with usage matrix)
✓ [anchor-1].md
✓ [anchor-2].md
✓ [anchor-3].md
These anchors will be automatically referenced by implementation-planner
when generating task instructions.
Next Step: Run /implementation-planner to generate milestones and tasks
The master index file includes: version, project, generated, technical_requirements_ref, categories (each with id, name, description, anchors list), anchors (each with id, name, file, category, source reference, applies_to rules, tags), usage_matrix (mapping architecture patterns and task types to recommended anchors), and meta (counts and dates).
Each anchor file includes: YAML frontmatter (id, name, category, tags, created), and sections for Overview, Source Reference, Code Example, What This Demonstrates, When to Use, Pattern Requirements, Common Mistakes to Avoid, Related Anchors, and Test Coverage.
See references/output-spec.md for the complete specification of both index.yaml and individual anchor files, including all fields, formatting rules, and usage matrix structure.
See references/example.md for a full example anchor document.
Requirements:
Mistakes:
Requirements:
Mistakes:
Requirements:
Mistakes:
Requirements:
Mistakes:
Map technical requirements to anchor recommendations:
From architecture.pattern:
effect-based-services → service-pattern, test-pattern, error-handlingschema-validation → validation-schema, api-validationrest-api → api-pattern, validation-schema, error-handlingBy task type:
code → primary pattern for layer + validation + error-handlingtest → test-pattern + pattern being testedapi → api-pattern + validation-schema + error-handlingdocs → (no anchors typically needed)config → (no anchors typically needed)If user has no current codebase:
I notice you don't have an existing codebase. Would you like to:
1. Skip style anchor collection for now (can add later)
2. Reference external examples (Effect documentation, framework examples)
3. Create minimal example files as anchors
Which approach works best for your project?
No style anchors collected. This means:
⚠️ Implementation-planner will generate tasks WITHOUT concrete examples
⚠️ Risk of architectural drift increases
⚠️ Developers will need to infer patterns from requirements
Recommendation: Collect at least 1-2 anchors for critical patterns
(e.g., service pattern, test pattern)
Continue without anchors? (yes/no)
If user provides file path that can't be read:
I can't access [file-path]. Would you like to:
1. Provide a different file path
2. Paste the code directly (I'll store it in the anchor)
3. Provide a URL to the file
4. Skip this anchor
Your choice:
When implementation-planner runs:
Load style anchors:
Read {base_directory}/artifacts/style-anchors/index.yaml
For each task generated:
Task instruction template:
instructions: |
## Style Anchors
Follow these patterns:
- `[anchor-id]` ([file]) - [what it demonstrates]
- `[anchor-id]` ([file]) - [what it demonstrates]
See artifacts/style-anchors/[anchor-id].md for detailed examples.
## [rest of task instructions]
After generation, validate:
To collect style anchors:
/style-anchors-collection [base-directory]
If no directory is provided, auto-detect by looking for requirements/technical-requirements.yaml in the current directory.
If not found, prompt the user: "Where are your requirements documents located?"
Wait for the user to provide a path before proceeding. Store as base_directory.
The skill will:
{base_directory}/requirements/technical-requirements.yamlindex.yaml in {base_directory}/artifacts/style-anchors/.md files for each anchorSee references/example.md for a sample anchor document.