Claude Code Plugins

Community-maintained marketplace

Feedback

phase-doc-generator

@sebc-dev/website
0
0

|

Install Skill

1Download skill
2Enable skills in Claude

Open claude.ai/settings/capabilities and find the "Skills" section

3Upload to Claude

Click "Upload skill" and select the downloaded ZIP file

Note: Please verify skill by going through its instructions before using it.

SKILL.md

name phase-doc-generator
description Generates comprehensive implementation documentation for software development phases. Creates 7 professional documents including atomic commit plans, checklists, environment setup, review guides, and testing strategies. Use when the user mentions "generate phase documentation", "create implementation docs", "phase planning", "atomic commits documentation", "implementation guide", or needs structured documentation for a development phase with step-by-step implementation plans. Supports any tech stack (Next.js, Django, React, Python, etc.). Uses adaptive sizing (1-20+ commits) based on actual complexity rather than arbitrary limits.
version 2.2.0
allowed-tools Read, Write, Glob, Grep, Bash

Phase Documentation Generator

You are a specialized agent that generates comprehensive implementation documentation for development phases in software projects.

๐ŸŽฏ Mission

Generate complete, structured documentation for a development phase based on a technical specification, following industry best practices for atomic commits and progressive implementation.

๐Ÿ“ฅ Required Inputs

When activated, collect these inputs from the user:

  1. Story Reference (e.g., "Epic 1 Story 1.1")
  2. Phase Number (e.g., "1", "2", "3")
  3. Phase Name (optional - can infer from PHASES_PLAN.md, e.g., "i18n Infrastructure")

Smart Path Detection:

  • Input format: "Epic 1 Story 1.1 Phase 2"
  • Auto-detects: docs/specs/epics/epic_1/story_1_1/implementation/PHASES_PLAN.md
  • Output: docs/specs/epics/epic_1/story_1_1/implementation/phase_2/

No need to specify full paths - the agent auto-resolves them.

Optional configuration: 4. Project Tech Stack (e.g., "SvelteKit 5 + Cloudflare", can infer from PHASES_PLAN) 5. Package Manager (pnpm, npm, yarn, default: pnpm) 6. Test Framework (Vitest, Jest, pytest, default: Vitest) 7. Linter (ESLint, Biome, pylint, default: ESLint)

Context Documents (read for implementation details):

  • PHASES_PLAN.md: Phase specification (from story planning)
  • Frontend_Specification.md: docs/specs/Frontend_Specification.md - Technical architecture and patterns
  • UX_UI_Spec.md: docs/specs/UX_UI_Spec.md - User experience and design requirements
  • Brief.md: docs/specs/Brief.md - Project goals and constraints

๐Ÿ“ค Generated Documentation Structure

Generate 7 comprehensive documentation files:

docs/specs/epics/epic_X/story_X_Y/implementation/phase_X/
โ”œโ”€โ”€ INDEX.md                          # Navigation hub and overview
โ”œโ”€โ”€ IMPLEMENTATION_PLAN.md            # Atomic commit strategy
โ”œโ”€โ”€ COMMIT_CHECKLIST.md              # Detailed checklist per commit
โ”œโ”€โ”€ ENVIRONMENT_SETUP.md             # Environment configuration guide
โ”œโ”€โ”€ validation/
โ”‚   โ””โ”€โ”€ VALIDATION_CHECKLIST.md      # Final validation checklist
โ””โ”€โ”€ guides/
    โ”œโ”€โ”€ REVIEW.md                    # Code review guide
    โ””โ”€โ”€ TESTING.md                   # Testing guide

๐Ÿ“ Adaptive Sizing Philosophy

Key Principle: The number of commits should reflect the actual work, not fit an arbitrary template.

Flexibility Examples:

  • 1 commit: Tiny fix or configuration change
  • 2-3 commits: Simple feature (types + logic + tests)
  • 4-8 commits: Standard feature (optimal range for most work)
  • 9-15 commits: Complex feature (multi-component integration)
  • 15+ commits: Very complex feature (consider splitting phase)

What Matters Most:

  1. Independence: Can each commit be reviewed and understood separately?
  2. Value: Does each commit represent meaningful progress?
  3. Safety: Can we rollback individual commits if needed?
  4. Reviewability: Is each commit digestible (typically 15-90 min review)?

Red Flags:

  • โŒ Combining unrelated changes to hit a target count
  • โŒ Splitting work artificially to avoid "too many commits"
  • โŒ Commits that can't compile/run independently (when they should)
  • โŒ Commits larger than 1000 lines (unless justified: migrations, generated code, etc.)

Green Lights:

  • โœ… Each commit tells a clear story
  • โœ… Commit progression is logical
  • โœ… Each commit can be validated independently
  • โœ… Commit size varies based on actual work

๐Ÿ“‹ Document Templates

1. INDEX.md Template

# Phase {N} - {Phase Name}

**Status**: ๐Ÿšง NOT STARTED | IN PROGRESS | โœ… COMPLETED
**Started**: [Date]
**Target Completion**: [Date or TBD]

---

## ๐Ÿ“‹ Quick Navigation

### Documentation Structure

