Understand-Anything
Graphs that teach > graphs that impress. Turn any code into an interactive knowledge graph you can explore, search, and ask questions about. Works with Claude Code, Codex, Cursor, Copilot, Gemini CLI, and more.
Graphs that teach > graphs that impress. Turn any code into an interactive knowledge graph you can explore, search, and ask questions about. Works with Claude Code, Codex, Cursor, Copilot, Gemini CLI, and more.
Pre-indexed code knowledge graph, auto syncs on code changes, for Claude Code, Codex, Gemini, Cursor, OpenCode, AntiGravity, Kiro, and Hermes Agent β fewer tokens, fewer tool calls, 100% local
npx @colbymchenry/codegraphA hand-picked collection of the finest of resources for the most awesome of agents, Claude Code, the undisputed champion of coding companions, from the unstoppable team at Anthropic PBC. A delectable showcase of top tier skills, ambidextrous agents, scintillating status lines, top notch developer tooling, and also we have plugins
"The purpose of vibe coding is not rapid productivity but code quality."
MoAI-ADK is a high-performance AI development environment for Claude Code. 8 retained AI agents (7 MoAI-custom + 1 Anthropic built-in Explore) and 27 moai-* template-managed skills collaborate to produce quality code. It automatically applies TDD (default) for new projects and feature development, or DDD for existing projects with minimal test coverage, and supports dual execution modes with Sub-Agent and Agent Teams.
A single binary written in Go -- runs instantly on any platform with zero dependencies.
We completely rewrote the Python-based MoAI-ADK (~73,000 lines) in Go.
| Aspect | Python Edition | Go Edition |
|---|---|---|
| Distribution | pip + venv + dependencies | Single binary, zero dependencies |
| Startup time | ~800ms interpreter boot | ~5ms native execution |
| Concurrency | asyncio / threading | Native goroutines |
| Type safety | Runtime (mypy optional) | Compile-time enforced |
| Cross-platform | Python runtime required | Prebuilt binaries (macOS, Linux, Windows) |
| Hook execution | Shell wrapper + Python | Compiled binary, JSON protocol |
moai-* skills (template-managed; excludes 2 harness-moaiadk-* user-owned)MoAI-ADK implements the Harness Engineering paradigm β designing the environment for AI agents rather than writing code directly.
| Component | Description | Command |
|---|---|---|
| Self-Verify Loop | Agents write code β test β fail β fix β pass cycle autonomously | /moai loop |
| Context Map | Codebase architecture maps and documentation always available to agents | /moai codemaps |
| Session Persistence | progress.md tracks completed phases across sessions; interrupted runs resume automatically | /moai run SPEC-XXX |
| Failing Checklist | All acceptance criteria registered as pending tasks at run start; marked complete as implemented | /moai run SPEC-XXX |
| Language-Agnostic | 16 languages supported: auto-detects language, selects correct LSP/linter/test/coverage tools | All workflows |
| Garbage Collection | Periodic scan and removal of dead code, AI Slop, and unused imports | /moai clean |
| Scaffolding First | Empty file stubs created before implementation to prevent entropy | /moai run SPEC-XXX |
| Harness v4 Builder | Orchestrator-direct harness build system with 4-phase workflow (ANALYZE β PLAN β GENERATE β ACTIVATE), manifest-driven Runner, and conditional worktree isolation | /moai:harness <natural-language request> |
| Harness Lifecycle | List/edit/remove harness lifecycle commands (/harness:<name> list, edit, remove) | /moai:harness status, , |
"Human steers, agents execute." β The engineer's role shifts from writing code to designing the harness: SPECs, quality gates, and feedback loops.
Harness v4 Architecture: See SPEC-V3R6-HARNESS-V4-001 and .claude/skills/moai/workflows/harness-builder.md for the orchestrator-direct Builder workflow, manifest.json schema, Runner primitive mapping, and conditional worktree isolation rules.
| Platform | Supported Environments | Notes |
|---|---|---|
| macOS | Terminal, iTerm2 | Fully supported |
| Linux | Bash, Zsh | Fully supported |
| Windows | WSL (recommended), PowerShell 7.x+ | Native cmd.exe is not supported |
Prerequisites:
curl -fsSL https://raw.githubusercontent.com/modu-ai/moai-adk/main/install.sh | bash
Recommended: Use WSL with the Linux installation command above for the best experience.
irm https://raw.githubusercontent.com/modu-ai/moai-adk/main/install.ps1 | iex
Requires Git for Windows to be installed first.
git clone https://github.com/modu-ai/moai-adk.git
cd moai-adk && make build
Prebuilt binaries are available on the Releases page.
If your Windows username contains non-ASCII characters (Korean, Chinese, etc.),
you may encounter EINVAL errors due to Windows 8.3 short filename conversion.
Workaround 1: Set an alternative temp directory:
# Command Prompt
set MOAI_TEMP_DIR=C:\temp
mkdir C:\temp 2>nul
# PowerShell
$env:MOAI_TEMP_DIR="C:\temp"
New-Item -ItemType Directory -Path "C:\temp" -Force
Workaround 2: Disable 8.3 filename generation (requires admin):
fsutil 8dot3name set 1
Workaround 3: Create a new Windows user account with ASCII-only username.
moai init my-project
An interactive wizard auto-detects your language, framework, and methodology, then generates Claude Code integration files.
# After launching Claude Code
/moai project # Generate project docs (product.md, structure.md, tech.md)
/moai plan "Add user authentication" # Create a SPEC document
/moai run SPEC-AUTH-001 # DDD/TDD implementation
/moai sync SPEC-AUTH-001 # Sync docs & create PR
/moai github issues # Fix GitHub issues with Agent Teams
/moai github pr 123 # Review PR with multi-perspective analysis
graph LR
A["π /moai project"] --> B["π /moai plan"]
B -->|"SPEC Document"| C["π¨ /moai run"]
C -->|"Implementation Complete"| D["π /moai sync"]
D -->|"PR Created"| E["β
Done"]
MoAI-ADK automatically selects the optimal development methodology based on your project's state.
flowchart TD
A["π Project Analysis"] --> B{"New Project or<br/>10%+ Test Coverage?"}
B -->|"Yes"| C["TDD (default)"]
B -->|"No"| D{"Existing Project<br/>< 10% Coverage?"}
D -->|"Yes"| E["DDD"]
C --> F["RED β GREEN β REFACTOR"]
E --> G["ANALYZE β PRESERVE β IMPROVE"]
style C fill:#4CAF50,color:#fff
style E fill:#2196F3,color:#fff
The default methodology for new projects and feature development. Write tests first, then implement.
| Phase | Description |
|---|---|
| RED | Write a failing test that defines expected behavior |
| GREEN | Write minimal code to make the test pass |
| REFACTOR | Improve code quality while keeping tests green. /simplify runs automatically after REFACTOR completes. |
For brownfield projects (existing codebases), TDD is enhanced with a pre-RED analysis step: read existing code to understand current behavior before writing tests.
A methodology for safely refactoring existing projects with minimal test coverage.
ANALYZE β Analyze existing code and dependencies, identify domain boundaries
PRESERVE β Write characterization tests, capture current behavior snapshots
IMPROVE β Improve incrementally under test protection. /simplify runs automatically after IMPROVE completes.
The methodology is automatically selected during
moai init(--mode <ddd|tdd>, default: tdd) and can be changed viadevelopment_modein.moai/config/sections/quality.yaml.Note: MoAI-ADK v2.5.0+ uses binary methodology selection (TDD or DDD only). The hybrid mode has been removed for clarity and consistency.
MoAI-ADK v2.6.0+ integrates two Claude Code native skills that MoAI invokes autonomously β no flags or manual commands required.
| Skill | Role | Trigger |
|---|---|---|
/simplify | Quality enforcement | Always runs after every TDD REFACTOR and DDD IMPROVE phase |
/batch | Scale-out execution | Auto-triggered when task complexity exceeds thresholds |
/simplify β Automatic Quality Pass
Uses parallel agents to review changed code for reuse opportunities, quality issues, efficiency, and CLAUDE.md compliance, then auto-fixes findings. MoAI calls this directly after every implementation cycle β no configuration needed.
/batch β Parallel Scale-Out
Spawns dozens of agents in isolated git worktrees for large-scale parallel work. Each agent runs tests and reports results; MoAI merges them. Auto-triggered per workflow:
| Workflow | Trigger Condition |
|---|---|
run | tasks β₯ 5, OR predicted file changes β₯ 10, OR independent tasks β₯ 3 |
mx | source files β₯ 50 |
clean | confirmed dead code items β₯ 20 |
MoAI is a strategic orchestrator. Rather than writing code directly, it delegates tasks to 8 retained agents.
graph LR
U["π€ User Request"] --> M["πΏ MoAI Orchestrator"]
M --> MS["π manager-spec"]
M --> MD["π¨ manager-develop"]
M --> MDoc["π manager-docs"]
M --> MG["πΏ manager-git"]
M --> PA["π plan-auditor"]
M --> SA["βοΈ sync-auditor"]
M --> BH["π§ builder-harness"]
M --> EX["ποΈ Explore (built-in)"]
style M fill:#FF6B35,color:#fff
style MS fill:#4CAF50,color:#fff
style MD fill:#2196F3,color:#fff
style MDoc fill:#2196F3,color:#fff
style MG fill:#2196F3,color:#fff
style PA fill:#FF5722,color:#fff
style SA fill:#FF5722,color:#fff
style BH fill:#9C27B0,color:#fff
style EX fill:#607D8B,color:#fff
| Category | Count | Agents | Role |
|---|---|---|---|
| Manager | 4 | manager-spec, manager-develop, manager-docs, manager-git | Plan-phase authoring, run-phase implementation, sync-phase docs, PR routing |
| Evaluator | 2 | plan-auditor, sync-auditor | Independent plan-phase audit, sync-phase 4-dimension quality scoring |
| Builder | 1 | builder-harness | Dynamic project-specific harness specialist generation |
| Anthropic built-in | 1 | Explore | Read-only codebase exploration (invoked directly, no MoAI file) |
Total: 8 retained agents (7 MoAI-custom + 1 Anthropic built-in Explore)
12 legacy agent names (e.g. manager-strategy, manager-quality, manager-project, the 6 expert-* agents) are archived and MUST NOT be spawned. When a paste-ready resume or Agent() invocation references an archived name, the orchestrator rejects the spawn and consults the migration table at .claude/rules/moai/workflow/archived-agent-rejection.md.
Note: Dynamic team teammates (researcher, analyst, architect, implementer, tester, designer, reviewer) are spawned at runtime via role profiles, not as static agent definitions.
/moai Slash Commands (13)MoAI exposes 13 /moai slash commands in .claude/commands/moai/, managed through a 3-level progressive disclosure system for token efficiency (skill metadata is always listed; bodies load on invocation; bundled references load on demand).
| Group | Commands |
|---|---|
| Workflow | plan, run, sync, project |
| Utility | fix, loop, clean, mx, codemaps |
| Quality | review, gate |
| Autonomy | harness |
| Feedback | feedback |
The full command set (13 total): clean Β· codemaps Β· feedback Β· fix Β· gate Β· harness Β· loop Β· mx Β· plan Β· project Β· review Β· run Β· sync.
MoAI-ADK assigns optimal AI models to each of the 8 retained agents based on your Claude Code subscription plan. This maximizes quality within your plan's rate limits.
| Policy | Plan | π£ Opus | π΅ Sonnet | π‘ Haiku | Best For |
|---|---|---|---|---|---|
| High | Max $200/mo | 16 | 5 | 3 | Maximum quality, highest throughput |
| Medium | Max $100/mo | 3 | 17 | 4 | Balanced quality and cost |
| Low | Plus $20/mo | 0 | 13 | 11 | Budget-friendly, no Opus access |
Why does this matter? The Plus $20 plan does not include Opus access. Setting
Lowensures all agents use only Sonnet and Haiku, preventing rate limit errors. Higher plans benefit from Opus on critical agents (security, strategy, architecture) while using Sonnet/Haiku for routine tasks.
Only the 8 retained agents appear below. 12 legacy agent names are archived β for the migration table of manager-strategy, manager-quality, manager-project, the 6 expert-* agents, and others, see .claude/rules/moai/workflow/archived-agent-rejection.md.
| Agent | High | Medium | Low |
|---|---|---|---|
| manager-spec | π£ opus | π£ opus | π΅ sonnet |
| manager-develop | π£ opus | π΅ sonnet | π΅ sonnet |
| manager-docs | π΅ sonnet | π‘ haiku | π‘ haiku |
| manager-git | π‘ haiku | π‘ haiku | π‘ haiku |
| Agent | High | Medium | Low |
|---|---|---|---|
| plan-auditor | π£ opus | π£ opus | π΅ sonnet |
| sync-auditor | π£ opus | π΅ sonnet | π΅ sonnet |
| Agent | High | Medium | Low |
|---|---|---|---|
| builder-harness | π£ opus | π΅ sonnet | π‘ haiku |
| Agent | High | Medium | Low |
|---|---|---|---|
| Explore (Anthropic built-in) | (inherits session model β no MoAI model-policy assignment) |
Team role profiles (researcher, analyst, architect, implementer, tester, designer, reviewer) are spawned dynamically at runtime via Agent(subagent_type: "general-purpose") with model + isolation overrides from workflow.yaml. They are NOT static agent definitions and do not have fixed tier-mapping rows.
# During project initialization
moai init my-project # Interactive wizard includes model policy selection
# Reconfigure existing project
moai update -c # Re-run the init wizard (no template sync)
moai updatevsmoai update -c: baremoai updatesyncs templates via 3-way merge;moai update -c(--config) re-runs the init wizard to edit project configuration and does NOT synchronize templates.
During moai update -c, you'll be asked:
Default policy is
High. GLM settings are isolated insettings.local.json(not committed to Git).
MoAI-ADK now captures your AskUserQuestion decisions and uses them to personalize future recommendations. This system learns from your choices while maintaining privacy through automatic data decay and session-scoped controls.
3-Tier Memory Layer (internal/cli/preference/)
Adaptive Recommendation Placement (.claude/rules/moai/core/askuser-protocol.md)
PostToolUse Capture Hook (internal/hook/user_decision_capture.go)
Decay Policy (moai preference decay-scan)
(age+1)^(-0.5) β Ξ±=0.5 fixed for Standard tierRecovery Controls
moai preference toggle β disable per project)# View captured preferences
moai preference list [--domain=<D>] [--key=<K>]
# Trigger decay scan (runs daily via cron/automation)
moai preference decay-scan [--memory-dir=<path>] [--now=<timestamp>] [--force]
# Toggle personalization (session-scoped)
moai preference toggle [--disable] [--project-root=<path>]
memory/user_decisions/, separate from engineering lessonsSee SPEC-V3R6-ASKUSER-DECISION-MEMORY-001 for complete requirements, architecture, and acceptance criteria.
MoAI-ADK provides both Sub-Agent and Agent Teams execution modes supported by Claude Code.
graph TD
A["πΏ MoAI Orchestrator"] --> B{"Select Execution Mode"}
B -->|"--solo"| C["Sub-Agent Mode"]
B -->|"--team"| D["Agent Teams Mode"]
B -->|"Default (Auto)"| E["Auto Selection"]
C --> F["Sequential Expert Delegation<br/>Task() β Expert Agent"]
D --> G["Parallel Team Collaboration<br/>Agent(name=β¦) β SendMessage"]
E -->|"High Complexity"| D
E -->|"Low Complexity"| C
style C fill:#2196F3,color:#fff
style D fill:#FF9800,color:#fff
style E fill:#4CAF50,color:#fff
MoAI-ADK automatically analyzes project complexity and selects the optimal execution mode:
| Condition | Selected Mode | Reason |
|---|---|---|
| 3+ domains | Agent Teams | Multi-domain coordination |
| 10+ affected files | Agent Teams | Large-scale changes |
| Complexity score 7+ | Agent Teams | High complexity |
| Otherwise | Sub-Agent | Simple, predictable workflow |
Agent Teams Mode uses parallel team-based development:
Agent(name=β¦) (implicit team), SendMessage, and TaskList/moai plan "large feature" # Auto: researcher + analyst + architect in parallel
/moai run SPEC-XXX # Auto: backend-dev + frontend-dev + tester in parallel
/moai run SPEC-XXX --team # Force Agent Teams mode
Quality Hooks for Agent Teams:
--solo)A sequential agent delegation approach using Claude Code's Task() API.
/moai run SPEC-AUTH-001 --solo # Force Sub-Agent mode
MoAI's core workflow consists of three phases:
graph TB
subgraph Plan ["π Plan Phase"]
P1["Explore Codebase"] --> P2["Analyze Requirements"]
P2 --> P3["Generate SPEC Document (EARS Format)"]
end
subgraph Run ["π¨ Run Phase"]
R1["Analyze SPEC & Create Execution Plan"] --> R2["DDD/TDD Implementation"]
R2 --> R3["TRUST 5 Quality Validation"]
end
subgraph Sync ["π Sync Phase"]
S1["Generate Documentation"] --> S2["Update README/CHANGELOG"]
S2 --> S3["Create Pull Request"]
end
Plan --> Run
Run --> Sync
style Plan fill:#E3F2FD,stroke:#1565C0
style Run fill:#E8F5E9,stroke:#2E7D32
style Sync fill:#FFF3E0,stroke:#E65100
3-phase lifecycle (V3R6): MoAI's lifecycle is exactly three phases β plan β run β sync. The former fourth "Mx-phase" was retired per
SPEC-V3R6-LIFECYCLE-REDESIGN-001; MX Tag validation is now a cross-cutting sync concern, not a separate phase. Dynamic workflows (/effort ultracode, Claude Code v2.1.154+) are available as an optional fan-out primitive within the run phase.
When transitioning from Plan to Run phase, MoAI automatically detects the current execution environment (cc/glm/cg) and presents a selection UI for the user to confirm or change the mode before implementation begins.
graph LR
A["Plan Complete"] --> B["Detect Environment"]
B --> C{"Mode Selection UI"}
C -->|"CC"| D["Claude-only Execution"]
C -->|"GLM"| E["GLM-only Execution"]
C -->|"CG"| F["Claude Leader + GLM Workers"]
This gate ensures the correct execution mode is used regardless of the environment state, preventing mode mismatches during implementation.
All subcommands are invoked within Claude Code as /moai <subcommand>.
| Subcommand | Aliases | Purpose | Key Flags |
|---|---|---|---|
plan | spec | Create SPEC document (EARS format) | --worktree, --branch, --resume SPEC-XXX, --team, --tmux |
run | impl | DDD/TDD implementation of a SPEC | --resume SPEC-XXX, --team |
sync | docs, pr | Sync documentation, codemaps, and create PR | --merge, --skip-mx |
| Subcommand | Aliases | Purpose | Key Flags |
|---|---|---|---|
fix | β | Auto-fix LSP errors, linting, type errors (single pass) | --dry, --seq, --level N, --resume, --team |
loop | β | Iterative auto-fix until completion (max 100 iterations) | --max N, --auto-fix, --seq |
review | code-review | Code review with security and @MX tag compliance check | --staged, --branch, --security |
clean | refactor-clean | Dead code identification and safe removal | --dry, --safe-only, --file PATH |
| Subcommand | Aliases | Purpose | Key Flags |
|---|---|---|---|
project | init | Generate project docs (product.md, structure.md, tech.md, .moai/project/codemaps/) | β |
mx | β | Scan codebase and add @MX code-level annotations | --all, --dry, --priority P1-P4, --force, --team |
codemaps | update-codemaps | Generate architecture docs in .moai/project/codemaps/ | --force, --area AREA |
feedback | fb, bug, issue | Collect user feedback and create GitHub issues | β |
| Subcommand | Purpose | Key Flags |
|---|---|---|
| (none) | Full autonomous plan β run β sync pipeline. Auto-generates SPEC when complexity score >= 5. | --loop, --max N, --branch, --pr, --resume SPEC-XXX, --team, --solo |
Control how agents are dispatched during workflow execution:
| Flag | Mode | Description |
|---|---|---|
--team | Agent Teams | Parallel team-based execution. Multiple agents work simultaneously. |
--solo | Sub-Agent | Sequential single-agent delegation per phase. |
| (default) | Auto | System auto-selects based on complexity (domains >= 3, files >= 10, or score >= 7). |
--team supports three execution environments:
| Environment | Command | Leader | Workers | Best For |
|---|---|---|---|---|
| Claude-only | moai cc | Claude | Claude | Maximum quality |
| GLM-only | moai glm | GLM | GLM | Maximum cost savings |
| CG (Claude+GLM) | moai cg | Claude | GLM | Quality + cost balance |
New in v2.7.1: CG mode is now the default team mode. When using
--team, the system runs in CG mode unless explicitly changed withmoai ccormoai glm.
Note:
moai cguses tmux pane-level env isolation to separate Claude leader from GLM workers. If switching frommoai glm,moai cgautomatically resets GLM settings first β no need to runmoai ccin between.
An autonomous error-fixing engine that combines LSP diagnostics with AST-grep:
/moai fix # Single pass: scan β classify β fix β verify
/moai loop # Iterative fix: repeats until completion marker detected (max 100 iterations)
How the Ralph Engine works:
New Feature Development:
/moai plan β /moai run SPEC-XXX β /moai review β /moai sync SPEC-XXX
Bug Fix:
/moai fix (or /moai loop) β /moai review β /moai sync
Refactoring:
/moai plan β /moai clean β /moai run SPEC-XXX β /moai review β /moai codemaps
Documentation Update:
/moai codemaps β /moai sync
Every code change is validated against five quality criteria:
| Criterion | Meaning | Validation |
|---|---|---|
| Tested | Tested | 85%+ coverage, characterization tests, unit tests passing |
| Readable | Readable | Clear naming conventions, consistent code style, 0 lint errors |
| Unified | Unified | Consistent formatting, import ordering, project structure adherence |
| Secured | Secured | OWASP compliance, input validation, 0 security warnings |
| Trackable | Trackable | Conventional commits, issue references, structured logging |
MoAI-ADK automatically captures Task tool metrics during development sessions:
.moai/logs/task-metrics.jsonlMetrics are logged by the PostToolUse hook when Task tool completes. Use this data to analyze agent efficiency and optimize token consumption.
All hook events follow the Claude Code hooks protocol with JSON stdin/stdout communication:
| Command | Description |
|---|---|
moai init | Interactive project setup (auto-detects language/framework/methodology) |
moai doctor | System health diagnosis and environment verification |
moai status | Project status summary including Git branch, quality metrics, etc. |
moai inventory | Unified read-only inventory of active sessions, worktrees, and harnesses (add --json for structured output) |
moai update | Update to the latest version (with automatic rollback support) |
moai update -c | Re-run the init wizard to edit project configuration (no template sync) |
moai update --check | Check for updates without installing |
moai update --project | Sync project templates only |
moai worktree new <name> | Create a new Git worktree (parallel branch development). Add --tmux to auto-create a tmux session in the worktree |
moai worktree list | List active worktrees |
moai worktree switch <name> | Switch to a worktree |
moai worktree sync | Sync with upstream |
moai worktree remove <name> |
MoAI-ADK supports z.ai GLM as an alternative AI backend for Claude Code, enabling multi-LLM development workflows.
| Item | Details |
|---|---|
| GLM Coding Plan | From $10/month (z.ai) |
| Compatibility | Works with Claude Code β no code changes needed |
| Models | glm-5.2[1m], glm-4.7, glm-4.5-air, and free models |
Default Model Mapping:
| Claude Tier | GLM Model | Input (per 1M tokens) | Output (per 1M tokens) |
|---|---|---|---|
| Opus / Sonnet / Haiku / Fable | glm-5.2[1m] | $2.00 | $8.00 |
All four Claude tiers (Opus, Sonnet, Haiku, Fable) are unified to
glm-5.2[1m]β a single 1M-context model. GLM models are intentionally NOT mapped disparately across these slots (e.g. opusβglm-5.2, sonnetβglm-4.7, haikuβglm-4.5-air) because mixing a 1M-context model with 200K-context models across those slots breaks agent-spawn session sharing: a 1M-context model and a 200K-context model cannot share a session.
The
[1m]suffix onglm-5.2[1m]activates Claude Code's 1M-token context mode. Claude Code parses and strips the suffix before the upstream z.ai API call, so z.ai never sees it.
The mapping is implemented via four Claude Code
ANTHROPIC_DEFAULT_*_MODELenvironment variables βANTHROPIC_DEFAULT_OPUS_MODEL,ANTHROPIC_DEFAULT_SONNET_MODEL,ANTHROPIC_DEFAULT_HAIKU_MODEL, andANTHROPIC_DEFAULT_FABLE_MODELβ all set toglm-5.2. The Fable variable is officially supported as of Claude Code v2.1.202.
Free models also available: GLM-4.7-Flash, GLM-4.5-Flash. See z.ai Pricing for full details.
CG Mode is a hybrid mode where the Leader uses Claude API while Workers use GLM API. It's implemented via tmux session-level environment variable isolation.
moai cg execution
β
βββ 1. Inject GLM config into tmux session env
β (ANTHROPIC_AUTH_TOKEN, BASE_URL, MODEL_* vars)
β
βββ 2. Remove GLM env from settings.local.json
β β Leader pane uses Claude API
β
βββ 3. Set CLAUDE_CODE_TEAMMATE_DISPLAY=tmux
β β Workers inherit GLM env in new panes
β
βββ 4. Launch Claude Code (replaces current process)
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β LEADER (current tmux pane, Claude API) β
β - Orchestrates workflow when /moai --team runs β
β - Handles plan, quality, sync phases β
β - No GLM env β uses Claude API β
ββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββ
β Agent Teams (new tmux panes)
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β TEAMMATES (new tmux panes, GLM API) β
β - Inherit tmux session env β use GLM API β
β - Execute implementation tasks in run phase β
β - Communicate with leader via SendMessage β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# 1. Save GLM API key (once)
moai glm sk-your-glm-api-key
# 2. Verify tmux environment (skip if already in tmux)
# If you need a new tmux session:
tmux new -s moai
# TIP: Set VS Code terminal default to tmux for automatic tmux environment.
# This allows you to skip this step entirely.
# 3. Launch CG mode (automatically starts Claude Code)
moai cg
# 4. Run team workflow
/moai --team "your task description"
| Item | Description |
|---|---|
| tmux Environment | If already using tmux, no need to create a new session. Set VS Code terminal default to tmux for convenience. |
| Auto Launch | moai cg automatically launches Claude Code in the current pane. No need to run claude separately. |
| Session End | session_end hook automatically clears tmux session env β next session uses Claude |
| Agent Teams Communication | SendMessage tool enables LeaderβWorkers communication |
| Command | Leader | Workers | tmux Required | Cost Savings | Use Case |
|---|---|---|---|---|---|
moai cc | Claude | Claude | No | - | Complex work, maximum quality |
moai glm | GLM | GLM | Recommended | ~70% | Cost optimization |
moai cg | Claude | GLM | Required | ~60% | Quality + cost balance |
Agent Teams supports two display modes:
| Mode | Description | Communication | Leader/Worker Separation |
|---|---|---|---|
in-process | Default mode, all terminals | β SendMessage | β Same env |
tmux | Split-pane display | β SendMessage | β Session env isolation |
CG Mode only supports Leader/Worker API separation in tmux display mode.
MoAI-ADK uses @MX code-level annotation system to communicate context, invariants, and danger zones between AI agents.
@MX tags are inline code annotations that help AI agents understand your codebase faster and more accurately.
// @MX:ANCHOR: [AUTO] Hook registry dispatch - 5+ callers
// @MX:REASON: [AUTO] Central entry point for all hook events, changes have wide impact
func DispatchHook(event string, data []byte) error {
// ...
}
// @MX:WARN: [AUTO] Goroutine executes without context.Context
// @MX:REASON: [AUTO] Cannot cancel goroutine, potential resource leak
func processAsync() {
go func() {
// ...
}()
}
| Tag Type | Purpose | Description |
|---|---|---|
@MX:ANCHOR | Important contracts | Functions with fan_in >= 3, changes have wide impact |
@MX:WARN | Danger zones | Goroutines, complexity >= 15, global state mutation |
@MX:NOTE | Context | Magic constants, missing godoc, business rules |
@MX:TODO | Incomplete work | Missing tests, unimplemented features |
The @MX tag system is NOT designed to add tags to all code. The core principle is to "mark only the most dangerous/important code that AI needs to notice first."
| Priority | Condition | Tag Type |
|---|---|---|
| P1 (Critical) | fan_in >= 3 | @MX:ANCHOR |
| P2 (Danger) | goroutine, complexity >= 15 | @MX:WARN |
| P3 (Context) | magic constant, no godoc | @MX:NOTE |
| P4 (Missing) | no test file | @MX:TODO |
Most code doesn't meet any criteria, so it has no tags. This is normal.
// β No tag (fan_in = 1, low complexity)
func calculateTotal(items []Item) int {
total := 0
for _, item := range items {
total += item.Price
}
return total
}
// β
@MX:ANCHOR added (fan_in = 5)
// @MX:ANCHOR: [AUTO] Config manager load - 5+ callers
// @MX:REASON: [AUTO] Entry point for all CLI commands
func LoadConfig() (*Config, error) {
// ...
}
.moai/config/sections/mx.yaml)thresholds:
fan_in_anchor: 3 # < 3 callers = no ANCHOR
complexity_warn: 15 # < 15 complexity = no WARN
branch_warn: 8 # < 8 branches = no WARN
limits:
anchor_per_file: 3 # Max 3 ANCHOR tags per file
warn_per_file: 5 # Max 5 WARN tags per file
exclude:
- "**/*_generated.go" # Exclude generated files
- "**/vendor/**" # Exclude external libraries
- "**/mock_*.go" # Exclude mock files
# Scan entire codebase (Go projects)
/moai mx --all
# Preview only (no file modifications)
/moai mx --dry
# Scan by priority (P1 only)
/moai mx --priority P1
# Scan specific languages only
/moai mx --all --lang go,python
| Situation | Reason |
|---|---|
| New projects | Most functions have fan_in = 0 β no tags (normal) |
| Small projects | Few functions = simple call graph = fewer tags |
| High-quality code | Low complexity, no goroutines β no WARN tags |
| High thresholds | fan_in_anchor: 5 = even fewer tags |
The @MX tag system optimizes "Signal-to-Noise Ratio":
Database schema tooling: database-schema synchronization is handled by the CLI hook
moai hook db-schema-sync(see the CLI reference), not a dedicated slash command.
A: This is normal. @MX tags are added "only where needed." Most code is simple and safe enough that tags aren't required.
| Question | Answer |
|---|---|
| Is having no tags a problem? | No. Most code doesn't need tags. |
| When are tags added? | High fan_in, complex logic, danger patterns only |
| Are all projects similar? | Yes. Most code in every project has no tags. |
See the "@MX Tag System" section above for details.
The statusline v3 features a multi-line layout with real-time API usage monitoring:
Full mode (5 lines β 40-block individual bars):
π€ Opus 4.7 β π
v2.1.170 β πΏ v2.7.12 β β³ 5h 32m β π¬ MoAI
CW: π ββββββββββββββββββββββββββββββββββββββββ 52%
5H: π ββββββββββββββββββββββββββββββββββββββββ 4%
7D: π βββββββββββββββββββββββββββββββββββββββββ 56%
π moai-adk-go β π
±οΈ main β π +0 M38 ?2
Default mode (3 lines β 10-block inline bars):
π€ Opus 4.7 β π
v2.1.170 β πΏ v2.7.12 β β³ 16m β π¬ MoAI
CW: π ββββββββββ 25% β 5H: π ββββββββββ 12% β 7D: π ββββββββββ 3%
π moai-adk-go β π
±οΈ fix/my-feature β π +0 M38 ?2
2 display modes are available:
Edit .moai/config/sections/statusline.yaml directly:
statusline:
segments:
model: true
context: true
usage_5h: true # 5-hour API usage bar
usage_7d: true # 7-day API usage bar
output_style: true
directory: true
git_status: true
claude_version: true
moai_version: true
git_branch: true
Note: The
presetshorthand (full/compact/minimal) has been retired β configure the segment map directly above. A legacypreset:key in an existing config is silently ignored by the loader. Segment selection was already removed from themoai init/moai updatewizard as of v2.7.8.
The MoAI statusline shows version information with update notifications:
πΏ v2.2.2 β¬οΈ v2.2.5
v2.2.2: Currently installed versionβ¬οΈ v2.2.5: New version available for updateWhen you're on the latest version, only the version number is displayed:
πΏ v2.2.5
To update: Run moai update and the update notification will disappear.
Note: This is different from Claude Code's built-in version indicator (π
v2.1.38). The MoAI indicator tracks MoAI-ADK versions, while Claude Code shows its own version separately.
When opening a project, Claude Code may show a security prompt about external file imports:
External imports:
/Users/<user>/.moai/config/sections/quality.yaml
/Users/<user>/.moai/config/sections/user.yaml
/Users/<user>/.moai/config/sections/language.yaml
Recommended action: Select "No, disable external imports" β
Why?
.moai/config/sections/ already contains these filesWhat are these files?
quality.yaml: TRUST 5 framework and development methodology settingslanguage.yaml: Language preferences (conversation, comments, commits)user.yaml: User name (optional, for Co-Authored-By attribution)Contributions are welcome! See CONTRIBUTING.md for detailed guidelines.
git checkout -b feature/my-featuremake testmake lintmake fmtCode quality requirements: 85%+ coverage Β· 0 lint errors Β· 0 type errors Β· Conventional commits
Apache License 2.0 -- See the LICENSE file for details.
/moai:harness edit <name>/moai:harness remove <name>| Remove a worktree |
moai worktree clean | Clean up stale worktrees |
moai worktree go <name> | Navigate to worktree directory in current shell |
moai hook <event> | Claude Code hook dispatcher |
moai glm | Start Claude Code with GLM 5 API (cost-effective alternative) |
moai cc | Start Claude Code without GLM settings (Claude-only mode) |
moai cg | Launch CG mode β Claude leader + GLM teammates (auto-starts Claude Code, tmux required) |
moai version | Display version, commit hash, and build date |