CLI Reference

Complete reference for all codeloops commands and options.

Overview

codeloops [OPTIONS] [COMMAND]

When no command is specified, codeloops runs the actor-critic loop (equivalent to codeloops run).

Commands

CommandDescription
runRun the actor-critic loop (default)
sessionsBrowse and inspect sessions
uiStart the web UI
initInteractive configuration setup
helpPrint help information

Run Command

Execute the actor-critic loop. This is the default command when none is specified.

codeloops run [OPTIONS]
codeloops [OPTIONS]  # Same as above

Prompt Options

OptionTypeDefaultDescription
-p, --prompt <PROMPT>String-Task prompt (inline)
--prompt-file <FILE>Pathprompt.mdPath to prompt file

If neither --prompt nor --prompt-file is provided, codeloops looks for prompt.md in the working directory.

Directory Options

OptionTypeDefaultDescription
-d, --working-dir <DIR>PathCurrent directoryWorking directory for the session

Agent Options

OptionTypeDefaultDescription
-a, --agent <AGENT>EnumclaudeAgent for both actor and critic
--actor-agent <AGENT>Enum-Agent specifically for actor role
--critic-agent <AGENT>Enum-Agent specifically for critic role
-m, --model <MODEL>String-Model to use (if agent supports it)

Agent values: claude, opencode, cursor

Loop Control

OptionTypeDefaultDescription
-n, --max-iterations <N>IntegerUnlimitedMaximum loop iterations

Output Options

OptionTypeDefaultDescription
--log-format <FORMAT>EnumprettyOutput format
--log-file <PATH>Path-Write structured logs to file
--json-outputFlag-Output final result as JSON
--no-colorFlag-Disable colored output

Log format values: pretty, json, compact

Other Options

OptionTypeDefaultDescription
--dry-runFlag-Show configuration without executing

Examples

# Run with default prompt.md
codeloops

# Run with inline prompt
codeloops --prompt "Fix the bug in main.rs"

# Run with custom prompt file
codeloops --prompt-file tasks/feature.md

# Run with specific agent
codeloops --agent opencode

# Run with mixed agents
codeloops --actor-agent opencode --critic-agent claude

# Limit iterations
codeloops --max-iterations 5

# Output as JSON
codeloops --json-output

# Dry run to verify configuration
codeloops --dry-run

Sessions Command

Browse and inspect recorded sessions.

codeloops sessions <SUBCOMMAND>

Subcommands

list

List all sessions with optional filtering.

codeloops sessions list [OPTIONS]
OptionTypeDescription
--outcome <OUTCOME>StringFilter by outcome: success, failed, interrupted, max_iterations_reached
--after <DATE>DateShow sessions after date (YYYY-MM-DD)
--before <DATE>DateShow sessions before date (YYYY-MM-DD)
--search <TEXT>StringSearch in prompt text
--project <NAME>StringFilter by project name

Examples:

# List all sessions
codeloops sessions list

# Filter by outcome
codeloops sessions list --outcome success

# Filter by date range
codeloops sessions list --after 2025-01-01 --before 2025-01-31

# Search prompts
codeloops sessions list --search "authentication"

# Filter by project
codeloops sessions list --project myapp

show

Show detailed session information.

codeloops sessions show [ID]

If no ID is provided, opens an interactive picker to select a session.

Examples:

# Interactive picker
codeloops sessions show

# Show specific session
codeloops sessions show 2025-01-27T15-30-45Z_a3f2c1

diff

Show the cumulative git diff from a session.

codeloops sessions diff [ID]

If no ID is provided, opens an interactive picker.

Examples:

# Interactive picker
codeloops sessions diff

# Show diff for specific session
codeloops sessions diff 2025-01-27T15-30-45Z_a3f2c1

stats

Show aggregate statistics across all sessions.

codeloops sessions stats

Output includes:

  • Total sessions
  • Success rate
  • Average iterations
  • Average duration
  • Sessions by project

UI Command

Start the web UI for visual session browsing.

codeloops ui [OPTIONS]
OptionTypeDefaultDescription
--devFlag-Development mode with hot reloading
--api-port <PORT>Integer3100API server port
--ui-port <PORT>Integer3101UI server port

Examples:

# Start UI with defaults
codeloops ui

# Custom ports
codeloops ui --api-port 4000 --ui-port 4001

# Development mode
codeloops ui --dev

The UI opens automatically in your default browser.

Init Command

Interactive first-time setup.

codeloops init

This command:

  1. Prompts for your preferred default agent
  2. Creates ~/.config/codeloops/config.toml
  3. Displays the generated configuration

Run this after installation to set up your defaults.

Global Options

These options work with any command:

OptionDescription
-h, --helpPrint help information
-V, --versionPrint version information

Exit Codes

CodeMeaning
0Success
1Max iterations reached
2Failed (error during execution)
130User interrupted (Ctrl+C)

Environment Variables

VariableDescription
CODELOOPS_UI_DIROverride the UI directory location
NO_COLORDisable colored output when set