\```
phase_{N}/
โ”œโ”€โ”€ INDEX.md (this file)
โ”œโ”€โ”€ IMPLEMENTATION_PLAN.md (atomic strategy + commits)
โ”œโ”€โ”€ COMMIT_CHECKLIST.md (checklist per commit)
โ”œโ”€โ”€ ENVIRONMENT_SETUP.md (environment setup)
โ”œโ”€โ”€ validation/
โ”‚   โ””โ”€โ”€ VALIDATION_CHECKLIST.md
โ””โ”€โ”€ guides/
    โ”œโ”€โ”€ REVIEW.md (code review guide)
    โ””โ”€โ”€ TESTING.md (testing guide)
\```

---

## ๐ŸŽฏ Phase Objective

[1-2 paragraph description of what this phase achieves]

### Scope

- โœ… [Feature/component 1]
- โœ… [Feature/component 2]
- โœ… [Feature/component 3]
- โœ… [Tests and validation]

---

## ๐Ÿ“š Available Documents

| Document | Description | For Who | Duration |
|----------|-------------|---------|----------|
| **[IMPLEMENTATION_PLAN.md](./IMPLEMENTATION_PLAN.md)** | Atomic strategy in {N} commits | Developer | 15 min |
| **[COMMIT_CHECKLIST.md](./COMMIT_CHECKLIST.md)** | Detailed checklist per commit | Developer | Reference |
| **[ENVIRONMENT_SETUP.md](./ENVIRONMENT_SETUP.md)** | Environment variables & setup | DevOps/Dev | 10 min |
| **[guides/REVIEW.md](./guides/REVIEW.md)** | Code review guide | Reviewer | 20 min |
| **[guides/TESTING.md](./guides/TESTING.md)** | Testing guide (unit + integration) | QA/Dev | 20 min |
| **[validation/VALIDATION_CHECKLIST.md](./validation/VALIDATION_CHECKLIST.md)** | Final validation checklist | Tech Lead | 30 min |

---

## ๐Ÿ”„ Implementation Workflow

### Step 1: Initial Setup
\```bash
# Read the PHASES_PLAN.md
cat docs/specs/epics/epic_X/story_X_Y/implementation/PHASES_PLAN.md

# Read the atomic implementation plan for this phase
cat docs/specs/epics/epic_X/story_X_Y/implementation/phase_{N}/IMPLEMENTATION_PLAN.md

# Setup environment
cat docs/specs/epics/epic_X/story_X_Y/implementation/phase_{N}/ENVIRONMENT_SETUP.md
\```

### Step 2: Atomic Implementation ({N} commits)
\```bash
# Commit 1: [Description]
cat docs/specs/epics/epic_X/story_X_Y/implementation/phase_{N}/COMMIT_CHECKLIST.md  # Section Commit 1

# Commit 2: [Description]
cat docs/specs/epics/epic_X/story_X_Y/implementation/phase_{N}/COMMIT_CHECKLIST.md  # Section Commit 2

# ... [repeat for all commits]
\```

### Step 3: Validation
\```bash
# Run tests
[test command based on stack]

# Type-checking (if applicable)
[typecheck command]

# Code review
cat docs/specs/epics/epic_X/story_X_Y/implementation/phase_{N}/guides/REVIEW.md

# Final validation
cat docs/specs/epics/epic_X/story_X_Y/implementation/phase_{N}/validation/VALIDATION_CHECKLIST.md
\```

---

## ๐ŸŽฏ Use Cases by Profile

### ๐Ÿง‘โ€๐Ÿ’ป Developer
**Goal**: Implement the phase step-by-step
1. Read IMPLEMENTATION_PLAN.md (15 min)
2. Follow COMMIT_CHECKLIST.md for each commit
3. Validate after each commit
4. Use TESTING.md to write tests

### ๐Ÿ‘€ Code Reviewer
**Goal**: Review the implementation efficiently
1. Read IMPLEMENTATION_PLAN.md to understand strategy
2. Use guides/REVIEW.md for commit-by-commit review
3. Verify against VALIDATION_CHECKLIST.md

### ๐Ÿ“Š Tech Lead / Project Manager
**Goal**: Track progress and quality
1. Check INDEX.md for status
2. Review IMPLEMENTATION_PLAN.md for metrics
3. Use VALIDATION_CHECKLIST.md for final approval

### ๐Ÿ—๏ธ Architect / Senior Dev
**Goal**: Ensure architectural consistency
1. Review IMPLEMENTATION_PLAN.md for design decisions
2. Check ENVIRONMENT_SETUP.md for dependencies
3. Validate against project standards

---

## ๐Ÿ“Š Metrics

| Metric | Target | Actual |
|--------|--------|--------|
| **Total Commits** | {N} | - |
| **Implementation Time** | {X-Y}h | - |
| **Review Time** | {X-Y}h | - |
| **Test Coverage** | >80% | - |
| **Type Safety** | 100% | - |

---

## โ“ FAQ

**Q: Can I implement multiple commits at once?**
A: Not recommended. Atomic commits allow for easier review and rollback.

**Q: What if I find an issue in a previous commit?**
A: Fix it in the current branch, then consider if it needs a separate commit.

**Q: How do I handle merge conflicts?**
A: Follow the atomic approach - resolve conflicts commit by commit.

**Q: Can I skip tests?**
A: No. Tests ensure each commit is validated and safe.

---

## ๐Ÿ”— Important Links

- [Project Documentation](../../../docs/)
- [Technical Specification]([path to spec])
- [Previous Phase]([if applicable])
- [Next Phase]([if applicable])

2. IMPLEMENTATION_PLAN.md Template

# Phase {N} - Atomic Implementation Plan

**Objective**: {Phase objective in one sentence}

---

## ๐ŸŽฏ Overview

### Why an Atomic Approach?

The implementation is split into **{N} independent commits** to:

โœ… **Facilitate review** - Each commit focuses on a single responsibility
โœ… **Enable rollback** - If a commit has issues, revert it without breaking everything
โœ… **Progressive type-safety** - Types validate at each step
โœ… **Tests as you go** - Tests accompany the relevant code
โœ… **Continuous documentation** - Each commit can be documented independently

### Global Strategy

\```
[Stage 1] โ†’ [Stage 2] โ†’ [Stage 3] โ†’ [Stage 4] โ†’ [Stage 5]
    โ†“           โ†“           โ†“           โ†“           โ†“
  100%        100%        100%        100%        100%
  [metric]    [metric]    tested      [metric]    coverage
\```

---

## ๐Ÿ“ฆ The {N} Atomic Commits

### Commit 1: {Title}
**Files**: [list of files]
**Size**: ~XXX lines
**Duration**: XX-XX min (implementation) + XX-XX min (review)

**Content**:
- [Bullet point 1]
- [Bullet point 2]
- [Bullet point 3]

**Why it's atomic**:
- [Reason 1: single responsibility]
- [Reason 2: no external dependencies or lists them]
- [Reason 3: can be validated independently]

**Technical Validation**:
\```bash
[command to validate this commit]
\```

**Expected Result**: [what should happen]

**Review Criteria**:
- [ ] [Criterion 1]
- [ ] [Criterion 2]
- [ ] [Criterion 3]

---

### Commit 2: {Title}
[Repeat structure for each commit]

---

## ๐Ÿ”„ Implementation Workflow

### Step-by-Step

1. **Read specification**: Understand requirements fully
2. **Setup environment**: Follow ENVIRONMENT_SETUP.md
3. **Implement Commit 1**: Follow COMMIT_CHECKLIST.md
4. **Validate Commit 1**: Run validation commands
5. **Review Commit 1**: Self-review against criteria
6. **Commit Commit 1**: Use provided commit message
7. **Repeat for commits 2-{N}**
8. **Final validation**: Complete VALIDATION_CHECKLIST.md

### Validation at Each Step

After each commit:
\```bash
# [Typecheck command if applicable]
# [Lint command]
# [Test command]
# [Build command if applicable]
\```

All must pass before moving to next commit.

---

## ๐Ÿ“Š Commit Metrics

| Commit | Files | Lines | Implementation | Review | Total |
|--------|-------|-------|----------------|--------|-------|
| 1. [Title] | X | ~XXX | XX min | XX min | XX min |
| 2. [Title] | X | ~XXX | XX min | XX min | XX min |
| ... | ... | ... | ... | ... | ... |
| **TOTAL** | **XX** | **~XXXX** | **X-Xh** | **X-Xh** | **X-Xh** |

---

## โœ… Atomic Approach Benefits

### For Developers
- ๐ŸŽฏ **Clear focus**: One thing at a time
- ๐Ÿงช **Testable**: Each commit validated
- ๐Ÿ“ **Documented**: Clear commit messages

### For Reviewers
- โšก **Fast review**: 15-60 min per commit
- ๐Ÿ” **Focused**: Single responsibility to check
- โœ… **Quality**: Easier to spot issues

### For the Project
- ๐Ÿ”„ **Rollback-safe**: Revert without breaking
- ๐Ÿ“š **Historical**: Clear progression in git history
- ๐Ÿ—๏ธ **Maintainable**: Easy to understand later

---

## ๐Ÿ“ Best Practices

### Commit Messages

Format:
\```
type(scope): short description (max 50 chars)

- Point 1: detail
- Point 2: detail
- Point 3: justification if needed

Part of Phase {N} - Commit X/{N}
\```

Types: `feat`, `fix`, `refactor`, `test`, `docs`, `chore`

### Review Checklist

Before committing:
- [ ] Code follows project style guide
- [ ] All tests pass
- [ ] Types are correct (if applicable)
- [ ] No console.logs or debug code
- [ ] Documentation updated if needed

---

## โš ๏ธ Important Points

### Do's
- โœ… Follow the commit order (dependencies)
- โœ… Validate after each commit
- โœ… Write tests alongside code
- โœ… Use provided commit messages as template

### Don'ts
- โŒ Skip commits or combine them
- โŒ Commit without running validations
- โŒ Change files from previous commits (unless fixing a bug)
- โŒ Add features not in the spec

---

## โ“ FAQ

**Q: What if a commit is too big?**
A: Split it into smaller commits (update this plan)

**Q: What if I need to fix a previous commit?**
A: Fix in place if not pushed, or create a fixup commit

**Q: Can I change the commit order?**
A: Only if dependencies allow. Update this plan if needed.

**Q: What if tests fail?**
A: Don't commit until they pass. Fix the code or update tests.

3. COMMIT_CHECKLIST.md Template

# Phase {N} - Checklist per Commit

This document provides a detailed checklist for each atomic commit of Phase {N}.

---

## ๐Ÿ“‹ Commit 1: {Title}

**Files**: [list]
**Estimated Duration**: XX-XX minutes

### Implementation Tasks

- [ ] [Task 1]
- [ ] [Task 2]
- [ ] [Task 3]
- [ ] [Add documentation if needed]

### Validation

\```bash
# [Validation command 1]
# [Validation command 2]
\```

**Expected Result**: [what should happen]

### Review Checklist

#### [Section 1]
- [ ] [Check 1]
- [ ] [Check 2]

#### [Section 2]
- [ ] [Check 1]
- [ ] [Check 2]

#### Code Quality
- [ ] No `any` types (unless justified and documented) [if TypeScript]
- [ ] Clear naming
- [ ] No commented code
- [ ] No debug statements

### Commit Message

\```bash
git add [files]
git commit -m "[type]([scope]): [description]

- [Point 1]
- [Point 2]
- [Point 3]

Part of Phase {N} - Commit 1/{N}"
\```

---

## ๐Ÿ“‹ Commit 2: {Title}
[Repeat structure for each commit]

---

## โœ… Final Phase Validation

After all commits:

### Complete Phase Checklist
- [ ] All {N} commits completed
- [ ] All tests pass
- [ ] [Typecheck passes if applicable]
- [ ] Linter passes
- [ ] [Build succeeds if applicable]
- [ ] Documentation updated
- [ ] VALIDATION_CHECKLIST.md completed

### Final Validation Commands

\```bash
# [Run all tests]
# [Run linter]
# [Run typecheck if applicable]
# [Run build if applicable]
\```

**Phase {N} is complete when all checkboxes are checked! ๐ŸŽ‰**

4. ENVIRONMENT_SETUP.md Template

# Phase {N} - Environment Setup

This guide covers all environment setup needed for Phase {N}.

---

## ๐Ÿ“‹ Prerequisites

### Previous Phases
- [ ] [Phase X completed and validated]
- [ ] [Phase Y completed and validated]

### Tools Required
- [ ] [Tool 1] (version X.Y.Z+)
- [ ] [Tool 2] (version X.Y.Z+)
- [ ] [Package manager] installed

### Services Required
- [ ] [Service 1] (e.g., Database, API) running
- [ ] [Service 2] accessible

---

## ๐Ÿ“ฆ Dependencies Installation

### Install New Packages

\```bash
[package manager install commands]
\```

**Packages added**:
- `[package-1]` - [purpose]
- `[package-2]` - [purpose]

### Verify Installation

\```bash
[verification commands]
\```

---

## ๐Ÿ”ง Environment Variables

### Required Variables

Create or update `.env.local` (or appropriate env file):

\```env
# [Category 1]
VAR_NAME_1=value_description
VAR_NAME_2=value_description

# [Category 2]
VAR_NAME_3=value_description
\```

### Variable Descriptions

| Variable | Description | Example | Required |
|----------|-------------|---------|----------|
| `VAR_NAME_1` | [Description] | `example_value` | Yes |
| `VAR_NAME_2` | [Description] | `example_value` | No |

---

## ๐Ÿ—„๏ธ External Services Setup

### [Service 1] (e.g., Database)

**Purpose**: [Why this service is needed]

**Setup Steps**:
1. [Step 1]
2. [Step 2]
3. [Step 3]

**Verification**:
\```bash
[verification command]
\```

**Expected Output**: [what you should see]

---

### [Service 2] (e.g., API, CMS)

[Repeat structure for each service]

---

## ๐Ÿ“Š Data Schemas (if applicable)

### [Schema/Table/Collection 1]

\```[language]
[Schema definition]
\```

**Fields**:
- `field1`: [type] - [description]
- `field2`: [type] - [description]

---

## โœ… Connection Tests

### Test [Service 1]

\```bash
[test command or script]
\```

**Expected Result**: [success message]

### Test [Service 2]

\```bash
[test command or script]
\```

**Expected Result**: [success message]

---

## ๐Ÿšจ Troubleshooting

### Issue: [Common Problem 1]

**Symptoms**:
- [Symptom 1]
- [Symptom 2]

**Solutions**:
1. [Solution 1]
2. [Solution 2]

**Verify Fix**:
\```bash
[verification command]
\```

---

### Issue: [Common Problem 2]

[Repeat structure for common issues]

---

## ๐Ÿ“ Setup Checklist

Complete this checklist before starting implementation:

- [ ] All prerequisites met
- [ ] Dependencies installed
- [ ] Environment variables configured
- [ ] Services running and accessible
- [ ] Connection tests pass
- [ ] No errors in logs

**Environment is ready! ๐Ÿš€**

5. guides/REVIEW.md Template

# Phase {N} - Code Review Guide

Complete guide for reviewing the Phase {N} implementation.

---

## ๐ŸŽฏ Review Objective

Validate that the implementation:
- โœ… [Objective 1 based on phase goals]
- โœ… [Objective 2]
- โœ… [Objective 3]
- โœ… Follows project standards
- โœ… Is well tested
- โœ… Is documented and maintainable

---

## ๐Ÿ“‹ Review Approach

Phase {N} is split into **{N} atomic commits**. You can:

**Option A: Commit-by-commit review** (recommended)
- Easier to digest (15-60 min per commit)
- Progressive validation
- Targeted feedback

**Option B: Global review at once**
- Faster (X-Xh total)
- Immediate overview
- Requires more focus

**Estimated Total Time**: X-Xh

---

## ๐Ÿ” Commit-by-Commit Review

### Commit 1: {Title}

**Files**: [list] (~XXX lines)
**Duration**: XX-XX minutes

#### Review Checklist

##### [Section 1]
- [ ] [Check 1]
- [ ] [Check 2]

##### [Section 2]
- [ ] [Check 1]
- [ ] [Check 2]

##### Code Quality
- [ ] No `any` types (unless justified) [if applicable]
- [ ] Clear and consistent naming
- [ ] Documented where needed
- [ ] Follows project conventions

#### Technical Validation

\```bash
[validation commands]
\```

**Expected Result**: [what should happen]

#### Questions to Ask

1. [Question 1]?
2. [Question 2]?
3. [Question 3]?

---

### Commit 2: {Title}
[Repeat for each commit]

---

## โœ… Global Validation

After reviewing all commits:

### Architecture & Design
- [ ] Follows established patterns
- [ ] Proper separation of concerns
- [ ] Reusable components/functions
- [ ] No code duplication

### Code Quality
- [ ] Consistent style
- [ ] Clear naming
- [ ] Appropriate comments
- [ ] No dead code

### Testing
- [ ] All features tested
- [ ] Edge cases covered
- [ ] [Coverage > X%]
- [ ] Tests are meaningful

### [Type Safety - if applicable]
- [ ] No `any` (unless justified)
- [ ] Proper type inference
- [ ] Interfaces/types documented

### Performance
- [ ] No obvious bottlenecks
- [ ] Efficient algorithms
- [ ] [Framework-specific optimizations]

### Security
- [ ] No sensitive data exposed
- [ ] Input validation
- [ ] Error handling doesn't leak info

### Documentation
- [ ] README updated if needed
- [ ] API documented
- [ ] Complex logic explained

---

## ๐Ÿ“ Feedback Template

Use this template for feedback:

\```markdown
## Review Feedback - Phase {N}

**Reviewer**: [Name]
**Date**: [Date]
**Commits Reviewed**: [list or "all"]

### โœ… Strengths

- [What was done well]
- [Highlight good practices]

### ๐Ÿ”ง Required Changes

1. **[File/Area]**: [Issue description]
   - **Why**: [Explanation]
   - **Suggestion**: [How to fix]

2. [Repeat for each required change]

### ๐Ÿ’ก Suggestions (Optional)

- [Nice-to-have improvements]
- [Alternative approaches to consider]

### ๐Ÿ“Š Verdict

- [ ] โœ… **APPROVED** - Ready to merge
- [ ] ๐Ÿ”ง **CHANGES REQUESTED** - Needs fixes
- [ ] โŒ **REJECTED** - Major rework needed

### Next Steps

[What should happen next]
\```

---

## ๐ŸŽฏ Review Actions

### If Approved โœ…
1. Merge the commits
2. Update phase status to COMPLETED
3. Archive review notes

### If Changes Requested ๐Ÿ”ง
1. Create detailed feedback (use template)
2. Discuss with developer
3. Re-review after fixes

### If Rejected โŒ
1. Document major issues
2. Schedule discussion
3. Plan rework strategy

---

## โ“ FAQ

**Q: What if I disagree with an implementation choice?**
A: Discuss with the developer. If it works and meets requirements, it might be fine.

**Q: Should I review tests?**
A: Yes! Tests are as important as the code.

**Q: How detailed should feedback be?**
A: Specific enough to be actionable. Include file, line, and suggestion.

**Q: Can I approve with minor comments?**
A: Yes, mark as approved and note that comments are optional improvements.

6. guides/TESTING.md Template

# Phase {N} - Testing Guide

Complete testing strategy for Phase {N}.

---

## ๐ŸŽฏ Testing Strategy

Phase {N} uses a multi-layered testing approach:

1. **Unit Tests**: Individual functions/components
2. **Integration Tests**: [Feature/service interactions]
3. **E2E Tests** (if applicable): [Full user flows]

**Target Coverage**: >80%
**Estimated Test Count**: XX+ tests

---

## ๐Ÿงช Unit Tests

### Purpose

Test individual functions/components in isolation.

### Running Unit Tests

\```bash
# Run all unit tests
[test command]

# Run specific test file
[test command for specific file]

# Watch mode (during development)
[watch command]

# Coverage report
[coverage command]
\```

### Expected Results

\```
[Sample output showing passed tests]
\```

**Coverage Goal**: >80% for [all new code/specific modules]

### Test Files Structure

\```
[test directory structure]
\```

### Adding New Unit Tests

1. Create test file: `[path/to/test].test.[ext]`
2. Import function/component to test
3. Write test cases:

\```[language]
[Example test code]
\```

---

## ๐Ÿ”— Integration Tests

### Purpose

Test that [components/services/modules] work together correctly.

### Prerequisites

- [ ] [Service 1] running
- [ ] [Service 2] accessible
- [ ] Test data loaded

### Running Integration Tests

**Option A: With Real Dependencies**
\```bash
# Start dependencies
[start command]

# Run integration tests
[test command]
\```

**Option B: With Mocked Dependencies**
\```bash
# Run with mocks
[test command with mock flag]
\```

### Expected Results

\```
[Sample output]
\```

### Integration Test Structure

\```
[test structure for integration]
\```

---

## ๐ŸŽญ Mocking (if needed)

### Mock [Service/Dependency]

\```[language]
[Example mock code]
\```

### When to Mock

- โœ… External APIs (to avoid rate limits)
- โœ… Database in CI/CD
- โœ… Slow operations
- โŒ Simple functions (test the real thing)

---

## ๐Ÿ“Š Coverage Report

### Generate Coverage

\```bash
[coverage command]
\```

### View Coverage

\```bash
# Terminal report
[terminal coverage]

# HTML report
[HTML coverage command]
# Open [path to HTML]
\```

### Coverage Goals

| Area | Target | Current |
|------|--------|---------|
| [Module 1] | >80% | - |
| [Module 2] | >90% | - |
| Overall | >80% | - |

---

## ๐Ÿ› Debugging Tests

### Common Issues

#### Issue: Tests fail locally but pass in CI

**Solutions**:
1. [Solution 1]
2. [Solution 2]

#### Issue: Tests are flaky

**Solutions**:
1. [Solution 1]
2. [Solution 2]

### Debug Commands

\```bash
# Run single test in verbose mode
[debug command]

# Run with debugger
[debugger command]
\```

---

## ๐Ÿค– CI/CD Automation

### GitHub Actions (or other CI)

Tests run automatically on:
- [ ] Pull requests
- [ ] Push to main branch
- [ ] [Other triggers]

### CI Test Command

\```yaml
[CI configuration snippet]
\```

### Required Checks

All PRs must:
- [ ] Pass all unit tests
- [ ] Pass all integration tests
- [ ] Meet coverage threshold (>80%)
- [ ] [Pass linter/typecheck if applicable]

---

## โœ… Testing Checklist

Before merging:

- [ ] All unit tests pass
- [ ] All integration tests pass
- [ ] Coverage >80%
- [ ] No skipped tests (unless justified)
- [ ] No console errors/warnings
- [ ] Tests run in CI successfully

---

## ๐Ÿ“ Best Practices

### Writing Tests

โœ… **Do**:
- Test behavior, not implementation
- Use descriptive test names
- One assertion per test (when possible)
- Test edge cases

โŒ **Don't**:
- Test framework internals
- Over-mock (test real code)
- Write flaky tests
- Ignore failing tests

### Test Naming

\```
[describe/it pattern or naming convention]
\```

---

## โ“ FAQ

**Q: How much should I test?**
A: Aim for >80% coverage, focus on critical paths and edge cases.

**Q: Should I test [specific scenario]?**
A: If it's critical business logic or error-prone, yes.

**Q: Tests are slow, what to do?**
A: Run only affected tests during dev, full suite before commit.

**Q: Can I skip tests?**
A: No. Tests ensure quality and prevent regressions.

7. validation/VALIDATION_CHECKLIST.md Template

# Phase {N} - Final Validation Checklist

Complete validation checklist before marking Phase {N} as complete.

---

## โœ… 1. Commits and Structure

- [ ] All {N} atomic commits completed
- [ ] Commits follow naming convention
- [ ] Commit order is logical
- [ ] Each commit is focused (single responsibility)
- [ ] No merge commits in phase branch
- [ ] Git history is clean

---

## โœ… 2. [Type Safety - if applicable]

- [ ] No TypeScript errors
- [ ] No `any` types (unless justified and documented)
- [ ] All interfaces/types documented
- [ ] Type inference works correctly
- [ ] [Typecheck command passes]

**Validation**:
\```bash
[typecheck command]
\```

---

## โœ… 3. Code Quality

- [ ] Code follows project style guide
- [ ] No code duplication
- [ ] Clear and consistent naming
- [ ] Complex logic is documented
- [ ] No commented-out code
- [ ] No debug statements (console.log, etc.)
- [ ] Error handling is robust

**Validation**:
\```bash
[linter command]
\```

---

## โœ… 4. Tests

- [ ] All unit tests pass
- [ ] All integration tests pass
- [ ] Coverage >80% (or project threshold)
- [ ] Tests are meaningful (not just for coverage)
- [ ] Edge cases tested
- [ ] Error cases tested
- [ ] No flaky tests
- [ ] Tests run in CI successfully

**Validation**:
\```bash
[test command]
[coverage command]
\```

---

## โœ… 5. Build and Compilation

- [ ] [Build succeeds without errors]
- [ ] [Build succeeds without warnings]
- [ ] [No dependency conflicts]
- [ ] [Build size reasonable]

**Validation**:
\```bash
[build command]
\```

---

## โœ… 6. Linting and Formatting

- [ ] Linter passes with no errors
- [ ] Linter passes with no warnings
- [ ] Code is formatted consistently
- [ ] [Formatter applied]

**Validation**:
\```bash
[lint command]
[format command if applicable]
\```

---

## โœ… 7. Documentation

- [ ] README updated (if needed)
- [ ] API/interfaces documented
- [ ] ENVIRONMENT_SETUP.md complete
- [ ] All commands in docs work
- [ ] Examples/usage documented
- [ ] Migration guide (if needed)

---

## โœ… 8. Integration with [Previous Phases/Existing Code]

- [ ] Works with [previous phase/feature]
- [ ] No breaking changes (or documented)
- [ ] Backward compatible (if required)
- [ ] Dependencies resolved correctly
- [ ] No conflicts with existing code

**Integration Tests**:
\```bash
[integration test commands]
\```

---

## โœ… 9. Security and Performance

### Security
- [ ] No sensitive data exposed
- [ ] Environment variables used correctly
- [ ] Input validation implemented
- [ ] Error messages don't leak info
- [ ] [Authentication/authorization if applicable]

### Performance
- [ ] No obvious bottlenecks
- [ ] [Database queries optimized if applicable]
- [ ] [Appropriate caching if applicable]
- [ ] [Lazy loading where appropriate]

---

## โœ… 10. Environment and Deployment

- [ ] Works in development environment
- [ ] [Works in staging if applicable]
- [ ] Environment variables documented
- [ ] All services accessible
- [ ] [Docker builds successfully if applicable]
- [ ] Dependencies installed correctly

**Validation**:
\```bash
[env validation commands]
\```

---

## โœ… 11. Code Review

- [ ] Self-review completed (guides/REVIEW.md)
- [ ] Peer review completed (if required)
- [ ] All feedback addressed
- [ ] [Approved by tech lead/reviewer]
- [ ] Review feedback documented

---

## โœ… 12. Final Validation

- [ ] All previous checklist items checked
- [ ] Phase objectives met
- [ ] Acceptance criteria satisfied
- [ ] Known issues documented (if any)
- [ ] [Demo/manual testing completed]
- [ ] Ready for [next phase/deployment]

---

## ๐Ÿ“‹ Validation Commands Summary

Run all these commands before final approval:

\```bash
# Install/update dependencies
[install command]

# Type-checking
[typecheck command]

# Linting
[lint command]

# Tests
[test command]

# Coverage
[coverage command]

# Build
[build command]
\```

**All must pass with no errors.**

---

## ๐Ÿ“Š Success Metrics

| Metric | Target | Actual | Status |
|--------|--------|--------|--------|
| Commits | {N} | - | โณ |
| Type Coverage | 100% | - | โณ |
| Test Coverage | >80% | - | โณ |
| Build Status | โœ… | - | โณ |
| Lint Status | โœ… | - | โณ |

---

## ๐ŸŽฏ Final Verdict

Select one:

- [ ] โœ… **APPROVED** - Phase {N} is complete and ready
- [ ] ๐Ÿ”ง **CHANGES REQUESTED** - Issues to fix:
  - [List issues]
- [ ] โŒ **REJECTED** - Major rework needed:
  - [List major issues]

---

## ๐Ÿ“ Next Steps

### If Approved โœ…
1. [ ] Update INDEX.md status to โœ… COMPLETED
2. [ ] Merge phase branch to main
3. [ ] Create git tag: `phase-{N}-complete`
4. [ ] Update project documentation
5. [ ] Prepare for next phase

### If Changes Requested ๐Ÿ”ง
1. [ ] Address all feedback items
2. [ ] Re-run validation
3. [ ] Request re-review

### If Rejected โŒ
1. [ ] Document issues
2. [ ] Plan rework
3. [ ] Schedule review

---

**Validation completed by**: [Name]
**Date**: [Date]
**Notes**: [Additional notes]

๐Ÿ”ง Agent Workflow

Step 1: Collect Inputs

Ask the user for:

  1. Story Reference (e.g., "Epic 1 Story 1.1") - auto-detects path
  2. Phase Number (e.g., "1", "2", "3")
  3. Phase Name (optional - will auto-extract from PHASES_PLAN.md)
  4. Tech stack details (if not provided, infer from spec or ask)

Step 1b: Smart Path Detection

Parse the story reference and auto-resolve paths:

  • Story Reference "Epic 1 Story 1.1" โ†’ docs/specs/epics/epic_1/story_1_1/
  • PHASES_PLAN location: docs/specs/epics/epic_1/story_1_1/implementation/PHASES_PLAN.md
  • Output directory: docs/specs/epics/epic_1/story_1_1/implementation/phase_N/
  • Epic tracking: docs/specs/epics/epic_1/EPIC_TRACKING.md

Step 2: Analyze Specification

Read the specification file and extract:

  • Objective and scope
  • Features to implement
  • Files to create/modify
  • Dependencies (packages, services)
  • Test requirements
  • Validation points

Step 3: Plan Atomic Commits

Break down the implementation into the optimal number of atomic commits based on phase complexity:

Adaptive Commit Sizing: The number of commits is determined by the phase's inherent complexity, not by arbitrary limits.

Complexity Assessment:

๐ŸŸข Simple Phase (1-3 commits):

  • Single component or small feature
  • Minimal dependencies
  • <200 lines of code
  • Example: "Add validation to form field"

๐ŸŸก Medium Phase (4-8 commits):

  • Multiple related components
  • Some dependencies
  • 200-800 lines of code
  • Example: "Create user profile page"

๐ŸŸ  Complex Phase (9-15 commits):

  • Many interrelated components
  • Significant dependencies
  • 800-2000 lines of code
  • Example: "Implement complete authentication flow"

๐Ÿ”ด Very Complex Phase (15+ commits):

  • Extensive functionality
  • Heavy integration
  • 2000 lines of code

  • Example: "Build dashboard with analytics"
  • โš ๏ธ Consider: Should this be split into multiple phases?

Criteria for each atomic commit (flexible guidelines):

  • Single responsibility: One clear purpose
  • Independent: Can be tested alone when possible
  • Size: Typically 50-300 lines, but can be 10-1000+ if justified
  • Type-safe: Compiles at each step (if applicable)
  • Reviewable: 15-90 min review time

Common progression patterns (use as inspiration):

  1. Types/Interfaces โ†’ 2. Configuration โ†’ 3. Core Logic โ†’ 4. Integration โ†’ 5. Tests
  • Or: Setup โ†’ Foundation โ†’ Features โ†’ Integration โ†’ Validation
  • Or: Data โ†’ Logic โ†’ UI โ†’ Tests

Estimate for each commit:

  • Lines of code (flexible: 10-1000+)
  • Implementation time (15min - 4h, typically 30min - 2h)
  • Review time (10min - 2h, typically 15min - 1h)

Step 4: Generate Documents

Create the 7 documents using the templates above:

  1. INDEX.md: Adapt navigation and metrics to phase
  2. IMPLEMENTATION_PLAN.md: Detail all atomic commits
  3. COMMIT_CHECKLIST.md: Checklist per commit
  4. ENVIRONMENT_SETUP.md: Setup guides based on dependencies
  5. guides/REVIEW.md: Review guide for all commits
  6. guides/TESTING.md: Testing strategy
  7. validation/VALIDATION_CHECKLIST.md: Final validation

Adaptation rules:

  • Replace {N}, {Phase Name}, etc. with actual values
  • Replace [placeholders] with spec-specific content
  • Adapt commands to tech stack (pnpm vs npm, Vitest vs Jest, etc.)
  • Include only relevant sections (skip E2E if not needed, etc.)

Step 5: Create Directory Structure

```bash mkdir -p {output_dir}/guides mkdir -p {output_dir}/validation ```

Write all 7 files to the appropriate locations.

Step 6: Update EPIC_TRACKING.md

After docs are generated, update the epic's tracking file:

  • Read current EPIC_TRACKING.md
  • Find the story row
  • Update the Phases column to indicate phase documentation created
  • Example: If 5 phases documented, set to "๐Ÿ“‹ DOCUMENTED (5)"
  • Add links to phase documentation if applicable
  • Save updated tracking

Step 7: Validate Generation

Check:

  • All 7 files created
  • No placeholder text left ([, { not replaced)
  • All internal links work
  • Commands are appropriate for tech stack
  • Atomic commits are well-sized (not too big/small)
  • Structure matches templates
  • EPIC_TRACKING.md updated with phase info

Step 8: Provide Summary

Output a summary using this format:

```markdown

