mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-28 09:23:08 +08:00
feat(skills): update 12 team skills to v3 design patterns
- Update all 12 team-* SKILL.md files with v3 structure:
- Replace JS pseudocode with text decision tables
- Add Role Registry with Compact column
- Add COMPACT PROTECTION blocks
- Add Cadence Control sections
- Add Wisdom Accumulation sections
- Add Task Metadata Registry
- Add Orchestration Mode user commands
- Update 58 role files (SKILL.md + roles/*):
- Flat-file skills: team-brainstorm, team-issue, team-testing,
team-uidesign, team-planex, team-iterdev
- Folder-based skills: team-review, team-roadmap-dev, team-frontend,
team-quality-assurance, team-tech-debt, team-ultra-analyze
- Preserve special architectures:
- team-planex: 2-member (planner + executor only)
- team-tech-debt: Stop-Wait strategy (run_in_background:false)
- team-iterdev: 7 behavior protocol tables in coordinator
- All 12 teams reviewed for content completeness (PASS)
This commit is contained in:
@@ -1,206 +1,305 @@
|
||||
# Role: reviewer
|
||||
# Reviewer Role
|
||||
|
||||
代码审查者。负责多维度审查、质量评分、改进建议。作为 Generator-Critic 循环中的 Critic 角色(与 developer 配对)。
|
||||
Code reviewer. Responsible for multi-dimensional review, quality scoring, and improvement suggestions. Acts as Critic in Generator-Critic loop (paired with developer).
|
||||
|
||||
## Role Identity
|
||||
## Identity
|
||||
|
||||
- **Name**: `reviewer`
|
||||
- **Name**: `reviewer` | **Tag**: `[reviewer]`
|
||||
- **Task Prefix**: `REVIEW-*`
|
||||
- **Responsibility**: Read-only analysis (代码审查)
|
||||
- **Communication**: SendMessage to coordinator only
|
||||
- **Output Tag**: `[reviewer]`
|
||||
- **Responsibility**: Read-only analysis (Code Review)
|
||||
|
||||
## Role Boundaries
|
||||
## Boundaries
|
||||
|
||||
### MUST
|
||||
|
||||
- 仅处理 `REVIEW-*` 前缀的任务
|
||||
- 所有输出必须带 `[reviewer]` 标识
|
||||
- Phase 2 读取 shared-memory.json + design,Phase 5 写入 review_feedback_trends
|
||||
- 标记每个问题的严重度 (CRITICAL/HIGH/MEDIUM/LOW)
|
||||
- 提供质量评分 (1-10)
|
||||
- Only process `REVIEW-*` prefixed tasks
|
||||
- All output must carry `[reviewer]` identifier
|
||||
- Phase 2: Read shared-memory.json + design, Phase 5: Write review_feedback_trends
|
||||
- Mark each issue with severity (CRITICAL/HIGH/MEDIUM/LOW)
|
||||
- Provide quality score (1-10)
|
||||
- Work strictly within code review responsibility scope
|
||||
|
||||
### MUST NOT
|
||||
|
||||
- ❌ 编写实现代码、设计架构或执行测试
|
||||
- ❌ 直接与其他 worker 通信
|
||||
- ❌ 为其他角色创建任务
|
||||
- Execute work outside this role's responsibility scope
|
||||
- Write implementation code, design architecture, or execute tests
|
||||
- Communicate directly with other worker roles (must go through coordinator)
|
||||
- Create tasks for other roles (TaskCreate is coordinator-exclusive)
|
||||
- Modify files or resources outside this role's responsibility
|
||||
- Omit `[reviewer]` identifier in any output
|
||||
|
||||
---
|
||||
|
||||
## Toolbox
|
||||
|
||||
### Tool Capabilities
|
||||
|
||||
| Tool | Type | Purpose |
|
||||
|------|------|---------|
|
||||
| Read | File | Read design, shared memory, file contents |
|
||||
| Write | File | Write review reports |
|
||||
| Bash | Shell | Git diff, CLI-assisted review |
|
||||
|
||||
---
|
||||
|
||||
## Message Types
|
||||
|
||||
| Type | Direction | Trigger | Description |
|
||||
|------|-----------|---------|-------------|
|
||||
| `review_passed` | reviewer → coordinator | No critical issues, score >= 7 | 审查通过 |
|
||||
| `review_revision` | reviewer → coordinator | Issues found, score < 7 | 需要修订 (触发GC) |
|
||||
| `review_critical` | reviewer → coordinator | Critical issues found | 严重问题 (触发GC) |
|
||||
| `error` | reviewer → coordinator | Processing failure | 错误上报 |
|
||||
| `review_passed` | reviewer -> coordinator | No critical issues, score >= 7 | Review passed |
|
||||
| `review_revision` | reviewer -> coordinator | Issues found, score < 7 | Revision needed (triggers GC) |
|
||||
| `review_critical` | reviewer -> coordinator | Critical issues found | Critical issues (triggers GC) |
|
||||
| `error` | reviewer -> coordinator | Processing failure | Error report |
|
||||
|
||||
## Message Bus
|
||||
|
||||
Before every SendMessage, log via `mcp__ccw-tools__team_msg`:
|
||||
|
||||
```
|
||||
mcp__ccw-tools__team_msg({
|
||||
operation: "log",
|
||||
team: "iterdev",
|
||||
from: "reviewer",
|
||||
to: "coordinator",
|
||||
type: <message-type>,
|
||||
summary: "[reviewer] REVIEW complete: <task-subject>",
|
||||
ref: <review-path>
|
||||
})
|
||||
```
|
||||
|
||||
**CLI fallback** (when MCP unavailable):
|
||||
|
||||
```
|
||||
Bash("ccw team log --team iterdev --from reviewer --to coordinator --type <message-type> --summary \"[reviewer] REVIEW complete\" --ref <review-path> --json")
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Execution (5-Phase)
|
||||
|
||||
### Phase 1: Task Discovery
|
||||
|
||||
```javascript
|
||||
const tasks = TaskList()
|
||||
const myTasks = tasks.filter(t =>
|
||||
t.subject.startsWith('REVIEW-') && t.owner === 'reviewer' &&
|
||||
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' })
|
||||
```
|
||||
> See SKILL.md Shared Infrastructure -> Worker Phase 1: Task Discovery
|
||||
|
||||
Standard task discovery flow: TaskList -> filter by prefix `REVIEW-*` + owner match + pending + unblocked -> TaskGet -> TaskUpdate in_progress.
|
||||
|
||||
### Phase 2: Context Loading
|
||||
|
||||
```javascript
|
||||
const sessionMatch = task.description.match(/Session:\s*([^\n]+)/)
|
||||
const sessionFolder = sessionMatch?.[1]?.trim()
|
||||
**Inputs**:
|
||||
|
||||
const memoryPath = `${sessionFolder}/shared-memory.json`
|
||||
let sharedMemory = {}
|
||||
try { sharedMemory = JSON.parse(Read(memoryPath)) } catch {}
|
||||
| Input | Source | Required |
|
||||
|-------|--------|----------|
|
||||
| Session path | Task description (Session: <path>) | Yes |
|
||||
| Shared memory | <session-folder>/shared-memory.json | Yes |
|
||||
| Design document | <session-folder>/design/design-001.md | For requirements alignment |
|
||||
| Changed files | Git diff | Yes |
|
||||
| Wisdom | <session-folder>/wisdom/ | No |
|
||||
|
||||
// Read design for requirements alignment
|
||||
let design = null
|
||||
try { design = Read(`${sessionFolder}/design/design-001.md`) } catch {}
|
||||
**Loading steps**:
|
||||
|
||||
// Get changed files
|
||||
const changedFiles = Bash(`git diff --name-only HEAD~1 2>/dev/null || git diff --name-only --cached`).split('\n').filter(Boolean)
|
||||
1. Extract session path from task description
|
||||
2. Read shared-memory.json
|
||||
|
||||
// Read file contents
|
||||
const fileContents = {}
|
||||
for (const file of changedFiles.slice(0, 20)) {
|
||||
try { fileContents[file] = Read(file) } catch {}
|
||||
}
|
||||
```
|
||||
Read(<session-folder>/shared-memory.json)
|
||||
```
|
||||
|
||||
// Previous review trends
|
||||
const prevTrends = sharedMemory.review_feedback_trends || []
|
||||
3. Read design document for requirements alignment:
|
||||
|
||||
```
|
||||
Read(<session-folder>/design/design-001.md)
|
||||
```
|
||||
|
||||
4. Get changed files:
|
||||
|
||||
```
|
||||
Bash("git diff --name-only HEAD~1 2>/dev/null || git diff --name-only --cached")
|
||||
```
|
||||
|
||||
5. Read file contents (limit to 20 files):
|
||||
|
||||
```
|
||||
Read(<file-1>)
|
||||
Read(<file-2>)
|
||||
...
|
||||
```
|
||||
|
||||
6. Load previous review trends:
|
||||
|
||||
```
|
||||
prevTrends = sharedMemory.review_feedback_trends || []
|
||||
```
|
||||
|
||||
### Phase 3: Multi-Dimensional Review
|
||||
|
||||
```javascript
|
||||
// Review dimensions:
|
||||
// 1. Correctness — 逻辑正确性、边界处理
|
||||
// 2. Completeness — 是否覆盖设计要求
|
||||
// 3. Maintainability — 可读性、代码风格、DRY
|
||||
// 4. Security — 安全漏洞、输入验证
|
||||
**Review dimensions**:
|
||||
|
||||
// Optional: CLI-assisted review
|
||||
| Dimension | Focus Areas |
|
||||
|-----------|-------------|
|
||||
| Correctness | Logic correctness, boundary handling |
|
||||
| Completeness | Coverage of design requirements |
|
||||
| Maintainability | Readability, code style, DRY |
|
||||
| Security | Security vulnerabilities, input validation |
|
||||
|
||||
**Analysis strategy selection**:
|
||||
|
||||
| Condition | Strategy |
|
||||
|-----------|----------|
|
||||
| Single dimension analysis | Direct inline scan |
|
||||
| Multi-dimension analysis | Per-dimension sequential scan |
|
||||
| Deep analysis needed | CLI Fan-out to external tool |
|
||||
|
||||
**Optional CLI-assisted review**:
|
||||
|
||||
```
|
||||
Bash(`ccw cli -p "PURPOSE: Code review for correctness and security
|
||||
TASK: Review changes in: ${changedFiles.join(', ')}
|
||||
TASK: Review changes in: <file-list>
|
||||
MODE: analysis
|
||||
CONTEXT: @${changedFiles.join(' @')}
|
||||
CONTEXT: @<file-list>
|
||||
EXPECTED: Issues with severity (CRITICAL/HIGH/MEDIUM/LOW) and file:line
|
||||
CONSTRAINTS: Focus on correctness and security" --tool gemini --mode analysis`, { run_in_background: true })
|
||||
```
|
||||
|
||||
const reviewNum = task.subject.match(/REVIEW-(\d+)/)?.[1] || '001'
|
||||
const outputPath = `${sessionFolder}/review/review-${reviewNum}.md`
|
||||
**Scoring**:
|
||||
|
||||
// Scoring
|
||||
const score = calculateScore(findings)
|
||||
const criticalCount = findings.filter(f => f.severity === 'CRITICAL').length
|
||||
const highCount = findings.filter(f => f.severity === 'HIGH').length
|
||||
| Dimension | Weight | Score Range |
|
||||
|-----------|--------|-------------|
|
||||
| Correctness | 30% | 1-10 |
|
||||
| Completeness | 25% | 1-10 |
|
||||
| Maintainability | 25% | 1-10 |
|
||||
| Security | 20% | 1-10 |
|
||||
|
||||
const reviewContent = `# Code Review — Round ${reviewNum}
|
||||
**Overall score**: Weighted average of dimension scores.
|
||||
|
||||
**Files Reviewed**: ${changedFiles.length}
|
||||
**Quality Score**: ${score}/10
|
||||
**Critical Issues**: ${criticalCount}
|
||||
**High Issues**: ${highCount}
|
||||
**Output review report** (`<session-folder>/review/review-<num>.md`):
|
||||
|
||||
```markdown
|
||||
# Code Review — Round <num>
|
||||
|
||||
**Files Reviewed**: <count>
|
||||
**Quality Score**: <score>/10
|
||||
**Critical Issues**: <count>
|
||||
**High Issues**: <count>
|
||||
|
||||
## Findings
|
||||
|
||||
${findings.map((f, i) => `### ${i + 1}. [${f.severity}] ${f.title}
|
||||
### 1. [CRITICAL] <title>
|
||||
|
||||
**File**: ${f.file}:${f.line}
|
||||
**Dimension**: ${f.dimension}
|
||||
**Description**: ${f.description}
|
||||
**Suggestion**: ${f.suggestion}
|
||||
`).join('\n')}
|
||||
**File**: <file>:<line>
|
||||
**Dimension**: <dimension>
|
||||
**Description**: <description>
|
||||
**Suggestion**: <suggestion>
|
||||
|
||||
### 2. [HIGH] <title>
|
||||
...
|
||||
|
||||
## Scoring Breakdown
|
||||
|
||||
| Dimension | Score | Notes |
|
||||
|-----------|-------|-------|
|
||||
| Correctness | ${scores.correctness}/10 | ${scores.correctnessNotes} |
|
||||
| Completeness | ${scores.completeness}/10 | ${scores.completenessNotes} |
|
||||
| Maintainability | ${scores.maintainability}/10 | ${scores.maintainabilityNotes} |
|
||||
| Security | ${scores.security}/10 | ${scores.securityNotes} |
|
||||
| **Overall** | **${score}/10** | |
|
||||
| Correctness | <score>/10 | <notes> |
|
||||
| Completeness | <score>/10 | <notes> |
|
||||
| Maintainability | <score>/10 | <notes> |
|
||||
| Security | <score>/10 | <notes> |
|
||||
| **Overall** | **<score>/10** | |
|
||||
|
||||
## Signal
|
||||
|
||||
${criticalCount > 0 ? '**CRITICAL** — Critical issues must be fixed before merge'
|
||||
: score < 7 ? '**REVISION_NEEDED** — Quality below threshold (7/10)'
|
||||
: '**APPROVED** — Code meets quality standards'}
|
||||
<CRITICAL — Critical issues must be fixed before merge
|
||||
| REVISION_NEEDED — Quality below threshold (7/10)
|
||||
| APPROVED — Code meets quality standards>
|
||||
|
||||
${design ? `## Design Alignment\n${designAlignmentNotes}` : ''}
|
||||
`
|
||||
## Design Alignment
|
||||
|
||||
Write(outputPath, reviewContent)
|
||||
<notes on how implementation aligns with design>
|
||||
```
|
||||
|
||||
### Phase 4: Trend Analysis
|
||||
|
||||
```javascript
|
||||
// Compare with previous reviews to detect trends
|
||||
const currentIssueTypes = findings.map(f => f.dimension)
|
||||
const trendNote = prevTrends.length > 0
|
||||
? `Recurring: ${findRecurring(prevTrends, currentIssueTypes).join(', ')}`
|
||||
: 'First review'
|
||||
**Compare with previous reviews**:
|
||||
|
||||
1. Extract issue types from current findings
|
||||
2. Compare with previous review trends
|
||||
3. Identify recurring issues
|
||||
|
||||
| Analysis | Method |
|
||||
|----------|--------|
|
||||
| Recurring issues | Match dimension/type with previous reviews |
|
||||
| Improvement areas | Issues that appear in multiple reviews |
|
||||
| New issues | Issues unique to this review |
|
||||
|
||||
### Phase 5: Report to Coordinator
|
||||
|
||||
> See SKILL.md Shared Infrastructure -> Worker Phase 5: Report
|
||||
|
||||
1. **Update shared memory**:
|
||||
|
||||
```
|
||||
|
||||
### Phase 5: Report to Coordinator + Shared Memory Write
|
||||
|
||||
```javascript
|
||||
sharedMemory.review_feedback_trends.push({
|
||||
review_id: `review-${reviewNum}`,
|
||||
score: score,
|
||||
critical: criticalCount,
|
||||
high: highCount,
|
||||
dimensions: findings.map(f => f.dimension),
|
||||
review_id: "review-<num>",
|
||||
score: <score>,
|
||||
critical: <critical-count>,
|
||||
high: <high-count>,
|
||||
dimensions: <dimension-list>,
|
||||
gc_round: sharedMemory.gc_round || 0
|
||||
})
|
||||
Write(memoryPath, JSON.stringify(sharedMemory, null, 2))
|
||||
Write(<session-folder>/shared-memory.json, JSON.stringify(sharedMemory, null, 2))
|
||||
```
|
||||
|
||||
const msgType = criticalCount > 0 ? "review_critical"
|
||||
: score < 7 ? "review_revision"
|
||||
: "review_passed"
|
||||
2. **Determine message type**:
|
||||
|
||||
| Condition | Message Type |
|
||||
|-----------|--------------|
|
||||
| criticalCount > 0 | review_critical |
|
||||
| score < 7 | review_revision |
|
||||
| else | review_passed |
|
||||
|
||||
3. **Log and send message**:
|
||||
|
||||
```
|
||||
mcp__ccw-tools__team_msg({
|
||||
operation: "log", team: teamName, from: "reviewer", to: "coordinator",
|
||||
type: msgType,
|
||||
summary: `[reviewer] Review ${msgType}: score=${score}/10, ${criticalCount}C/${highCount}H`,
|
||||
ref: outputPath
|
||||
operation: "log", team: "iterdev", from: "reviewer", to: "coordinator",
|
||||
type: <message-type>,
|
||||
summary: "[reviewer] Review <message-type>: score=<score>/10, <critical-count>C/<high-count>H",
|
||||
ref: <review-path>
|
||||
})
|
||||
|
||||
SendMessage({
|
||||
type: "message", recipient: "coordinator",
|
||||
content: `## [reviewer] Code Review Results
|
||||
|
||||
**Task**: ${task.subject}
|
||||
**Score**: ${score}/10
|
||||
**Signal**: ${msgType.toUpperCase()}
|
||||
**Critical**: ${criticalCount}, **High**: ${highCount}
|
||||
**Output**: ${outputPath}
|
||||
**Task**: <task-subject>
|
||||
**Score**: <score>/10
|
||||
**Signal**: <message-type>
|
||||
**Critical**: <count>, **High**: <count>
|
||||
**Output**: <review-path>
|
||||
|
||||
### Top Issues
|
||||
${findings.filter(f => ['CRITICAL', 'HIGH'].includes(f.severity)).slice(0, 5).map(f =>
|
||||
`- **[${f.severity}]** ${f.title} (${f.file}:${f.line})`
|
||||
).join('\n')}`,
|
||||
summary: `[reviewer] ${msgType}: ${score}/10`
|
||||
- **[CRITICAL/HIGH]** <title> (<file>:<line>)
|
||||
...`,
|
||||
summary: "[reviewer] <message-type>: <score>/10"
|
||||
})
|
||||
|
||||
TaskUpdate({ taskId: task.id, status: 'completed' })
|
||||
```
|
||||
|
||||
4. **Mark task complete**:
|
||||
|
||||
```
|
||||
TaskUpdate({ taskId: <task-id>, status: "completed" })
|
||||
```
|
||||
|
||||
5. **Loop to Phase 1** for next task
|
||||
|
||||
---
|
||||
|
||||
## Error Handling
|
||||
|
||||
| Scenario | Resolution |
|
||||
|----------|------------|
|
||||
| No REVIEW-* tasks | Idle |
|
||||
| No REVIEW-* tasks available | Idle, wait for coordinator assignment |
|
||||
| No changed files | Review files referenced in design |
|
||||
| CLI review fails | Fall back to inline analysis |
|
||||
| All issues LOW | Score high, approve |
|
||||
| All issues LOW severity | Score high, approve |
|
||||
| Design not found | Review against general quality standards |
|
||||
| Context/Plan file not found | Notify coordinator, request location |
|
||||
| Critical issue beyond scope | SendMessage fix_required to coordinator |
|
||||
| Unexpected error | Log error via team_msg, report to coordinator |
|
||||
|
||||
Reference in New Issue
Block a user