Reference

CLI Reference

Complete command-line reference for semfora-engine.

Quick Reference

# Analyze a file or directory
semfora-engine analyze src/main.rs
semfora-engine analyze ./src --output-mode symbols_only

# Search for code (hybrid: symbol + semantic by default)
semfora-engine search "authenticate" --limit 10
semfora-engine search --symbols "login" --kind fn

# Generate semantic index with smart refresh
semfora-engine index generate
semfora-engine index generate --force --incremental

# Get repository overview
semfora-engine query overview --max-modules 50

# Analyze git changes
semfora-engine analyze --diff main --limit 20
semfora-engine analyze --uncommitted --summary-only

# Find callers with depth control
semfora-engine query callers <hash> --depth 2 --limit 30

# Quality validation with duplicate detection
semfora-engine validate --module api --duplicates
semfora-engine validate --file-path src/auth.rs --include-source

# Lint with auto-detection and fixes
semfora-engine lint scan --fixable-only
semfora-engine lint fix --dry-run --safe-only

# Trace dependencies
semfora-engine trace <symbol> --direction both --depth 3

Main Commands

Top-level commands available in the semfora-engine CLI.

CommandAliasDescription
analyzeaAnalyze files, directories, or git changes with 19 parameters including diff analysis
searchsUnified search with symbol/semantic/raw modes and 15 parameters
queryqQuery the semantic index with 7 subcommands (overview, module, symbol, source, callers, callgraph, file, languages)
trace-Dependency tracing with direction controls and depth parameters
validatevQuality validation with duplicate detection and complexity analysis
index-Semantic index management with generate, check, and export subcommands
cache-Cache management with info, clear, and prune subcommands
test-Test framework detection and execution
lintlCode linting with scan, fix, typecheck, detect, and recommend modes
commit-Git commit analysis and preparation with semantic metrics
setup-MCP client setup with agent installation options
uninstall-Remove MCP/engine components with selective cleanup
config-Configuration management with show, set, and reset options
benchmark-Performance testing and token efficiency measurement
serve-Start repository server with file watching and git polling

Query Subcommands

Query the semantic index for symbols, source code, and call relationships

Usage: semfora-engine query <subcommand>

SubcommandDescription
overviewGet repository overview with modules and risk breakdown
moduleGet a specific module's symbols and details
symbolGet symbol information by hash or file location
sourceGet source code for files or symbols with context
callersGet callers of a symbol with depth control (max 3)
callgraphGet call graph with module/symbol filtering and SQLite export
fileGet all symbols in a file with risk and kind filtering
languagesList all supported programming languages

Index Subcommands

Manage the semantic index for your repository

Usage: semfora-engine index <subcommand>

SubcommandDescription
generateGenerate or refresh semantic index with incremental options
checkCheck index freshness and auto-refresh capabilities
exportExport the complete index to SQLite database

Cache Subcommands

Manage the local cache system

Usage: semfora-engine cache <subcommand>

SubcommandDescription
infoShow comprehensive cache information and statistics
clearClear cache for the current directory
pruneRemove caches older than specified days

Lint Subcommands

Code linting with auto-detection of 26+ linters across 16 languages

Usage: semfora-engine lint <subcommand>

SubcommandDescription
scanScan for linting issues (default mode)
fixAuto-fix linting issues with dry-run and safety options
typecheckRun type checking only
detectDetect available linters for the project
recommendRecommend linters for the project setup

Config Subcommands

Manage semfora configuration settings

Usage: semfora-engine config <subcommand>

SubcommandDescription
showDisplay current configuration values
setSet configuration key-value pairs
resetReset configuration to default values

Global Options

These options can be used with any command.

OptionDescription
-f, --format <FORMAT>Output format: text (default), toon, json
-v, --verboseShow verbose output
--progressShow progress percentage during long operations

Exit Codes

CodeMeaning
0Success
1File not found or IO error
2Unsupported language
3Parse failure
4Semantic extraction or query error
5Git error (not a git repo, etc.)

Environment Variables

RUST_LOG

Control logging verbosity

RUST_LOG=semfora_engine=debug semfora-engine analyze ./src

Example Workflows

Initial Setup & Analysis

# 1. Generate index for a project (smart refresh)
cd my-project
semfora-engine index generate

# 2. Get project overview with modules
semfora-engine query overview --max-modules 50

# 3. Search with different modes
semfora-engine search "authenticate" --kind fn --limit 20
semfora-engine search --symbols "Config" --module api
semfora-engine search --raw "TODO|FIXME" --file-types rs,ts

# 4. Get symbol details and source
semfora-engine query symbol --hash <hash> --source --context 5
semfora-engine query source --file src/main.rs --start 10 --end 50

Code Review Workflow

# Analyze PR changes with semantic analysis
semfora-engine analyze --diff main --limit 50 --offset 0

# Analyze uncommitted changes before commit  
semfora-engine analyze --uncommitted --target-ref WORKING

# Get summary for large diffs first
semfora-engine analyze --diff main --summary-only

# Prepare detailed commit information
semfora-engine commit --metrics --all-metrics

# Review specific files with symbols
semfora-engine query file src/auth.rs --source --context 3

Quality & Validation

# Comprehensive quality validation
semfora-engine validate --module api --include-source
semfora-engine validate --duplicates --threshold 0.85 --sort-by similarity

# Lint with multiple modes
semfora-engine lint scan --fixable-only --limit 100
semfora-engine lint fix --safe-only --dry-run
semfora-engine lint typecheck --limit 50

# Trace dependencies and impact analysis
semfora-engine trace <symbol_name> --direction both --depth 2
semfora-engine query callers <hash> --depth 3 --source

Performance & Setup

# Benchmark token efficiency
semfora-engine benchmark ./large-project

# Setup MCP integration with agents
semfora-engine setup --clients cursor,vscode --with-agents
semfora-engine setup --list-clients --agents-scope project

# Server mode for AI integration
semfora-engine serve --repo . --no-git-poll

# Cache management
semfora-engine cache info
semfora-engine cache prune 30  # older than 30 days