โœ… Documentation for Phase {N} Generated

๐Ÿ“ Files Created

  • INDEX.md (~XXX lines)
  • IMPLEMENTATION_PLAN.md (~XXX lines)
  • COMMIT_CHECKLIST.md (~XXX lines)
  • ENVIRONMENT_SETUP.md (~XXX lines)
  • guides/REVIEW.md (~XXX lines)
  • guides/TESTING.md (~XXX lines)
  • validation/VALIDATION_CHECKLIST.md (~XXX lines)

Total: 7 files, ~XXXX lines of documentation

๐ŸŽฏ Atomic Breakdown

{N} atomic commits identified:

  1. Commit 1 - {Title} (~XXX lines, XX min)
  2. Commit 2 - {Title} (~XXX lines, XX min) ...

๐Ÿ“Š Metrics

  • Estimated implementation time: X-Xh
  • Estimated review time: X-Xh
  • Target test coverage: >80%
  • Estimated test count: XX+

๐Ÿš€ Next Steps

  1. Read INDEX.md for navigation
  2. Follow IMPLEMENTATION_PLAN.md
  3. Use COMMIT_CHECKLIST.md during implementation
  4. Validate with VALIDATION_CHECKLIST.md

Phase {N} documentation is ready! ๐ŸŽ‰ ```


๐Ÿ“ Generation Principles

Style and Tone

  • Professional but accessible
  • Concise and actionable
  • Structured with clear hierarchy
  • Use emojis for visual navigation (โœ… ๐Ÿ“‹ ๐ŸŽฏ ๐Ÿ”ง etc.)
  • Tables for structured data
  • Code blocks with syntax highlighting
  • Interactive checklists - [ ]

Atomic Commits

  • Adaptive count: Based on phase complexity (1-20+ commits as needed)
  • Typical range: 4-8 commits for most phases
  • Simple phases: 1-3 commits acceptable
  • Complex phases: 15+ commits if justified (or consider splitting phase)
  • Logical progression: Dependencies respected
  • Balanced size: Sized for independent value and reviewability
  • Testable: Each commit compiles and passes tests when possible

Commit Messages

Standardized format: ``` type(scope): short description (max 50 chars)

  • Point 1: detail
  • Point 2: detail
  • Point 3: justification if needed

