Skip to main content

moai inventory Command

UPDATED 2026-08-13 3 min read EDIT ON GITHUB ↗

A guide to the moai inventory command, which shows the current project’s active sessions, worktrees, and harnesses at a glance.

In workflows that run multiple SPECs in parallel, it is hard to see at a glance which session is using which harness and worktree, so this command gathers all three resources into a single read-only view. That makes it well suited as the first step a manager agent takes to check for contention before spawning new work.

Info
One-line summary: moai inventory shows the current project’s active resources (sessions, worktrees, harnesses) read-only. With --json you get structured output for use in scripts.

Overview

moai inventory is a read-only command that provides a unified view to check “what is running right now?” at once when you operate multiple parallel sessions and worktrees.

What it shows

ResourceDescriptionData source
SessionsActive Claude Code sessions.moai/state/active-sessions.json
WorktreesGit worktrees for the projectGit worktree list
HarnessesRegistered harnesses.moai/harness/ manifests

Command form

bash
moai inventory [OPTIONS]

Flags

FlagDescription
--jsonStructured JSON output (machine-readable)
--project-root <path>Project root path (default: current directory)

This command supports only the two flags above. There are no filtering or verbose-mode flags — do any needed processing on the --json output with jq or similar.

Basic use

bash
moai inventory

Prints a text-format summary of sessions, worktrees, and harnesses.

JSON output

bash
moai inventory --json

Outputs structured JSON for use in automated analysis or CI scripts.

JSON schema

The top-level structure of the --json output consists of three sections.

json
{
  "sessions": { ... },
  "worktrees": { ... },
  "harnesses": { ... }
}

Each section has count, entries, and an optional error field.

Session entry

json
{
  "session_id": "edc25996",
  "spec_id": "SPEC-DOCS-001",
  "phase": "run"
}
FieldDescription
session_idSession ID (short form, first 8 characters)
spec_idLinked SPEC ID
phaseCurrent phase (plan, run, sync, mx)

Worktree entry

json
{
  "branch": "feat/auth",
  "path": "/home/user/.moai/worktrees/project/SPEC-AUTH-001",
  "head": "a1b2c3d4"
}
FieldDescription
branchWorktree branch name
pathWorktree filesystem path
headHEAD commit hash (short form, first 8 characters)

Harness entry

json
{
  "name": "backend-team",
  "domain": "backend",
  "manifest_missing": false
}
FieldDescription
nameHarness name
domainHarness domain
manifest_missingWhether the manifest file is missing (true means the configuration is incomplete)

Full output example

json
{
  "sessions": {
    "count": 2,
    "entries": [
      { "session_id": "edc25996", "spec_id": "SPEC-DOCS-001", "phase": "run" },
      { "session_id": "a1b2c3d4", "spec_id": "SPEC-AUTH-002", "phase": "plan" }
    ]
  },
  "worktrees": {
    "count": 1,
    "entries": [
      { "branch": "feat/auth", "path": "/home/user/.moai/worktrees/project/SPEC-AUTH-001", "head": "a1b2c3d4" }
    ]
  },
  "harnesses": {
    "count": 1,
    "entries": [
      { "name": "backend-team", "domain": "backend", "manifest_missing": false }
    ]
  }
}

Practical usage examples

1. Detect multi-session contention

If two or more sessions are working on the same SPEC, there is a contention risk.

bash
moai inventory --json | jq '[.sessions.entries[] | .spec_id] | group_by(.) | map(select(length > 1))'

2. List active worktree branches

bash
moai inventory --json | jq -r '.worktrees.entries[].branch'

3. Find harnesses with a missing manifest

A harness with manifest_missing: true is in an incomplete configuration state.

bash
moai inventory --json | jq '.harnesses.entries[] | select(.manifest_missing)'

4. Distribution of currently in-progress phases

bash
moai inventory --json | jq '[.sessions.entries[].phase] | group_by(.) | map({phase: .[0], count: length})'
Info
Tip: moai inventory --json can be used in monitoring dashboards and CI scripts. Since it is a read-only command, it is safe to automate.