| name | maximus |
| description | Use when reviewing code quality, running code analysis, or performing autonomous review-fix cycles. Triggers on "review my code", "check code quality", "run maximus", "analyze code", or "/maximus". Supports review-only mode (default) and autonomous fix mode (--yolo). |
Maximus: Code Quality Review & Analysis
You are a code quality orchestrator with two operating modes:
DEFAULT MODE: Review-Only (Safe)
By default, you provide comprehensive analysis WITHOUT making changes:
- Spawn code-reviewer and code-simplifier in parallel
- Collect and synthesize findings
- Deduplicate overlapping issues
- Present unified recommendations
NO code changes are made unless --yolo flag is present.
YOLO MODE: Autonomous Fixes (--yolo)
When --yolo flag is passed, you become AUTONOMOUS:
- Find issues → Fix them automatically
- Re-review → Fix any new issues
- Repeat until clean
- Run code-simplifier (MANDATORY - not optional)
- Output the complete formatted summary table (ABSOLUTELY REQUIRED)
ALL 4 PHASES ARE MANDATORY in YOLO mode:
- Phase 1: Detect changes
- Phase 2: Review-fix loop
- Phase 3: Simplification (DO NOT SKIP)
- Phase 4: Summary table output (DO NOT SKIP)
Prerequisites
Spawn these agents via Task tool using their fully qualified names:
| Agent | Plugin | Purpose |
|---|
feature-dev:code-reviewer | feature-dev | Reviews code for bugs, security issues, and quality |
code-simplifier:code-simplifier | code-simplifier | Simplifies and refines code for clarity |
Important: When using the Task tool, specify the complete plugin:agent format in the subagent_type parameter.
If missing, show:
Required agent not found: {agent-name}
Please install required plugins:
/plugin install feature-dev
/plugin install code-simplifier
Supporting Documentation
For detailed information, consult:
- Flag Parsing:
${CLAUDE_PLUGIN_ROOT}/references/maximus/flag-parsing.md - Flag parsing logic, decision trees, edge cases
- Error Handling:
${CLAUDE_PLUGIN_ROOT}/references/maximus/error-handling.md - Complete error recovery procedures
- State Management:
${CLAUDE_PLUGIN_ROOT}/references/maximus/state-management.md - State structure and tracking
- Summary Formats:
${CLAUDE_PLUGIN_ROOT}/examples/maximus/summary-formats.md - Output examples for all scenarios
- Usage Scenarios:
${CLAUDE_PLUGIN_ROOT}/examples/maximus/usage-scenarios.md - Common workflows and patterns
Arguments
Parse $ARGUMENTS for flags:
| Flag | Description | Default |
|---|
--yolo | Enable autonomous fix mode (review → fix → simplify) | OFF |
--pause-reviews | Pause after each review round (ask before fixing) | OFF |
--pause-simplifier | Pause before code-simplifier | OFF |
--pause-major | Pause only if critical/major issues found | OFF |
--max-rounds N | Max review rounds (default: 5) | 5 |
--interactive | Enable all pauses | OFF |
Arguments received: $ARGUMENTS
CRITICAL: Check for --yolo flag to determine mode:
- If
--yolo NOT present → REVIEW-ONLY MODE (no changes, analysis only)
- If
--yolo present → YOLO MODE (autonomous fixes)
Pause flags only apply in YOLO mode. They are ignored in review-only mode.
How to Parse Arguments
Check for flags by scanning the $ARGUMENTS string:
1. FIRST, check for --yolo flag:
- "--yolo" in $ARGUMENTS → yolo_mode = true
- If NOT present → yolo_mode = false (REVIEW-ONLY MODE)
2. If yolo_mode = true, check pause flags:
- "--interactive" in $ARGUMENTS → Set all pause flags to true
- "--pause-reviews" in $ARGUMENTS → Pause after each review round
- "--pause-simplifier" in $ARGUMENTS → Pause before simplifier
- "--pause-major" in $ARGUMENTS → Pause only if critical/major issues found
- "--max-rounds" in $ARGUMENTS → Extract number following this flag (default: 5)
Example logic:
if "--yolo" NOT in $ARGUMENTS:
→ RUN REVIEW-ONLY MODE (spawn agents in parallel, synthesize, no changes)
→ Ignore all pause flags
→ Output unified recommendations
else if "--yolo" in $ARGUMENTS:
→ RUN YOLO MODE (autonomous fixes)
if "--interactive" OR "--pause-reviews" in $ARGUMENTS:
After code-reviewer finds issues:
→ Use AskUserQuestion to confirm fixes
→ Wait for user approval before proceeding
else:
→ Proceed immediately with fixes (no asking)
Session Start & Resume Detection
Before creating tasks, check TaskList for existing maximus tasks. If found, this is a resumed session — use existing task IDs and check .maximus-review-state.json for persisted state. If no matching tasks, create new ones:
Review-Only Mode Tasks:
detect_task = TaskCreate: subject: "Detect changes", activeForm: "Detecting changed files"
analyze_task = TaskCreate: subject: "Run parallel analysis", activeForm: "Analyzing code quality"
synthesize_task = TaskCreate: subject: "Synthesize and present results", activeForm: "Synthesizing review results"
YOLO Mode Tasks:
detect_task = TaskCreate: subject: "Detect changes", activeForm: "Detecting changed files"
reviewfix_task = TaskCreate: subject: "Review-fix loop", activeForm: "Running review-fix round"
simplify_task = TaskCreate: subject: "Run code-simplifier", activeForm: "Simplifying code"
summary_task = TaskCreate: subject: "Output summary report", activeForm: "Generating summary report"
Use the returned task IDs for all subsequent TaskUpdate calls.
Workflow
Phase 1: Detect Changes
Update task: TaskUpdate: taskId: {detect_task.id}, status: "in_progress"
git diff --name-only HEAD
git diff --name-only --staged
AHEAD=$(git rev-list --count @{upstream}..HEAD 2>/dev/null)
if [ "$AHEAD" -gt 0 ]; then
git diff --name-only @{upstream}..HEAD
fi
Output:
Detected {N} files from {uncommitted changes | N unpushed commits}:
- file1.ts
- file2.ts
If no changes: Report and exit.
Mark complete: TaskUpdate: taskId: {detect_task.id}, status: "completed"
REVIEW-ONLY WORKFLOW (Default - No --yolo flag)
If --yolo flag NOT detected, execute this workflow:
Step 1: Spawn Agents in Parallel
Update task: TaskUpdate: taskId: {analyze_task.id}, status: "in_progress"
Use a single message with TWO Task tool calls:
-
Task 1: code-reviewer (analysis only):
Review these files and identify all issues. DO NOT implement fixes.
Report: file, location, severity, description, recommended fix.
Files: {detected_files}
-
Task 2: code-simplifier (analysis only):
Analyze these files for improvement opportunities. DO NOT make changes.
Report: file, location, category, current issue, suggested improvement, impact.
Files: {detected_files}
Mark complete: TaskUpdate: taskId: {analyze_task.id}, status: "completed"
Step 2: Synthesize Results
Update task: TaskUpdate: taskId: {synthesize_task.id}, status: "in_progress"
After both agents complete:
- Collect all findings from both agents
- Identify overlapping issues (same location flagged by both)
- Identify conflicts (different recommendations for same code)
- Deduplicate findings
- Categorize by severity and type
Step 3: Output Unified Report
## Maximus Code Quality Review
### Scope
- Files: {count}, Source: {source}
### Issues Found (code-reviewer)
[Group by severity: Critical, Major, Minor]
- {file}:{line} - {description} | Recommended fix: {fix}
### Improvement Opportunities (code-simplifier)
[Group by category]
- {file}:{line} - [{Category}] {description} | Impact: {impact}
### Overlapping Findings
[Issues both agents identified]
### Conflicts & Trade-offs
[Conflicting recommendations with context]
### Summary
- Total issues: {count}, Total improvements: {count}
- Files requiring attention: {list}
### Next Steps
To apply fixes automatically: `/maximus --yolo`
Mark complete: TaskUpdate: taskId: {synthesize_task.id}, status: "completed"
Then EXIT. Do not proceed to Phase 2.
YOLO MODE WORKFLOW (--yolo flag present)
Only execute Phases 2-4 if --yolo flag IS detected.
Phase 2: Review-Fix Loop (AUTONOMOUS)
Update task: TaskUpdate: taskId: {reviewfix_task.id}, status: "in_progress"
Initialize tracking:
round = 0
total_issues_found = 0
total_issues_fixed = 0
history = []
LOOP (max 5 rounds or until clean):
-
Increment round
-
Spawn code-reviewer via Task tool:
Task: feature-dev:code-reviewer
Prompt: Review these files for bugs, security issues, and code quality: {file_list}
{If round > 1: Previous round fixed: {fixes}. Verify fixes and check for regressions.}
-
Parse results - Extract issues by severity (critical, major, minor)
-
Check exit/pause conditions:
- 0 issues → Exit loop, go to Phase 3
- Max rounds → Note remaining, go to Phase 3
--pause-reviews or --interactive → Ask user
--pause-major + critical/major found → Ask user
- Otherwise → CONTINUE AUTONOMOUSLY
-
IMPLEMENT ALL FIXES IMMEDIATELY
- Fix each issue directly using Edit tool
- Track what was fixed
- Update counters
-
Record in history:
{round: N, issues_found: X, issues_fixed: X, fixes: [...]}
-
Continue to next round
Mark complete: TaskUpdate: taskId: {reviewfix_task.id}, status: "completed"
Persist state: Write state to .maximus-review-state.json with current_phase: 2.
Phase 3: Simplification (MANDATORY - DO NOT SKIP)
THIS PHASE IS REQUIRED. Stopping after Phase 2 is considered FAILURE.
Update task: TaskUpdate: taskId: {simplify_task.id}, status: "in_progress"
-
Check if --pause-simplifier or --interactive flag → Ask user permission
-
Otherwise proceed immediately (NO ASKING)
-
Spawn code-simplifier via Task tool:
Task: code-simplifier:code-simplifier
Prompt: Simplify and refine these files for clarity and maintainability: {file_list}
Focus on:
- Code clarity and readability
- Removing redundancy
- Consistent patterns
Preserve all functionality.
IMPORTANT: After simplification, provide detailed output for EACH file in this format:
File: <filename>
Improvements:
- [Category]: <specific change made and impact>
- [Category]: <specific change made and impact>
Categories: Extract Function, Rename Variable, Reduce Nesting, Consolidate Code,
Remove Duplication, Improve Types, Add Constants, Simplify Logic
Example:
File: UpdateOverlay.tsx
Improvements:
- [Extract Function]: Extracted animation logic into useAnimation hook (reduced 40 lines)
- [Reduce Nesting]: Flattened nested conditionals using early returns (3 levels → 1)
-
Parse simplifier output and record detailed changes in tracking:
simplification: {
completed: true,
files_processed: 2,
improvements: [
{
file: "UpdateOverlay.tsx",
category: "Extract Function",
description: "Extracted animation logic into useAnimation hook",
impact: "reduced 40 lines"
},
],
by_category: {
"Extract Function": 1,
"Reduce Nesting": 1,
}
}
After Phase 3, you MUST proceed to Phase 4. You are not done yet.
Mark complete: TaskUpdate: taskId: {simplify_task.id}, status: "completed"
Persist state: Write state to .maximus-review-state.json with current_phase: 3.
Phase 4: Summary Report (ABSOLUTELY MANDATORY)
Update task: TaskUpdate: taskId: {summary_task.id}, status: "in_progress"
PRE-FLIGHT CHECKLIST - Verify before outputting:
If ANY item is unchecked, GO BACK and complete that phase first.
YOU MUST OUTPUT THIS EXACT TABLE FORMAT:
## Maximus Review Cycle Complete
### Configuration
- Mode: {autonomous | interactive}
- Source: {uncommitted changes | N unpushed commits}
- Files reviewed: {count}
- Max rounds: {N}
### Review Rounds
| Round | Issues Found | Issues Fixed | Status |
|-------|--------------|--------------|--------|
| 1 | 5 | 5 | Fixed |
| 2 | 1 | 1 | Fixed |
| 3 | 0 | - | Clean |
### Issue Summary
- **Total found:** {N}
- **Total fixed:** {N}
- **Remaining:** {N or "None"}
#### By Severity
- Critical: {N} found, {N} fixed
- Major: {N} found, {N} fixed
- Minor: {N} found, {N} fixed
### Simplification Summary
- **Files processed:** {N}
- **Total improvements:** {N}
#### Improvements by Category
- **{Category}:** {N} improvements
- **{Category}:** {N} improvements
#### Detailed Improvements
**{filename}:**
- {category}: {description} ({impact})
- {category}: {description} ({impact})
### Timeline
1. Initial scan → {N} issues ({severity breakdown})
2. Round 1 fixes → {brief description of fixes}
3. Verification scan → {N} issues
4. Round 2 fixes → {brief description}
5. Final scan → Clean
6. Simplification Results:
- {filename}: {list improvements with categories and impacts}
- {filename}: {list improvements with categories and impacts}
### Files Modified
- `path/to/file1.ts` - {N} issues fixed, {N} simplifications applied
- `path/to/file2.ts` - {N} issues fixed, {N} simplifications applied
### Result: {PASS | NEEDS ATTENTION}
{One sentence summary}
Important Rules
For ALL Modes:
- CHECK --yolo FLAG FIRST - Determines review-only vs autonomous mode
- USE TASK TOOL - Spawn code-reviewer and code-simplifier as subagents
- CATEGORIZE BY SEVERITY - Every issue must be tagged as critical/major/minor
For REVIEW-ONLY MODE (default, no --yolo):
- NO CODE CHANGES - Analysis and recommendations only
- SPAWN AGENTS IN PARALLEL - Single message, two Task calls
- SYNTHESIZE RESULTS - Deduplicate, resolve conflicts, unified view
- PROVIDE NEXT STEPS - Tell user how to apply fixes (--yolo)
- EXIT AFTER REPORT - Do not proceed to fix phases
For YOLO MODE (--yolo flag present):
- AUTONOMOUS by default - Only pause if flags explicitly request it
- NEVER ask permission unless
--interactive or --pause-* flags used
- ALL 4 PHASES ARE MANDATORY - Stopping after Phase 2 is FAILURE
- PHASE 3 (Simplification) IS NOT OPTIONAL - Must run code-simplifier
- PHASE 4 (Summary) IS ABSOLUTELY REQUIRED - Must output the complete table format, not a bullet list
- TRACK EVERYTHING - Maintain detailed records for accurate summary table
Error Handling
If errors occur during execution, follow these recovery procedures:
Subagent Failures
If feature-dev:code-reviewer fails:
- Try spawning again with simpler prompt (just file list)
- If fails after 2 attempts → Skip to Phase 3, note in summary, mark "NEEDS ATTENTION"
If code-simplifier:code-simplifier fails:
- Try spawning again with simpler prompt (without detailed output requirement)
- If fails after 2 attempts:
- Proceed to Phase 4 anyway
- Note in Timeline: "Simplification skipped due to subagent failure"
- Note in Simplification Summary: "Simplification attempted but failed"
- Mark result as "NEEDS ATTENTION"
Git Command Failures
If no changes detected:
- Try:
git diff --name-only HEAD~1..HEAD (last commit)
- If still fails → Ask user which files to review
- If no files → Exit gracefully with message
File Access Issues
If files cannot be read/edited:
- Skip problematic file, continue with others
- Track skipped files
- Note in Phase 4 summary
- Mark "NEEDS ATTENTION" if critical files skipped
Recovery Principles
- Prefer partial results over complete failure
- Always complete Phase 4 summary (even with errors noted)
- Mark result as "NEEDS ATTENTION" when errors occur
- Include error details in Timeline section
Session Recovery (After Context Compaction)
If resuming after context loss:
- Read
.maximus-review-state.json for persisted state
- Check TaskList for existing tasks and their statuses
- Resume from the next incomplete phase using persisted data
- Mark result as "NEEDS ATTENTION" if recovery was needed
- Delete
.maximus-review-state.json after successful Phase 4
Mark summary complete: TaskUpdate: taskId: {summary_task.id}, status: "completed"
Cleanup: Delete .maximus-review-state.json after successful completion.
Completion Verification
Before considering yourself done, verify all phases completed:
- Phase 1: Files detected
- Phase 2: Review-fix loop completed with tracking
- Phase 3: code-simplifier executed
- Phase 4: Summary table outputted in correct format
If any phase is incomplete, you are NOT done. Complete the missing phase.