Skip to content

Commit 72578a2

Browse files
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 formatting
1 parent 12fc545 commit 72578a2

File tree

6 files changed

+1142
-139
lines changed

6 files changed

+1142
-139
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ repos:
3737
hooks:
3838
- id: run-tests
3939
name: Run pytest before push
40-
entry: pytest
40+
entry: uv run pytest
4141
language: system
4242
stages: [pre-push]
4343
pass_filenames: false
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
# Spec-Driven Development Workflow Refactoring
2+
3+
The main goal here is to improve the workflow while maintaining its simplicity. One of the main points of the workflow is to keep it simple and easy to use - that is what differentiates it from other workflows like Taskmaster, GitHub SpecKit, Kiro, etc.
4+
5+
Additional goals:
6+
7+
- The workflow should be accessible to newcomers
8+
- Configuration should be barebones since different tools support different customizations. Any customization of the workflow should be handled within the prompts.
9+
10+
## Best Practices to document
11+
12+
1. Start each workflow command in a fresh conversation to avoid context confusion and overloading
13+
2. Provide clear instructions on what to expect from the AI and what to expect from the user
14+
15+
## Improvements
16+
17+
### Improve prompt clarity and structure based on research findings
18+
19+
Based on prompt engineering best practices for spec-driven development, the workflow should provide more guidance to newcomers without requiring constant reference to the README. Each prompt should guide users through the flow with clear context and next steps.
20+
21+
**Prompt Structure Improvements:**
22+
23+
- Use explicit role-based prompting ("You are a senior developer implementing...")
24+
- Add chain-of-thought reasoning steps to prevent premature task generation
25+
- Include negative constraints to prevent common failure modes
26+
- Add output format templates with concrete examples
27+
- Implement progressive disclosure - reveal complexity gradually
28+
29+
**General pattern for all prompts:**
30+
31+
- Each prompt should start with "You are here in the workflow" context
32+
- End with "What comes next" guidance
33+
- Include progress indicators where applicable
34+
35+
#### Specific Prompt Enhancements
36+
37+
**generate-spec.md:**
38+
39+
- Add scope size validation prompts with the Bad/Good examples
40+
- Add clear guidance on "What happens next" section after spec creation, including when to move to task generation and how to do it
41+
42+
**generate-task-list-from-spec.md:**
43+
44+
- Add explanation of why parent tasks are generated first
45+
- Add guidance on how to evaluate top-level tasks against the spec
46+
- Enhance the "Generate sub tasks" interaction with clearer context
47+
- Add "DO NOT generate sub-tasks until explicitly requested" constraint
48+
- Add clear guidance on "What happens next" section after task generation, including when to move to task implementation and how to do it
49+
50+
**manage-tasks.md:**
51+
52+
- Instruct the AI to present checkpoint options prominently at the start of this prompt
53+
- Add a brief overview of what this prompt does and how it progresses through tasks
54+
- Add clear guidance on "What happens next" section after task implementation, including when to move to validation and how to do it
55+
- Add explicit commit enforcement protocol after each parent task completion to ensure consistent git history. Commits should be created, at minimum, for each parent task completion.
56+
- Add proof artifact generation and validation steps to ensure they are created during task implementation and invocation of the `/manage-tasks` command
57+
58+
**validate-spec-implementation.md:**
59+
60+
- Add brief "When to use this prompt" context (after completing all tasks in a spec)
61+
- Update Auto-Discovery Protocol to look in `./docs/specs/` instead of `/tasks/`
62+
63+
### Scope size recommendation as part of initial spec creation
64+
65+
The intent here is to detect when a spec is too large and should be split into multiple specs. The workflow is currently focused with the expected output of the workflow to be code changes of a relatively small scope.
66+
67+
Similarly, the workflow should attempt to evaluate when a spec is too small and could probably be "vibe-coded" instead of going through the entire workflow.
68+
69+
#### Bad Examples (scope too large)
70+
71+
- Rewriting an entire application architecture or framework
72+
- Migrating a complete database system to a new technology
73+
- Refactoring multiple interconnected modules simultaneously
74+
- Implementing a full authentication system from scratch
75+
- Building a complete microservices architecture
76+
- Creating an entire admin dashboard with all features
77+
- Redesigning the entire UI/UX of an application
78+
- Implementing a comprehensive reporting system with all widgets
79+
80+
#### Bad Examples (scope too small)
81+
82+
- Adding a single console.log statement for debugging
83+
- Changing the color of a button in CSS
84+
- Adding a missing import statement
85+
- Fixing a simple off-by-one error in a loop
86+
- Updating documentation for an existing function
87+
88+
#### Good Examples (scope just right)
89+
90+
- Adding a new CLI flag with validation and help text
91+
- Implementing a single API endpoint with request/response validation
92+
- Refactoring one module while maintaining backward compatibility
93+
- Adding a new component with integration to existing state management
94+
- Creating a single database migration with rollback capability
95+
- Implementing one user story with complete end-to-end flow
96+
97+
> Note: these examples should be incorporated into the documentation for this workflow.
98+
99+
### Optional input for defining when the AI should ask the user for input/continue
100+
101+
This would allow the user to specify how the AI should manage the implementation in `/manage-tasks`. Basically there are three options:
102+
103+
- Ask for input/continue after each sub task (1.1, 1.2, 1.3)
104+
- Ask for input/continue after each task (1.0, 2.0, 3.0)
105+
- Ask for input/continue after each spec
106+
107+
If the user does not specify one of these options up invocation of the `/manage-tasks` command, then the AI should ask the user which option they would like to use for this invocation. The prompt should instruct the AI to use any option that was previously specified by the user in the current conversation.
108+
109+
### Centralize spec/tasks/proofs location
110+
111+
All specs, tasks, and proofs should be stored in `./docs/specs`. Simple directory structure:
112+
113+
```text
114+
./docs/specs/
115+
├── 01-spec-feature-name
116+
├── 01-spec-feature-name.md
117+
├── 01-tasks-feature-name.md
118+
└── 01-proofs/
119+
├── 01-01-proofs.md
120+
├── 01-02-proofs.md
121+
├── 01-03-proofs.md
122+
├── 02-spec-another-feature
123+
├── 02-spec-another-feature.md
124+
├── 02-tasks-another-feature.md
125+
└── 02-proofs/
126+
├── 02-01-proofs.md
127+
├── 02-02-proofs.md
128+
├── 02-03-proofs.md
129+
```
130+
131+
**Key Principles:**
132+
133+
- **Spec-based organization**: Each spec gets its own directory with related files
134+
- **Co-located artifacts**: Proofs are organized by task number within each spec
135+
- **Team-managed lifecycle**: Teams determine when to archive specs, tasks, and proofs as they see fit
136+
- **Clear traceability**: Easy to see which proofs belong to which tasks and specs
137+
- **Consistent naming**: Proof artifacts follow single Markdown file pattern `[spec]-[task]-proofs.md` containing all evidence as Markdown code blocks
138+
139+
### Simplify numbering system
140+
141+
The numbering system should have a single leading zero based on 01, 02, 03, etc. Having 3 leading zeros is not necessary and makes it more difficult to navigate the files.

0 commit comments

Comments
 (0)