Get Started

CLI Reference

Command-line interface for Memoria setup and standalone usage.

Installation

You can use Memoria via npx (no installation) or install it globally:

# Use with npx (recommended)
npx @byronwade/memoria <command>

# Or install globally
npm install -g @byronwade/memoria
memoria <command>

Commands

init

Initialize Memoria for your AI tools. Creates rule files for auto-pilot mode.

npx @byronwade/memoria init [options]

Options:
  --all       Set up rules for all detected AI tools
  --cursor    Set up rules for Cursor
  --claude    Set up rules for Claude Code
  --windsurf  Set up rules for Windsurf
  --cline     Set up rules for Cline

Examples:

# Auto-detect and set up all tools
npx @byronwade/memoria init --all

# Set up only Cursor
npx @byronwade/memoria init --cursor

# Set up multiple specific tools
npx @byronwade/memoria init --cursor --claude

analyze

Analyze a file and output forensics data to stdout. Useful for testing or scripting.

npx @byronwade/memoria analyze <file> [options]

Options:
  --json      Output as JSON instead of formatted text
  --verbose   Include all available metadata

Examples:

# Analyze a file
npx @byronwade/memoria analyze src/api/route.ts

# Get JSON output for scripting
npx @byronwade/memoria analyze src/api/route.ts --json

# Full verbose output
npx @byronwade/memoria analyze src/api/route.ts --verbose

serve

Start the MCP server. This is called automatically by your AI tool's configuration.

npx @byronwade/memoria serve [options]

Options:
  --stdio     Use stdio transport (default)
  --port      Use HTTP transport on specified port

version

Show the installed version:

npx @byronwade/memoria --version

help

Show help for any command:

npx @byronwade/memoria --help
npx @byronwade/memoria init --help
npx @byronwade/memoria analyze --help

Global vs npx

MethodProsCons
npxAlways latest version, no install neededSlower first run, downloads each time
Global installFaster startup, works offlineManual updates needed

For MCP server configuration, npx is recommended as it ensures you always have the latest version.

Environment Variables

VariableDescriptionDefault
MEMORIA_DEBUGEnable debug loggingfalse
MEMORIA_CONFIGPath to config file.memoria.json
MEMORIA_CACHE_DIRCache directory location.memoria-cache
# Enable debug mode
MEMORIA_DEBUG=true npx @byronwade/memoria analyze src/api/route.ts

# Use custom config
MEMORIA_CONFIG=./my-config.json npx @byronwade/memoria serve

Exit Codes

CodeMeaning
0Success
1General error
2Invalid arguments
3File not found
4Not a git repository

Scripting Examples

Use Memoria in your CI/CD or scripts:

#!/bin/bash

# Analyze changed files in a PR
for file in $(git diff --name-only main...HEAD); do
  echo "Analyzing $file"
  npx @byronwade/memoria analyze "$file" --json >> analysis.json
done

# Check if any file has high risk
HIGH_RISK=$(jq '[.[] | select(.risk > 70)] | length' analysis.json)
if [ "$HIGH_RISK" -gt 0 ]; then
  echo "Warning: $HIGH_RISK files have high risk scores"
  exit 1
fi

MCP Server Mode

When running as an MCP server (the default for AI tools), Memoria uses the stdio transport and communicates via JSON-RPC. You don't need to interact with the CLI directly in this mode.

CLI Reference | Memoria | Memoria