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 ClineExamples:
# 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 --claudeanalyze
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 metadataExamples:
# 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 --verboseserve
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 portversion
Show the installed version:
npx @byronwade/memoria --versionhelp
Show help for any command:
npx @byronwade/memoria --help
npx @byronwade/memoria init --help
npx @byronwade/memoria analyze --helpGlobal vs npx
| Method | Pros | Cons |
|---|---|---|
npx | Always latest version, no install needed | Slower first run, downloads each time |
| Global install | Faster startup, works offline | Manual updates needed |
For MCP server configuration, npx is recommended as it ensures you always have the latest version.
Environment Variables
| Variable | Description | Default |
|---|---|---|
MEMORIA_DEBUG | Enable debug logging | false |
MEMORIA_CONFIG | Path to config file | .memoria.json |
MEMORIA_CACHE_DIR | Cache 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 serveExit Codes
| Code | Meaning |
|---|---|
0 | Success |
1 | General error |
2 | Invalid arguments |
3 | File not found |
4 | Not 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
fiMCP 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.