Initial commit

This commit is contained in:
Zhongwei Li
2025-11-29 18:20:36 +08:00
commit 88de006432
16 changed files with 1310 additions and 0 deletions

View File

@@ -0,0 +1,151 @@
---
name: implementing-tasks
description: Implements tasks from .plans/ directories by following implementation guidance, writing code and tests, and updating task status. Use when task file is in implementation/ directory and requires code implementation with comprehensive testing. Launches research agents when stuck.
---
# Implementation
Given task file path `.plans/<project>/implementation/NNN-task.md`:
## Process
**Use TodoWrite to track implementation progress:**
```
☐ Read task file (LLM Prompt, Working Result, Validation)
☐ [LLM Prompt step 1]
☐ [LLM Prompt step 2]
...
☐ Write tests for new functionality
☐ Run full test suite
☐ Mark validation checkboxes
☐ Update status to READY_FOR_REVIEW
```
Convert each step from the task's LLM Prompt into a todo. Mark completed as you progress.
1. Read task file - LLM Prompt, Working Result, Validation, Files
2. Follow LLM Prompt step-by-step, write code + tests, run full suite
3. Update task status using Edit tool:
- Find: `**Status:** [current status]`
- Replace: `**Status:** READY_FOR_REVIEW`
4. Append implementation notes using bash:
```bash
cat >> "$task_file" <<EOF
**implementation:**
- Followed LLM Prompt steps 1-N
- Implemented [key functionality]
- Added [N] tests: all passing
- Full test suite: [M]/[M] passing
- Working Result verified: ✓ [description]
- Files: [list with brief descriptions]
EOF
```
5. Mark validation checkboxes: `[ ]` → `[x]` using Edit tool
6. Report completion
## Stuck Handling
When blocked during implementation:
### 1. Mark Task as Stuck
- Update status using Edit tool:
- Find: `**Status:** [current status]`
- Replace: `**Status:** STUCK`
- Append notes:
```bash
cat >> "$task_file" <<EOF
**implementation:**
- Attempted [what tried]
- BLOCKED: [specific issue]
- Launching research agents to investigate...
EOF
```
### 2. Launch Research Agents
Based on blocker type, launch 2-3 agents in parallel:
**New technology/framework** → `research-breadth` + `research-technical`:
- research-breadth: General understanding of technology/approach
- research-technical: Official API documentation
**Specific error/issue** → `research-depth` + `research-technical`:
- research-depth: Detailed analysis of specific solutions
- research-technical: Official API documentation
**API integration** → `research-technical` + `research-depth`:
- research-technical: Official API documentation
- research-depth: Detailed implementation examples
**Best practices/patterns** → `research-breadth` + `research-depth`:
- research-breadth: General surveys and comparisons
- research-depth: Detailed analysis of specific approaches
Example:
```bash
# Launch agents with specific questions
research-breadth "How to [solve blocker]?"
research-depth "Detailed solutions for [specific issue]"
research-technical "[library/framework] official documentation for [feature]"
```
### 3. Synthesize Findings
Use research-synthesis skill (from essentials) to:
- Consolidate findings from all agents
- Identify concrete path forward
- Extract actionable implementation guidance
Update task file with research findings:
```bash
cat >> "$task_file" <<EOF
**research findings:**
- [Agent 1]: [key insights]
- [Agent 2]: [key insights]
- [Agent 3]: [key insights]
**resolution:**
[Concrete path forward based on research]
EOF
```
### 4. Continue or Escalate
**If unblocked:**
- Update status back to `IN_PROGRESS`
- Resume implementation following research guidance
- Complete normally as per main Process section
**If still stuck after research:**
- Keep status as `STUCK`
- Append escalation notes
- STOP and report blocker with research context
```bash
cat >> "$task_file" <<EOF
**escalation:**
- Research completed but blocker remains
- Reason: [why research didn't unblock]
- Need: [what's needed - human decision, missing requirement, etc.]
EOF
```
Then STOP and report blocker with full context.
## Rejection Handling
If task moved back from review:
1. Read review notes for issues
2. Fix all blocking issues
3. Update status to `READY_FOR_REVIEW` again
4. Append revision notes:
```
**implementation (revision):**
- Fixed [issue 1]
- Fixed [issue 2]
- Re-ran tests: [M]/[M] passing
```

