Commit 72578a2
authored
refactor(workflow): comprehensive spec-driven workflow prompt refactoring (#26)
* feat: add validation prompt
* docs: add comprehensive spec-driven workflow refactoring plan
This commit introduces a detailed refactoring roadmap for the Spec-Driven Development
Workflow that maintains simplicity while improving newcomer accessibility.
Key improvements include:
- Enhanced prompt clarity with workflow guidance and next steps
- Scope size recommendations with concrete examples (too large/small/just right)
- Centralized directory structure for specs, tasks, and proofs
- Simplified numbering system (01, 02, 03 instead of 0001, 0002, 0003)
- Implementation steps for migration and prompt updates
- Research-based prompt engineering best practices
The document consolidates previous scattered improvements into a single,
actionable plan that preserves the workflow's core differentiation: simplicity.
* feat: enhance generate-spec prompt with research-based improvements and workflow guidance
This commit implements comprehensive enhancements to the generate-spec prompt based on
extensive prompt engineering research and the spec-driven workflow refactoring plan.
**Applied findings from 2025 prompt engineering best practices research:
- Role-based prompting: Added Senior Product Manager and Technical Lead persona to
improve domain-specific response quality and expertise alignment
- Chain-of-thought reasoning: Implemented step-by-step scope assessment process to
prevent premature task generation and improve decision quality
- Negative constraints: Added NEVER/ALWAYS sections to prevent common failure modes
and establish clear behavioral guardrails
- Output format templates: Provided exact markdown structure with concrete examples
to ensure consistent, actionable specification output
- Progressive disclosure: Structured questioning approach that starts with core
understanding and expands based on feature complexity
**Enhanced newcomer accessibility without external documentation dependencies:
- Added "You are here in the workflow" section providing current position and
next steps guidance
- Clear workflow progression: idea → spec → tasks → implementation → validation
- Enhanced process overview with 5-step structured approach
- Explicit "What comes next" guidance pointing to task generation command
**Implemented proactive scope management to prevent inappropriate spec sizes:
- Chain-of-thought reasoning for scope evaluation
- Concrete examples categorizing features as too large/small/just right
- Three-tiered assessment with specific actionable recommendations
- Validation step after gathering user requirements
**Improved clarifying questions while maintaining original flexibility:
- Reduced from 18 formal questions to 9 guided questions
- Thematic grouping: Core Understanding, Success & Boundaries, Design & Technical,
Demo & Proof
- Preserved adaptive questioning: "Adapt your questions based on user input"
- Progressive disclosure guidance for intelligent question expansion
**Updated to align with new directory structure and numbering system:
- File location: /tasks/ → ./docs/specs/ for centralized artifact management
- Numbering system: 4-digit (0001) → 2-digit (01) for improved navigation
- Enhanced FR1/FR2/FR3 requirement numbering for better traceability
- Integrated proof artifacts throughout the specification process
**Enhanced output quality and maintainability:
- Comprehensive review and refinement process with specific validation questions
- Enhanced spec structure with detailed templates and examples
- Improved proof artifact integration and validation criteria
- Better alignment with junior developer audience needs
**Achieved optimal balance between comprehensiveness and efficiency:
- Original: ~1133 tokens across 75 lines
- Enhanced: ~1929 tokens across 248 lines
- 70% increase delivers substantial value: workflow guidance, scope validation,
research-based improvements, and enhanced newcomer experience
- Maintains original's elegance and flexibility while adding robust capabilities
This enhancement represents a thoughtful evolution that preserves the original's
core philosophy while addressing key workflow pain points and incorporating modern
prompt engineering research findings.
* refactor: move context assessment earlier in spec-driven workflow
This commit restructures the spec-driven workflow to move context assessment
from the task generation phase to the specification creation phase for better
decision-making and more realistic specifications.
## Workflow Improvements
**Enhanced generate-spec.md:**
- Added Step 3: Context Assessment (Optional) to review existing codebase
and documentation for architecture patterns, components, and constraints
- Updated Process Overview from 5 to 6 steps to include context assessment
- Enhanced Scope Validation to consider both user requirements AND existing
codebase context for more accurate scope decisions
- Updated Final Instructions to reflect the new 9-step process
**Streamlined generate-task-list-from-spec.md:**
- Removed redundant Step 4: Assess Current State since context is now
gathered during spec creation
- Reduced process from 11 to 10 steps for cleaner workflow
- Updated Phase 1 to reference existing codebase context captured during
spec creation process
## Benefits
**Better Scope Decisions:**
- Context available when making scope validation decisions
- Can identify if existing infrastructure makes features easier/harder
- More realistic assessment of feature complexity and feasibility
**Improved Spec Quality:**
- Requirements can reference existing patterns and constraints
- Prevents specifying impossible or redundant functionality
- Better alignment with established architecture and conventions
**Cleaner Workflow Separation:**
- Spec phase handles "what exists" context gathering
- Task phase focuses on "how to build" implementation planning
- Eliminates redundant codebase analysis across workflow phases
**Enhanced Documentation Coverage:**
- Context assessment includes both codebase AND existing documentation
- Captures architectural decisions, API specs, and design patterns
- Prevents missing important documented constraints or standards
This change maintains the workflow's focus on specification while providing
better context for realistic planning and implementation decisions.
* refactor: refine spec template to reduce verbosity and duplication
This commit refines the generate-spec template to address verbosity concerns
and eliminate content duplication across specification sections.
## Template Structure Improvements
**Enhanced Section Guidance:**
- Updated User Stories to focus on user motivation and WHY
- Clarified Demoable Units to focus on tangible progress and WHAT
- Refined Functional Requirements to focus on system behavior and WHAT
- Improved Design Considerations to focus on UI/UX requirements
- Enhanced Technical Considerations to focus on implementation constraints and HOW
**Formatting Consistency:**
- Changed "Work Unit" to "Unit" for conciseness
- Updated FR1/FR2/FR3 format to standard numbered lists with bold requirements
- Improved Non-Goals, Success Metrics, and Open Questions formatting
- Added explicit fallback text for Design and Technical Considerations
**Duplication Prevention:**
- Added comprehensive guidance in Final Instructions section
- Explicit instruction to ensure each section has distinct purpose
- Clear mapping of sections to their specific focus areas (WHY vs WHAT vs HOW)
- Guidance to avoid restating content from previous sections
## Benefits
**Reduced Verbosity:**
- Each section now has clear, distinct purpose
- Eliminates redundant content across sections
- More concise, focused specifications
**Improved Clarity:**
- Users understand what each section should contain
- Clear separation between user value, demonstration, system behavior, and implementation
- Better readability and maintainability
**Better Implementation Guidance:**
- Developers get clear requirements without duplication
- Technical considerations focus on constraints, not restating requirements
- Demoable units focus on tangible proof, not user stories
This refinement maintains all research-based improvements while producing
leaner, more focused specifications that avoid content redundancy.
* refactor: update spec output structure to use subdirectories
This commit updates the generate-spec prompt to use a subdirectory structure
for specification files instead of flat files in the specs directory.
## Directory Structure Changes
**Previous Structure:**
- Location: ./docs/specs/
- Format: [n]-spec-[feature-name].md (flat files)
**New Structure:**
- Location: ./docs/specs/[n]-spec-[feature-name]/
- Format: [n]-spec-[feature-name]/[n]-spec-[feature-name].md
## Benefits
**Better Organization:**
- Each spec gets its own dedicated directory
- Related files can be co-located with the spec
- Cleaner directory listing with logical grouping
**Enhanced Extensibility:**
- Room for additional spec-related artifacts
- Can include diagrams, examples, or supporting documents
- Future-proof for spec evolution needs
**Improved Navigation:**
- Clear separation between different specifications
- Easier to find all files related to a specific feature
- Better support for spec versioning or iterations
## Updated References
- Updated Output Requirements section with new path structure
- Modified Final Instructions to reflect new save location
- Maintains all existing functionality while improving organization
This change supports better long-term maintenance and organization of
specification artifacts while preserving the established numbering system
and workflow compatibility.
* refactor(spec): fix prompt flow inconsistencies and enhance workflow integration
- Resolve conflicting process sequences causing unpredictable AI behavior
- Add comprehensive Workflow Integration section with value chain mapping
- Standardize section naming across workflow prompts
- Fix directory structure instructions to ensure proper subdirectory creation
- Simplify process from 6-step to 5-step sequence removing duplicate validation
- Enhance Output Requirements with explicit directory creation guidance
These changes improve prompt reliability and consistency in the SDD workflow.
* refactor(tasks): fix two-phase process by separating output formats
- Add separate Phase 2 (parent tasks only) and Phase 3 (complete) output formats
- Remove conflicting examples that caused AI to skip phase separation
- Simplify overly restrictive instructions now that format confusion is resolved
- Add fallback logic to auto-select oldest spec without tasks file
- Enhance save process to preserve parent tasks before confirmation wait
These changes ensure consistent two-phase behavior: generate parent tasks → save → wait for confirmation → generate sub-tasks.
* feat: refactor manage-tasks prompt with research-backed workflow engineering
- Apply structured workflow patterns from agentic AI research
- Implement Chain-of-Verification (CoV) technique for self-checking
- Add explicit command execution with immediate verification steps
- Create blocking verification mechanisms that prevent progression
- Replace heavy-handed enforcement with structured protocols
- Use task-driven proof artifact requirements instead of prescriptive lists
- Apply schema enforcement through checklist-based verification
- Implement error recovery protocols with clear fix-verify cycles
Research-backed techniques applied:
1. Structured workflows with validation gates (Skywork AI, 2024)
2. Self-verification mechanisms (Medium CoVe research, 2024)
3. Schema enforcement and structured outputs (OpenAI, 2024)
4. Chain-of-thought reasoning with verification checkpoints
5. Positive directives over negative constraints (PromptHub principles)
Key improvements achieved:
- Task list management: ✅ Working consistently
- Git commits: ✅ Created after each parent task
- Proof artifacts: ✅ Generated with proper naming convention
- Progress tracking: ✅ Real-time task file updates
- Verification: ✅ Built-in checkpoints prevent errors
The refactor transforms prompt behavior from 0% compliance to
consistent workflow adherence through structured guidance
rather than authoritarian enforcement.
* refactor(workflow): simplify proof artifacts to single markdown file per task
Replace complex multi-file artifact creation with single markdown file approach:
- Change from multiple files with naming conventions to one [spec]-task-[number]-proofs.md file
- Include structured sections for CLI output, test results, screenshots, and configuration
- Simplify verification from checking multiple files to validating one comprehensive file
- Maintain all blocking verification and checkpoint mechanisms
- Reduce cognitive load while preserving proof quality and validation requirements
This addresses user feedback about naming convention complexity and follows
the pattern where the AI successfully implemented simpler, single-action workflows.
* refactor(workflow): update validation prompt to use new directory structure
- Update Auto-Discovery Protocol to scan ./docs/specs/ for directories
- Change pattern from flat files to [n]-spec-[feature-name]/ directories
- Maintain consistency with other workflow prompts
- Ensure validation works with new subdirectory-based spec organization
* fix(workflow): enhance validation prompt and standardize next-step guidance
- Add 'You are here in the workflow' section to validation prompt
- Add 'Your Role' section defining QA Engineer persona
- Standardize 'What comes next' format across all prompts
- Include final code review instruction in validation phase
- Ensure consistent workflow progression messaging
* docs: move refactor spec to archive
* chore: tweak pre-commit
* feat(workflow): integrate repository pattern compliance across spec-driven workflow
This commit implements comprehensive repository pattern compliance guidance across all four SDD workflow prompts, ensuring AI implementations follow established project standards regardless of technology stack.
**Applied research-backed prompt engineering findings:**
- Context Engineering: Grounded pattern discovery in repository documentation and configuration rather than prescribing specific tools
- Progressive Disclosure: Integrated pattern guidance throughout workflow phases rather than treating as separate concern
- Structured Verification: Added repository compliance as validation gates and verification checkpoints following existing research-backed patterns
- Framework-Agnostic Design: Used generic examples (pytest, npm test, cargo test, etc.) to work across any technology stack
**Enhanced Prompts with Pattern Integration:**
1. **generate-spec.md**: Added repository pattern discovery to Context Assessment and 'Repository Standards' section to spec template
2. **generate-task-list-from-spec.md**: Enhanced Current State Assessment to identify repository standards and added pattern compliance to Quality Checklist
3. **manage-tasks.md**: Added repository pattern review to all execution phases with framework-agnostic quality gate integration
4. **validate-spec-implementation.md**: Added repository compliance as validation gate (GATE E) with dedicated coverage matrix table
**Key Improvements Achieved:**
- Repository Standards Discovery: AI now automatically identifies coding standards, testing patterns, quality gates, and workflows from project documentation
- Framework-Agnostic Guidance: Works with any repository (Python, JavaScript, Rust, etc.) without prescribing specific tools
- Seamless Workflow Integration: Pattern compliance woven throughout existing verification mechanisms
- Blocking Verification: Repository standards enforced through same checkpoints that ensure workflow adherence
**Technical Implementation:**
- Enhanced verification checkpoints from 3 to 4 in manage-tasks.md to include pattern compliance
- Added R6 Repository Compliance to validation rubric with dedicated evidence collection
- Fixed consistency issues (table count, validation process references)
- Maintained backward compatibility while adding comprehensive pattern guidance
This enhancement ensures that any AI using these prompts will automatically discover and follow existing repository patterns, addressing the critical gap where implementations previously ignored project conventions and standards.
Research sources: Context engineering best practices (DAIR AI), structured workflow verification (Skywork AI), and the repository's established research-backed prompt patterns.
* fix: address PR review feedback - proof artifact structure and placeholder consistency
- Fix proof artifact structure conflict in archive document to show single markdown files
- Clarify [n] placeholder format to [NN] with explicit zero-padded definition across all prompt files
- Fix grammar: 'single line changes' → 'single-line changes'
- All quality gates pass: pre-commit hooks, tests, and linting
* fix: address additional PR review feedback - placeholder consistency and grammar
- Fix remaining [n] → [NN] placeholder inconsistencies in generate-spec.md and generate-task-list-from-spec.md
- Fix grammar: 'top level' → 'top-level' in archive document
- Fix capitalization: 'markdown' → 'Markdown' as proper noun
- All quality gates pass: pre-commit hooks, tests (79/85%), and linting
* fix: complete [n] → [NN] placeholder consistency across all prompt files
- Fixed remaining [n] placeholders in validate-spec-implementation.md
- Fixed [n] → [NN] in generate-spec.md template header
- Fixed [n] → [NN] in generate-task-list-from-spec.md final instructions
- Fixed [n] → [NN] in manage-tasks.md checklist and protocol sections
- All prompt files now consistently use [NN] for zero-padded two-digit spec numbers
- Quality gates pass: pre-commit hooks, linting, and formatting1 parent 12fc545 commit 72578a2
File tree
6 files changed
+1142
-139
lines changed- docs/archive
- prompts
6 files changed
+1142
-139
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
| 40 | + | |
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
0 commit comments