CLI Reference

Complete reference for all Moatlog CLI commands.

moatlog init

Usage: moatlog init [--force] [--agent cursor|claude-code|all]

Scaffold hooks, MCP config, rules, and .moatlog/.

FlagTypeDefaultDescription
--forcebooleanfalseOverwrite existing scaffold files
--agentcursor | claude-code | allautoWhich agent hooks to scaffold. auto always scaffolds Cursor; also scaffolds Claude Code when .claude/ exists or claude is on PATH
shell
$ moatlog init

moatlog status

Usage: moatlog status [--verbose]

Hooks status and moat strength.

FlagTypeDefaultDescription
--verbosebooleanfalseShow window quality breakdown (high / low / meta). Also accepted as --detail
shell
$ moatlog status

moatlog distill

Usage: moatlog distill [days]

Compress events into moat.json.

ArgumentTypeDefaultDescription
daysnumber30How many days of event logs to include
shell
$ moatlog distill

moatlog report

Usage: moatlog report [--by-agent]

Show what your agent has been doing.

FlagTypeDefaultDescription
--by-agentbooleanfalseGroup report output by agent

With --by-agent, hot files are grouped under each agent name and session count.

shell
$ moatlog report

moatlog check-moat

Usage: moatlog check-moat [days]

Validate moat.json exists and is fresh.

ArgumentTypeDefaultDescription
daysnumber30Event log window to compare against moat.json generatedAt
shell
$ moatlog check-moat

moatlog doctor

Usage: moatlog doctor

Health check for hooks, MCP, moat.json, permissions.

shell
$ moatlog doctor

moatlog merge

Usage: moatlog merge [--branch <branch>] [--dry-run] [--no-llm]

Merge another branch's moat.json into the current one.

FlagTypeDefaultDescription
--branchstringmainBranch to merge from
--dry-runbooleanfalseShow what would change without writing moat.json
--no-llmbooleanfalseDeterministic pass only; surface conflicts as text
--helpbooleanfalseShow help

Reads base, ours, and theirs moat.json from git (three-way when a common ancestor exists; two-way otherwise). Unresolved conflicts can be sent to cursor, claude, or ANTHROPIC_API_KEY for automatic resolution unless --no-llm is set.

shell
$ moatlog merge
shell
$ moatlog merge --help

moatlog merge — merge another branch's moat.json into the current one

Usage:
  moatlog merge [--branch <branch>] [--dry-run] [--no-llm]

Options:
  --branch <branch>  Branch to merge from (default: main)
  --dry-run          Show what would change without writing moat.json
  --no-llm           Deterministic pass only; surface conflicts as text
  --help             Show this help

On success, prints a summary from formatMergeSummary (e.g. merged: N new files from theirs, N files with summed counts, N new prompt windows — no conflicts, moat.json updated) and saves .moatlog/moat.json unless --dry-run is set.

moatlog eval

Usage: moatlog eval [--threshold <n>] [--limit <n>] [--baseline] [--json]

Offline retrieval quality report.

FlagTypeDefaultDescription
--thresholdnumber2Minimum file count for a window to be included
--limitnumberall qualifyingMax windows to evaluate
--baselinebooleanfalseAlso run naive hot-file baseline for comparison
--jsonbooleanfalseOutput full results as JSON
--helpbooleanfalseShow help
shell
$ moatlog eval --baseline

moatlog clean

Usage: moatlog clean [--all] [--keep N]

Delete old event logs (keeps 30 days).

FlagTypeDefaultDescription
--allbooleanfalseDelete all event logs
--keepnumber30Keep last N days of event logs
shell
$ moatlog clean

moatlog mcp

Usage: moatlog mcp

Start the MCP server.

Runs the @moatlog/mcp server on stdio with the project root as cwd. Cursor and Claude Code invoke this via .cursor/mcp.json — you rarely run it manually.

shell
$ moatlog mcp

Environment variables

VariableDescription
ANTHROPIC_API_KEYUsed by moatlog merge for LLM conflict resolution when neither cursor nor claude CLI is detected on PATH.

Common workflows

shell
# verify setup after moatlog init
moatlog doctor

# check moat health before committing
moatlog check-moat
moatlog distill

# after a git merge conflict on moat.json
moatlog merge --branch main

# measure retrieval quality
moatlog eval --baseline

# team member joining an existing repo with moat.json
moatlog init
moatlog distill
moatlog status