View File

@@ -0,0 +1,163 @@
---
name: reviewing-code
description: Reviews implemented code for security, quality, performance, and test coverage using specialized review agents. Use when task file is in review/ directory and requires comprehensive code review before approval. Launches test-coverage-analyzer, error-handling-reviewer, and security-reviewer in parallel.
---
# Review
Given task file path `.plans/<project>/review/NNN-task.md`:
## Process
1. **Initial Review**:
- Run `git diff` on Files listed
- Read test files
- Run tests to verify passing
- Check Validation checkboxes marked [x]
- Score (0-100 each): Security, Quality, Performance, Tests
2. **Specialized Review (Parallel Agents)**:
Launch 3 review agents in parallel for deep analysis:
- **test-coverage-analyzer**: Identifies critical test gaps (1-10 criticality ratings)
- **error-handling-reviewer**: Finds silent failures and poor error handling (CRITICAL/HIGH/MEDIUM severity)
- **security-reviewer**: Checks for OWASP Top 10 vulnerabilities (0-100 confidence scores)
Agents run in separate contexts and return scored findings.
3. **Consolidate Findings**:
- Combine initial review with agent findings
- Filter by confidence/severity:
- **CRITICAL**: Security 90-100 confidence, Error handling CRITICAL, Test gaps 9-10
- **HIGH**: Security 70-89, Error handling HIGH, Test gaps 7-8
- **MEDIUM**: Security 50-69, Error handling MEDIUM, Test gaps 5-6
- Drop low-confidence issues (<50)
- Prioritize by severity
4. **Decide** - APPROVE or REJECT:
- APPROVE: Security ≥80, no CRITICAL findings from agents
- REJECT: Security <80 OR any CRITICAL findings
- HIGH findings acceptable with justification
5. **Update task status** using Edit tool:
- If approved: Find `**Status:** [current status]` → Replace `**Status:** APPROVED`
- If rejected: Find `**Status:** [current status]` → Replace `**Status:** REJECTED`
6. **Append notes** (see formats below) - include agent findings
7. **Report completion**
## Review Focus
| Area | Check |
|------|-------|
| **Security** | Input validation, auth checks, secrets in env, rate limiting, SQL parameterized |
| **Quality** | Readable, no duplication, error handling, follows patterns, diff <500 lines |
| **Performance** | No N+1 queries, efficient algorithms, proper indexing |
| **Tests** | Covers Validation, behavior-focused, edge cases, error paths, suite passing |
## Invoking Specialized Agents
After initial review, invoke agents in parallel using the Task tool with `subagent_type="general-purpose"`:
```
Launch all three agents simultaneously using Task tool:
Task(
description: "Analyze test coverage",
prompt: "You are test-coverage-analyzer. Analyze test coverage for:
Task file: [task_file_path]
Test files: [list test files]
Implementation files: [list impl files]
[Include full agent prompt from experimental/agents/review/test-coverage-analyzer.md]",
subagent_type: "general-purpose"
)
Task(
description: "Review error handling",
prompt: "You are error-handling-reviewer. Review error handling in:
Task file: [task_file_path]
Implementation files: [list impl files]
[Include full agent prompt from experimental/agents/review/error-handling-reviewer.md]",
subagent_type: "general-purpose"
)
Task(
description: "Security review",
prompt: "You are security-reviewer. Review security in:
Task file: [task_file_path]
Implementation files: [list impl files]
[Include full agent prompt from experimental/agents/review/security-reviewer.md]",
subagent_type: "general-purpose"
)
```
Call all three Task invocations in a single message to run them in parallel.
Each agent returns:
- **test-coverage-analyzer**: List of test gaps with 1-10 criticality scores
- **error-handling-reviewer**: List of error handling issues with CRITICAL/HIGH/MEDIUM severity
- **security-reviewer**: List of vulnerabilities with 0-100 confidence scores and OWASP categories
Consolidate findings using the confidence/severity mappings from Process step 3.
## Approval Format
```markdown
**review:**
Security: 90/100 | Quality: 95/100 | Performance: 95/100 | Tests: 90/100
Working Result verified: ✓ [description]
Validation: 4/4 passing
Full test suite: [M]/[M] passing
Diff: [N] lines
**Specialized Review Findings:**
- Test Coverage: No CRITICAL gaps (0 gaps rated 9-10)
- Error Handling: 1 HIGH finding - [description with justification why acceptable]
- Security: No vulnerabilities detected (0 findings >70 confidence)
APPROVED → testing
```
## Rejection Format
```markdown
**review:**
Security: 65/100 | Quality: 85/100 | Performance: 90/100 | Tests: 75/100
**Specialized Review Findings:**
CRITICAL Issues (must fix):
1. [Security/Test/Error] - [Description from agent] - [Confidence/Severity/Criticality score]
2. [Security/Test/Error] - [Description from agent] - [Confidence/Severity/Criticality score]
HIGH Issues (review recommended):
1. [Security/Test/Error] - [Description from agent] - [Confidence/Severity/Criticality score]
REJECTED - Blocking issues:
1. [Specific issue + fix needed]
2. [Specific issue + fix needed]
Required actions:
- [Action 1 - address CRITICAL findings]
- [Action 2 - address blocking issues]
- [Action 3 - consider HIGH findings]
REJECTED → implementation
```
## Blocking Thresholds
**Must REJECT if any:**
- Security score <80
- Critical vulnerability from initial review
- Any CRITICAL findings from specialized agents (Security 90-100 confidence, Error handling CRITICAL, Test gaps 9-10)
- Tests failing
- Validation incomplete
- Working Result not achieved
**Can APPROVE with HIGH findings** if:
- Security score ≥80
- No CRITICAL findings
- HIGH findings include justification why acceptable
- All tests passing
- Validation complete

