Command Overview
The AI-CLI integration provides commands for both manual and automated memory management. Commands fall into three categories:
| Command | Purpose | Usage |
|---|---|---|
integrations ai-cli | Manage integration setup | Manual setup and configuration |
process-session | Analyze and store sessions | Manual or scripting |
inject-context | Retrieve relevant memories | Manual or scripting |
*-hook | Automated hook commands | Called by AI CLI hooks |
Integration Management
setup
Auto-detect and configure AI CLI hooks.
# Auto-detect and setup both Claude Code and Gemini CLI
trix integrations ai-cli setup
# Setup will:
# 1. Detect installed AI CLIs (Claude Code, Gemini CLI)
# 2. Configure session capture hooks
# 3. Configure context injection hooks
# 4. Test the integrationOptions:
--provider <name>- Specify provider:claude-codeorgemini-cli--claude- Shorthand for--provider claude-code--gemini- Shorthand for--provider gemini-cli--global- Install globally (default: true)--force- Force reinstall, overwriting existing hooks
status
Check integration configuration and hook installation status.
# Check integration status for all providers
trix integrations ai-cli status
# Check status for specific provider
trix integrations ai-cli status --provider claude-codeOptions:
--provider <name>- Check specific provider--claude- Check Claude Code CLI only--gemini- Check Gemini CLI only
remove
Remove Trix hooks from AI CLI configuration.
# Remove all AI-CLI hooks
trix integrations ai-cli remove
# Remove for specific provider
trix integrations ai-cli remove --provider claude-codeOptions:
--provider <name>- Remove from specific provider--claude- Remove from Claude Code CLI only--gemini- Remove from Gemini CLI only
process-session
Process an AI CLI session transcript, analyze its importance, and optionally store it as a memory.
Basic Usage
# Process a session transcript
trix process-session --file session.jsonl
# Auto-stores if importance >= 6.0
# Output shows:
# - Importance score
# - Key topics extracted
# - Whether it was storedThe command analyzes the session and outputs an importance score (0-10). Sessions with scores ≥ 6.0 are automatically stored by default.
Options
Required:
--file <path>- Path to session transcript (JSONL format)
Optional:
--session-id <id>- Explicit session identifier--space <name>- Store in specific space (default: default space)--auto-store- Enable auto-storage for important sessions (default: true)--verbose- Show detailed scoring breakdown and reasoning
Examples
With Session ID
# Process with explicit session ID
trix process-session --session-id "chat_123" --file session.jsonlWith Space
# Process and store in specific space
trix process-session --file session.jsonl --space "project_alpha"Verbose Output
# Process with verbose output
trix process-session --file session.jsonl --verbose
# Shows:
# - Full transcript analysis
# - Importance calculation details
# - Extracted entities and topics
# - Storage decision reasoningAuto-Store Control
# Process with auto-store enabled (default)
trix process-session --file session.jsonl --auto-store
# Disable auto-store for scoring only
trix process-session --file session.jsonl --auto-store=falseOutput Format
The command outputs JSON with:
{
"importance_score": 7.5,
"recommendation": "store",
"components": {
"novelty": 8,
"technical_depth": 7,
"actionable": 9,
"completeness": 6
},
"topics": ["authentication", "JWT", "security"],
"entities": ["Express.js", "bcrypt"],
"stored": true,
"memory_id": "mem_abc123xyz"
}Use --verbose to see why a session received a particular importance
score. This helps you understand what makes conversations valuable.
inject-context
Search your memory library and inject relevant context formatted for AI consumption.
Basic Usage
# Inject relevant context for a query
trix inject-context "How do I implement authentication?"
# Searches memories and returns:
# - Top 5 most relevant memories
# - Formatted for AI consumption
# - Within 2000 token budgetOptions
Required:
<query>- Search query (semantic search)
Optional:
--space <name>- Search in specific space--max-tokens <n>- Maximum tokens for context (default: 2000)--max-memories <n>- Maximum number of memories (default: 5)--verbose- Show memory metadata and search details
Examples
Custom Token Budget
# Inject with custom token budget
trix inject-context "database schema design" --max-tokens 4000
# Returns more context within 4000 tokensLimit Memories
# Limit number of memories
trix inject-context "API endpoints" --max-memories 10
# Returns up to 10 relevant memoriesSpace-Specific
# Inject from specific space
trix inject-context "bug fix" --space "project_alpha"Verbose Output
# Inject with verbose output
trix inject-context "authentication" --verbose
# Shows:
# - Semantic search results
# - Memory metadata
# - Token usage detailsOutput Format
The command outputs formatted context ready for AI injection:
# Relevant Context from Memory
## Authentication implementation (similarity: 0.92)
User implemented JWT authentication using Express.js middleware...
## Security best practices (similarity: 0.87)
Always use bcrypt for password hashing, never store plaintext...
---
Retrieved 2 memories (estimated 487 tokens)The context is automatically formatted with headings, similarity scores, and token estimates to help the AI assistant understand relevance and prioritize information.
Hook Commands
These commands are called automatically by AI CLI hooks. You typically don't run them manually, but they can be useful for testing.
capture-session-hook
Called automatically after an AI CLI session ends. Reads transcript from stdin.
# Customize hook behavior with flags
# For capture session hook:
trix capture-session-hook --async --verbose
# For context injection hook:
trix inject-context-hook --max-tokens 4000 --max-memories 10Stdin Input: JSON object with session metadata and transcript path
Default Behavior:
- Runs asynchronously in background (non-blocking)
- Auto-stores sessions with importance ≥ 6.0
- Errors are logged but don't crash the CLI
inject-context-hook
Called automatically at AI CLI session start. Reads session context from stdin.
Stdin Input: JSON object with working directory, git context, and query
Default Behavior:
- Detects git repository automatically
- Searches for relevant memories (semantic search)
- Returns formatted context to stdout
- Returns empty string on errors (graceful degradation)
Hook commands expect specific JSON input from stdin. Don't call them manually unless you're testing with proper input data.
Exit Codes
| Code | Meaning | Common Causes |
|---|---|---|
0 | Success | Command completed successfully |
1 | General error | Invalid arguments, file not found, network error |
2 | Invalid input | Malformed JSON, invalid transcript format |
3 | API error | Invalid API key, rate limit, server error |
4 | Configuration error | Missing config file, invalid hook configuration |
Error Handling
Common Errors
File not found
Error: Session transcript file not found: session.jsonlSolution: Check the file path is correct and file exists
Invalid transcript format
Error: Failed to parse transcript: invalid JSON on line 12Solution: Ensure transcript is valid JSONL (one JSON object per line)
API authentication failed
Error: Invalid API key or unauthorized accessSolution: Check your API key with trix auth status
Rate limit exceeded
Error: Rate limit exceeded. Please try again in 60 secondsSolution: Wait and retry, or upgrade your plan for higher limits
Next Steps
- Advanced Usage - Customize configuration, troubleshoot issues, and optimize performance
- Setup & Configuration - Return to setup documentation
- CLI Reference - Explore other Trix CLI commands