# 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 (5401 patterns, 22 languages)
truemend fix <path> --dry-run           # Preview deterministic fixes
truemend fix <path>                     # Apply deterministic fixes
truemend verify <path>                  # Verify fixes didn't regress
truemend resolve <id> --status fixed    # Mark issue resolved
truemend status                         # Health score and progress
```

### Analysis
```bash
truemend analyze <path> --quick         # Metrics only, <2s
truemend analyze <path> --improve       # Full pipeline: analyze + fix + validate
truemend analyze <path> --diff HEAD~1   # Changed files only
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 review <path>                  # 20-dimension subjective review
truemend dashboard <path>               # Full health overview
truemend cost <path>                    # Tech debt in dollars
truemend roadmap <path> --strategy impact  # Prioritized refactoring plan
truemend coupling <path>                # Module coupling analysis
truemend predict <path>                 # Forecast issues before coding
```

### Advanced
```bash
truemend compliance <path> --framework SOC2
truemend postmortem HEAD~5 HEAD
truemend slop <path>
truemend scan-config
truemend watch <path>
truemend hooks install --type pre-commit
truemend ux-audit <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 verify` after fixes, before resolving.
- Use `truemend fix --dry-run` before applying.
- Use `truemend analyze --diff HEAD~1` for PR-scoped checks.