74
skills/testing/SKILL.md Normal file
View File

@@ -0,0 +1,74 @@
---
name: testing
description: Validates test coverage and quality by checking behavior focus, identifying gaps, and ensuring >80% statement coverage. Use when task file is in testing/ directory and requires test validation before marking complete. Adds minimal tests for genuinely missing edge cases.
---
# Testing
Given task file path `.plans/<project>/testing/NNN-task.md`:
## Process
**Use TodoWrite to track testing validation:**
```
☐ Validate existing tests (behavior-focused?)
☐ Check coverage of Validation checklist items
☐ Identify gaps (empty/null, boundaries, errors)
☐ Add tests for genuine gaps
☐ Run coverage (>80% statements, >75% branches)
☐ Update task status
```
1. Validate existing tests - behavior-focused? Covers Validation?
2. Identify gaps - empty/null inputs, boundaries, errors, race conditions, security
3. Add minimal tests if genuinely missing
4. Run coverage - verify >80% statements, >75% branches
5. Update task status using Edit tool:
- Find: `**Status:** [current status]`
- Replace: `**Status:** COMPLETED`
6. Append testing notes:
```bash
cat >> "$task_file" <<EOF
**testing:**
Validated [N] tests (behavior-focused)
Added [M] edge cases:
- [Test description]
- [Test description]
Test breakdown: Unit: X | Integration: Y | Total: Z
Coverage: Statements: XX% | Branches: XX% | Functions: XX% | Lines: XX%
Full suite: XXX/XXX passing
Working Result verified: ✓ [description]
COMPLETED
EOF
```
7. Report completion
## Test Quality
Good: `expect(response.status).toBe(401)` (tests behavior)
Bad: `expect(bcrypt.compare).toHaveBeenCalled()` (tests implementation)
Granularity: Pure functions → Unit | DB/API → Integration | Critical workflows → E2E (rare)
## Failure Handling
If tests fail or coverage <80%:
- Fix test scenarios first
- If code bug found:
- Update status using Edit tool: Find `**Status:** [current status]` → Replace `**Status:** NEEDS_FIX`
- Append notes:
```bash
cat >> "$task_file" <<EOF
**testing:**
Found issues:
- [Specific issue]
- [Specific issue]
Requires code fixes. Moving back to implementation.
EOF
```