SaveContext CLI (sc)
The Rust-native command-line interface for SaveContext. This CLI is the primary implementation, with the MCP server delegating operations to it via a bridge pattern.
Installation
From Source (Development)
# Binary at target/release/sc
Add to PATH
# Option 1: Symlink to a directory in PATH
# Option 2: Add to shell profile
Architecture
AI Coding Tools (Claude Code, Cursor, Cline, etc.)
│
▼
┌───────────────────────────────────────────┐
│ MCP Server (TypeScript) │
│ @savecontext/mcp │
│ │ │
│ ▼ │
│ ┌─────────────────────────────────────┐ │
│ │ CLI Bridge │ │
│ │ server/src/cli/bridge.ts │ │
│ │ Delegates to Rust CLI │ │
│ └─────────────────────────────────────┘ │
└───────────────────┬───────────────────────┘
│
▼
┌───────────────────────────────────────────┐
│ Rust CLI (`sc`) │
│ 45+ commands for sessions, issues, │
│ context, memory, plans, checkpoints │
│ Background embedding generation │
└───────────────────┬───────────────────────┘
│
▼
┌───────────────────────────────────────────┐
│ SQLite Database │
│ ~/.savecontext/data/savecontext.db │
└───────────────────────────────────────────┘
The MCP server acts as a thin transport layer that receives tool calls from AI coding assistants and delegates them to the Rust CLI. This architecture provides:
- Single source of truth: All business logic lives in Rust
- Direct CLI access: Power users can use
scdirectly from terminal - Background processing: Embedding generation happens asynchronously after save
- Performance: Native Rust execution for database operations
Quick Reference
Global Flags
Commands
Session Management
Context Items
Issues
Checkpoints
Memory (Persistent Across Sessions)
Projects
Plans
Embeddings
Sync (JSONL Export/Import)
Prime (Context Injection)
Smart prime flags:
| Flag | Default | Description |
|---|---|---|
--smart |
off | Enable relevance-ranked selection |
--budget <n> |
4000 | Token budget for context items |
--query <text> |
none | Semantic boost for a topic |
--decay-days <n> |
14 | Temporal decay half-life in days |
Scoring: temporal_decay * priority_weight * category_weight * semantic_boost
- Temporal decay: exponential (
today=1.0, 7d=0.71, 14d=0.5, 28d=0.25) - Priority:
high=3.0, normal=1.0, low=0.5 - Category:
decision=2.0, reminder=1.5, progress=1.0, note=0.5 - Semantic boost:
0.5x-2.5xbased on cosine similarity to--query - MMR diversity: penalizes near-duplicate items by embedding similarity
Other
Embedding Configuration
The CLI supports background embedding generation for semantic search. Configure via environment variables or the embeddings configure command:
Ollama (Recommended for Local)
# Uses nomic-embed-text by default
# Or with custom model
HuggingFace (Cloud API)
Environment Variables
# or huggingface
# For HuggingFace
Output Modes
JSON Output
All commands support --json for machine-readable output:
|
|
|
Auto-JSON (Non-TTY)
When stdout is piped, output is automatically JSON — no flag needed:
|
Format Flag
Silent Mode
For scripting — create/mutate commands print only the ID:
ID=
Dry Run
Preview mutations without writing to the database:
Error Handling
Structured Errors
Errors include machine-readable codes, hints, and recovery suggestions:
Structured JSON errors are automatic when piped (non-TTY) or with --json.
Exit Code Categories
| Exit | Category | Action |
|---|---|---|
| 0 | Success | Continue |
| 1 | Internal | Report bug |
| 2 | Database | Check init/permissions |
| 3 | Not Found | Verify ID, check hint for suggestions |
| 4 | Validation | Fix input, retry |
| 5 | Dependency | Resolve dependency first |
| 6-9 | Other | See cli/AGENTS.md for full reference |
For the complete error code table and retryable flags, see cli/AGENTS.md.
Intent Detection
The CLI auto-normalizes common synonyms, so you don't need to memorize canonical values:
- Status:
done→closed,wip→in_progress,todo→open - Type:
defect→bug,story→feature,cleanup→chore - Priority:
critical→ 4,high→ 3,low→ 1,P0-P4accepted
Similar ID Suggestions
When an ID isn't found, the error includes suggestions for similar existing IDs.
Session Hints
When no active session is bound to your terminal, the error lists recent resumable sessions with their IDs, names, and statuses.
Shell Completions
# Bash
# Zsh
# Fish
# PowerShell
Development
# Build debug
# Build release
# Run tests
# Run with verbose logging (or use -v/-vv flags)
RUST_LOG=debug
# Note: Debug output shows search pipeline stages, session/project resolution, and embedding operations
# Check lints
License
AGPL-3.0 - See LICENSE for details.