moai inventory Command
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.
InfoOne-line summary:moai inventoryshows the current project’s active resources (sessions, worktrees, harnesses) read-only. With--jsonyou get structured output for use in scripts.
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.
| Resource | Description | Data source |
|---|---|---|
| Sessions | Active Claude Code sessions | .moai/state/active-sessions.json |
| Worktrees | Git worktrees for the project | Git worktree list |
| Harnesses | Registered harnesses | .moai/harness/ manifests |
moai inventory [OPTIONS]| Flag | Description |
|---|---|
--json | Structured 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.
moai inventoryPrints a text-format summary of sessions, worktrees, and harnesses.
moai inventory --jsonOutputs structured JSON for use in automated analysis or CI scripts.
The top-level structure of the --json output consists of three sections.
{
"sessions": { ... },
"worktrees": { ... },
"harnesses": { ... }
}Each section has count, entries, and an optional error field.
{
"session_id": "edc25996",
"spec_id": "SPEC-DOCS-001",
"phase": "run"
}| Field | Description |
|---|---|
session_id | Session ID (short form, first 8 characters) |
spec_id | Linked SPEC ID |
phase | Current phase (plan, run, sync, mx) |
{
"branch": "feat/auth",
"path": "/home/user/.moai/worktrees/project/SPEC-AUTH-001",
"head": "a1b2c3d4"
}| Field | Description |
|---|---|
branch | Worktree branch name |
path | Worktree filesystem path |
head | HEAD commit hash (short form, first 8 characters) |
{
"name": "backend-team",
"domain": "backend",
"manifest_missing": false
}| Field | Description |
|---|---|
name | Harness name |
domain | Harness domain |
manifest_missing | Whether the manifest file is missing (true means the configuration is incomplete) |
{
"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 }
]
}
}If two or more sessions are working on the same SPEC, there is a contention risk.
moai inventory --json | jq '[.sessions.entries[] | .spec_id] | group_by(.) | map(select(length > 1))'moai inventory --json | jq -r '.worktrees.entries[].branch'A harness with manifest_missing: true is in an incomplete configuration state.
moai inventory --json | jq '.harnesses.entries[] | select(.manifest_missing)'moai inventory --json | jq '[.sessions.entries[].phase] | group_by(.) | map({phase: .[0], count: length})'- CLI Reference — full CLI commands
- Project Status — the
moai statuscommand - SPEC-based Development — the SPEC lifecycle
InfoTip:moai inventory --jsoncan be used in monitoring dashboards and CI scripts. Since it is a read-only command, it is safe to automate.