review-code
关于
This skill reviews code against specification requirements to ensure implementation compliance. It checks for deviations, generates a compliance score with detailed reports, and can trigger spec evolution when mismatches are found. Use it after implementation completion or before deployment to validate that code matches the intended specification.
技能文档
Code Review Against Specification
Overview
Review code implementation against specification to ensure compliance.
Key Difference from Standard Code Review:
- Primary focus: Does code match spec?
- Secondary focus: Code quality, patterns, best practices
- Output: Compliance score + deviation list
- Triggers: Spec evolution if mismatches found
When to Use
- After implementation complete (called by
sdd:implement) - Before merging/deploying code
- When validating existing code against spec
- As part of verification workflow
The Process
1. Load Spec and Code
Read specification:
cat specs/features/[feature-name].md
Identify implementation files:
# From implementation plan or code exploration
ls -la [implementation-files]
2. Review Functional Requirements
For each functional requirement in spec:
- Find implementation in code
- Compare behavior: Does code do what spec says?
- Check completeness: All aspects implemented?
- Note deviations: Any differences?
Create compliance matrix:
Requirement 1: [Spec text]
Implementation: [file:line]
Status: ✓ Compliant | ✗ Deviation | ? Missing
Notes: [If deviation, explain]
Requirement 2: [Spec text]
...
3. Review Error Handling
For each error case in spec:
- Find error handling in code
- Check error response: Matches spec?
- Verify error codes: Correct HTTP status / error codes?
- Test error messages: Clear and helpful?
Error handling compliance:
Error Case 1: [From spec]
Implemented: Yes/No
Location: [file:line]
Response: [What code returns]
Spec Expected: [What spec says]
Status: ✓ / ✗
4. Review Edge Cases
For each edge case in spec:
- Find handling in code
- Check behavior: Matches spec?
- Verify tests: Edge case tested?
5. Check for Extra Features
Identify code features NOT in spec:
- Functions/endpoints not mentioned in spec
- Behavior beyond spec requirements
- Additional error handling
- Extra validations
For each extra feature:
- Document what it does
- Assess: Helpful addition or scope creep?
- Note for potential spec update
6. Calculate Compliance Score
Formula:
Compliance % = (Compliant Requirements / Total Requirements) × 100
Include:
- Functional requirements
- Error cases
- Edge cases
- Non-functional requirements
Example:
Functional: 8/8 = 100%
Error Cases: 3/4 = 75%
Edge Cases: 2/3 = 67%
Non-Functional: 3/3 = 100%
Overall: 16/18 = 89%
7. Generate Report
Report structure:
# Code Review: [Feature Name]
**Spec:** specs/features/[feature].md
**Date:** YYYY-MM-DD
**Reviewer:** Claude (sdd:review-code)
## Compliance Summary
**Overall Score: XX%**
- Functional Requirements: X/X (XX%)
- Error Handling: X/X (XX%)
- Edge Cases: X/X (XX%)
- Non-Functional: X/X (XX%)
## Detailed Review
### Functional Requirements
#### ✓ Requirement 1: [Spec text]
**Implementation:** src/[file]:line
**Status:** Compliant
**Notes:** Correctly implemented as specified
#### ✗ Requirement 2: [Spec text]
**Implementation:** src/[file]:line
**Status:** Deviation
**Issue:** [What differs from spec]
**Impact:** [Minor/Major]
**Recommendation:** [Update spec / Fix code]
### Error Handling
[Similar format for each error case]
### Edge Cases
[Similar format for each edge case]
### Extra Features (Not in Spec)
#### [Feature name]
**Location:** src/[file]:line
**Description:** [What it does]
**Assessment:** [Helpful / Scope creep]
**Recommendation:** [Add to spec / Remove]
## Code Quality Notes
[Secondary observations about code quality, patterns, etc.]
## Recommendations
### Critical (Must Fix)
- [ ] [Issue requiring immediate attention]
### Spec Evolution Candidates
- [ ] [Deviation that might warrant spec update]
### Optional Improvements
- [ ] [Nice-to-have suggestions]
## Conclusion
[Overall assessment]
**Next Steps:**
- If compliance < 100%: Use `sdd:evolve` to reconcile deviations
- If compliance = 100%: Proceed to verification
8. Trigger Evolution if Needed
If deviations found:
- Present review results to user
- Recommend using
sdd:evolve - Don't proceed to verification until resolved
If 100% compliant:
- Approve for verification
- Proceed to
sdd:verification-before-completion
Review Checklist
Use TodoWrite to track:
- Load specification
- Identify all implementation files
- Review each functional requirement
- Review each error case
- Review each edge case
- Identify extra features not in spec
- Calculate compliance score
- Generate detailed review report
- Make recommendations
- Trigger evolution if deviations found
Example Output
# Code Review: User Profile Update API
**Spec:** specs/features/user-profile-api.md
**Date:** 2025-11-10
**Reviewer:** Claude (sdd:review-code)
## Compliance Summary
**Overall Score: 94%**
- Functional Requirements: 6/6 (100%)
- Error Handling: 4/4 (100%)
- Edge Cases: 3/3 (100%)
- Non-Functional: 2/3 (67%)
## Detailed Review
### Functional Requirements
#### ✓ Requirement 1: PUT endpoint accepts requests
**Implementation:** src/api/users/profile.ts:12
**Status:** Compliant
**Notes:** Route correctly configured at PUT /api/users/:id/profile
#### ✓ Requirement 2: Validates request body
**Implementation:** src/middleware/validation/profile.ts:5
**Status:** Compliant
**Notes:** All validations match spec (name 2-50, bio max 500, avatar_url URL)
[... all ✓ ...]
### Error Handling
#### ✓ Error: Missing/Invalid JWT
**Implementation:** src/middleware/auth.ts:22
**Status:** Compliant
**Spec Expected:** 401 with "Authentication required"
**Actual:** 401 with "Authentication required" ✓
[... all ✓ ...]
### Non-Functional Requirements
#### ✗ Performance: Response time < 200ms
**Status:** Not Verified
**Issue:** No performance testing implemented
**Impact:** Minor (likely meets requirement but unverified)
**Recommendation:** Add performance test or update spec to remove specific timing
### Extra Features (Not in Spec)
#### Updated timestamp in response
**Location:** src/api/users/profile.ts:45
**Description:** Adds `updated_at` timestamp to response object
**Assessment:** Helpful - standard practice for update endpoints
**Recommendation:** Add to spec (minor addition)
## Recommendations
### Spec Evolution Candidates
- [ ] Add `updated_at` field to response spec (minor addition)
- [ ] Remove specific performance timing or add perf tests
## Conclusion
Code implementation is 94% compliant with spec. All functional requirements and error handling correctly implemented. One non-functional requirement unverified and one helpful feature added beyond spec.
**Next Steps:**
Use `sdd:evolve` to update spec with:
1. `updated_at` field (minor addition)
2. Clarify performance requirement (remove specific timing or add test)
After spec evolution, compliance will be 100%.
Assessment Criteria
Compliant (✓)
- Code does exactly what spec says
- No deviations in behavior
- All aspects covered
Minor Deviation (⚠)
- Small differences (naming, details)
- Non-breaking additions
- Better error messages than spec
- Typically → Update spec
Major Deviation (✗)
- Different behavior than spec
- Missing functionality
- Wrong error handling
- Typically → Fix code or evolve spec
Missing (?)
- Spec requires it, code doesn't have it
- Critical gap
- Must fix code
Remember
Spec compliance is primary concern.
This is not just code quality review - it's spec validation.
- Does code match spec? (Most important)
- Is code quality good? (Secondary)
- Any improvements? (Tertiary)
100% compliance is the goal.
- < 90%: Significant issues, fix before proceeding
- 90-99%: Minor deviations, likely spec updates
- 100%: Perfect compliance, ready for verification
Deviations trigger evolution.
- Don't force-fit wrong spec
- Don't ignore deviations
- Use
sdd:evolveto reconcile
The code and spec must tell the same story.
快速安装
/plugin add https://github.com/rhuss/cc-superpowers-sdd/tree/main/review-code在 Claude Code 中复制并粘贴此命令以安装该技能
GitHub 仓库
相关推荐技能
llamaguard
其他LlamaGuard是Meta推出的7-8B参数内容审核模型,专门用于过滤LLM的输入和输出内容。它能检测六大安全风险类别(暴力/仇恨、性内容、武器、违禁品、自残、犯罪计划),准确率达94-95%。开发者可通过HuggingFace、vLLM或Sagemaker快速部署,并能与NeMo Guardrails集成实现自动化安全防护。
sglang
元SGLang是一个专为LLM设计的高性能推理框架,特别适用于需要结构化输出的场景。它通过RadixAttention前缀缓存技术,在处理JSON、正则表达式、工具调用等具有重复前缀的复杂工作流时,能实现极速生成。如果你正在构建智能体或多轮对话系统,并追求远超vLLM的推理性能,SGLang是理想选择。
evaluating-llms-harness
测试该Skill通过60+个学术基准测试(如MMLU、GSM8K等)评估大语言模型质量,适用于模型对比、学术研究及训练进度追踪。它支持HuggingFace、vLLM和API接口,被EleutherAI等行业领先机构广泛采用。开发者可通过简单命令行快速对模型进行多任务批量评估。
langchain
元LangChain是一个用于构建LLM应用程序的框架,支持智能体、链和RAG应用开发。它提供多模型提供商支持、500+工具集成、记忆管理和向量检索等核心功能。开发者可用它快速构建聊天机器人、问答系统和自主代理,适用于从原型验证到生产部署的全流程。
