Skip to content

CLI Reference

Complete reference for the rai command-line interface.

These options are available on all commands:

FlagShortDescription
--version-VShow version and exit
--format-fOutput format: human, json, or table
--verbose-vIncrease verbosity (-v, -vv, -vvv)
--quiet-qSuppress non-error output
--helpShow help and exit

Initialize a RaiSE project in the current directory. Detects project type (greenfield or brownfield), creates .raise/manifest.yaml, and sets up the project structure.

With --detect, also analyzes code conventions and generates guardrails.

FlagShortDescription
--name-nProject name (defaults to directory name)
--path-pProject path (defaults to current directory)
--detect-dDetect conventions and generate guardrails.md
Terminal window
# New project
rai init
# Named project
rai init --name my-api
# Existing project with convention detection
rai init --detect

Start a new working session. Increments the session counter and sets active session state. Checks for orphaned sessions (started but not closed) and warns if found.

With --context, outputs a token-optimized context bundle (~150 tokens) assembled from your developer profile, session state, and memory graph.

FlagShortDescription
--name-nYour name (required for first-time setup)
--project-pProject path to associate with this session
--agentAgent type (e.g., claude-code, cursor). Default: unknown
--contextOutput a context bundle for AI consumption
Terminal window
# First-time setup
rai session start --name "Alice" --project .
# Start session with context bundle
rai session start --project . --context
# Simple start
rai session start

End the current working session. With --summary or --state-file, performs a full structured close — records session, patterns, corrections, and updates state.

FlagShortDescription
--summary-sSession summary
--type-tSession type (feature, research, maintenance, etc.)
--patternPattern description to record
--correctionCoaching correction observed
--correction-lessonLesson from the correction
--state-fileYAML file with full structured session output
--sessionSession ID to close (e.g., SES-177). Falls back to RAI_SESSION_ID env var
--project-pProject path
Terminal window
# Simple close
rai session close
# Close with summary
rai session close --summary "Implemented auth module" --type feature
# Close with pattern learned
rai session close --summary "Refactored tests" --type maintenance \
--pattern "Use fixtures for database setup"

Search the unified memory for relevant concepts. The memory contains all context sources: governance (principles, requirements, terms), memory (patterns, calibration, sessions), skills (workflow metadata), and work (epics, stories, decisions).

FlagShortDescription
--format-fOutput format: human or json
--output-oOutput file path (default: stdout)
--strategy-sQuery strategy: keyword_search or concept_lookup
--types-tFilter by types (comma-separated: pattern, calibration, principle, etc.)
--edge-typesFilter by edge types (comma-separated: constrained_by, depends_on, etc.)
--limit-lMaximum number of results (default: 10)
--index-iMemory index path
Terminal window
# Search by keywords
rai memory query "planning estimation"
# Filter to patterns only
rai memory query "testing" --types pattern,calibration
# Lookup specific concept by ID
rai memory query "PAT-001" --strategy concept_lookup
# Output as JSON
rai memory query "velocity" --format json

Show full architectural context for a module. Returns the module’s bounded context (domain), architectural layer, applicable guardrails (constraints), and module dependencies.

FlagShortDescription
--format-fOutput format: human or json
--index-iMemory index path
Terminal window
# Show context for memory module
rai memory context mod-memory
# JSON output
rai memory context mod-memory --format json

Build the unified memory index from all sources: governance documents, memory (patterns, calibration, sessions), work tracking (epics, stories), skills, and components from discovery.

FlagShortDescription
--output-oPath to save index JSON
Terminal window
# Build index to default location
rai memory build
# Save to custom location
rai memory build --output custom_index.json

Validate memory index structure and relationships. Checks for cycles in depends_on relationships, valid relationship types, and that all edge targets exist as nodes.

FlagShortDescription
--index-iPath to index JSON file
Terminal window
# Validate default index
rai memory validate
# Validate specific index file
rai memory validate --index custom_index.json

List concepts in the memory index. Shows concepts for inspection and debugging.

FlagShortDescription
--format-fOutput format: human, json, or table
--output-oOutput file path (default: stdout)
--index-iMemory index path
--memory-only / --allShow only memory types (pattern, calibration, session) or all
Terminal window
# Show summary table
rai memory list
# Show only patterns/calibrations/sessions
rai memory list --memory-only
# Export as JSON
rai memory list --format json --output memory.json

