From xpowers
Verifies completed implementation against epic spec, checking all success criteria and anti-patterns before claiming work is done.
How this skill is triggered — by the user, by Claude, or both
Slash command
/xpowers:review-implementationThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
<skill_overview>
<skill_overview> Review completed implementation against the epic spec to catch gaps before claiming completion; the spec is the contract, and implementation must fulfill it completely. </skill_overview>
<rigidity_level> LOW FREEDOM - Follow the 4-step review process exactly. Review with Google Fellow-level scrutiny. Never skip automated checks, quality gates, or code reading. No approval without evidence for every criterion. </rigidity_level>
<evidence_requirements>
Every claim requires evidence:
| Claim Type | Required Evidence |
|---|---|
| "Code implements X" | File path:line number showing implementation |
| "Test covers Y" | Test name + specific assertion |
| "Criterion met" | Command output proving criterion |
| "No anti-pattern" | Search command showing no matches |
Confidence Scores:
Rate each finding 0.0-1.0:
Findings below 0.8 confidence must be investigated until ≥0.8 or marked UNCERTAIN.
Example evidence format:
| Criterion | Status | Confidence | Evidence |
|-----------|--------|------------|----------|
| All tests pass | ✅ Met | 1.0 | `cargo test`: 127 passed, 0 failed |
| No unwrap in production | ❌ Not met | 1.0 | `rg "\.unwrap\(\)" src/`: Found at jwt.ts:45 |
| Error handling proper | ⚠️ Uncertain | 0.5 | Read jwt.ts, unclear if all paths covered |
</evidence_requirements>
<quick_reference>
| Step | Action | Deliverable |
|---|---|---|
| 1 | Load bd epic + all tasks | TodoWrite with tasks to review |
| 2 | Review each task (automated checks, quality gates, read code, audit tests, verify criteria) | Findings per task |
| 3 | Report findings (approved / gaps found) | Review decision |
| 4 | Gate: If approved → finishing-a-development-branch, If gaps → STOP | Next action |
Review Perspective: Google Fellow-level SRE with 20+ years experience reviewing junior engineer code.
Test Quality Gate: Every new test must catch a real bug. Tautological tests (pass by definition, test mocks, verify compiler-checked facts) = GAPS FOUND. </quick_reference>
<when_to_use>
Don't use for:
<the_process>
Announce: "I'm using xpowers:review-implementation to verify implementation matches spec. Reviewing with Google Fellow-level scrutiny."
Get epic and tasks:
tm show bd-1 # Epic specification
tm dep tree bd-1 # Task tree
tm list --parent bd-1 # All tasks
Create TodoWrite tracker:
TodoWrite todos:
- Review bd-2: Task Name
- Review bd-3: Task Name
- Review bd-4: Task Name
- Compile findings and make decision
For each task:
tm show bd-3
Extract:
# TODOs/FIXMEs without issue numbers
rg -i "todo|fixme" src/ tests/ || echo "✅ None"
# Stub implementations
rg "unimplemented!|todo!|unreachable!|panic!\(\"not implemented" src/ || echo "✅ None"
# Unsafe patterns in production
rg "\.unwrap\(\)|\.expect\(" src/ | grep -v "/tests/" || echo "✅ None"
# Ignored/skipped tests
rg "#\[ignore\]|#\[skip\]|\.skip\(\)" tests/ src/ || echo "✅ None"
Context: After refactoring, old code must be REMOVED, not kept as fallback. The canonical implementation is the new one. Old code is dead code.
Key principle: "Don't bother with unused code. Delete it before you try to improve anything."
Automated detection patterns:
# 1. Fallback/Legacy Code Detection
# Patterns indicating old code left behind:
rg -i "fallback|legacy|old_|_old|deprecated|obsolete" src/ || echo "✅ None"
# Conditional using old implementation:
rg -i "if.*use.*old|if.*legacy|if.*fallback|ENABLE_OLD|USE_LEGACY|FALLBACK_TO" src/ || echo "✅ None"
# "was:" or "previously:" comments (describing removed behavior):
rg -i "was:|previously:|used to|before refactor" src/ || echo "✅ None"
# 2. Unused Code Detection (Language-Specific)
# Rust - dead code warnings:
cargo build 2>&1 | grep -E "warning.*never used|warning.*dead_code" || echo "✅ None"
# TypeScript/JavaScript - unused exports (if eslint configured):
npx eslint --rule 'no-unused-vars: error' src/ 2>/dev/null || echo "Check manually"
# Swift - unused variables (SwiftLint):
swiftlint lint --reporter json 2>/dev/null | jq '.[] | select(.rule_id == "unused")' || echo "Check manually"
# Python - vulture if available:
vulture src/ --min-confidence 80 2>/dev/null || echo "vulture not installed, check manually"
# 3. Orphaned Tests Detection
# Find tests that reference functions/classes that no longer exist:
git diff main...HEAD --name-only | grep -E "(test|spec)" || echo "No test files changed"
# 4. Deprecation Remnants (should be REMOVED, not marked):
rg "@deprecated|#\[deprecated\]|// deprecated|DEPRECATED|@Deprecated" src/ || echo "✅ None"
# 5. Backwards Compatibility Shims (unless external API):
rg -i "backward.*compat|legacy.*support|shim|polyfill" src/ || echo "✅ None"
If any patterns found, investigate:
Dead Code Audit Results Template:
#### Dead Code Audit Results
| Category | Pattern | Found | Location | Action |
|----------|---------|-------|----------|--------|
| Fallback code | `legacy\|old_\|fallback` | 0 | - | ✅ None |
| Unused functions | compiler warnings | 0 | - | ✅ None |
| Deprecation markers | `@deprecated` | 0 | - | ✅ None |
| Orphaned tests | tests for removed code | 0 | - | ✅ None |
| Backwards compat shims | `shim\|polyfill` | 0 | - | ✅ None |
**Verdict:** ✅ No dead code / ❌ Dead code found - refactoring incomplete
If dead code found: This is a GAP. Old code after refactoring = incomplete refactoring.
IMPORTANT: Use xpowers:test-runner agent to avoid context pollution.
Dispatch xpowers:test-runner: "Run: cargo test"
Dispatch xpowers:test-runner: "Run: cargo fmt --check"
Dispatch xpowers:test-runner: "Run: cargo clippy -- -D warnings"
Dispatch xpowers:test-runner: "Run: .git/hooks/pre-commit"
CRITICAL: READ actual files, not just git diff.
# See changes
git diff main...HEAD -- src/auth/jwt.ts
# THEN READ FULL FILE
Read tool: src/auth/jwt.ts
While reading, check:
Assume code written by junior engineer. Apply production-grade scrutiny.
Error Handling:
Safety:
Clarity:
Testing (CRITICAL - Apply strict scrutiny):
Production Readiness:
CRITICAL: Review every new/modified test for meaningfulness. Tautological tests are WORSE than no tests - they give false confidence.
For each test, ask:
expect(result != nil) is weaker than expect(result == expectedValue)Red flags (REJECT implementation until fixed):
expect(builder.build() != nil) when build() can't return nil)Examples of meaningless tests to reject:
// ❌ REJECT: Tautological - compiler ensures enum has cases
func testEnumHasCases() {
_ = MyEnum.caseOne // This proves nothing
_ = MyEnum.caseTwo
}
// ❌ REJECT: Tautological - build() returns non-optional, can't be nil
func testBuilderReturnsValue() {
let result = Builder().build()
#expect(result != nil) // Always passes by type system
}
// ❌ REJECT: Tests mock, not production code
func testServiceCallsAPI() {
let mock = MockAPI()
let service = Service(api: mock)
service.fetchData()
#expect(mock.fetchCalled) // Tests mock behavior, not real logic
}
// ❌ REJECT: Happy path only, no edge cases
func testCodable() {
let original = User(name: "John", age: 30)
let data = try! encoder.encode(original)
let decoded = try! decoder.decode(User.self, from: data)
#expect(decoded == original) // What about empty name? Max age? Unicode?
}
Examples of meaningful tests to approve:
// ✅ APPROVE: Catches missing validation bug
func testEmptyPayloadReturnsValidationError() {
let result = validator.validate(payload: "")
#expect(result == .error(.emptyPayload))
}
// ✅ APPROVE: Catches race condition bug
func testConcurrentWritesDontCorruptData() {
let store = ThreadSafeStore()
DispatchQueue.concurrentPerform(iterations: 1000) { i in
store.write(key: "k\(i)", value: i)
}
#expect(store.count == 1000) // Would fail if race condition exists
}
// ✅ APPROVE: Catches error handling bug
func testMalformedJSONReturns400Not500() {
let response = api.parse(json: "{invalid")
#expect(response.status == 400) // Not 500 which would indicate unhandled exception
}
// ✅ APPROVE: Catches encoding bug with edge case
func testUnicodeNamePreservedAfterRoundtrip() {
let original = User(name: "日本語テスト 🎉")
let decoded = roundtrip(original)
#expect(decoded.name == original.name)
}
Audit process:
# Find all new/modified test files
git diff main...HEAD --name-only | grep -E "(test|spec)"
# Read each test file
Read tool: tests/new_feature_test.swift
# For EACH test function, document:
# - Test name
# - What bug it catches (or "TAUTOLOGICAL" if none)
# - Verdict: ✅ Keep / ⚠️ Strengthen / ❌ Remove/Replace
If tautological tests found:
## Test Quality Audit: GAPS FOUND ❌
### Tautological/Meaningless Tests
| Test | Problem | Action |
|------|---------|--------|
| testEnumHasCases | Compiler already ensures this | ❌ Remove |
| testBuilderReturns | Non-optional return, can't be nil | ❌ Remove |
| testCodable | Happy path only, no edge cases | ⚠️ Add: empty, unicode, max values |
| testServiceCalls | Tests mock, not production | ❌ Replace with integration test |
**Cannot approve until tests are meaningful.**
For EACH criterion in bd task:
Example:
Criterion: "All tests passing"
Command: cargo test
Evidence: "127 tests passed, 0 failures"
Result: ✅ Met
Criterion: "No unwrap in production"
Command: rg "\.unwrap\(\)" src/
Evidence: "No matches"
Result: ✅ Met
Search for each prohibited pattern from bd task:
# Example anti-patterns from task
rg "\.unwrap\(\)" src/ # If task prohibits unwrap
rg "TODO" src/ # If task prohibits untracked TODOs
rg "\.skip\(\)" tests/ # If task prohibits skipped tests
Read code to confirm edge cases handled:
Example: Task says "Must handle empty payload" → Find validation code for empty payload.
### Task: bd-3 - Implement JWT authentication
#### Evidence-Based Findings
| Criterion | Status | Confidence | Evidence |
|-----------|--------|------------|----------|
| All tests pass | ✅ Met | 1.0 | `cargo test`: 127 passed |
| Pre-commit passes | ❌ Not met | 1.0 | `cargo clippy`: 3 warnings |
| No unwrap in production | ❌ Not met | 1.0 | `rg "\.unwrap()"`: src/auth/jwt.ts:45 |
#### File Evidence
| File | Line | What Verified | Confidence |
|------|------|---------------|------------|
| src/auth/jwt.ts | 45 | unwrap violation | 1.0 |
| src/auth/jwt.ts | 12-30 | token generation logic | 0.9 |
**Findings below 0.8:** None (all verified)
#### Automated Checks
- TODOs: ✅ None
- Stubs: ✅ None
- Unsafe patterns: ❌ Found `.unwrap()` at src/auth/jwt.ts:45
- Ignored tests: ✅ None
#### Quality Gates
- Tests: ✅ Pass (127 tests)
- Formatting: ✅ Pass
- Linting: ❌ 3 warnings
- Pre-commit: ❌ Fails due to linting
#### Files Reviewed
- src/auth/jwt.ts: ⚠️ Contains `.unwrap()` at line 45
- tests/auth/jwt_test.rs: ✅ Complete
#### Code Quality
- Error Handling: ⚠️ Uses unwrap instead of proper error propagation
- Safety: ✅ Good
- Clarity: ✅ Good
- Testing: See Test Quality Audit below
#### Test Quality Audit (New/Modified Tests)
| Test | Bug It Catches | Verdict |
|------|----------------|---------|
| test_valid_token_accepted | Missing validation | ✅ Keep |
| test_expired_token_rejected | Expiration bypass | ✅ Keep |
| test_jwt_struct_exists | Nothing (tautological) | ❌ Remove |
| test_encode_decode | Encoding bug (but happy path only) | ⚠️ Add edge cases |
**Tautological tests found:** 1 (test_jwt_struct_exists)
**Weak tests found:** 1 (test_encode_decode needs edge cases)
#### Anti-Patterns
- "NO unwrap in production": ❌ Violated at src/auth/jwt.ts:45
#### Issues
**Critical:**
1. unwrap() at jwt.ts:45 - violates anti-pattern, must use proper error handling
2. Tautological test: test_jwt_struct_exists must be removed
**Important:**
3. 3 clippy warnings block pre-commit hook
4. test_encode_decode needs edge cases (empty, unicode, max length)
After reviewing ALL tasks:
If NO gaps:
## Implementation Review: APPROVED ✅
Reviewed bd-1 (OAuth Authentication) against implementation.
### Tasks Reviewed
- bd-2: Configure OAuth provider ✅
- bd-3: Implement token exchange ✅
- bd-4: Add refresh logic ✅
### Verification Summary
- All success criteria verified
- No anti-patterns detected
- All key considerations addressed
- All files implemented per spec
### Evidence
- Tests: 127 passed, 0 failures (2.3s)
- Linting: No warnings
- Pre-commit: Pass
- Code review: Production-ready
Ready to proceed to xpowers:finishing-a-development-branch.
If gaps found:
## Implementation Review: GAPS FOUND ❌
Reviewed bd-1 (OAuth Authentication) against implementation.
### Tasks with Gaps
#### bd-3: Implement token exchange
**Gaps:**
- ❌ Success criterion not met: "Pre-commit hooks pass"
- Evidence: cargo clippy shows 3 warnings
- ❌ Anti-pattern violation: Found `.unwrap()` at src/auth/jwt.ts:45
- ⚠️ Key consideration not addressed: "Empty payload validation"
- No check for empty payload in generateToken()
#### bd-4: Add refresh logic
**Gaps:**
- ❌ Success criterion not met: "All tests passing"
- Evidence: test_verify_expired_token failing
### Cannot Proceed
Implementation does not match spec. Fix gaps before completing.
If APPROVED:
Announce: "I'm using xpowers:finishing-a-development-branch to complete this work."
Use Skill tool: xpowers:finishing-a-development-branch
If GAPS FOUND:
STOP. Do not proceed to finishing-a-development-branch.
Fix gaps or discuss with partner.
Re-run review after fixes.
</the_process>
Developer only checks git diff, doesn't read actual files
# Review process
git diff main...HEAD # Shows changes
Developer sees:
- function generateToken(payload) {
- return jwt.sign(payload, secret);
- }
Approves based on diff
"Looks good, token generation implemented ✅"
Misses: Full context shows no validation
function generateToken(payload) {
// No validation of payload!
// No check for empty payload (key consideration)
// No error handling if jwt.sign fails
return jwt.sign(payload, secret);
}
<why_it_fails>
# See changes
git diff main...HEAD -- src/auth/jwt.ts
# THEN READ FULL FILE
Read tool: src/auth/jwt.ts
Reading full file reveals:
function generateToken(payload) {
// Missing: empty payload check (key consideration from bd task)
// Missing: error handling for jwt.sign failure
return jwt.sign(payload, secret);
}
Record in findings:
⚠️ Key consideration not addressed: "Empty payload validation"
- No check for empty payload in generateToken()
- Code at src/auth/jwt.ts:15-17
⚠️ Error handling: jwt.sign can throw, not handled
What you gain:
# Run tests
cargo test
# Output: 127 tests passed
Developer concludes
"Tests pass, implementation complete ✅"
Proceeds to finishing-a-development-branch
Misses:
- bd task has 5 success criteria
- Only checked 1 (tests pass)
- Anti-pattern: unwrap() present (prohibited)
- Key consideration: Unicode handling not tested
Linter has warnings (blocks pre-commit)
<why_it_fails>
bd task has 5 success criteria:
1. "All tests pass" ✅ - Evidence: 127 passed
2. "Pre-commit passes" ❌ - Evidence: clippy warns (3 warnings)
3. "No unwrap in production" ❌ - Evidence: Found at jwt.ts:45
4. "Unicode handling tested" ⚠️ - Need to verify test exists
5. "Rate limiting implemented" ⚠️ - Need to check code
Result: 1/5 criteria verified met. GAPS EXIST.
Run additional checks:
# Check criterion 2
cargo clippy
# 3 warnings found ❌
# Check criterion 3
rg "\.unwrap\(\)" src/
# src/auth/jwt.ts:45 ❌
# Check criterion 4
rg "unicode" tests/
# No matches ⚠️ Need to verify
Decision: GAPS FOUND, cannot proceed
What you gain:
bd task: "Add logging to error paths"
Developer thinks: "Simple task, just added console.log"
Skips:
- Automated checks (assumes no issues)
- Code quality review (seems obvious)
- Full success criteria verification
Approves quickly:
"Logging added ✅"
Misses:
- console.log used instead of proper logger (anti-pattern)
- Only added to 2 of 5 error paths (incomplete)
- No test verifying logs actually output (criterion)
Logs contain sensitive data (security issue)
<why_it_fails>
# Automated checks
rg "console\.log" src/
# Found at error-handler.ts:12, 15 ⚠️
# Read bd task
tm show bd-5
# Success criteria:
# 1. "All error paths logged"
# 2. "No sensitive data in logs"
# 3. "Test verifies log output"
# Check criterion 1
grep -n "throw new Error" src/
# 5 locations found
# Only 2 have logging ❌ Incomplete
# Check criterion 2
Read tool: src/error-handler.ts
# Logs contain password field ❌ Security issue
# Check criterion 3
rg "test.*log" tests/
# No matches ❌ Test missing
Decision: GAPS FOUND
What you gain:
# Test results show good coverage
cargo test
# 45 tests passed ✅
# Coverage: 92% ✅
Developer approves based on numbers
"Tests pass with 92% coverage, implementation complete ✅"
Proceeds to finishing-a-development-branch
Later in production:
- Validation bypassed because test only checked "validator exists"
- Race condition because test only checked "lock was acquired"
- Encoding corruption because test only checked "encode != nil"
<why_it_fails>
expect(validator != nil) - always passes, doesn't test validation logicexpect(lock.acquire()) - tests mock, not thread safetyexpect(encoded.count > 0) - tests non-empty, not correctness# Find new tests
git diff main...HEAD --name-only | grep test
# Read and audit each test
Read tool: tests/validator_test.swift
For each test, document:
#### Test Quality Audit
| Test | Assertion | Bug Caught? | Verdict |
|------|-----------|-------------|---------|
| testValidatorExists | `!= nil` | ❌ None (compiler checks) | ❌ Remove |
| testValidInput | `isValid == true` | ⚠️ Happy path only | ⚠️ Add edge cases |
| testEmptyInputFails | `isValid == false` | ✅ Missing validation | ✅ Keep |
| testLockAcquired | mock.acquireCalled | ❌ Tests mock | ❌ Replace |
| testConcurrentAccess | count == expected | ✅ Race condition | ✅ Keep |
| testEncodeNotNil | `!= nil` | ❌ Type guarantees this | ❌ Remove |
| testUnicodeRoundtrip | decoded == original | ✅ Encoding corruption | ✅ Keep |
**Tautological tests:** 3 (must remove)
**Weak tests:** 1 (must strengthen)
**Meaningful tests:** 3 (keep)
Decision: GAPS FOUND ❌
## Test Quality Audit: GAPS FOUND
### Tautological Tests (Must Remove)
- testValidatorExists: Compiler ensures non-nil, test proves nothing
- testLockAcquired: Tests mock behavior, not actual thread safety
- testEncodeNotNil: Return type is non-optional, can never be nil
### Weak Tests (Must Strengthen)
- testValidInput: Only happy path, add:
- testEmptyStringRejected
- testMaxLengthRejected
- testUnicodeNormalized
### Action Required
Remove 3 tautological tests, add 3 edge case tests, then re-review.
What you gain:
# After refactoring auth system:
git diff shows:
+ function authenticateV2(token) { ... } # New implementation
function authenticate(token) { ... } # Old still exists!
function authenticateLegacy(token) { ... } # Even older!
In config:
const USE_LEGACY_AUTH = process.env.LEGACY_AUTH ?? true
Developer claims: "Refactoring complete"
<why_it_fails>
# Fallback patterns
rg -i "legacy|old_|fallback" src/
# Found: authenticateLegacy, USE_LEGACY_AUTH ❌
# Check callers
rg "authenticate\(" src/ --type ts
# authenticate: 0 callers ❌ DEAD
# authenticateLegacy: 0 callers ❌ DEAD
# authenticateV2: 15 callers ✅ ACTIVE
Dead Code Audit Results:
| Category | Pattern | Found | Location | Action |
|---|---|---|---|---|
| Fallback code | legacy|fallback | 2 | auth.ts:45,89 | ❌ Delete |
| Unused functions | no callers | 2 | authenticate(), authenticateLegacy() | ❌ Delete |
| Feature flags | USE_LEGACY | 1 | config.ts:12 | ❌ Delete |
Decision: GAPS FOUND ❌
## Dead Code Audit: GAPS FOUND
### Refactoring Remnants
- authenticate() at auth.ts:12 - 0 callers, delete
- authenticateLegacy() at auth.ts:45 - 0 callers, delete
- USE_LEGACY_AUTH flag at config.ts:12 - enables dead code, delete
### Required Actions
1. Delete authenticate() - replaced by authenticateV2()
2. Delete authenticateLegacy() - obsolete
3. Delete USE_LEGACY_AUTH flag - no longer needed
4. Rename authenticateV2() to authenticate() (cleaner API)
5. Update/delete tests for removed functions
**Cannot approve until old code is removed.**
What you gain:
<critical_rules>
All of these mean: STOP. Follow full review process.
</critical_rules>
<verification_checklist> Before approving implementation:
Per task:
Overall:
Can't check all boxes? Return to Step 2 and complete review. </verification_checklist>
**This skill is called by:** - xpowers:executing-plans (Step 5, after all tasks executed)This skill calls:
This skill uses:
Call chain:
xpowers:executing-plans → xpowers:review-implementation → xpowers:finishing-a-development-branch
↓
(if gaps: STOP)
CRITICAL: Use tm commands (tm show, tm list, tm dep tree), never read .beads/issues.jsonl directly.
When stuck:
npx claudepluginhub dpolishuk/xpowers --plugin xpowersVerifies code implementations match specs, PRDs, epics, or tasks by checking completeness, acceptance criteria, edge cases, and scope creep. Use post- or during-implementation.
Verifies implementation in task directory against plan.md, acceptance checks, and anti-goals using evidence from files and commands. Use after execution, before claiming completion or deleting directory.
Reviews implementation against spec requirements and code quality standards using a two-pass workflow. Useful for validating task completion.