SPEC workflow orchestration with EARS format, requirement clarification, and Plan-Run-Sync integration for MoAI-ADK development methodology
Installation
Details
Usage
After installing, this skill will be available to your AI coding assistant.
Verify installation:
npx agent-skills-cli listSkill Instructions
name: moai-workflow-spec description: SPEC workflow orchestration with EARS format, requirement clarification, and Plan-Run-Sync integration for MoAI-ADK development methodology version: 1.0.0 category: workflow tags:
- workflow
- spec
- ears
- requirements
- moai-adk
- planning updated: 2025-12-07 status: active author: MoAI-ADK Team allowed-tools: Read, Write, Edit, Bash, Grep, Glob
SPEC Workflow Management
Quick Reference (30 seconds)
SPEC Workflow Orchestration - Comprehensive specification management using EARS format for systematic requirement definition and Plan-Run-Sync workflow integration.
Core Capabilities:
- EARS Format Specifications: Five requirement patterns for clarity
- Requirement Clarification: Four-step systematic process
- SPEC Document Templates: Standardized structure for consistency
- Plan-Run-Sync Integration: Seamless workflow connection
- Parallel Development: Git Worktree-based SPEC isolation
- Quality Gates: TRUST 5 framework validation
EARS Five Patterns:
Ubiquitous: "μμ€ν
μ νμ [λμ]ν΄μΌ νλ€" - Always perform
Event-Driven: "WHEN [μ΄λ²€νΈ] THEN [λμ]" - Trigger-response
State-Driven: "IF [쑰건] THEN [λμ]" - Conditional behavior
Unwanted: "μμ€ν
μ [λμ]νμ§ μμμΌ νλ€" - Prohibition
Optional: "κ°λ₯νλ©΄ [λμ]μ μ 곡νλ€" - Nice-to-have
When to Use:
- Feature planning and requirement definition
- SPEC document creation and maintenance
- Parallel feature development coordination
- Quality assurance and validation planning
Quick Commands:
# Create new SPEC
/moai:1-plan "user authentication system"
# Create parallel SPECs with Worktrees
/moai:1-plan "login feature" "signup feature" --worktree
# Create SPEC with new branch
/moai:1-plan "payment processing" --branch
# Update existing SPEC
/moai:1-plan SPEC-001 "add OAuth support"
Implementation Guide (5 minutes)
Core Concepts
SPEC-First Development Philosophy:
- EARS format ensures unambiguous requirements
- Requirement clarification prevents scope creep
- Systematic validation through test scenarios
- Integration with TDD workflow for implementation
- Quality gates enforce completion criteria
- Constitution reference ensures project-wide consistency
Constitution Reference (SDD 2025 Standard)
Constitution defines the project DNA that all SPECs must respect. Before creating any SPEC, verify alignment with project constitution defined in .moai/project/tech.md (extended with Constitution section).
Constitution Components:
- Technology Stack: Required versions and frameworks (e.g., Python 3.13+, FastAPI 0.118+)
- Naming Conventions: Variable, function, and file naming standards
- Forbidden Libraries: Libraries explicitly prohibited (with alternatives)
- Architectural Patterns: Layering rules, dependency directions
- Security Standards: Authentication patterns, encryption requirements
- Logging Standards: Log format, structured logging requirements
Constitution Verification Checklist:
- All SPEC technology choices align with Constitution stack versions
- No SPEC introduces forbidden libraries or patterns
- SPEC follows naming conventions defined in Constitution
- SPEC respects architectural boundaries and layering
WHY: Constitution prevents architectural drift and ensures maintainability IMPACT: SPECs aligned with Constitution reduce integration conflicts by 60%
SPEC Workflow Stages:
- User Input Analysis: Parse natural language feature description
- Requirement Clarification: Four-step systematic process
- EARS Pattern Application: Structure requirements using five patterns
- Success Criteria Definition: Establish completion metrics
- Test Scenario Generation: Create verification test cases
- SPEC Document Generation: Produce standardized markdown output
EARS Format Deep Dive
Ubiquitous Requirements - Always Active:
- Pattern: "μμ€ν μ νμ [λμ]ν΄μΌ νλ€"
- Use Case: System-wide quality attributes
- Examples:
- "μμ€ν μ νμ λ‘κ·Έλ₯Ό κΈ°λ‘ν΄μΌ νλ€" (logging)
- "μμ€ν μ νμ μ¬μ©μ μ λ ₯μ κ²μ¦ν΄μΌ νλ€" (input validation)
- "μμ€ν μ νμ μλ¬ λ©μμ§λ₯Ό νμν΄μΌ νλ€" (error handling)
- Test Strategy: Include in all feature test suites as common verification
Event-Driven Requirements - Trigger-Response:
- Pattern: "WHEN [μ΄λ²€νΈ]κ° λ°μνλ©΄ THEN [λμ]νλ€"
- Use Case: User interactions and inter-system communication
- Examples:
- "WHEN μ¬μ©μκ° λ‘κ·ΈμΈ λ²νΌμ ν΄λ¦νλ©΄ THEN μΈμ¦μ μλνλ€"
- "WHEN νμΌμ΄ μ λ‘λλλ©΄ THEN λ°μ΄λ¬μ€ μ€μΊμ μ€ννλ€"
- "WHEN κ²°μ κ° μλ£λλ©΄ THEN μμμ¦μ λ°μ‘νλ€"
- Test Strategy: Event simulation with expected response verification
State-Driven Requirements - Conditional Behavior:
- Pattern: "IF [쑰건]μ΄λ©΄ THEN [λμ]νλ€"
- Use Case: Access control, state machines, conditional business logic
- Examples:
- "IF κ³μ μ΄ νμ± μνμ΄λ©΄ THEN λ‘κ·ΈμΈμ νμ©νλ€"
- "IF μ¬κ³ κ° μμΌλ©΄ THEN μ£Όλ¬Έμ μ²λ¦¬νλ€"
- "IF κ΄λ¦¬μ κΆνμ΄λ©΄ THEN μμ λ₯Ό νμ©νλ€"
- Test Strategy: State setup with conditional behavior verification
Unwanted Requirements - Prohibited Actions:
- Pattern: "μμ€ν μ [λμ]νμ§ μμμΌ νλ€"
- Use Case: Security vulnerabilities, data integrity protection
- Examples:
- "μμ€ν μ νλ¬Έ λΉλ°λ²νΈλ₯Ό μ μ₯νμ§ μμμΌ νλ€"
- "μμ€ν μ μΈμ¦λμ§ μμ μ κ·Όμ νμ©νμ§ μμμΌ νλ€"
- "μμ€ν μ λ―Όκ° μ 보λ₯Ό λ‘κ·Έμ κΈ°λ‘νμ§ μμμΌ νλ€"
- Test Strategy: Negative test cases with prohibited behavior verification
Optional Requirements - Enhancement Features:
- Pattern: "κ°λ₯νλ©΄ [λμ]μ μ 곡νλ€"
- Use Case: MVP scope definition, feature prioritization
- Examples:
- "κ°λ₯νλ©΄ OAuth λ‘κ·ΈμΈμ μ 곡νλ€"
- "κ°λ₯νλ©΄ λ€ν¬ λͺ¨λλ₯Ό μ§μνλ€"
- "κ°λ₯νλ©΄ μ€νλΌμΈ λͺ¨λλ₯Ό μ 곡νλ€"
- Test Strategy: Conditional test execution based on implementation status
Requirement Clarification Process
Step 0: Assumption Analysis (Philosopher Framework) [NEW]
Before defining scope, surface and validate underlying assumptions using AskUserQuestion:
Assumption Categories to Examine:
- Technical Assumptions: Technology capabilities, API availability, performance characteristics
- Business Assumptions: User behavior, market requirements, timeline feasibility
- Team Assumptions: Skill availability, resource allocation, knowledge gaps
- Integration Assumptions: Third-party service reliability, compatibility expectations
Assumption Documentation Format:
- Assumption Statement: Clear description of what is assumed
- Confidence Level: High, Medium, or Low based on evidence
- Evidence Basis: What supports this assumption
- Risk if Wrong: Consequence if assumption proves false
- Validation Method: How to verify before committing significant effort
Example Assumption Analysis:
## Assumptions Declared
| # | Assumption | Confidence | Risk if Wrong |
|---|-----------|------------|---------------|
| 1 | Users have stable internet | Medium | Need offline mode |
| 2 | OAuth provider maintains API compatibility | High | Migration needed |
| 3 | Team familiar with JWT patterns | Low | Training required |
Use AskUserQuestion to verify critical assumptions before proceeding to scope definition.
Step 0.5: Root Cause Analysis [NEW]
For feature requests or problem-driven SPECs, apply Five Whys:
- Surface Problem: What is the user observing or requesting?
- First Why: What immediate need drives this request?
- Second Why: What underlying problem creates that need?
- Third Why: What systemic factor contributes?
- Root Cause: What fundamental issue must the solution address?
Alternative Approaches Section (SPEC Document):
## Approaches Considered
| Approach | Pros | Cons | Selected |
|----------|------|------|----------|
| Option A | ... | ... | Yes |
| Option B | ... | ... | No - higher complexity |
| Option C | ... | ... | No - vendor lock-in |
Step 1: Scope Definition
- Identify supported authentication methods (email/password, OAuth, SSO)
- Define password complexity rules and validation
- Determine login failure handling strategy
- Establish session management approach
Step 2: Constraint Extraction
- Performance Requirements: Response time targets (e.g., 500ms P95)
- Security Requirements: OWASP compliance, encryption standards
- Compatibility Requirements: Supported browsers, mobile devices
- Scalability Requirements: Concurrent user targets
Step 3: Success Criteria Definition
- Test Coverage: Minimum 85% code coverage target
- Response Time: P50 < 50ms, P95 < 200ms, P99 < 500ms
- Functional Completion: All normal scenarios pass verification
- Quality Gates: Zero linter warnings, zero security vulnerabilities
Step 4: Test Scenario Creation
- Normal Cases: Valid inputs with expected outputs
- Error Cases: Invalid inputs with error handling
- Edge Cases: Boundary conditions and corner cases
- Security Cases: Injection attacks, privilege escalation attempts
SPEC Document Structure
Header Section:
# SPEC-001: User Authentication System
Created: 2025-12-07
Status: Planned
Priority: High
Assigned: manager-tdd
Related SPECs: SPEC-002 (User Registration)
Requirements Section (EARS Format):
## Requirements
### Ubiquitous
- μμ€ν
μ νμ λ‘κ·ΈμΈ μλλ₯Ό λ‘κΉ
ν΄μΌ νλ€
- μμ€ν
μ νμ λΉλ°λ²νΈλ₯Ό ν΄μ±νμ¬ μ μ₯ν΄μΌ νλ€
### Event-Driven
- WHEN μ¬μ©μκ° λ‘κ·ΈμΈ λ²νΌμ ν΄λ¦νλ©΄ THEN μ격μ¦λͺ
μ κ²μ¦νλ€
- WHEN λ‘κ·ΈμΈμ΄ μ±κ³΅νλ©΄ THEN JWT ν ν°μ λ°κΈνλ€
### State-Driven
- IF κ³μ μ΄ νμ± μνμ΄λ©΄ THEN λ‘κ·ΈμΈμ νμ©νλ€
- IF λ‘κ·ΈμΈ μ€ν¨ νμκ° 5ν μ΄μμ΄λ©΄ THEN κ³μ μ μΌμ μ κΈνλ€
### Unwanted
- μμ€ν
μ νλ¬Έ λΉλ°λ²νΈλ₯Ό λ‘κ·Έμ κΈ°λ‘νμ§ μμμΌ νλ€
- μμ€ν
μ ν ν° μμ΄ λ³΄νΈλ 리μμ€ μ κ·Όμ νμ©νμ§ μμμΌ νλ€
### Optional
- κ°λ₯νλ©΄ OAuth 2.0 μμ
λ‘κ·ΈμΈμ μ 곡νλ€
- κ°λ₯νλ©΄ μ΄μ€ μΈμ¦(2FA)μ μ§μνλ€
Constraints Section:
## Constraints
Technical Constraints:
- Backend: Node.js 20+, Express.js framework
- Database: PostgreSQL 15+ for user credentials
- Authentication: JWT with RS256 algorithm
- Password Hashing: bcrypt with salt rounds 12
Business Constraints:
- Session timeout: 24 hours for standard users, 1 hour for admin
- Password complexity: Minimum 8 characters, mixed case, numbers, symbols
- Login attempt limit: 5 failures trigger 15-minute account lockout
Success Criteria Section:
## Success Criteria
Functional Criteria:
- All EARS requirements implemented and verified
- Test coverage >= 85% for authentication module
- All test scenarios pass with expected results
Performance Criteria:
- Login response time P95 < 200ms
- Token generation time < 50ms
- Password hashing time < 500ms
Security Criteria:
- OWASP Authentication Cheat Sheet compliance
- No SQL injection vulnerabilities (verified by SQLMap)
- No XSS vulnerabilities (verified by OWASP ZAP)
Test Scenarios Section:
## Test Scenarios
| ID | Category | Scenario | Input | Expected | Status |
|---|---|---|---|---|---|
| TC-1 | Normal | Valid login | email+password | JWT token, 200 | Pending |
| TC-2 | Error | Invalid password | wrong password | 401 error | Pending |
| TC-3 | Error | Nonexistent user | unknown email | 401 error | Pending |
| TC-4 | Edge | Empty password | empty string | 400 error | Pending |
| TC-5 | Security | SQL injection | ' OR '1'='1 | 400 error, blocked | Pending |
| TC-6 | State | Locked account | valid credentials | 403 error | Pending |
| TC-7 | Performance | Concurrent logins | 100 requests/sec | < 200ms P95 | Pending |
Plan-Run-Sync Workflow Integration
PLAN Phase (/moai:1-plan):
- manager-spec agent analyzes user input
- EARS format requirements generation
- Requirement clarification with user interaction
- SPEC document creation in .moai/specs/ directory
- Git branch creation (optional --branch flag)
- Git Worktree setup (optional --worktree flag)
RUN Phase (/moai:2-run):
- manager-tdd agent loads SPEC document
- RED-GREEN-REFACTOR TDD cycle execution
- moai-workflow-testing skill reference for test patterns
- Domain Expert agent delegation (expert-backend, expert-frontend, etc.)
- Quality validation through manager-quality agent
SYNC Phase (/moai:3-sync):
- manager-docs agent synchronizes documentation
- API documentation generation from SPEC
- README and architecture document updates
- CHANGELOG entry creation
- Version control commit with SPEC reference
Parallel Development with Git Worktree
Worktree Concept:
- Independent working directories for multiple branches
- Each SPEC gets isolated development environment
- No branch switching needed for parallel work
- Reduced merge conflicts through feature isolation
Worktree Creation Process:
# Command creates two SPECs with Worktrees
/moai:1-plan "login feature" "signup feature" --worktree
# Result directory structure:
# /project (main branch)
# /project-worktrees/SPEC-001 (login feature branch)
# /project-worktrees/SPEC-002 (signup feature branch)
Worktree Benefits:
- Parallel Development: Multiple features developed simultaneously
- Team Collaboration: Clear ownership boundaries per SPEC
- Dependency Isolation: Different library versions per feature
- Risk Reduction: Unstable code doesn't affect other features
Worktree Cleanup:
# After feature completion and merge
git worktree remove /project-worktrees/SPEC-001
git branch -d SPEC-001-login-feature
Advanced Implementation (10+ minutes)
For advanced patterns including SPEC templates, quality validation, and workflow optimization, see:
- Advanced Patterns: Custom SPEC templates, validation automation
- Reference Guide: SPEC metadata schema, integration examples
- Examples: Real-world SPEC documents, workflow scenarios
Resources
SPEC File Organization
Directory Structure:
.moai/
βββ specs/
β βββ SPEC-001-user-authentication.md
β βββ SPEC-002-user-registration.md
β βββ SPEC-003-password-reset.md
βββ memory/
β βββ last-session-state.json
βββ docs/
βββ api-documentation.md
SPEC Metadata Schema
Required Fields:
- SPEC ID: Sequential number (SPEC-001, SPEC-002, etc.)
- Title: Feature name in English
- Created: ISO 8601 timestamp
- Status: Planned, In Progress, Completed, Blocked
- Priority: High, Medium, Low
- Assigned: Agent responsible for implementation
Optional Fields:
- Related SPECs: Dependencies and related features
- Epic: Parent feature group
- Estimated Effort: Time estimate in hours or story points
- Labels: Tags for categorization
SPEC Lifecycle Management (SDD 2025 Standard)
Lifecycle Level Field (NEW):
SPEC maturity follows three levels based on SDD 2025 best practices:
Level 1 - spec-first:
- Description: SPEC written before implementation, discarded after completion
- Use Case: One-time features, prototypes, experiments
- Maintenance Policy: No maintenance required after implementation
- Recommended For: Quick iterations, exploratory development
Level 2 - spec-anchored:
- Description: SPEC maintained alongside implementation for evolution and maintenance
- Use Case: Core features, API contracts, integration points
- Maintenance Policy: Quarterly review, update when implementation changes
- Recommended For: Production features requiring long-term maintenance
Level 3 - spec-as-source:
- Description: SPEC is the single source of truth; only SPEC is edited by humans
- Use Case: Critical systems, regulated environments, code generation workflows
- Maintenance Policy: SPEC changes trigger implementation regeneration
- Recommended For: High-reliability systems, compliance-required features
SPEC Document Header with Lifecycle:
---
id: SPEC-AUTH-001
version: "1.0.0"
status: "planned"
created: "2025-12-19"
updated: "2025-12-19"
author: "developer"
priority: "high"
lifecycle_level: "spec-anchored"
maintenance_policy: "quarterly_review"
---
Lifecycle Transition Rules:
- spec-first to spec-anchored: When feature becomes production-critical
- spec-anchored to spec-as-source: When compliance or regeneration workflow required
- Downgrade allowed but requires explicit justification in SPEC history
Spec Drift Prevention:
- For spec-anchored and spec-as-source levels, /moai:3-sync validates SPEC-implementation alignment
- Drift detection triggers warning before documentation sync
- Manual override requires explicit acknowledgment
Quality Metrics
SPEC Quality Indicators:
- Requirement Clarity: All EARS patterns used appropriately
- Test Coverage: All requirements have corresponding test scenarios
- Constraint Completeness: Technical and business constraints defined
- Success Criteria Measurability: Quantifiable completion metrics
Validation Checklist:
- All EARS requirements testable
- No ambiguous language ("should", "might", "usually")
- All error cases documented
- Performance targets quantified
- Security requirements OWASP-compliant
Works Well With
- moai-foundation-core: SPEC-First TDD methodology and TRUST 5 framework
- moai-workflow-testing: TDD implementation and test automation
- moai-workflow-project: Project initialization and configuration
- moai-worktree: Git Worktree management for parallel development
- manager-spec: SPEC creation and requirement analysis agent
- manager-tdd: TDD implementation based on SPEC requirements
- manager-quality: TRUST 5 quality validation and gate enforcement
Integration Examples
Sequential Workflow:
# Step 1: Plan - Create SPEC
/moai:1-plan "user authentication system"
# Step 2: Run - Implement with TDD
/moai:2-run SPEC-001
# Step 3: Sync - Update documentation
/moai:3-sync SPEC-001
Parallel Workflow:
# Create multiple SPECs with Worktrees
/moai:1-plan "backend API" "frontend UI" "database schema" --worktree
# Parallel implementation in separate sessions
# Session 1: /moai:2-run SPEC-001 (backend API)
# Session 2: /moai:2-run SPEC-002 (frontend UI)
# Session 3: /moai:2-run SPEC-003 (database schema)
Token Management
Session Strategy:
- PLAN phase: Requirements analysis and SPEC generation (~30% tokens)
- Clear context: /clear command after SPEC document saved
- RUN phase: Fresh session for TDD implementation (~60% tokens)
- SYNC phase: Documentation update in final session (~10% tokens)
Context Optimization:
- SPEC document persists in .moai/specs/ directory
- Session memory in .moai/memory/ for cross-session context
- Minimal context transfer through SPEC ID reference
- Agent delegation reduces token overhead
Version: 1.2.0 (SDD 2025 Standard Integration) Last Updated: 2025-12-19 Integration Status: Complete - Full Plan-Run-Sync workflow with SDD 2025 features (Constitution, Tasks Decomposition, Lifecycle Management)
More by junseokandylee
View allJava 21 LTS development specialist covering Spring Boot 3.3, virtual threads, pattern matching, and enterprise patterns. Use when building enterprise applications, microservices, or Spring projects.
Clerk modern authentication specialist covering WebAuthn, passkeys, passwordless, and beautiful UI components. Use when implementing modern auth with great UX.
Ruby 3.3+ development specialist covering Rails 7.2, ActiveRecord, Hotwire/Turbo, and modern Ruby patterns. Use when developing Ruby APIs, web applications, or Rails projects.
Enterprise context and session management with token budget optimization and state persistence