Extract concepts from governance markdown files. If no file path is provided, extracts from all standard governance locations (governance/prd.md, governance/vision.md, framework/reference/constitution.md).

FlagShortDescription
--format-fOutput format: human or json
Terminal window
# Extract from all governance files
rai memory extract
# Extract from specific file
rai memory extract governance/prd.md

Add a new pattern to memory. Patterns capture learnings from development — process improvements, technical discoveries, architectural decisions.

FlagShortDescription
--context-cContext keywords (comma-separated)
--type-tPattern type: codebase, process, architecture, technical (default: process)
--from-fStory/session where learned
--scope-sMemory scope: global, project, personal (default: project)
--memory-dir-mMemory directory path (overrides scope)
Terminal window
# Add a process pattern
rai memory add-pattern "HITL before commits" -c "git,workflow"
# Add a technical pattern
rai memory add-pattern "Use capsys for stdout tests" -t technical -c "pytest,testing"
# Add with source reference
rai memory add-pattern "BFS reuse across modules" -t architecture --from S2.3
# Add to personal scope
rai memory add-pattern "My workflow preference" --scope personal

Add calibration data for a completed story. Tracks estimate vs. actual duration for velocity analysis.

FlagShortDescription
--nameStory name (required)
--size-sT-shirt size: XS, S, M, L, XL (required)
--actual-aActual minutes spent (required)
--estimated-eEstimated minutes
--spStory points
--kata / --no-kataWhether kata cycle was followed (default: yes)
--notes-nAdditional notes
--scope-sMemory scope: global, project, personal
--memory-dir-mMemory directory path
Terminal window
# Basic calibration
rai memory add-calibration S3.5 --name "Skills Integration" -s XS -a 20
# With estimate for velocity calculation
rai memory add-calibration S3.5 --name "Skills Integration" -s XS -a 20 -e 60
# Full details
rai memory add-calibration S3.5 --name "Skills Integration" -s XS -a 20 -e 60 --sp 2 -n "Hook-assisted"

Add a session record to memory. Sessions are developer-specific and always written to the personal directory.

FlagShortDescription
--outcomes-oSession outcomes (comma-separated)
--type-tSession type (default: story)
--log-lPath to session log file
--memory-dir-mMemory directory path
Terminal window
# Basic session
rai memory add-session "S3.5 Skills Integration"
# With outcomes
rai memory add-session "S3.5 Skills Integration" -o "Writer API,Hooks setup,CLI commands"
# Full details
rai memory add-session "S3.5 Skills Integration" -t story -o "Writer API,Hooks" \
-l "dev/sessions/2026-02-02-s3.5.md"

Emit a work lifecycle event for Lean flow analysis. Tracks work items (epics, stories) through normalized phases to enable lead time, wait time, WIP, and bottleneck analysis.

Phases: design, plan, implement, review.

FlagShortDescription
--event-eEvent type: start, complete, blocked, unblocked, abandoned (default: start)
--phase-pPhase: design, plan, implement, review (default: design)
--blocker-bBlocker description (for blocked events)
Terminal window
# Epic lifecycle
rai memory emit-work epic E9 --event start --phase design
rai memory emit-work epic E9 -e complete -p design
# Story lifecycle
rai memory emit-work story S9.4 --event start --phase implement
rai memory emit-work story S9.4 -e complete -p implement
# Work blocked
rai memory emit-work story S9.4 -e blocked -p plan -b "unclear requirements"

Emit a session event to telemetry. Records session completion for local learning and insights.

FlagShortDescription
--type-tSession type: story, research, maintenance, etc. (default: story)
--outcome-oSession outcome: success, partial, abandoned (default: success)
--duration-dSession duration in minutes
--stories-fStories worked on (comma-separated)
Terminal window
# Basic session complete
rai memory emit-session --type story --outcome success
# With duration and stories
rai memory emit-session -t story -o success -d 45 -f S9.1,S9.2,S9.3

Emit a calibration event to telemetry. Records estimate vs. actual for velocity tracking. Velocity is calculated automatically: estimated / actual (>1.0 = faster than estimated).

FlagShortDescription
--size-sT-shirt size: XS, S, M, L (default: S)
--estimated-eEstimated duration in minutes
--actual-aActual duration in minutes
Terminal window
# Story completed faster than estimated
rai memory emit-calibration S9.4 --size S --estimated 30 --actual 15
# Story took longer
rai memory emit-calibration S9.4 -s M -e 60 -a 90