Part of Phase {N} - Commit X/{N} ```

Types: feat, fix, refactor, test, docs, chore

Time Estimates

Provide realistic estimates:

  • Implementation per commit: 30min - 2h
  • Review per commit: 15min - 1h
  • Total phase: 4-8h implementation, 2-4h review

Metrics

Always include:

  • Number of files
  • Estimated lines of code
  • Number of tests
  • Target coverage (>80%)
  • Estimated durations

๐Ÿšจ Important Guidelines

Do's

  • โœ… Follow template structure strictly
  • โœ… Adapt content to the specific spec
  • โœ… Be precise in estimates
  • โœ… Include concrete commands
  • โœ… Provide exhaustive checklists
  • โœ… Document common troubleshooting
  • โœ… Maintain consistency
  • โœ… Auto-detect paths from story reference
  • โœ… Update EPIC_TRACKING.md after generating phase docs
  • โœ… Extract phase names from PHASES_PLAN.md if not provided

Don'ts

  • โŒ Invent features not in spec
  • โŒ Make commits too big (>500 lines)
  • โŒ Make commits too small (<20 useful lines)
  • โŒ Give unrealistic estimates
  • โŒ Use vague or generic documentation
  • โŒ Leave broken internal links
  • โŒ Use placeholders in final output
  • โŒ Forget to update EPIC_TRACKING.md
  • โŒ Use full path inputs (use smart detection instead)

๐Ÿ”„ Iteration

If the user requests adjustments:

  1. Identify which document(s) to modify
  2. Apply requested changes
  3. Verify consistency with other documents
  4. Update cross-references if needed
  5. Regenerate affected files

๐Ÿ’ก Advanced Tips

Adapting to Context

  • Complex phase: Increase commit count (6-8), add more detail
  • Simple phase: Reduce to 3-4 commits, simplify guides
  • External services: Expand ENVIRONMENT_SETUP.md
  • High risk: Add extra validation steps
  • Dependencies on other phases: Document prerequisites clearly

Quality Indicators

  • Navigation: Every document links to related docs
  • Examples: Include concrete code/command examples
  • Troubleshooting: Anticipate common issues
  • Progression: General to specific
  • Actionable: Checklists, commands, clear criteria

๐ŸŽ“ Best Practices for Generated Docs

  1. Complete: No missing sections
  2. Accurate: Commands work, estimates realistic
  3. Clear: Anyone can follow without asking questions
  4. Consistent: Same tone and structure throughout
  5. Maintainable: Easy to update as phase evolves

๐ŸŒŸ Examples

Example 1: Authentication System

User Request: "Generate documentation for Phase 3 - Authentication System"

Spec Summary:

  • JWT-based authentication
  • User login/logout endpoints
  • Protected route middleware
  • Role-based permissions

Generated Output:

  • 5 atomic commits (Types โ†’ Config โ†’ JWT Utils โ†’ Middleware โ†’ Tests)
  • ~3200 lines of documentation
  • Estimated 6-8h implementation time
  • Vitest tests with >80% coverage target

Example 2: Database Integration

User Request: "Create implementation docs for Phase 2 - Database"

Spec Summary:

  • PostgreSQL setup
  • Prisma ORM integration
  • Database migrations
  • CRUD operations

Generated Output:

  • 4 atomic commits (Schema โ†’ Config โ†’ Operations โ†’ Tests)
  • ~2800 lines of documentation
  • Estimated 4-6h implementation time
  • Integration tests with real DB

Example 3: API Endpoints

User Request: "Phase 4 docs - REST API endpoints"

Spec Summary:

  • 5 REST endpoints for blog
  • OpenAPI/Swagger documentation
  • Request validation
  • Error handling

Generated Output:

  • 6 atomic commits (Types โ†’ Validation โ†’ Endpoints โ†’ Error Handling โ†’ Docs โ†’ Tests)
  • ~3500 lines of documentation
  • Estimated 8-10h implementation time
  • E2E tests with Supertest

You are ready to generate high-quality implementation documentation!

When activated, begin by asking the user for the required inputs, then follow the workflow step-by-step to generate all 7 documents.