# TrueMend — Code Quality Agent Workflow (Cursor)

## Primary Loop: `next` Workflow

Always use this workflow for iterative code improvement:

1. `truemend next <path>` — Get the single highest-impact issue
2. Fix the issue
3. `truemend resolve <id> --status fixed` — Mark done
4. Repeat from step 1

## Commands

### Core
```bash
truemend next <path>                    # Next highest-priority issue
truemend analyze <path>                 # Full analysis
truemend fix <path> --dry-run           # Preview deterministic fixes
truemend fix <path>                     # Apply deterministic fixes
truemend workflow verify <path>                  # Verify fixes didn't regress
truemend resolve <id> --status fixed    # Mark issue resolved
truemend workflow status                         # Health score and progress
```

### Analysis
```bash
truemend analyze <path> --quick         # Metrics only, <2s
truemend fix <path> --apply             # Apply deterministic fixes, each re-verified
truemend audit <path> --since HEAD~1    # Only functions changed since HEAD~1
truemend analyze <path> --ai-focus      # Stricter for AI code
truemend analyze <path> --ci            # CI gate (exit 0/1/2)
truemend analyze <path> --json          # Machine-readable output
```

### Review and Planning
```bash
truemend audit --only review <path>                  # 20-dimension subjective review
truemend report health <path>               # Full health overview
truemend report cost <path>                    # Tech debt in dollars
truemend workflow roadmap <path> --strategy impact  # Prioritized refactoring plan
truemend audit --only coupling <path>                # Module coupling analysis
truemend workflow predict <path>                 # Forecast issues before coding
```

### Advanced
```bash
truemend report compliance <path> --framework SOC2
truemend workflow postmortem HEAD~5 HEAD
truemend audit --only slop <path>
truemend rules scan-config
truemend watch <path>
truemend setup hooks install --type pre-commit
truemend audit --only ux <path>
```

## Aggression Presets
```bash
truemend analyze <path> --aggression discovery     # Lenient
truemend analyze <path> --aggression recommended   # Default
truemend analyze <path> --aggression excellence    # Strict
truemend analyze <path> --aggression beast         # Very strict
truemend analyze <path> --aggression zealot        # Maximum
```

## Severity Levels
- **critical**: Security/data loss. Fix immediately.
- **high**: Bug-prone. Fix before merging.
- **medium**: Maintainability. Fix this sprint.
- **low**: Style. Fix when convenient.

## Fix Types
- **deterministic**: `truemend fix` handles automatically. Zero cost.
- **cataloged_refactor**: Named procedure, constrained recipe.
- **structural_rewrite**: Architecture change. Show to human.

## Tips
- Prefer `truemend next` over full scans — it prioritizes for you.
- Use `--json` for machine-readable output.
- Run `truemend workflow verify` after fixes, before resolving.
- Use `truemend fix --dry-run` before applying.
- Use `truemend audit . --base main` for PR-scoped checks.