Generate an interactive HTML visualization of the memory graph. Creates a self-contained HTML file with a D3.js force-directed graph. Nodes are color-coded by type, filterable, zoomable, and searchable.

FlagShortDescription
--output-oOutput HTML file path
--index-iMemory index path
--open / --no-openOpen in browser after generating (default: open)
Terminal window
# Generate and open in browser
rai memory viz
# Generate to specific path
rai memory viz --output graph.html
# Generate without opening
rai memory viz --no-open

Commands for scanning, analyzing, and tracking your codebase architecture.

Scan a directory and extract code symbols (classes, functions, methods, interfaces, module docstrings). Supports Python, TypeScript, and JavaScript.

FlagShortDescription
--language-lLanguage: python, typescript, javascript (auto-detect if not set)
--output-oOutput format: human, json, or summary
--pattern-pGlob pattern for files
--exclude-ePatterns to exclude (can be repeated)
Terminal window
# Scan current directory
rai discover scan
# Scan Python files only
rai discover scan src/ --language python
# JSON output for piping to analyze
rai discover scan src/ -l python -o json
# Exclude tests
rai discover scan . --exclude "**/test_*" --exclude "**/__tests__/**"

Analyze scan results with confidence scoring and module grouping. Takes raw scan output and produces an analysis with auto-categorization, hierarchical folding, and module grouping. All analysis is deterministic — no AI inference required.

FlagShortDescription
--input-iPath to scan result JSON (reads stdin if not provided)
--output-oOutput format: human, json, or summary
--category-map-cYAML file with custom path-to-category mappings
Terminal window
# Analyze from file
rai discover analyze --input scan-result.json
# Pipe from scan
rai discover scan src/ -l python -o json | rai discover analyze
# Summary only
rai discover analyze --input scan-result.json --output summary

Build unified graph with discovered components. Reads validated components from JSON and integrates them into the unified context graph, making them queryable via rai memory context.

FlagShortDescription
--input-iPath to validated components JSON
--project-root-rProject root directory (default: .)
--output-oOutput format: human, json, or summary
Terminal window
# Build with default input file
rai discover build
# Build with custom input
rai discover build --input my-components.json

Check for architectural drift against baseline components. Compares scanned code against the validated component baseline to identify potential drift (files in wrong locations, naming convention violations, missing documentation).

Exit codes: 0 = no drift, 1 = drift warnings found.

FlagShortDescription
--project-root-rProject root directory (default: .)
--output-oOutput format: human, json, or summary
Terminal window
# Check entire project
rai discover drift
# Check specific directory
rai discover drift src/new_module/
# Output as JSON
rai discover drift --output json

List all skills in the skill directory. Shows skills grouped by lifecycle with version and description.

FlagShortDescription
--format-fOutput format: human or json
Terminal window
rai skill list

Validate skill structure against the RaiSE schema. Checks frontmatter, required fields, sections, and naming conventions.

FlagShortDescription
--format-fOutput format: human or json
Terminal window
# Validate all skills
rai skill validate
# Validate specific skill
rai skill validate .claude/skills/story-start/SKILL.md

Create a new skill from template. Generates a SKILL.md file with proper structure in .claude/skills/<name>/.

FlagShortDescription
--lifecycle-lLifecycle: session, epic, story, discovery, utility, meta
--afterSkill that should come before this one
--beforeSkill that should come after this one
--format-fOutput format: human or json
Terminal window
# Create a new story skill
rai skill scaffold story-validate
# With lifecycle and ordering
rai skill scaffold story-validate --lifecycle story --after story-implement --before story-close

Check a proposed skill name against naming conventions. Validates the {domain}-{action} pattern, checks for conflicts with existing skills or CLI commands, and verifies the lifecycle domain.

FlagShortDescription
--format-fOutput format: human or json
Terminal window
rai skill check-name story-validate

Display the developer profile in YAML format. Shows the contents of ~/.rai/developer.yaml. If no profile exists, guides you to create one.

Terminal window
rai profile show

Display base Rai package information. Shows the bundled base version, contents (identity, patterns, methodology), and whether it has been installed in the current project.

Terminal window
rai base show

List releases from the memory graph. Shows all release nodes with their status, target date, and associated epics.

FlagShortDescription
--project-pProject root path (default: .)
Terminal window
rai release list