mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-11 02:33:51 +08:00
feat: Simplify agent architecture with test-fix workflow (v3.2.0)
Major architectural improvements: - Simplify from 3 agents to 2 core agents - Adopt "Tests Are the Review" philosophy - Enhance test-gen as 4-phase orchestrator - Simplify review.md following update-memory pattern Agent Changes: - NEW: @test-fix-agent - Execute tests, diagnose failures, fix code - ENHANCED: @code-developer - Now writes implementation + tests together - REMOVED: @code-review-agent, @code-review-test-agent Task Type Updates: - "test" → "test-gen" (generate tests) - NEW: "test-fix" (execute and fix tests) Workflow Improvements: - test-gen.md: 4-phase orchestrator (context-gather → concept-enhanced → task-generate → execute) - review.md: Simplified to optional specialized reviews (security, architecture, quality, action-items) - All 16 files updated with new agent references See CHANGELOG.md for full details. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -185,9 +185,9 @@ TodoWrite({
|
||||
activeForm: "Executing IMPL-1.2: Implement auth logic"
|
||||
},
|
||||
{
|
||||
content: "Execute IMPL-2: Review implementations [code-review-agent]",
|
||||
content: "Execute TEST-FIX-1: Validate implementation tests [test-fix-agent]",
|
||||
status: "pending",
|
||||
activeForm: "Executing IMPL-2: Review implementations"
|
||||
activeForm: "Executing TEST-FIX-1: Validate implementation tests"
|
||||
}
|
||||
]
|
||||
});
|
||||
@@ -384,8 +384,8 @@ Task(subagent_type="{meta.agent}",
|
||||
"title": "Task title",
|
||||
"status": "pending|active|completed|blocked",
|
||||
"meta": {
|
||||
"type": "feature|bugfix|refactor|test|docs",
|
||||
"agent": "@code-developer|@planning-agent|@code-review-test-agent"
|
||||
"type": "feature|bugfix|refactor|test-gen|test-fix|docs",
|
||||
"agent": "@code-developer|@test-fix-agent|@general-purpose"
|
||||
},
|
||||
"context": {
|
||||
"requirements": ["req1", "req2"],
|
||||
@@ -451,8 +451,9 @@ Task(subagent_type="{meta.agent}",
|
||||
meta.agent specified → Use specified agent
|
||||
meta.agent missing → Infer from meta.type:
|
||||
- "feature" → @code-developer
|
||||
- "test" → @code-review-test-agent
|
||||
- "review" → @code-review-agent
|
||||
- "test-gen" → @code-developer
|
||||
- "test-fix" → @test-fix-agent
|
||||
- "review" → @general-purpose
|
||||
- "docs" → @doc-generator
|
||||
```
|
||||
|
||||
|
||||
@@ -1,85 +1,272 @@
|
||||
---
|
||||
name: review
|
||||
description: Execute review phase for quality validation
|
||||
usage: /workflow:review
|
||||
argument-hint: none
|
||||
description: Optional specialized review (security, architecture, docs) for completed implementation
|
||||
usage: /workflow:review [--type=<type>] [session-id]
|
||||
argument-hint: "[--type=security|architecture|action-items|quality] [session-id]"
|
||||
examples:
|
||||
- /workflow:review
|
||||
- /workflow:review # Quality review of active session
|
||||
- /workflow:review --type=security # Security audit of active session
|
||||
- /workflow:review --type=architecture WFS-user-auth # Architecture review of specific session
|
||||
- /workflow:review --type=action-items # Pre-deployment verification
|
||||
---
|
||||
|
||||
# Workflow Review Command (/workflow:review)
|
||||
### 🚀 Command Overview: `/workflow:review`
|
||||
|
||||
## Overview
|
||||
Final phase for quality validation, testing, and completion.
|
||||
**Optional specialized review** for completed implementations. In the standard workflow, **passing tests = approved code**. Use this command only when specialized review is required (security, architecture, compliance, docs).
|
||||
|
||||
## Core Principles
|
||||
**Session Management:** @~/.claude/workflows/workflow-architecture.md
|
||||
## Philosophy: "Tests Are the Review"
|
||||
|
||||
## Review Process
|
||||
- ✅ **Default**: All tests pass → Code approved
|
||||
- 🔍 **Optional**: Specialized reviews for:
|
||||
- 🔒 Security audits (vulnerabilities, auth/authz)
|
||||
- 🏗️ Architecture compliance (patterns, technical debt)
|
||||
- 📋 Action items verification (requirements met, acceptance criteria)
|
||||
|
||||
1. **Validation Checks**
|
||||
- All tasks completed
|
||||
- Tests passing
|
||||
- Code quality metrics
|
||||
- Documentation complete
|
||||
## Review Types
|
||||
|
||||
2. **Generate Review Report**
|
||||
| Type | Focus | Use Case |
|
||||
|------|-------|----------|
|
||||
| `quality` | Code quality, best practices, maintainability | Default general review |
|
||||
| `security` | Security vulnerabilities, data handling, access control | Security audits |
|
||||
| `architecture` | Architectural patterns, technical debt, design decisions | Architecture compliance |
|
||||
| `action-items` | Requirements met, acceptance criteria verified, action items completed | Pre-deployment verification |
|
||||
|
||||
**Notes**:
|
||||
- For documentation generation, use `/workflow:tools:docs`
|
||||
- For CLAUDE.md updates, use `/update-memory-related`
|
||||
|
||||
## Execution Template
|
||||
|
||||
```bash
|
||||
#!/bin/bash
|
||||
# Optional specialized review for completed implementation
|
||||
|
||||
# Step 1: Session ID resolution
|
||||
if [ -n "$SESSION_ARG" ]; then
|
||||
sessionId="$SESSION_ARG"
|
||||
else
|
||||
sessionId=$(find .workflow/ -name '.active-*' | head -1 | sed 's/.*active-//')
|
||||
fi
|
||||
|
||||
# Step 2: Validation
|
||||
if [ ! -d ".workflow/${sessionId}" ]; then
|
||||
echo "❌ Session ${sessionId} not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check for completed tasks
|
||||
if [ ! -d ".workflow/${sessionId}/.summaries" ] || [ -z "$(ls .workflow/${sessionId}/.summaries/IMPL-*.md 2>/dev/null)" ]; then
|
||||
echo "❌ No completed implementation found. Complete implementation first"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Step 3: Determine review type (default: quality)
|
||||
review_type="${TYPE_ARG:-quality}"
|
||||
|
||||
# Redirect docs review to specialized command
|
||||
if [ "$review_type" = "docs" ]; then
|
||||
echo "💡 For documentation generation, please use:"
|
||||
echo " /workflow:tools:docs"
|
||||
echo ""
|
||||
echo "The docs command provides:"
|
||||
echo " - Hierarchical architecture documentation"
|
||||
echo " - API documentation generation"
|
||||
echo " - Documentation structure analysis"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Step 4: Analysis handover → Model takes control
|
||||
# BASH_EXECUTION_STOPS → MODEL_ANALYSIS_BEGINS
|
||||
```
|
||||
|
||||
### 🧠 Model Analysis Phase
|
||||
|
||||
After bash validation, the model takes control to:
|
||||
|
||||
1. **Load Context**: Read completed task summaries and changed files
|
||||
```bash
|
||||
# Load implementation summaries
|
||||
cat .workflow/${sessionId}/.summaries/IMPL-*.md
|
||||
|
||||
# Load test results (if available)
|
||||
cat .workflow/${sessionId}/.summaries/TEST-FIX-*.md 2>/dev/null
|
||||
|
||||
# Get changed files
|
||||
git log --since="$(cat .workflow/${sessionId}/workflow-session.json | jq -r .created_at)" --name-only --pretty=format: | sort -u
|
||||
```
|
||||
|
||||
2. **Perform Specialized Review**: Based on `review_type`
|
||||
|
||||
**Security Review** (`--type=security`):
|
||||
- Use MCP code search for security patterns:
|
||||
```bash
|
||||
mcp__code-index__search_code_advanced(pattern="password|token|secret|auth", file_pattern="*.{ts,js,py}")
|
||||
mcp__code-index__search_code_advanced(pattern="eval|exec|innerHTML|dangerouslySetInnerHTML", file_pattern="*.{ts,js,tsx}")
|
||||
```
|
||||
- Use Gemini for security analysis:
|
||||
```bash
|
||||
cd .workflow/${sessionId} && ~/.claude/scripts/gemini-wrapper -p "
|
||||
PURPOSE: Security audit of completed implementation
|
||||
TASK: Review code for security vulnerabilities, insecure patterns, auth/authz issues
|
||||
CONTEXT: @{.summaries/IMPL-*.md,../..,../../CLAUDE.md}
|
||||
EXPECTED: Security findings report with severity levels
|
||||
RULES: Focus on OWASP Top 10, authentication, authorization, data validation, injection risks
|
||||
" --approval-mode yolo
|
||||
```
|
||||
|
||||
**Architecture Review** (`--type=architecture`):
|
||||
- Use Qwen for architecture analysis:
|
||||
```bash
|
||||
cd .workflow/${sessionId} && ~/.claude/scripts/qwen-wrapper -p "
|
||||
PURPOSE: Architecture compliance review
|
||||
TASK: Evaluate adherence to architectural patterns, identify technical debt, review design decisions
|
||||
CONTEXT: @{.summaries/IMPL-*.md,../..,../../CLAUDE.md}
|
||||
EXPECTED: Architecture assessment with recommendations
|
||||
RULES: Check for patterns, separation of concerns, modularity, scalability
|
||||
" --approval-mode yolo
|
||||
```
|
||||
|
||||
**Quality Review** (`--type=quality`):
|
||||
- Use Gemini for code quality:
|
||||
```bash
|
||||
cd .workflow/${sessionId} && ~/.claude/scripts/gemini-wrapper -p "
|
||||
PURPOSE: Code quality and best practices review
|
||||
TASK: Assess code readability, maintainability, adherence to best practices
|
||||
CONTEXT: @{.summaries/IMPL-*.md,../..,../../CLAUDE.md}
|
||||
EXPECTED: Quality assessment with improvement suggestions
|
||||
RULES: Check for code smells, duplication, complexity, naming conventions
|
||||
" --approval-mode yolo
|
||||
```
|
||||
|
||||
**Action Items Review** (`--type=action-items`):
|
||||
- Verify all requirements and acceptance criteria met:
|
||||
```bash
|
||||
# Load task requirements and acceptance criteria
|
||||
find .workflow/${sessionId}/.task -name "IMPL-*.json" -exec jq -r '
|
||||
"Task: " + .id + "\n" +
|
||||
"Requirements: " + (.context.requirements | join(", ")) + "\n" +
|
||||
"Acceptance: " + (.context.acceptance | join(", "))
|
||||
' {} \;
|
||||
|
||||
# Check implementation summaries against requirements
|
||||
cd .workflow/${sessionId} && ~/.claude/scripts/gemini-wrapper -p "
|
||||
PURPOSE: Verify all requirements and acceptance criteria are met
|
||||
TASK: Cross-check implementation summaries against original requirements
|
||||
CONTEXT: @{.task/IMPL-*.json,.summaries/IMPL-*.md,../..,../../CLAUDE.md}
|
||||
EXPECTED:
|
||||
- Requirements coverage matrix
|
||||
- Acceptance criteria verification
|
||||
- Missing/incomplete action items
|
||||
- Pre-deployment readiness assessment
|
||||
RULES:
|
||||
- Check each requirement has corresponding implementation
|
||||
- Verify all acceptance criteria are met
|
||||
- Flag any incomplete or missing action items
|
||||
- Assess deployment readiness
|
||||
" --approval-mode yolo
|
||||
```
|
||||
|
||||
|
||||
3. **Generate Review Report**: Create structured report
|
||||
```markdown
|
||||
# Review Report
|
||||
|
||||
## Task Completion
|
||||
- Total: 10
|
||||
- Completed: 10
|
||||
- Success Rate: 100%
|
||||
|
||||
## Quality Metrics
|
||||
- Test Coverage: 85%
|
||||
- Code Quality: A
|
||||
- Documentation: Complete
|
||||
|
||||
## Issues Found
|
||||
- Minor: 2
|
||||
- Major: 0
|
||||
- Critical: 0
|
||||
# Review Report: ${review_type}
|
||||
|
||||
**Session**: ${sessionId}
|
||||
**Date**: $(date)
|
||||
**Type**: ${review_type}
|
||||
|
||||
## Summary
|
||||
- Tasks Reviewed: [count IMPL tasks]
|
||||
- Files Changed: [count files]
|
||||
- Severity: [High/Medium/Low]
|
||||
|
||||
## Findings
|
||||
|
||||
### Critical Issues
|
||||
- [Issue 1 with file:line reference]
|
||||
- [Issue 2 with file:line reference]
|
||||
|
||||
### Recommendations
|
||||
- [Recommendation 1]
|
||||
- [Recommendation 2]
|
||||
|
||||
### Positive Observations
|
||||
- [Good pattern observed]
|
||||
|
||||
## Action Items
|
||||
- [ ] [Action 1]
|
||||
- [ ] [Action 2]
|
||||
```
|
||||
|
||||
3. **Update Session**
|
||||
```json
|
||||
{
|
||||
"current_phase": "REVIEW",
|
||||
"phases": {
|
||||
"REVIEW": {
|
||||
"status": "completed",
|
||||
"output": "REVIEW.md",
|
||||
"test_results": {
|
||||
"passed": 45,
|
||||
"failed": 0,
|
||||
"coverage": 85
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
4. **Output Files**:
|
||||
```bash
|
||||
# Save review report
|
||||
Write(.workflow/${sessionId}/REVIEW-${review_type}.md)
|
||||
|
||||
# Update session metadata
|
||||
# (optional) Update workflow-session.json with review status
|
||||
```
|
||||
|
||||
## Auto-fix (Default)
|
||||
Auto-fix is enabled by default:
|
||||
- Automatically fixes minor issues
|
||||
- Runs formatters and linters
|
||||
- Updates documentation
|
||||
- Re-runs tests
|
||||
5. **Optional: Update Memory** (if docs review or significant findings):
|
||||
```bash
|
||||
# If architecture or quality issues found, suggest memory update
|
||||
if [ "$review_type" = "architecture" ] || [ "$review_type" = "quality" ]; then
|
||||
echo "💡 Consider updating project documentation:"
|
||||
echo " /update-memory-related"
|
||||
fi
|
||||
```
|
||||
|
||||
## Completion Criteria
|
||||
- All tasks marked complete
|
||||
- Tests passing (configurable threshold)
|
||||
- No critical issues
|
||||
- Documentation updated
|
||||
## Usage Examples
|
||||
|
||||
## Output Files
|
||||
- `REVIEW.md` - Review report
|
||||
- `workflow-session.json` - Updated with results
|
||||
- `test-results.json` - Detailed test output
|
||||
```bash
|
||||
# General quality review after implementation
|
||||
/workflow:review
|
||||
|
||||
# Security audit before deployment
|
||||
/workflow:review --type=security
|
||||
|
||||
# Architecture review for specific session
|
||||
/workflow:review --type=architecture WFS-payment-integration
|
||||
|
||||
# Documentation review
|
||||
/workflow:review --type=docs
|
||||
```
|
||||
|
||||
## ✨ Features
|
||||
|
||||
- **Simple Validation**: Check session exists and has completed tasks
|
||||
- **No Complex Orchestration**: Direct analysis, no multi-phase pipeline
|
||||
- **Specialized Reviews**: Different prompts and tools for different review types
|
||||
- **MCP Integration**: Fast code search for security and architecture patterns
|
||||
- **CLI Tool Integration**: Gemini for analysis, Qwen for architecture
|
||||
- **Structured Output**: Markdown reports with severity levels and action items
|
||||
- **Optional Memory Update**: Suggests documentation updates for significant findings
|
||||
|
||||
## Integration with Workflow
|
||||
|
||||
```
|
||||
Standard Workflow:
|
||||
plan → execute → test-gen → execute ✅
|
||||
|
||||
Optional Review (when needed):
|
||||
plan → execute → test-gen → execute → review (security/architecture/docs)
|
||||
```
|
||||
|
||||
**When to Use**:
|
||||
- Before production deployment (security review + action-items review)
|
||||
- After major feature (architecture review)
|
||||
- Before code freeze (quality review)
|
||||
- Pre-deployment verification (action-items review)
|
||||
|
||||
**When NOT to Use**:
|
||||
- Regular development (tests are sufficient)
|
||||
- Simple bug fixes (test-fix-agent handles it)
|
||||
- Minor changes (update-memory-related is enough)
|
||||
|
||||
## Related Commands
|
||||
- `/workflow:execute` - Must complete first
|
||||
- `/task:status` - Check task completion
|
||||
- `/workflow:status` - View overall status
|
||||
|
||||
- `/workflow:execute` - Must complete implementation first
|
||||
- `/workflow:test-gen` - Primary quality gate (tests)
|
||||
- `/workflow:tools:docs` - Generate hierarchical documentation (use instead of `--type=docs`)
|
||||
- `/update-memory-related` - Update CLAUDE.md docs after architecture findings
|
||||
- `/workflow:status` - Check session status
|
||||
|
||||
@@ -1,145 +1,365 @@
|
||||
---
|
||||
name: test-gen
|
||||
description: Generate comprehensive test workflow based on completed implementation tasks
|
||||
description: Orchestrate test-fix workflow by analyzing implementation and generating TEST-FIX tasks
|
||||
usage: /workflow:test-gen [session-id]
|
||||
argument-hint: "WFS-session-id"
|
||||
argument-hint: "[session-id]"
|
||||
examples:
|
||||
- /workflow:test-gen
|
||||
- /workflow:test-gen WFS-user-auth
|
||||
allowed-tools: SlashCommand(*), TodoWrite(*), Read(*), Bash(*)
|
||||
---
|
||||
|
||||
# Workflow Test Generation Command
|
||||
# Workflow Test Generation Command (/workflow:test-gen)
|
||||
|
||||
## Overview
|
||||
Analyzes completed implementation sessions and generates comprehensive test requirements, then calls workflow:plan to create test workflow.
|
||||
## Coordinator Role
|
||||
|
||||
## Usage
|
||||
```bash
|
||||
/workflow:test-gen # Auto-detect active session
|
||||
/workflow:test-gen WFS-session-id # Analyze specific session
|
||||
**This command is a pure orchestrator**: Analyze completed implementation session, generate test-fix workflow through standardized tool commands, and trigger automated test validation.
|
||||
|
||||
**Execution Flow**:
|
||||
1. Initialize TodoWrite → Execute Phase 1 → Parse output → Update TodoWrite
|
||||
2. Execute Phase 2 with Phase 1 data → Parse output → Update TodoWrite
|
||||
3. Execute Phase 3 with Phase 2 data → Parse output → Update TodoWrite
|
||||
4. Execute Phase 4 with Phase 3 validation → Update TodoWrite → Return summary
|
||||
|
||||
## Core Rules
|
||||
|
||||
1. **Start Immediately**: First action is TodoWrite initialization, second action is Phase 1 session discovery
|
||||
2. **No Preliminary Analysis**: Do not read files or analyze before Phase 1
|
||||
3. **Parse Every Output**: Extract required data from each phase for next phase
|
||||
4. **Sequential Execution**: Each phase depends on previous phase's output
|
||||
5. **Complete All Phases**: Do not return to user until Phase 4 completes
|
||||
6. **Track Progress**: Update TodoWrite after every phase completion
|
||||
7. **Use Standard Tools**: Follow plan.md pattern using context-gather, concept-enhanced, task-generate
|
||||
|
||||
## 4-Phase Execution
|
||||
|
||||
### Phase 1: Session Discovery & Context Gathering
|
||||
**Command**: `SlashCommand(command="/workflow:tools:context-gather --session [sessionId] \"TEST-FIX: Validate implementation for [sessionId]\"")`
|
||||
|
||||
**Session ID Resolution**:
|
||||
- If argument provided → Use directly as `sessionId`
|
||||
- If no argument → Auto-detect from `.workflow/.active-*` marker
|
||||
- Format: `WFS-[session-name]`
|
||||
|
||||
**Task Description Structure**:
|
||||
```
|
||||
GOAL: Execute and validate all tests for completed implementation
|
||||
SCOPE: Test execution, failure diagnosis, code fixing
|
||||
CONTEXT: Implementation session [sessionId] with completed IMPL tasks
|
||||
```
|
||||
|
||||
## Dynamic Session ID Resolution
|
||||
**Parse Output**:
|
||||
- Extract: context package path (store as `contextPath`)
|
||||
- Typical pattern: `.workflow/[sessionId]/.process/context-package-test.json`
|
||||
|
||||
The `${SESSION_ID}` variable is dynamically resolved based on:
|
||||
**Validation**:
|
||||
- Session directory `.workflow/[sessionId]/` exists
|
||||
- Session has completed IMPL tasks (check .summaries/IMPL-*-summary.md)
|
||||
- Context package created successfully
|
||||
|
||||
1. **Command argument**: If session-id provided as argument, use it directly
|
||||
2. **Auto-detection**: If no argument, detect from active session markers
|
||||
3. **Format**: Always in format `WFS-session-name`
|
||||
**TodoWrite**: Mark phase 1 completed, phase 2 in_progress
|
||||
|
||||
```bash
|
||||
# Example resolution logic:
|
||||
# If argument provided: SESSION_ID = "WFS-user-auth"
|
||||
# If no argument: SESSION_ID = $(find .workflow/ -name '.active-*' | head -1 | sed 's/.*active-//')
|
||||
---
|
||||
|
||||
### Phase 2: Implementation Analysis
|
||||
**Command**: `SlashCommand(command="/workflow:tools:concept-enhanced --session [sessionId] --context [contextPath]")`
|
||||
|
||||
**Input**: `sessionId` from Phase 1, `contextPath` from Phase 1
|
||||
|
||||
**Expected Analysis**:
|
||||
- Review completed implementation summaries
|
||||
- Identify test files and coverage gaps
|
||||
- Assess test execution strategy
|
||||
- Determine failure diagnosis approach
|
||||
|
||||
**Parse Output**:
|
||||
- Verify `.workflow/[sessionId]/.process/ANALYSIS_RESULTS.md` created
|
||||
- Extract test execution recommendations
|
||||
- Identify critical test areas
|
||||
|
||||
**Validation**:
|
||||
- File `.workflow/[sessionId]/.process/ANALYSIS_RESULTS.md` exists
|
||||
- Contains test strategy and execution plan
|
||||
- Lists focus test paths and acceptance criteria
|
||||
|
||||
**TodoWrite**: Mark phase 2 completed, phase 3 in_progress
|
||||
|
||||
---
|
||||
|
||||
### Phase 3: TEST-FIX Task Generation
|
||||
**Command**: `SlashCommand(command="/workflow:tools:task-generate --session [sessionId]")`
|
||||
|
||||
**Input**: `sessionId` from Phase 1
|
||||
|
||||
**Expected Behavior**:
|
||||
- Parse ANALYSIS_RESULTS.md for test requirements
|
||||
- Generate TEST-FIX-001.json with:
|
||||
- `meta.type: "test-fix"`
|
||||
- `meta.agent: "@test-fix-agent"`
|
||||
- `context.requirements`: Test execution requirements
|
||||
- `context.focus_paths`: Test files and source files
|
||||
- `context.acceptance`: All tests pass criteria
|
||||
- `flow_control.pre_analysis`: Load implementation summaries
|
||||
- `flow_control.implementation_approach`: Test execution strategy
|
||||
|
||||
**Parse Output**:
|
||||
- Verify `.workflow/[sessionId]/.task/TEST-FIX-001.json` exists
|
||||
- Verify `.workflow/[sessionId]/IMPL_PLAN.md` updated
|
||||
- Verify `.workflow/[sessionId]/TODO_LIST.md` updated
|
||||
|
||||
**Validation**:
|
||||
- Task JSON has correct structure (id, meta.type="test-fix", meta.agent="@test-fix-agent")
|
||||
- IMPL_PLAN.md contains test-fix strategy
|
||||
- TODO_LIST.md shows TEST-FIX-001 task
|
||||
|
||||
**TodoWrite**: Mark phase 3 completed, phase 4 in_progress
|
||||
|
||||
---
|
||||
|
||||
### Phase 4: Execute Test-Fix Workflow
|
||||
**Command**: `SlashCommand(command="/workflow:execute --session [sessionId]")`
|
||||
|
||||
**Input**: `sessionId` from Phase 1
|
||||
|
||||
**Expected Behavior**:
|
||||
- Workflow executor detects TEST-FIX-001 task
|
||||
- Assigns to @test-fix-agent
|
||||
- Agent executes tests using flow_control.pre_analysis
|
||||
- If failures: diagnoses and fixes code
|
||||
- Re-runs tests until all pass
|
||||
- Generates completion summary
|
||||
|
||||
**Validation**:
|
||||
- Workflow execution started successfully
|
||||
- TEST-FIX-001 task status updated to "active" or "completed"
|
||||
|
||||
**TodoWrite**: Mark phase 4 completed
|
||||
|
||||
**Return to User**:
|
||||
```
|
||||
Test-fix workflow initiated for session: [sessionId]
|
||||
- TEST-FIX-001 created and executing
|
||||
- @test-fix-agent validating implementation
|
||||
- Progress: /workflow:status [sessionId]
|
||||
```
|
||||
|
||||
## Implementation Flow
|
||||
---
|
||||
|
||||
### Step 1: Identify Target Session
|
||||
```bash
|
||||
# Auto-detect active session (if no session-id provided)
|
||||
find .workflow/ -name '.active-*' | head -1 | sed 's/.*active-//'
|
||||
## TodoWrite Pattern
|
||||
|
||||
# Use provided session-id or detected session-id
|
||||
# SESSION_ID = provided argument OR detected active session
|
||||
```javascript
|
||||
// Initialize (before Phase 1)
|
||||
TodoWrite({todos: [
|
||||
{"content": "Execute context gathering for test-fix", "status": "in_progress", "activeForm": "Executing context gathering for test-fix"},
|
||||
{"content": "Execute implementation analysis", "status": "pending", "activeForm": "Executing implementation analysis"},
|
||||
{"content": "Execute TEST-FIX task generation", "status": "pending", "activeForm": "Executing TEST-FIX task generation"},
|
||||
{"content": "Execute test-fix workflow", "status": "pending", "activeForm": "Executing test-fix workflow"}
|
||||
]})
|
||||
|
||||
// After Phase 1
|
||||
TodoWrite({todos: [
|
||||
{"content": "Execute context gathering for test-fix", "status": "completed", "activeForm": "Executing context gathering for test-fix"},
|
||||
{"content": "Execute implementation analysis", "status": "in_progress", "activeForm": "Executing implementation analysis"},
|
||||
{"content": "Execute TEST-FIX task generation", "status": "pending", "activeForm": "Executing TEST-FIX task generation"},
|
||||
{"content": "Execute test-fix workflow", "status": "pending", "activeForm": "Executing test-fix workflow"}
|
||||
]})
|
||||
|
||||
// Continue pattern for Phase 2, 3, 4...
|
||||
```
|
||||
|
||||
### Step 2: Get Session Start Time
|
||||
```bash
|
||||
cat .workflow/WFS-${SESSION_ID}/workflow-session.json | jq -r .created_at
|
||||
## Data Flow
|
||||
|
||||
```
|
||||
Session ID (from argument or auto-detect)
|
||||
↓
|
||||
Phase 1: context-gather --session sessionId "test-fix description"
|
||||
↓ Output: contextPath (context-package-test.json)
|
||||
↓
|
||||
Phase 2: concept-enhanced --session sessionId --context contextPath
|
||||
↓ Input: sessionId + contextPath
|
||||
↓ Output: ANALYSIS_RESULTS.md (test execution strategy)
|
||||
↓
|
||||
Phase 3: task-generate --session sessionId
|
||||
↓ Input: sessionId + ANALYSIS_RESULTS.md
|
||||
↓ Output: TEST-FIX-001.json, IMPL_PLAN.md, TODO_LIST.md
|
||||
↓
|
||||
Phase 4: execute --session sessionId
|
||||
↓ Input: sessionId + TEST-FIX-001.json
|
||||
↓ Output: Test execution and fixing
|
||||
↓
|
||||
Return summary to user
|
||||
```
|
||||
|
||||
### Step 3: Git Change Analysis (using session start time)
|
||||
```bash
|
||||
git log --since="$(cat .workflow/WFS-${SESSION_ID}/workflow-session.json | jq -r .created_at)" --name-only --pretty=format: | sort -u | grep -v '^$'
|
||||
## Context Gathering Customization
|
||||
|
||||
context-gather will analyze:
|
||||
- Completed IMPL task summaries
|
||||
- Git changes since session start
|
||||
- Test files in focus_paths
|
||||
- Implementation files to be tested
|
||||
- Test framework configuration
|
||||
|
||||
## Analysis Focus
|
||||
|
||||
concept-enhanced will analyze:
|
||||
- Test coverage gaps
|
||||
- Test execution strategy (unit, integration, e2e)
|
||||
- Failure diagnosis approaches
|
||||
- Code fixing patterns
|
||||
- Test framework best practices
|
||||
|
||||
## Task Generation Output
|
||||
|
||||
task-generate creates TEST-FIX-001.json with:
|
||||
|
||||
```json
|
||||
{
|
||||
"id": "TEST-FIX-001",
|
||||
"title": "Execute and validate tests for [sessionId]",
|
||||
"status": "pending",
|
||||
"meta": {
|
||||
"type": "test-fix",
|
||||
"agent": "@test-fix-agent"
|
||||
},
|
||||
"context": {
|
||||
"requirements": [
|
||||
"Execute complete test suite for all implemented modules",
|
||||
"Diagnose and fix any test failures",
|
||||
"Ensure all tests pass before completion"
|
||||
],
|
||||
"focus_paths": ["src/**/*.test.ts", "src/**/implementation.ts"],
|
||||
"acceptance": [
|
||||
"All tests pass successfully",
|
||||
"No test failures or errors",
|
||||
"Code is approved and ready for deployment"
|
||||
],
|
||||
"depends_on": [],
|
||||
"artifacts": []
|
||||
},
|
||||
"flow_control": {
|
||||
"pre_analysis": [
|
||||
{
|
||||
"step": "load_implementation_summaries",
|
||||
"action": "Load completed IMPL task summaries",
|
||||
"commands": [
|
||||
"bash(find .workflow/[sessionId]/.summaries/ -name 'IMPL-*-summary.md' 2>/dev/null)",
|
||||
"Read(.workflow/[sessionId]/.summaries/IMPL-001-summary.md)"
|
||||
],
|
||||
"output_to": "implementation_context",
|
||||
"on_error": "skip_optional"
|
||||
},
|
||||
{
|
||||
"step": "analyze_test_files",
|
||||
"action": "Identify test files and coverage",
|
||||
"commands": [
|
||||
"mcp__code-index__find_files(pattern=\"*.test.*\")",
|
||||
"mcp__code-index__search_code_advanced(pattern=\"test|describe|it\", file_pattern=\"*.test.*\")"
|
||||
],
|
||||
"output_to": "test_inventory",
|
||||
"on_error": "fail"
|
||||
}
|
||||
],
|
||||
"implementation_approach": {
|
||||
"task_description": "Execute tests and fix failures until all pass",
|
||||
"modification_points": [
|
||||
"Run test suite using detected framework",
|
||||
"Parse test output to identify failures",
|
||||
"Diagnose root cause of failures",
|
||||
"Modify source code to fix issues",
|
||||
"Re-run tests to verify fixes"
|
||||
],
|
||||
"logic_flow": [
|
||||
"Load implementation context",
|
||||
"Identify test framework and configuration",
|
||||
"Execute complete test suite",
|
||||
"If failures: analyze error messages",
|
||||
"Fix source code based on diagnosis",
|
||||
"Re-run tests",
|
||||
"Repeat until all tests pass"
|
||||
]
|
||||
},
|
||||
"target_files": ["src/**/*.test.ts", "src/**/implementation.ts"]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Step 4: Filter Code Files
|
||||
```bash
|
||||
git log --since="$(cat .workflow/WFS-${SESSION_ID}/workflow-session.json | jq -r .created_at)" --name-only --pretty=format: | sort -u | grep -E '\.(js|ts|jsx|tsx|py|java|go|rs)$'
|
||||
## Error Handling
|
||||
|
||||
### Phase 1 Failures
|
||||
- **No session found**: Return error "No active session detected. Provide session-id or run /workflow:plan first"
|
||||
- **Invalid session**: Return error "Session [sessionId] not found or incomplete"
|
||||
- **No implementation**: Return error "No completed IMPL tasks found. Complete implementation first"
|
||||
|
||||
### Phase 2 Failures
|
||||
- **Analysis failed**: Return error "Implementation analysis failed. Check context package"
|
||||
- **No test strategy**: Return error "Could not determine test execution strategy"
|
||||
|
||||
### Phase 3 Failures
|
||||
- **Task generation failed**: Retry once, then return error with details
|
||||
- **Invalid task structure**: Return error with JSON validation details
|
||||
|
||||
### Phase 4 Failures
|
||||
- **Execution failed**: Return error "Could not start test-fix workflow. Check session state"
|
||||
|
||||
## Workflow Integration
|
||||
|
||||
### Complete Flow Example
|
||||
```
|
||||
1. Implementation Phase (prior to test-gen)
|
||||
/workflow:plan "Build auth system"
|
||||
→ @code-developer implements + writes tests
|
||||
→ Creates IMPL-001-summary.md
|
||||
|
||||
2. Test Generation Phase (test-gen)
|
||||
/workflow:test-gen WFS-auth
|
||||
Phase 1: context-gather → Creates context-package-test.json
|
||||
Phase 2: concept-enhanced → Creates ANALYSIS_RESULTS.md
|
||||
Phase 3: task-generate → Creates TEST-FIX-001.json
|
||||
Phase 4: execute → Triggers @test-fix-agent
|
||||
|
||||
3. Test-Fix Phase (automated)
|
||||
@test-fix-agent picks up TEST-FIX-001
|
||||
→ Runs test suite
|
||||
→ Diagnoses failures (if any)
|
||||
→ Fixes source code
|
||||
→ Re-runs tests
|
||||
→ All pass → Code approved ✅
|
||||
```
|
||||
|
||||
### Step 5: Load Session Context
|
||||
```bash
|
||||
cat .workflow/WFS-${SESSION_ID}/.summaries/IMPL-*-summary.md 2>/dev/null
|
||||
```
|
||||
### Output Files Created
|
||||
- `.workflow/[sessionId]/.process/context-package-test.json` - Test context package
|
||||
- `.workflow/[sessionId]/.process/ANALYSIS_RESULTS.md` - Test execution strategy
|
||||
- `.workflow/[sessionId]/.task/TEST-FIX-001.json` - Task definition
|
||||
- `.workflow/[sessionId]/IMPL_PLAN.md` - Updated with test-fix plan
|
||||
- `.workflow/[sessionId]/TODO_LIST.md` - Updated with TEST-FIX task
|
||||
- `.workflow/[sessionId]/.summaries/TEST-FIX-001-summary.md` - Created by test-fix-agent after completion
|
||||
|
||||
### Step 6: Extract Focus Paths
|
||||
```bash
|
||||
find .workflow/WFS-${SESSION_ID}/.task/ -name '*.json' -exec jq -r '.context.focus_paths[]?' {} \;
|
||||
```
|
||||
## Best Practices
|
||||
|
||||
### Step 7: Gemini Analysis and Planning Document Generation
|
||||
```bash
|
||||
cd project-root && ~/.claude/scripts/gemini-wrapper -p "
|
||||
PURPOSE: Analyze implementation and generate comprehensive test planning document
|
||||
TASK: Review changed files and implementation context to create detailed test planning document
|
||||
CONTEXT: Changed files: [changed_files], Implementation summaries: [impl_summaries], Focus paths: [focus_paths]
|
||||
EXPECTED: Complete test planning document including:
|
||||
- Test strategy analysis
|
||||
- Critical test scenarios identification
|
||||
- Edge cases and error conditions
|
||||
- Test priority matrix
|
||||
- Resource requirements
|
||||
- Implementation approach recommendations
|
||||
- Specific test cases with acceptance criteria
|
||||
RULES: Generate structured markdown document suitable for workflow planning. Focus on actionable test requirements based on actual implementation changes.
|
||||
" > .workflow/WFS-${SESSION_ID}/.process/GEMINI_TEST_PLAN.md
|
||||
```
|
||||
1. **Run after implementation complete**: Ensure all IMPL tasks are done before test-gen
|
||||
2. **Check git commits**: Make sure implementation changes are committed
|
||||
3. **Verify test files exist**: Code-developer should have created tests
|
||||
4. **Monitor execution**: Use `/workflow:status` to track test-fix progress
|
||||
5. **Review failures**: If tests fail repeatedly, check test-fix-agent summary for details
|
||||
|
||||
### Step 8: Generate Combined Test Requirements Document
|
||||
```bash
|
||||
mkdir -p .workflow/WFS-${SESSION_ID}/.process
|
||||
```
|
||||
## Coordinator Checklist
|
||||
|
||||
```bash
|
||||
cat > .workflow/WFS-${SESSION_ID}/.process/TEST_REQUIREMENTS.md << 'EOF'
|
||||
# Test Requirements Summary for WFS-${SESSION_ID}
|
||||
|
||||
## Analysis Data Sources
|
||||
- Git change analysis results
|
||||
- Implementation summaries and context
|
||||
- Gemini-generated test planning document
|
||||
|
||||
## Reference Documents
|
||||
- Detailed test plan: GEMINI_TEST_PLAN.md
|
||||
- Implementation context: IMPL-*-summary.md files
|
||||
|
||||
## Integration Note
|
||||
This document combines analysis data with Gemini-generated planning document for comprehensive test workflow generation.
|
||||
EOF
|
||||
```
|
||||
|
||||
### Step 9: Call Workflow Plan with Gemini Planning Document
|
||||
```bash
|
||||
/workflow:plan .workflow/WFS-${SESSION_ID}/.process/GEMINI_TEST_PLAN.md
|
||||
```
|
||||
|
||||
## Simple Bash Commands
|
||||
|
||||
### Basic Operations
|
||||
- **Find active session**: `find .workflow/ -name '.active-*'`
|
||||
- **Get git changes**: `git log --since='date' --name-only`
|
||||
- **Filter code files**: `grep -E '\.(js|ts|py)$'`
|
||||
- **Load summaries**: `cat .workflow/WFS-*/summaries/*.md`
|
||||
- **Extract JSON data**: `jq -r '.context.focus_paths[]'`
|
||||
- **Create directory**: `mkdir -p .workflow/session/.process`
|
||||
- **Write file**: `cat > file << 'EOF'`
|
||||
|
||||
### Gemini CLI Integration
|
||||
- **Planning command**: `~/.claude/scripts/gemini-wrapper -p "prompt" > GEMINI_TEST_PLAN.md`
|
||||
- **Context loading**: Include changed files and implementation context
|
||||
- **Document generation**: Creates comprehensive test planning document
|
||||
- **Direct handoff**: Pass Gemini planning document to workflow:plan
|
||||
|
||||
## No Complex Logic
|
||||
- No variables or functions
|
||||
- No conditional statements
|
||||
- No loops or complex pipes
|
||||
- Direct bash commands only
|
||||
- Gemini CLI for intelligent analysis
|
||||
✅ Initialize TodoWrite before any command
|
||||
✅ Execute Phase 1 immediately with session ID
|
||||
✅ Parse context package path from Phase 1 output
|
||||
✅ Pass session ID and context path to Phase 2 command
|
||||
✅ Verify ANALYSIS_RESULTS.md after Phase 2
|
||||
✅ Pass session ID to Phase 3 command
|
||||
✅ Verify all Phase 3 outputs (task JSON, IMPL_PLAN, TODO_LIST)
|
||||
✅ Pass session ID to Phase 4 command
|
||||
✅ Update TodoWrite after each phase
|
||||
✅ Return summary only after Phase 4 completes
|
||||
|
||||
## Related Commands
|
||||
- `/workflow:plan` - Called to generate test workflow
|
||||
- `/workflow:execute` - Executes generated test tasks
|
||||
- `/workflow:status` - Shows test workflow progress
|
||||
- `/workflow:plan` - Create implementation workflow (run before test-gen)
|
||||
- `/workflow:tools:context-gather` - Phase 1 tool for context collection
|
||||
- `/workflow:tools:concept-enhanced` - Phase 2 tool for analysis
|
||||
- `/workflow:tools:task-generate` - Phase 3 tool for task creation
|
||||
- `/workflow:execute` - Phase 4 workflow execution
|
||||
- `/workflow:status` - Check workflow progress
|
||||
- `@test-fix-agent` - Agent that executes and fixes tests
|
||||
|
||||
@@ -158,7 +158,7 @@ Task(
|
||||
"status": "pending",
|
||||
"meta": {
|
||||
"type": "feature|bugfix|refactor|test|docs",
|
||||
"agent": "@code-developer|@code-review-test-agent"
|
||||
"agent": "@code-developer|@test-fix-agent|@general-purpose"
|
||||
},
|
||||
"context": {
|
||||
"requirements": ["extracted from analysis"],
|
||||
|
||||
@@ -67,8 +67,8 @@ Generate task JSON files and IMPL_PLAN.md from analysis results with automatic a
|
||||
"title": "Descriptive task name",
|
||||
"status": "pending|active|completed|blocked|container",
|
||||
"meta": {
|
||||
"type": "feature|bugfix|refactor|test|docs",
|
||||
"agent": "@code-developer|@planning-agent|@code-review-test-agent"
|
||||
"type": "feature|bugfix|refactor|test-gen|test-fix|docs",
|
||||
"agent": "@code-developer|@test-fix-agent|@general-purpose"
|
||||
},
|
||||
"context": {
|
||||
"requirements": ["Clear requirement from analysis"],
|
||||
|
||||
Reference in New Issue
Block a user