# Maximus

> 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).

- Skill: `tomevault-io/maximus` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add tomevault-io/maximus`
- Raw SKILL.md: https://api.skillmd.com/api/skills/tomevault-io/maximus/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: AI & ML
- Author: tomevault-io (https://skillmd.com/u/tomevault-io)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/tomevault-io/maximus

---


# 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:**
1. Spawn code-reviewer and code-simplifier in parallel
2. Collect and synthesize findings
3. Deduplicate overlapping issues
4. 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:**
1. Find issues → Fix them automatically
2. Re-review → Fix any new issues
3. Repeat until clean
4. **Run code-simplifier (MANDATORY - not optional)**
5. **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"`

```bash
# 1. Check uncommitted changes
git diff --name-only HEAD
git diff --name-only --staged

# 2. If none, check unpushed commits
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**:

1. **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}
   ```

2. **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:
1. Collect all findings from both agents
2. Identify overlapping issues (same location flagged by both)
3. Identify conflicts (different recommendations for same code)
4. Deduplicate findings
5. Categorize by severity and type

#### Step 3: Output Unified Report

```markdown
## 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):**

1. **Increment round**

2. **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.}
   ```

3. **Parse results** - Extract issues by severity (critical, major, minor)

4. **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**

5. **IMPLEMENT ALL FIXES IMMEDIATELY**
   - Fix each issue directly using Edit tool
   - Track what was fixed
   - Update counters

6. **Record in history:**
   ```
   {round: N, issues_found: X, issues_fixed: X, fixes: [...]}
   ```

7. **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"`

1. Check if `--pause-simplifier` or `--interactive` flag → Ask user permission
2. **Otherwise proceed immediately (NO ASKING)**

3. **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)
   ```

4. **Parse simplifier output and record detailed changes** in tracking:
   ```javascript
   simplification: {
     completed: true,
     files_processed: 2,
     improvements: [
       {
         file: "UpdateOverlay.tsx",
         category: "Extract Function",
         description: "Extracted animation logic into useAnimation hook",
         impact: "reduced 40 lines"
       },
       // ... more improvements
     ],
     by_category: {
       "Extract Function": 1,
       "Reduce Nesting": 1,
       // ... more categories
     }
   }
   ```

**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:**

- [ ] Phase 1 completed: Files detected and stored
- [ ] Phase 2 completed: At least 1 review round with issues tracked by severity
- [ ] Phase 3 completed: code-simplifier ran successfully
- [ ] Have complete tracking data for all rounds
- [ ] Have severity breakdowns (critical/major/minor)
- [ ] Have detailed simplification results (improvements per file, categories, impacts)

**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:
1. **CHECK --yolo FLAG FIRST** - Determines review-only vs autonomous mode
2. **USE TASK TOOL** - Spawn code-reviewer and code-simplifier as subagents
3. **CATEGORIZE BY SEVERITY** - Every issue must be tagged as critical/major/minor

### For REVIEW-ONLY MODE (default, no --yolo):
1. **NO CODE CHANGES** - Analysis and recommendations only
2. **SPAWN AGENTS IN PARALLEL** - Single message, two Task calls
3. **SYNTHESIZE RESULTS** - Deduplicate, resolve conflicts, unified view
4. **PROVIDE NEXT STEPS** - Tell user how to apply fixes (--yolo)
5. **EXIT AFTER REPORT** - Do not proceed to fix phases

### For YOLO MODE (--yolo flag present):
1. **AUTONOMOUS by default** - Only pause if flags explicitly request it
2. **NEVER ask permission** unless `--interactive` or `--pause-*` flags used
3. **ALL 4 PHASES ARE MANDATORY** - Stopping after Phase 2 is FAILURE
4. **PHASE 3 (Simplification) IS NOT OPTIONAL** - Must run code-simplifier
5. **PHASE 4 (Summary) IS ABSOLUTELY REQUIRED** - Must output the complete table format, not a bullet list
6. **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:**
1. Try spawning again with simpler prompt (just file list)
2. If fails after 2 attempts → Skip to Phase 3, note in summary, mark "NEEDS ATTENTION"

**If `code-simplifier:code-simplifier` fails:**
1. Try spawning again with simpler prompt (without detailed output requirement)
2. 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:**
1. Try: `git diff --name-only HEAD~1..HEAD` (last commit)
2. If still fails → Ask user which files to review
3. If no files → Exit gracefully with message

### File Access Issues

**If files cannot be read/edited:**
1. Skip problematic file, continue with others
2. Track skipped files
3. Note in Phase 4 summary
4. 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:
1. Read `.maximus-review-state.json` for persisted state
2. Check TaskList for existing tasks and their statuses
3. Resume from the next incomplete phase using persisted data
4. Mark result as "NEEDS ATTENTION" if recovery was needed
5. 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.**

---
> Converted and distributed by [TomeVault](https://tomevault.io/claim/itsdevcoffee) — claim your Tome and manage your conversions.
<!-- tomevault:4.0:skill_md:2026-04-13 -->

