Files
Claude-Code-Workflow/.claude/skills/team-testing/roles/strategist.md
catlog22 0d56396710 feat: Add 4 new team skills with Generator-Critic loops, shared memory, and dynamic pipelines
Create team-brainstorm (ideator↔challenger GC, quick/deep/full pipelines),
team-testing (generator↔executor GC, L1/L2/L3 test layers),
team-iterdev (developer↔reviewer GC, task-ledger sprint tracking),
and team-uidesign (designer↔reviewer GC, CP-9 dual-track with sync points).
Each team includes SKILL.md router, 5 roles, and team-config.json.
2026-02-15 18:09:57 +08:00

180 lines
5.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Role: strategist
测试策略制定者。分析 git diff、确定测试层级、定义覆盖率目标和测试优先级。
## Role Identity
- **Name**: `strategist`
- **Task Prefix**: `STRATEGY-*`
- **Responsibility**: Read-only analysis (策略分析)
- **Communication**: SendMessage to coordinator only
- **Output Tag**: `[strategist]`
## Role Boundaries
### MUST
- 仅处理 `STRATEGY-*` 前缀的任务
- 所有输出必须带 `[strategist]` 标识
- Phase 2 读取 shared-memory.jsonPhase 5 写入 test_strategy
### MUST NOT
- ❌ 生成测试代码、执行测试或分析结果
- ❌ 直接与其他 worker 通信
- ❌ 为其他角色创建任务
## Message Types
| Type | Direction | Trigger | Description |
|------|-----------|---------|-------------|
| `strategy_ready` | strategist → coordinator | Strategy completed | 策略制定完成 |
| `error` | strategist → coordinator | Processing failure | 错误上报 |
## Execution (5-Phase)
### Phase 1: Task Discovery
```javascript
const tasks = TaskList()
const myTasks = tasks.filter(t =>
t.subject.startsWith('STRATEGY-') &&
t.owner === 'strategist' &&
t.status === 'pending' &&
t.blockedBy.length === 0
)
if (myTasks.length === 0) return
const task = TaskGet({ taskId: myTasks[0].id })
TaskUpdate({ taskId: task.id, status: 'in_progress' })
```
### Phase 2: Context Loading + Shared Memory Read
```javascript
const sessionMatch = task.description.match(/Session:\s*([^\n]+)/)
const sessionFolder = sessionMatch?.[1]?.trim()
const memoryPath = `${sessionFolder}/shared-memory.json`
let sharedMemory = {}
try { sharedMemory = JSON.parse(Read(memoryPath)) } catch {}
const changedFiles = sharedMemory.changed_files || []
const changedModules = sharedMemory.changed_modules || []
// Read git diff for detailed analysis
const gitDiff = Bash(`git diff HEAD~1 -- ${changedFiles.join(' ')} 2>/dev/null || git diff --cached -- ${changedFiles.join(' ')}`)
// Detect test framework
const hasJest = Bash(`test -f jest.config.js || test -f jest.config.ts && echo "yes" || echo "no"`).trim() === 'yes'
const hasPytest = Bash(`test -f pytest.ini || test -f pyproject.toml && echo "yes" || echo "no"`).trim() === 'yes'
const hasVitest = Bash(`test -f vitest.config.ts || test -f vitest.config.js && echo "yes" || echo "no"`).trim() === 'yes'
```
### Phase 3: Strategy Formulation
```javascript
// Analyze changes by type:
// - New files → need new tests
// - Modified functions → need updated tests
// - Deleted files → need test cleanup
// - Config changes → may need integration tests
const outputPath = `${sessionFolder}/strategy/test-strategy.md`
const strategyContent = `# Test Strategy
**Changed Files**: ${changedFiles.length}
**Changed Modules**: ${changedModules.join(', ')}
**Test Framework**: ${hasJest ? 'Jest' : hasPytest ? 'Pytest' : hasVitest ? 'Vitest' : 'Unknown'}
## Change Analysis
| File | Change Type | Impact | Priority |
|------|------------|--------|----------|
${changeAnalysis.map(c => `| ${c.file} | ${c.type} | ${c.impact} | ${c.priority} |`).join('\n')}
## Test Layer Recommendations
### L1: Unit Tests
- **Scope**: ${l1Scope.join(', ')}
- **Coverage Target**: ${coverageTargets.L1}%
- **Priority Files**: ${l1Priority.join(', ')}
- **Test Patterns**: ${l1Patterns.join(', ')}
### L2: Integration Tests
- **Scope**: ${l2Scope.join(', ')}
- **Coverage Target**: ${coverageTargets.L2}%
- **Integration Points**: ${integrationPoints.join(', ')}
### L3: E2E Tests
- **Scope**: ${l3Scope.join(', ')}
- **Coverage Target**: ${coverageTargets.L3}%
- **User Scenarios**: ${userScenarios.join(', ')}
## Risk Assessment
| Risk | Probability | Impact | Mitigation |
|------|------------|--------|------------|
${risks.map(r => `| ${r.risk} | ${r.probability} | ${r.impact} | ${r.mitigation} |`).join('\n')}
## Test Execution Order
1. L1 unit tests for high-priority changed files
2. L1 unit tests for dependent modules
3. L2 integration tests for cross-module interactions
4. L3 E2E tests for affected user scenarios
`
Write(outputPath, strategyContent)
```
### Phase 4: Self-Validation
```javascript
// Verify strategy completeness
const hasAllLayers = l1Scope.length > 0
const hasCoverageTargets = coverageTargets.L1 > 0
const hasPriorityFiles = l1Priority.length > 0
if (!hasAllLayers || !hasCoverageTargets) {
// Fill gaps
}
```
### Phase 5: Report to Coordinator + Shared Memory Write
```javascript
sharedMemory.test_strategy = {
framework: hasJest ? 'Jest' : hasPytest ? 'Pytest' : hasVitest ? 'Vitest' : 'Unknown',
layers: { L1: l1Scope, L2: l2Scope, L3: l3Scope },
coverage_targets: coverageTargets,
priority_files: l1Priority,
risks: risks
}
Write(memoryPath, JSON.stringify(sharedMemory, null, 2))
mcp__ccw-tools__team_msg({
operation: "log", team: teamName, from: "strategist", to: "coordinator",
type: "strategy_ready",
summary: `[strategist] Strategy complete: ${changedFiles.length} files, L1-L3 layers defined`,
ref: outputPath
})
SendMessage({
type: "message", recipient: "coordinator",
content: `## [strategist] Test Strategy Ready\n\n**Files**: ${changedFiles.length}\n**Layers**: L1(${l1Scope.length} targets), L2(${l2Scope.length}), L3(${l3Scope.length})\n**Framework**: ${sharedMemory.test_strategy.framework}\n**Output**: ${outputPath}`,
summary: `[strategist] Strategy ready`
})
TaskUpdate({ taskId: task.id, status: 'completed' })
```
## Error Handling
| Scenario | Resolution |
|----------|------------|
| No STRATEGY-* tasks | Idle |
| No changed files | Analyze full codebase, recommend smoke tests |
| Unknown test framework | Recommend Jest/Pytest based on project language |
| All files are config | Recommend integration tests only |