MoAI-ADK Documentation

repository·main·Indexed 22 days ago

https://github.com/modu-ai/moai-adk

An agentic development harness for Claude Code that provides a structured environment to manage cost, quality, and continuous self-improvement. It features a hierarchical agent system led by Mr.Alfred, offering autonomous development cycles via commands like /moai:alfred, /moai:loop, and /moai:fix. The toolkit includes project initialization, specification generation using EARS format, and integration with the z.ai GLM 4.7 model for cost-effective AI coding.

Tokens
185.6K
Snippets
457
Records
816
Agent score
77%

What's inside MoAI-ADK

  1. Overview of the moai CLI command tree

    main

    The moai CLI (the Go binary) is organized into three functional groups:

    1. Launch: Commands to start Claude Code sessions with specific backends (moai cc, moai cg, moai glm).
    2. Project: Commands for lifecycle management, including initialization, updates, and diagnostics (moai init, moai update, moai doctor, moai status).
    3. Tools: Advanced utilities for configuration, inventory, hooks, worktrees, and specifications (moai profile, moai inventory, moai hook, moai worktree, moai spec, moai harness).

    Use moai version to check your current installation.

    moai version
  2. Overview of the MoAI CLI

    main

    The moai CLI (a Go binary) is a tool for managing agentic AI development workflows. It is distinct from the /moai slash command used within Claude Code's interactive interface. The CLI is organized into three main command groups:

    1. Launch: Commands to start Claude Code sessions with specific backends (moai cc, moai cg, moai glm).
    2. Project: Commands for project lifecycle management, including initialization, updates, diagnostics, and status checks (moai init, moai update, moai doctor, moai status).
    3. Tools: Utilities for configuration, inventory, hooks, worktrees, and more (moai profile, moai inventory, moai hook, etc.).

    Use moai version to check your currently installed version.

    moai version
  3. Overview of MoAI-ADK v3 Component Inventory

    main

    MoAI-ADK v3 is organized into several core architectural layers: Skills, Agents, Hooks, Commands, Rules, and Configuration.

    • Skills: Modular functional units (e.g., moai-workflow-tdd, moai-tool-ast-grep) that provide specific capabilities to the system.
    • Agents: High-level personas (e.g., manager-spec, expert-backend) that orchestrate skills to achieve complex goals.
    • Hooks: Native event listeners (e.g., SessionStart, FileChanged, PermissionRequest) that allow the system to react to lifecycle changes or user actions.
    • Commands: Slash-style triggers (e.g., /moai plan) used to invoke specific workflows.
    • Rules: Logic files (located in core/, design/, etc.) that govern agent behavior and system constraints.
    • Configuration: YAML-based settings (e.g., language.yaml, llm.yaml, workflow.yaml) loaded via Go to define the environment and agent parameters.
  4. Overview of Claude Code features

    main

    Claude Code is a model that reasons about code with built-in tools for file editing, search, and execution, supplemented by layers for context, extension, and automation.

    Its features are organized into four functional groups:

    1. Foundations: Core capabilities like code editing, search, command execution, and slash commands.
    2. Context and Memory: Managing the session state via CLAUDE.md and the context window.
    3. Extensibility: Expanding capabilities using Skills, MCP (Model Context Protocol), Hooks, and Plugins.
    4. Agents and Automation: Scaling work via Subagents, Agent teams, Worktrees, and Checkpoints.
  5. Overview of Agent Orchestration and Automation

    main

    MoAI-ADK provides orchestration primitives for moving beyond single-conversation interactions toward autonomous agentic loops. Developers can delegate tasks to multiple workers, facilitate collaboration within teams, and manage large-scale work via scripts.

    Core orchestration primitives include:

    • Subagents: Delegated workers operating in isolated contexts.
    • Agent Teams: Collaborative groups typically consisting of 3-5 members.
    • Dynamic Workflows: Script-based, large-scale orchestration for fanning out work.

    To build reliable autonomous execution loops, these primitives are combined with Worktrees (for isolation), Goal-Directed Execution (using /goal to run until a condition is met), Scheduled Tasks (for recurring background runs), and specific strategies for navigating Large Codebases.

  6. Overview of MoAI-ADK Core Values

    main

    MoAI-ADK (Agentic Development Kit) is a strategic orchestration framework designed for Claude Code. It focuses on three primary axes to move from 'vibe coding' to 'harness engineering':

    1. Tokenomics: Focuses on reducing inference costs (by 60-70%) using techniques like context dieting and prompt caching.
    2. Agentic Loop Engineering: Enables autonomous improvement cycles where agent loops accumulate observations to evolve harness guidance through recursive self-learning.
    3. Agentic Harness: Provides a composable execution environment utilizing skills, hooks, and MCP (Model Context Protocol) for extensible orchestration.

    Key features include the MoAI Orchestrator for task delegation, SPEC-Based TDD/DDD methodologies, the TRUST 5 Framework (Tested, Readable, Unified, Secured, Trackable), and Progressive Disclosure for efficient skill loading.

  7. What is MoAI-ADK?

    main

    MoAI-ADK (Agentic Development Kit) is an agentic harness designed for Claude Code. It acts as a system that wraps around the model to enforce constraints that the model itself cannot maintain due to its probabilistic, token-based nature.

    While Claude Code handles the generation, MoAI-ADK provides the structural layer for:

    • Cost (Tokenomics): Optimizing token usage and managing model routing to ensure high quality at predictable costs.
    • Self-Improvement (Agentic Loop Engineering): Turning observations from previous sessions into rules to prevent repeating mistakes.
    • Quality Control (Agentic Harness): Using lifecycle management (SPEC) and quality gates (TRUST 5) to prevent expensive rework.

    It is distributed as a single Go binary that runs on macOS, Linux, and Windows without external dependencies.

  8. Foundations of Claude Code

    main

    The Claude Code foundations group provides the essential knowledge required to use the agentic harness effectively. It covers the agentic loop, core features, interactive usage, slash commands, tools, and the configuration directory. Understanding these fundamentals is critical because the MoAI-ADK harness is built directly upon these core components (the loop, tools, permissions, and settings directory).

    To master the fundamentals, follow this recommended learning flow:

    1. How It Works: Understand the agentic loop and core components.
    2. Features at a Glance: Scan the full feature catalog.
    3. Interactive Mode: Learn REPL usage, shortcuts, and permission modes.
    4. Slash Commands: Learn built-in and custom commands (including the /moai relationship).
    5. Tools Reference: Understand built-in tools and permission requirements.
    6. .claude Directory: Learn the settings directory structure and scopes.
  9. Compare MoAI CLI Launchers (cc, cg, glm)

    main

    MoAI provides three primary launchers to run Claude Code with different backend configurations. Choosing a launcher is a tokenomics decision based on your cost and reasoning requirements.

    LauncherBackendPurpose
    moai ccClaude onlyStandard execution where every agent uses Claude models.
    moai glmGLM onlyEvery agent uses GLM models via the Z.AI proxy.
    moai cgClaude + GLM hybridCost-optimized: The Leader uses Claude, while Teammates use GLM (60-70% cost reduction).

    Note on GLM limitations:

    • GLM does not support the auto permission mode.
    • Z.AI has low concurrent-request limits (1-3 in-flight on paid tier). For parallel multi-agent execution, moai cg is more stable.
  10. Explore MoAI-ADK Advanced Topics

    main

    MoAI-ADK is built upon three core pillars. Developers can dive into specific implementation details for each:

    1. Tokenomics (Cost Axis)

    Focuses on managing the economic efficiency of agentic workflows. Key topics include:

    • Token Budgeting: Using circuit breakers and context diets to prevent cost overages.
    • 3-Tier Policy: Implementing reasoning depth based on task complexity.
    • Profile Matrix: Managing the relationship between models and effort levels.
    • Statusline: Monitoring context usage, cache hit rates, and rate limits.

    2. Agentic Loop Engineering (Self-improvement Axis)

    Focuses on how the system learns and evolves. Key topics include:

    • Self-Evolving Systems: Moving through the learning ladder (observation → heuristic → rule → auto-update).
    • Autonomous Loops: Using /moai goal and /moai loop for diagnostic-driven execution.
    • Decision Memory: Learning from user choices via an observation system.
    • Ultracode Workflows: Orchestrating multi-agent fan-out workflows.

    3. Agentic Harness (Quality-control Axis)

    Focuses on the implementation of the environment. Key topics include:

    • Skills & Agents: Building specialized expertise and task performers.
    • Builder Agents: Generating new skills, agents, commands, and plugins.
    • Harness Profiles: Implementing verification depth and scoring systems.
    • Catalog System: Managing the 3-tier manifest.

    4. Control and Automation

    Focuses on the configuration and scripting of the harness, including Hooks, settings.json, CLAUDE.md, and @MX Tags for inline agent annotations.

  11. Overview of the MoAI Statusline System

    main

    The MoAI Statusline is a 3-line terminal layout designed for Claude Code and moai-adk-go integrations. It provides real-time visibility into tokenomics (context usage, cache hit rates, rate limits), model reasoning depth, and development workflow (Git status, active SPEC tasks, and PR states).

    3-Line Layout Structure

    • Line 1 (Info): Displays model name, effort/thinking level, cache hit rate, Claude Code version, MoAI version, session duration, and output style.
    • Line 2 (Usage Bars): Visualizes token usage via bars for Context Window (CW), 5-hour rolling limits (5H), and 7-day rolling limits (7D).
    • Line 3 (Git/PR): Shows the current directory, repository/branch info, Git status (staged/modified/untracked), active SPEC tasks, and active Pull Request details.

    Data Flow

    1. Claude Code passes stdin JSON.
    2. .moai/status_line.sh (shell wrapper defined in settings.json) receives it.
    3. moai statusline (Go binary) parses the data.
    4. internal/statusline/renderer.go renders the 3-line v3 layout to the terminal.
  12. What is a Claude Code plugin

    main

    A Claude Code plugin is an extension bundle that packages multiple elements—such as commands, agents, skills, hooks, and MCP—into a single versioned directory for sharing and reuse.

    Unlike standalone configuration in the .claude/ directory, plugins use a manifest file (.claude-plugin/plugin.json) to provide an identity and automatic namespacing. For example, a skill named hello in a plugin named my-plugin is invoked as /my-plugin:hello to prevent collisions with other configurations.

    {
      "name": "my-first-plugin",
      "description": "A greeting plugin to learn the basics",
      "version": "1.0.0",
      "author": { "name": "Your Name" }
    }