
reedom-quick-refactor
Post-implementation review and refactoring with specialized multi-agent architecture
Install
/plugin install reedom-quick-refactor@reedom-commands-and-skillsRun it inside Claude Code after adding the marketplace with /plugin marketplace add reedom/claude-code-commands.
Contents
Discovered from sourceSkills 1
Skill for collecting files to review: runs git diff against target branch, merges explicit files, categorizes by type.
Arguments
| Arg | Default | Description |
|---|---|---|
--against | origin/main | Target branch for diff comparison |
--files | (none) | Comma-separated explicit file paths |
Workflow
1. Collect File Info
Run:
${CLAUDE_PLUGIN_ROOT}/skills/collect-commits-and-files/scripts/collect-info.sh --against <branch> --files <paths>
Returns JSON manifest:
{
"temp_dir": "<git-root>/.tmp/quick-refactor-XXXXXX",
"repo_root": "/path/to/repo",
"against_branch": "origin/main",
"paths": {
"diff_dir": "<temp_dir>/diff",
"files_dir": "<temp_dir>/files",
"reviews_dir": "<temp_dir>/reviews"
},
"summary": {
"total_files": 10,
"source": 6,
"test": 2,
"config": 1,
"docs": 1
},
"project_rules": ["/path/to/CLAUDE.md", "/path/to/.kiro/steering.md"]
}
2. Handle Errors
If script returns error, report to caller:
{"error": "No files to review", "error_code": "NO_FILES"}
Error codes:
NOT_GIT_REPO: Not in a git repositoryBRANCH_NOT_FOUND: Target branch does not existNO_FILES: No files found to reviewNO_EXISTING_FILES: All files are deleted
3. Temp Directory Structure
The script creates temp directory at <git-root>/.tmp/ (falls back to system temp):
<git-root>/.tmp/
├── .gitignore # Contains `*` to ignore all temp files
└── quick-refactor-XXXXXX/
├── diff/ # Individual file diffs
│ └── <md5hash>.diff
├── files/ # File paths by category (JSON arrays)
│ ├── source.json # ["path/to/file1.ts", "path/to/file2.ts"]
│ ├── test.json
│ ├── config.json
│ └── docs.json
└── reviews/ # Empty, for review agent outputs
4. Cleanup
After processing is complete, run:
${CLAUDE_PLUGIN_ROOT}/skills/collect-commits-and-files/scripts/cleanup.sh <temp_dir>
File Categories
| Category | Description | Example patterns |
|---|---|---|
| source | Source code files | *.ts, *.py, *.go |
| test | Test files | *_test.go, *.spec.ts, tests/ |
| config | Configuration | *.yaml, .eslintrc, .github/ |
| docs | Documentation | *.md, docs/ |
Return Value
Return the manifest JSON directly. Orchestrator uses this to:
- Read file lists from
paths.files_dir - Route to appropriate review agents based on
summarycounts - Store review outputs in
paths.reviews_dir - Clean up
temp_diron completion
Commands 1
Post-implementation review and refactoring. Spawns specialized reviewer agents in parallel, evaluates findings, then applies refactorings sequentially.
Arguments
| Flag | Default | Description |
|---|---|---|
--against, -a | origin/main | Target branch for diff comparison |
--files, -f | (none) | Comma-separated file paths to review |
--commit, -c | false | Commit after each successful refactoring |
--cleanup | false | Remove temp directory after completion (preserved by default) |
Workflow
Step 0: Create Todos
Create todo list to track progress:
1. [if --commit] Pre-review: commit uncommitted files
2. Phase 1: Collect files
3. Phase 2: Run parallel reviews
4. Phase 3: Evaluate findings
5. Phase 4: Process accepted findings
6. [if --cleanup] Cleanup temp directory
7. Report summary
Step 1: Pre-Review (if --commit)
If --commit flag is set:
- Run
git status --porcelain - If non-empty output: invoke
Skill(reedom-git:smart-commit)
Step 2: Phase 1 - Collection
Invoke the collection skill:
Skill(reedom-quick-refactor:collect-commits-and-files) --against=<branch> --files=<paths>
Store from response:
temp_dir: Base temporary directorypaths.files_dir: Directory containing file listspaths.reviews_dir: Directory for review outputssummary: File count summary
Step 3: Phase 2 - Parallel Review
-
Read JSON files from
files_dir:source.json: Source file listtest.json: Test file listconfig.json: Config file list
-
Spawn reviewer agents (max 2 concurrent) using Task tool:
| Agent | Condition |
|---|---|
reedom-quick-refactor:security-reviewer | 0 < source count |
reedom-quick-refactor:project-rules-reviewer | 0 < total count |
reedom-quick-refactor:redundancy-reviewer | 0 < source + test count |
reedom-quick-refactor:code-quality-reviewer | 0 < source count |
reedom-quick-refactor:test-quality-reviewer | 0 < test count |
reedom-quick-refactor:performance-reviewer | 0 < source count |
- Spawn first batch (2 agents) with
run_in_background: true:
Task(
subagent_type: "reedom-quick-refactor:security-reviewer",
prompt: "temp_dir=<path>",
run_in_background: true
)
Task(
subagent_type: "reedom-quick-refactor:project-rules-reviewer",
prompt: "temp_dir=<path>",
run_in_background: true
)
- Wait for batch completion with
TaskOutput, then spawn next batch of 2 - Continue until all applicable reviewers complete
Step 4: Phase 3 - Evaluate Findings
Spawn finding-evaluator agent:
Task(
subagent_type: "reedom-quick-refactor:finding-evaluator",
prompt: "temp_dir=<path>"
)
The agent:
- Reads all review JSON files from
reviews_dir - Filters findings by acceptance criteria:
- Accept if
auto_fixable= true (quick wins) - Accept if
score>= 70 ANDseverityin [high, medium] - Reject otherwise
- Accept if
- Writes
decisions.jsonto temp directory - Reports summary counts
Step 5: Phase 4 - Process Accepted Findings (MANDATORY)
Execute even if no accepted findings.
- Read
<temp_dir>/decisions.json - For each finding in
acceptedarray, spawn refactorer sequentially:
Task(
subagent_type: "reedom-quick-refactor:refactorer",
prompt: "finding={...} commit=true|false"
)
Wait for each refactorer to complete before spawning next.
- If no accepted findings: log "No findings to refactor"
Step 6: Cleanup (if --cleanup)
Only if --cleanup flag is set, run cleanup script:
${CLAUDE_PLUGIN_ROOT}/skills/collect-commits-and-files/scripts/cleanup.sh <temp_dir>
If --cleanup is not set:
- Keep temp directory for user review
- Log temp directory path: "Review results preserved at: <temp_dir>"
Step 7: Report Summary
Output final summary:
{
"files_reviewed": N,
"reviews": {
"security": {"findings": N},
"project-rules": {"findings": N},
...
},
"evaluation": {
"total": N,
"accepted": N,
"rejected": N
},
"refactorings": {
"applied": N,
"skipped": N,
"failed": N
},
"temp_dir": "<path>"
}
Include temp_dir in summary so user knows where to find review results.
Review Categories
| Agent | Focus | Triggers |
|---|---|---|
| security-reviewer | Vulnerabilities, secrets, injection | Source files |
| project-rules-reviewer | CLAUDE.md, .kiro rules compliance | All files |
| redundancy-reviewer | DRY violations, duplicate logic | Source + test files |
| code-quality-reviewer | Complexity, readability, SRP | Source files |
| test-quality-reviewer | Meaningless tests, coverage gaps | Test files only |
| performance-reviewer | N+1 queries, memory leaks | Source files |
Agents 8
Code quality reviewer. Analyzes maintainability, complexity, and adherence to clean code principles.
Input
Parse from prompt:
temp_dir: Path to temp directorybatch: Batch numberfiles: Comma-separated file paths to review
Focus Areas
High Severity
- Functions exceeding complexity thresholds (cyclomatic complexity > 10)
- God classes/functions doing too much
- Deeply nested logic (> 3 levels)
- Missing error handling for critical operations
Medium Severity
- Functions too long (> 30 lines)
- Poor naming (unclear intent)
- Mixed abstraction levels
- Tight coupling between modules
- SRP violations
Low Severity
- Minor readability improvements
- Suboptimal variable naming
- Missing type annotations
- Opportunities for more idiomatic code
Workflow
- Read each file from
fileslist - Analyze for:
- Cyclomatic complexity
- Function/method length
- Nesting depth
- Coupling indicators
- Naming clarity
- Identify improvement opportunities
- Write JSON report to
<temp_dir>/reviews/code-quality.json
Output Schema
Write to <temp_dir>/reviews/code-quality.json:
{
"reviewer": "code-quality-reviewer",
"batch": 1,
"findings": [
{
"id": "CQ-001",
"file": "src/services/order.ts",
"line": 120,
"code_snippet": "function processOrder(order: Order) {\n if (order.items.length > 0) {\n if (order.customer) {\n if (order.customer.verified) {",
"severity": "high",
"score": 90,
"category": "complexity",
"description": "Deeply nested conditionals reduce readability",
"why": "4 levels of nesting make logic hard to follow and maintain. Each level adds cognitive load for developers",
"suggestion": "Use guard clauses with early returns: if (order.items.length === 0) return; if (!order.customer) return; if (!order.customer.verified) return;",
"auto_fixable": true
}
],
"summary": {
"total": 1,
"high": 1,
"medium": 0,
"low": 0
}
}
Field Definitions
| Field | Description |
|---|---|
id | Unique finding ID: CQ-NNN |
file | Relative file path |
line | Line number |
code_snippet | Code showing the issue |
severity | high, medium, or low |
score | Confidence 0-100 |
category | complexity, naming, coupling, srp, readability |
description | Brief description |
why | Impact on maintainability |
suggestion | Concrete improvement |
auto_fixable | true if can be refactored automatically |
Complexity Heuristics
- Cyclomatic complexity: Count branches (if, else, switch, loops, ternary)
- Nesting depth: Count indentation levels from function start
- Function length: Count logical lines (exclude blanks, comments)
- Coupling: Count external dependencies and shared state
Rules
- Focus on impactful improvements, not nitpicks
- Suggestions must be concrete and actionable
- Consider language idioms when suggesting improvements
- Don't suggest changes that would alter behavior
- Guard clause refactoring is usually safe and auto-fixable
Finding evaluator agent. Reads review outputs and filters findings for refactoring.
Input
Parse from prompt:
temp_dir: Path to the quick-refactor temp directory
Workflow
1. Read Review Files
Read all JSON files from <temp_dir>/reviews/:
security.jsonproject-rules.jsonredundancy.jsoncode-quality.jsontest-quality.jsonperformance.json
Use Glob to find all *.json files in reviews directory.
2. Evaluate Each Finding
For each finding, apply acceptance criteria:
Accept if ANY of:
auto_fixableis true (quick win)score>= 70 ANDseverityin ["high", "medium"]
Reject if:
- Does not meet any acceptance criteria
3. Record Decisions
For each finding, record:
id: Finding ID (e.g., "SEC-001")file: Target file pathreason: Why accepted or rejected
Acceptance reasons:
- "quick win: auto-fixable"
- "high confidence (score >= 70) and high severity"
- "high confidence (score >= 70) and medium severity"
Rejection reasons:
- "low confidence (score < 70)"
- "low severity"
- "low confidence and low severity"
4. Write Decisions
Write <temp_dir>/decisions.json:
{
"accepted": [
{
"id": "SEC-001",
"file": "src/auth/login.ts",
"reviewer": "security",
"reason": "high confidence (score >= 70) and high severity",
"finding": { ... }
}
],
"rejected": [
{
"id": "CQ-003",
"file": "src/utils/format.ts",
"reviewer": "code-quality",
"reason": "low severity",
"finding": { ... }
}
],
"summary": {
"total": 15,
"accepted": 8,
"rejected": 7,
"by_reviewer": {
"security": { "accepted": 2, "rejected": 0 },
"project-rules": { "accepted": 1, "rejected": 2 },
"code-quality": { "accepted": 3, "rejected": 3 },
"test-quality": { "accepted": 2, "rejected": 2 }
}
}
}
5. Report Summary
Output summary to conversation:
Finding Evaluation Complete
===========================
Total findings: 15
Accepted: 8
Rejected: 7
By reviewer:
- security: 2 accepted, 0 rejected
- project-rules: 1 accepted, 2 rejected
- code-quality: 3 accepted, 3 rejected
- test-quality: 2 accepted, 2 rejected
Decisions written to: <temp_dir>/decisions.json
Acceptance Criteria Details
| Criterion | Threshold | Rationale |
|---|---|---|
| auto_fixable | true | Low-risk automated fixes |
| score | >= 70 | High confidence findings |
| severity | high, medium | Impactful issues only |
Priority Order
When evaluating:
- Check
auto_fixablefirst (quick wins always accepted) - Then check score AND severity combination
Edge Cases
- Missing
auto_fixablefield: treat as false - Missing
scorefield: reject with reason "missing score" - Missing
severityfield: reject with reason "missing severity" - Empty reviews: write empty accepted/rejected arrays
Output Schema
The decisions.json file contains the full finding object in each entry, allowing the refactorer to process directly from this file.
Performance reviewer. Identifies efficiency issues and resource management problems.
Input
Parse from prompt:
temp_dir: Path to temp directorybatch: Batch numberfiles: Comma-separated file paths to review
Focus Areas
High Severity
- N+1 query patterns (database calls in loops)
- Memory leaks (unreleased resources, event listeners)
- Blocking I/O on main thread
- Unbounded data loading
Medium Severity
- Inefficient algorithms (O(n^2) when O(n) possible)
- Redundant computations in loops
- Missing caching opportunities
- Large object creation in hot paths
Low Severity
- Suboptimal data structures
- Minor loop inefficiencies
- Unnecessary object copies
Workflow
- Read each file from
fileslist - Analyze for:
- Database/API calls in loops
- Resource acquisition without release
- Algorithm complexity
- Memory allocation patterns
- Identify optimization opportunities
- Write JSON report to
<temp_dir>/reviews/performance.json
Output Schema
Write to <temp_dir>/reviews/performance.json:
{
"reviewer": "performance-reviewer",
"batch": 1,
"findings": [
{
"id": "PERF-001",
"file": "src/services/report.ts",
"line": 78,
"code_snippet": "for (const userId of userIds) {\n const user = await db.users.findById(userId);\n results.push(user);\n}",
"severity": "high",
"score": 95,
"category": "n-plus-one",
"description": "N+1 query pattern: database call inside loop",
"why": "For 100 userIds, this executes 100 separate database queries instead of 1. Each query has network overhead and connection pool cost",
"suggestion": "Batch query: const users = await db.users.findByIds(userIds);",
"estimated_impact": "100x reduction in database calls for typical usage",
"auto_fixable": true
}
],
"summary": {
"total": 1,
"high": 1,
"medium": 0,
"low": 0
}
}
Field Definitions
| Field | Description |
|---|---|
id | Unique finding ID: PERF-NNN |
file | Relative file path |
line | Line number |
code_snippet | Code with performance issue |
severity | high, medium, or low |
score | Confidence 0-100 |
category | n-plus-one, memory-leak, blocking-io, algorithm, allocation |
description | Brief description |
why | Performance impact explanation |
suggestion | Optimization approach |
estimated_impact | Expected improvement |
auto_fixable | true if safe to refactor automatically |
Patterns to Detect
- N+1:
awaitorfetchinsidefor/forEach/map - Memory leak:
addEventListenerwithoutremoveEventListener - Blocking I/O: Sync file operations (
readFileSync) - Unbounded: Missing pagination, loading all records
Rules
- Focus on measurable performance impact
estimated_impacthelps prioritize fixes- N+1 patterns are usually auto-fixable if batch API exists
- Memory leaks require understanding component lifecycle
- Don't micro-optimize; focus on algorithmic improvements
Project rules compliance reviewer. Checks adherence to documented conventions and guidelines.
Input
Parse from prompt:
temp_dir: Path to temp directorybatch: Batch numberfiles: Comma-separated file paths to reviewproject_rules: JSON array of rule file paths (from manifest)
Focus Areas
High Severity
- Direct violations of MUST/SHALL requirements
- Breaking architectural constraints
- Security rules violations
- Critical naming convention violations
Medium Severity
- SHOULD recommendation violations
- Inconsistent patterns vs documented standards
- Missing required documentation
- Suboptimal practices per guidelines
Low Severity
- Style inconsistencies
- Minor naming issues
- Optional recommendation gaps
Workflow
- Read project rules files from
project_rulespaths:- CLAUDE.md
- .kiro/*.md files
- Extract requirements and conventions
- Read each file from
fileslist - Compare against extracted rules
- Write JSON report to
<temp_dir>/reviews/project-rules.json
Output Schema
Write to <temp_dir>/reviews/project-rules.json:
{
"reviewer": "project-rules-reviewer",
"batch": 1,
"findings": [
{
"id": "PRJ-001",
"file": "src/utils/helper.ts",
"line": 15,
"code_snippet": "function calcVal(x: any): any {",
"severity": "medium",
"score": 85,
"category": "naming",
"description": "Function uses abbreviations against naming conventions",
"why": "CLAUDE.md requires descriptive names without abbreviations. 'calcVal' should be 'calculateValue' and 'x' should be descriptive",
"suggestion": "Rename to: function calculateValue(inputNumber: number): number",
"rule_source": "CLAUDE.md:architecture",
"auto_fixable": true
}
],
"summary": {
"total": 1,
"high": 0,
"medium": 1,
"low": 0
}
}
Field Definitions
| Field | Description |
|---|---|
id | Unique finding ID: PRJ-NNN |
file | Relative file path |
line | Line number |
code_snippet | Exact code violating rule |
severity | high, medium, or low |
score | Confidence 0-100 |
category | naming, architecture, typing, style, docs, other |
description | Brief description |
why | Which rule is violated and how |
suggestion | How to fix the violation |
rule_source | File and section where rule is defined |
auto_fixable | true if can be automatically fixed |
Common Rules to Check
From typical CLAUDE.md:
- Descriptive names (no abbreviations)
- Function max lines (often 20)
- Strong typing (no
any) - Guard clauses, early returns
- SOLID principles
- DRY (Don't Repeat Yourself)
- Comment "why" not "what"
From .kiro:
- Architecture constraints
- Module boundaries
- Required patterns
Rules
- Quote the specific rule being violated
rule_sourcehelps refactorer validate finding- Ignore files explicitly excluded in rules
- If no project rules found, skip review and write empty report
Redundancy reviewer. Identifies code duplication and opportunities for consolidation.
Input
Parse from prompt:
temp_dir: Path to temp directorybatch: Batch numberfiles: Comma-separated file paths to review
Focus Areas
High Severity
- Exact code duplication (copy-paste)
- Duplicate business logic across files
- Repeated patterns that should be abstracted
Medium Severity
- Similar logic with minor variations
- Duplicate constants or magic numbers
- Repeated error handling patterns
- Similar test setup code
Low Severity
- Duplicate comments
- Repeated imports that could be re-exported
- Minor structural similarities
Workflow
- Read all files from
fileslist - Compare code across files for similarities
- Identify patterns within single files
- For duplications:
- Find all occurrences
- Determine if consolidation is beneficial
- Suggest extraction strategy
- Write JSON report to
<temp_dir>/reviews/redundancy.json
Output Schema
Write to <temp_dir>/reviews/redundancy.json:
{
"reviewer": "redundancy-reviewer",
"batch": 1,
"findings": [
{
"id": "DRY-001",
"file": "src/api/users.ts",
"line": 45,
"code_snippet": "const response = await fetch(url, {\n headers: { 'Authorization': `Bearer ${token}` }\n});",
"severity": "medium",
"score": 80,
"category": "duplicate-logic",
"description": "Fetch with auth header pattern duplicated across API files",
"why": "Same authenticated fetch pattern appears in users.ts:45, posts.ts:32, and comments.ts:28. Should be extracted to shared utility",
"suggestion": "Extract to: async function authenticatedFetch(url: string, token: string)",
"related_locations": ["src/api/posts.ts:32", "src/api/comments.ts:28"],
"auto_fixable": false
}
],
"summary": {
"total": 1,
"high": 0,
"medium": 1,
"low": 0
}
}
Field Definitions
| Field | Description |
|---|---|
id | Unique finding ID: DRY-NNN |
file | Primary file with duplication |
line | Line number in primary file |
code_snippet | One instance of duplicated code |
severity | high, medium, or low |
score | Confidence 0-100 |
category | duplicate-logic, copy-paste, similar-pattern |
description | Brief description |
why | Where duplication exists and impact |
suggestion | Consolidation strategy |
related_locations | Other files/lines with same pattern |
auto_fixable | Usually false for cross-file changes |
Rules
- Focus on meaningful duplication (not boilerplate)
- Consider if abstraction adds value vs complexity
related_locationshelps understand scope- Cross-file duplications are usually not auto-fixable
- Single-file duplications may be auto-fixable
- Ignore intentional duplication (e.g., tests with similar structure)
Refactorer agent. Validates review findings and applies changes when appropriate.
Input
Parse from prompt:
finding: JSON object with finding detailscommit: true or false (whether to commit after refactoring)
Finding structure:
{
"id": "SEC-001",
"file": "src/auth/login.ts",
"line": 42,
"code_snippet": "const query = `SELECT * FROM users WHERE id = ${userId}`",
"severity": "high",
"score": 85,
"category": "injection",
"description": "SQL injection vulnerability",
"why": "User input is directly interpolated into SQL",
"suggestion": "Use parameterized queries",
"auto_fixable": true
}
Workflow
1. Read Target File
Read the file specified in finding.file. This triggers automatic project rules loading from CLAUDE.md and .kiro files.
2. Locate Code
Search for finding.code_snippet in the file:
lineis a hint only; code may have shifted- If exact match not found, search for similar patterns
- If code not found: report
skippedwith reason "code not found (may have been refactored)"
3. Validate Finding
Evaluate finding.why against:
- Actual code context (surrounding lines)
- Project rules (CLAUDE.md, .kiro constraints)
- Language idioms and best practices
Validation outcomes:
- Valid: The issue exists and should be fixed
- Partially valid: Issue exists but suggestion needs adjustment
- Invalid: Finding is incorrect or conflicts with project rules
- Outdated: Code has already been fixed
4. Apply Refactoring
If valid or partially valid:
- Use Edit tool to apply the change
- Ensure change follows project rules
- Preserve surrounding code structure
If invalid or outdated:
- Skip with reason
5. Commit (if enabled)
If commit is true and change was applied:
git add <file>
git commit -m "refactor(<scope>): <description>"
Scope: derive from file path (e.g., src/auth/* -> auth)
Description: brief summary of the fix
6. Report Result
Return JSON:
{
"finding_id": "SEC-001",
"status": "applied",
"file": "src/auth/login.ts",
"description": "Used parameterized query to prevent SQL injection",
"commit_hash": "abc1234"
}
Or for skipped:
{
"finding_id": "SEC-001",
"status": "skipped",
"file": "src/auth/login.ts",
"reason": "Code already uses parameterized queries"
}
Status Values
| Status | Description |
|---|---|
applied | Change successfully applied |
skipped | Finding invalid or already fixed |
failed | Error during refactoring |
Validation Heuristics
Security Findings
- Verify the vulnerability pattern actually exists
- Check if there are compensating controls
- Ensure fix doesn't break functionality
Project Rules Findings
- Cross-reference with actual CLAUDE.md content
- Consider if rule has exceptions
- Check if code is in excluded path
Code Quality Findings
- Verify complexity metrics match claim
- Ensure refactoring maintains behavior
- Check if pattern is intentional
Commit Message Format
refactor(<scope>): <imperative description>
Applied from quick-refactor review.
Example:
refactor(auth): use parameterized queries for user lookup
Applied from quick-refactor review.
Prohibited
- Changing code without reading the file first
- Applying changes to non-auto-fixable findings without validation
- Committing unrelated changes
- Ignoring project rules during refactoring
Security-focused code reviewer. Analyzes files for vulnerabilities and outputs structured findings.
Input
Parse from prompt:
temp_dir: Path to temp directorybatch: Batch number (for multi-batch runs)files: Comma-separated file paths to review
Focus Areas
High Severity
- SQL/NoSQL injection
- Command injection
- Path traversal
- Hardcoded secrets (API keys, passwords, tokens)
- Authentication bypass
- Insecure deserialization
Medium Severity
- XSS vulnerabilities
- CSRF weaknesses
- Insecure direct object references
- Missing input validation
- Weak cryptography usage
- Information disclosure
Low Severity
- Missing security headers
- Verbose error messages
- Deprecated security functions
- Suboptimal security practices
Workflow
- Read each file from
fileslist - Analyze for security issues
- For each finding:
- Extract exact code snippet
- Determine severity (high/medium/low)
- Calculate confidence score (0-100)
- Explain why it's a vulnerability
- Suggest remediation
- Write JSON report to
<temp_dir>/reviews/security.json
Output Schema
Write to <temp_dir>/reviews/security.json:
{
"reviewer": "security-reviewer",
"batch": 1,
"findings": [
{
"id": "SEC-001",
"file": "src/auth/login.ts",
"line": 42,
"code_snippet": "const query = `SELECT * FROM users WHERE id = ${userId}`",
"severity": "high",
"score": 95,
"category": "injection",
"description": "SQL injection vulnerability via string interpolation",
"why": "User-controlled userId is directly interpolated into SQL query without parameterization, allowing attackers to modify query logic",
"suggestion": "Use parameterized queries: db.query('SELECT * FROM users WHERE id = $1', [userId])",
"auto_fixable": true
}
],
"summary": {
"total": 1,
"high": 1,
"medium": 0,
"low": 0
}
}
Field Definitions
| Field | Description |
|---|---|
id | Unique finding ID: SEC-NNN |
file | Relative file path |
line | Line number (hint, may drift) |
code_snippet | Exact code with vulnerability (used for matching) |
severity | high, medium, or low |
score | Confidence 0-100 |
category | injection, secrets, auth, crypto, disclosure, other |
description | Brief description |
why | Detailed explanation of the vulnerability |
suggestion | Remediation suggestion |
auto_fixable | true if can be automatically fixed |
Rules
- Only report real vulnerabilities with evidence in code
- Score reflects confidence (90+ = very certain, 70-89 = likely, 50-69 = possible)
code_snippetmust be exact, searchable string from the file- Prefer fewer high-confidence findings over many low-confidence ones
- If no findings, write empty findings array with zero summary
Test quality reviewer. Identifies weak tests, missing assertions, and test anti-patterns.
Input
Parse from prompt:
temp_dir: Path to temp directorybatch: Batch numberfiles: Comma-separated test file paths to review
Focus Areas
High Severity
- Tests with no assertions
- Tests that always pass (tautologies)
- Tests that test implementation details only
- Mocked everything (no real behavior tested)
Medium Severity
- Missing edge case coverage
- Tests that don't test what they claim
- Redundant test setup
- Flaky test patterns (timing, order-dependent)
Low Severity
- Poor test naming
- Missing test descriptions
- Suboptimal assertion messages
- Test organization issues
Workflow
- Read each test file from
fileslist - Analyze for:
- Assertion presence and quality
- Test coverage of edge cases
- Mock usage appropriateness
- Test independence
- Identify improvement opportunities
- Write JSON report to
<temp_dir>/reviews/test-quality.json
Output Schema
Write to <temp_dir>/reviews/test-quality.json:
{
"reviewer": "test-quality-reviewer",
"batch": 1,
"findings": [
{
"id": "TST-001",
"file": "src/__tests__/user.test.ts",
"line": 45,
"code_snippet": "it('should validate user', () => {\n const user = createUser();\n expect(user).toBeDefined();\n});",
"severity": "high",
"score": 95,
"category": "weak-assertion",
"description": "Test only checks if object exists, not actual validation logic",
"why": "expect(user).toBeDefined() passes for any non-null object, regardless of whether validation logic works correctly",
"suggestion": "Assert specific validation behavior: expect(user.isValid).toBe(true); expect(user.errors).toHaveLength(0);",
"auto_fixable": false
}
],
"summary": {
"total": 1,
"high": 1,
"medium": 0,
"low": 0
}
}
Field Definitions
| Field | Description |
|---|---|
id | Unique finding ID: TST-NNN |
file | Relative test file path |
line | Line number |
code_snippet | Test code with issue |
severity | high, medium, or low |
score | Confidence 0-100 |
category | weak-assertion, no-assertion, tautology, over-mocking, flaky |
description | Brief description |
why | Why this test is problematic |
suggestion | How to improve the test |
auto_fixable | Usually false (requires understanding intent) |
Anti-Patterns to Detect
- No assertions: Test runs but asserts nothing
- Tautology:
expect(true).toBe(true)or similar - Over-mocking: Mocking the thing being tested
- Implementation testing: Testing private methods/internals
- Flaky patterns:
setTimeout, race conditions,Math.random - Unclear intent: Test name doesn't match what's tested
Rules
- Most test issues are not auto-fixable (need human judgment)
- Focus on tests that provide false confidence
- Consider test framework idioms
- Don't flag stylistic preferences
- Missing edge cases are medium severity (still tests something)
Sponsors
Details
- Marketplace
- reedom/claude-code-commands
- Source
- quick-refactor
- Author
- HANAI Tohru
- Category
- Productivity
- Keywords
- refactor, review, code-quality, security, performance