Skip to Content
Quality Commands/moai review

/moai review

A code review command that analyzes your codebase from 4 perspectives: Security, Performance, Quality, and UX.

One-line summary: /moai review is an “AI Code Reviewer”. It simultaneously reviews from 4 perspectives — OWASP security checks, performance analysis, TRUST 5 quality verification, and UX accessibility.

Slash Command: Type /moai:review in Claude Code to run this command directly. Type /moai alone to see the full list of available subcommands.

Overview

Code review is at the heart of software quality. However, thoroughly checking security, performance, quality, and UX all at once is challenging. /moai review systematically analyzes code from 4 perspectives and produces a review report organized by severity.

It also checks @MX tag compliance to help AI agents better understand the code.

Usage

# Review most recent commit changes > /moai review # Review only staged changes > /moai review --staged # Review against a specific branch > /moai review --branch develop # Security-focused review > /moai review --security # Review specific file only > /moai review --file src/auth/service.py

Supported Flags

FlagDescriptionExample
--stagedReview only staged (git add) changes/moai review --staged
--branch BRANCHCompare against specified branch (default: main)/moai review --branch develop
--securityFocus primarily on security review (OWASP, injection, auth)/moai review --security
--file PATHReview specific file(s) only/moai review --file src/auth/
--teamAgent Teams mode (4 expert reviewers analyze in parallel)/moai review --team

—staged Flag

Reviews only changes staged with git add. Useful for final checks before committing:

> git add src/auth/ > /moai review --staged

—security Flag

Performs deeper analysis focused on the security perspective:

> /moai review --security

Provides in-depth analysis of OWASP Top 10, injection risks, authentication/authorization logic, and secrets exposure.

—team Flag

4 expert review agents analyze simultaneously:

> /moai review --team

Security, performance, quality, and UX specialists each review independently, enabling deeper analysis.

Execution Process

/moai review runs in 5 phases.

Phase 1: Identify Change Scope

Determines the review target based on flags:

ConditionCommand Used
--stagedgit diff --staged
--branch BRANCHgit diff {BRANCH}...HEAD
--file PATHRead specified files directly
No flaggit diff HEAD~1

Phase 2: 4-Perspective Analysis

Analyzes code from 4 expert perspectives:

Perspective 1: Security Review

Check ItemDescription
OWASP Top 10 ComplianceMajor web security vulnerability check
Input Validation & SanitizationUser input handling safety
Authentication/Authorization LogicAccess control implementation
Secrets ExposureAPI keys, passwords, token leaks
Injection RisksSQL, command, XSS, CSRF risks
Dependency VulnerabilitiesThird-party library vulnerabilities

Perspective 2: Performance Review

Check ItemDescription
Algorithmic ComplexityO(n) analysis
Database Query EfficiencyN+1 queries, missing indexes
Memory Usage PatternsMemory leaks, excessive allocation
Caching OpportunitiesIdentifying cacheable areas
Bundle Size ImpactFrontend change bundle size impact
Concurrency SafetyRace conditions, deadlocks

Perspective 3: Quality Review

Check ItemDescription
TRUST 5 ComplianceTested, Readable, Unified, Secured, Trackable
Naming ConventionsCode readability
Error HandlingError handling completeness
Test CoverageTest existence for changed code
DocumentationPublic API documentation
Project Pattern ConsistencyAdherence to existing codebase patterns

Perspective 4: UX Review

Check ItemDescription
User Flow IntegrityWhether changes break existing flows
Error StatesError and edge cases from user perspective
AccessibilityWCAG, ARIA compliance
Loading StatesLoading indicators and feedback
Breaking ChangesPublic interface compatibility

Phase 3: @MX Tag Compliance Check

Checks @MX tag compliance for changed files:

  • New exported functions: Need @MX:NOTE or @MX:ANCHOR
  • High fan_in functions (>=3 callers): Must have @MX:ANCHOR
  • Dangerous patterns: Should have @MX:WARN
  • Untested public functions: Should have @MX:TODO

Phase 4: Report Consolidation

Generates a consolidated report organized by severity:

## Code Review Report ### Critical Issues (must fix) - [SECURITY] src/auth/service.py:45: SQL injection risk - [PERFORMANCE] src/api/handler.py:23: N+1 query pattern ### Warnings (should fix) - [QUALITY] src/utils/helper.py:12: Missing error handling - [UX] src/components/Form.tsx:88: Missing accessibility attributes ### Suggestions (nice to have) - [QUALITY] src/models/user.py:34: Method extraction recommended ### @MX Tag Compliance - Missing tags: 3 - Outdated tags: 1 - Compliant files: 8/12 ### Overall Assessment - Security: PASS - Performance: WARN - Quality: PASS - UX: WARN - TRUST 5 Score: 4/5

Phase 5: Next Steps

Guides next steps based on review results:

  • Auto-fix: Run /moai fix to auto-resolve Level 1-2 issues
  • Create fix tasks: Register each finding as individual tasks
  • Export report: Save review report to .moai/reports/
  • Dismiss: Acknowledge without immediate action

Agent Delegation Chain

Agent Roles:

AgentRoleKey Tasks
MoAI OrchestratorChange identification & result consolidationgit diff, report generation
manager-qualityCode quality analysis (default mode)Sequential 4-perspective analysis
expert-securitySecurity-focused analysis (--security)OWASP, injection, authentication

FAQ

Q: What’s the difference between —team mode and default mode?

Default mode uses a single manager-quality agent to analyze all 4 perspectives sequentially. --team mode uses 4 expert reviewers analyzing simultaneously for deeper analysis, but consumes approximately 4x more tokens.

Q: What’s the best flag combination for pre-PR review?

/moai review --staged is the most efficient for reviewing staged changes. For security-critical code, use /moai review --staged --security.

Q: Can I skip the @MX tag check?

Currently, @MX tag checking is always included. Results are shown in a separate section of the report, and tags are not added automatically.

Q: Can issues found in the review be auto-fixed?

Yes, after the review you can run /moai fix to auto-fix Level 1-2 issues. Level 3-4 issues require manual review.

Last updated on