CLI Reference¶
The Nexus command-line interface provides comprehensive access to all Nexus operations. The CLI mirrors the Python API and is ideal for shell scripts, automation, and interactive use.
Quick Start¶
# Install Nexus
pip install nexus-ai-fs
# Verify installation
nexus --version
# Get help
nexus --help
nexus <command> --help
Command Categories¶
File Operations¶
Commands for reading, writing, and manipulating files.
write- Write file contentcat- Display file contentsrm- Delete filescp/copy- Copy filesmove- Move/rename files
→ Full File Operations Reference
Directory Operations¶
Commands for managing directories and listing files.
mkdir- Create directoriesrmdir- Remove directoriesls- List directory contentstree- Display directory tree
→ Full Directory Operations Reference
Search Operations¶
Commands for finding and searching files.
→ Full Search Operations Reference
Version Tracking¶
Commands for version history and time-travel.
versions history- Show version historyversions get- Get specific versionversions diff- Compare versionsversions rollback- Rollback to version
Workspace Management¶
Commands for workspace snapshots and management.
workspace register- Register workspaceworkspace list- List workspacesworkspace snapshot- Create snapshotworkspace log- Show snapshot historyworkspace restore- Restore snapshotworkspace diff- Compare snapshots
Memory Management¶
Commands for memory storage and retrieval.
memory register- Register memorymemory list-registered- List memoriesmemory store- Store memory entrymemory search- Search memories
Semantic Search¶
Commands for AI-powered semantic search.
search init- Initialize semantic searchsearch index- Index documentssearch query- Search documentssearch stats- Show statistics
→ Full Semantic Search Reference
LLM Document Reading¶
Commands for AI-powered document question answering.
llm read- Ask questions about documents
→ Full LLM Document Reading Reference
Permissions (ReBAC)¶
Commands for relationship-based access control.
rebac create- Create relationshiprebac check- Check permissionrebac explain- Explain permissionrebac expand- Find subjects with permissionrebac namespace-*- Manage namespaces
Backend Mounts¶
Commands for managing storage backend mounts.
mounts list- List mountsmounts add- Add mountmounts info- Show mount infomounts remove- Remove mount
Server & Mounting¶
Commands for server management and FUSE mounting.
Model Context Protocol (MCP)¶
Commands for MCP server to integrate with AI agents and tools.
mcp serve- Start MCP server for Claude Desktop and other MCP clients
Advanced Operations¶
Advanced commands for operation tracking, analysis, and sync.
ops log- View operation historyundo- Undo last operationsize- Calculate directory sizefind-duplicates- Find duplicate filessync- One-way sync
→ Full Advanced Operations Reference
Global Options¶
Most commands support these global options:
Configuration¶
--config PATH- Path to Nexus config file (nexus.yaml)--data-dir PATH- Path to Nexus data directory (or useNEXUS_DATA_DIRenv var)--backend [local|gcs]- Backend type (default: local)
Remote Mode¶
--remote-url URL- Remote Nexus server URL (or useNEXUS_URLenv var)--remote-api-key KEY- API key for authentication (or useNEXUS_API_KEYenv var)
Multi-Tenancy & Identity¶
--tenant-id TEXT- Tenant ID for multi-tenant isolation (or useNEXUS_TENANT_IDenv var)--subject TEXT- Subject in format 'type:id' (e.g., 'user:alice') (or useNEXUS_SUBJECTenv var)
Admin Operations¶
--is-admin- Run operation with admin privileges--admin-capability TEXT- Grant specific admin capability (can specify multiple times)
Remote Mode - Two Ways to Connect¶
1. Environment Variables (Recommended - Works for ALL commands):
export NEXUS_URL=http://localhost:8765
export NEXUS_API_KEY=your-api-key
# Now all commands use remote mode
nexus ls /
nexus write /file.txt "data"
2. Command-line Flags (Works for most commands):
Note: Memory commands and some workspace commands only support remote mode via NEXUS_URL environment variable.
Environment Variables¶
Key environment variables for configuration:
Remote Mode (takes priority over local)¶
Local Mode¶
Multi-Tenancy & Identity¶
Database¶
GCS Configuration¶
Priority: If NEXUS_URL is set, all commands use remote mode. Otherwise, commands use local mode with NEXUS_DATA_DIR.
Configuration File¶
Create nexus.yaml for persistent configuration:
# Backend configuration
backend:
type: local
data_dir: ./nexus-data
# Or use GCS
backend:
type: gcs
gcs_bucket: my-bucket
gcs_project: my-project
# Multi-tenant
tenant_id: org_acme
# Subject identity
subject: user:alice
# Permissions
enforce_permissions: true
# Database (optional)
database_url: postgresql://user:pass@localhost/nexus
Use it:
CLI vs Python API¶
Every CLI command has a Python API equivalent:
| CLI Command | Python API |
|---|---|
nexus write /file.txt "data" | nx.write("/file.txt", b"data") |
nexus cat /file.txt | nx.read("/file.txt") |
nexus ls /workspace | nx.list("/workspace") |
nexus glob "*.py" | nx.glob("*.py") |
nexus grep "TODO" | nx.grep("TODO") |
nexus versions history /file.txt | nx.list_versions("/file.txt") |
nexus workspace snapshot /ws | nx.workspace_snapshot("/ws") |
nexus search query "auth" | await nx.semantic_search("auth") |
nexus llm read /doc.pdf "Question" | await nx.llm_read("/doc.pdf", "Question") |
See individual command references for detailed Python API examples.
Common Workflows¶
1. Initialize and use Nexus¶
# Set data directory
export NEXUS_DATA_DIR=./my-nexus
# Write files
nexus write /docs/README.md "# My Project"
nexus write /src/main.py "print('hello')"
# List files
nexus ls / --recursive
# Search
nexus grep "hello" /src
2. Version tracking workflow¶
# Write initial version
nexus write /config.json '{"version": "1.0"}'
# Update file
nexus write /config.json '{"version": "2.0"}'
# View history
nexus versions history /config.json
# Rollback
nexus versions rollback /config.json --version 1
3. Workspace snapshot workflow¶
# Register workspace
nexus workspace register /my-project --name main
# Make changes
nexus write /my-project/file.txt "changes"
# Create snapshot
nexus workspace snapshot /my-project --description "Before refactor"
# Make more changes
nexus write /my-project/file.txt "more changes"
# Restore if needed
nexus workspace restore /my-project --snapshot 1
4. Remote server workflow¶
# Terminal 1: Start server
nexus serve --host 0.0.0.0 --port 8765 --api-key secret123
# Terminal 2: Set environment and use remote mode
export NEXUS_URL=http://localhost:8765
export NEXUS_API_KEY=secret123
nexus write /workspace/file.txt "remote data"
nexus cat /workspace/file.txt
nexus memory store "Important fact" --scope user
5. Multi-backend workflow¶
# Use local backend
nexus --backend local ls /
# Use GCS backend
nexus --backend gcs --gcs-bucket my-bucket ls /
6. LLM document reading workflow¶
# Set up API key
export ANTHROPIC_API_KEY=sk-ant-...
# Index documents for semantic search
nexus search init --provider openai
nexus search index /docs
# Ask questions
nexus llm read /docs/**/*.md "How does authentication work?"
# Get detailed output with citations
nexus llm read /reports/q4.pdf "What were the challenges?" --detailed
# Stream long analysis
nexus llm read /data/**/*.csv "Analyze trends" --stream
See Also¶
- Getting Started - Installation and setup
- Python API Documentation - Python SDK reference
- RPC API - Remote server API
- Configuration Guide - Configuration options
- Server Setup - Production deployment