Skip to main content

AI-CLI Integration

Automatically capture and inject context from Claude Code CLI and Gemini CLI sessions with intelligent memory management.

Overview

The AI-CLI integration automatically captures important conversations from your AI assistant sessions and injects relevant context from your memory library when starting new sessions. This creates a seamless, persistent memory layer for Claude Code CLI and Gemini CLI.

With AI-CLI integration, your assistant remembers important details from past conversations and automatically surfaces relevant context when you need it—no manual prompting required.

What is AI-CLI Integration?

AI-CLI integration connects Trix to your command-line AI assistants through hooks, enabling automatic memory capture and context injection. Instead of manually copying and pasting important information or losing context between sessions, the integration handles this automatically in the background.

How It Works

The integration uses hooks at two key points in your AI assistant workflow:

  1. Session Start - Injects relevant memories based on your current context (working directory, project, query)
  2. Session End - Analyzes the conversation and stores important information with an importance score

Only conversations with high importance scores (≥ 6.0 out of 10) are automatically stored, ensuring your memory library stays focused on valuable information.

Key Benefits

  • Zero effort - Automatic capture and injection with no manual steps
  • Intelligent filtering - Importance scoring ensures only valuable conversations are stored
  • Context-aware - Git repository detection provides project-specific memories
  • Semantic search - Relevant memories surface automatically based on your query
  • Non-blocking - Async processing means no slowdown in your workflow

Supported AI CLIs

Trix integrates with popular command-line AI assistants:

Claude Code CLI
  • Session capture via SessionEnd hook
  • Context injection via SessionStart hook
  • JSON configuration format
  • 3-second timeout per hook
Gemini CLI
  • Session capture via session_end hook
  • Context injection via session_start hook
  • YAML configuration format
  • 3-second timeout per hook

The setup command automatically detects which AI CLIs you have installed and configures the appropriate hooks for each one.

Key Features

Auto-Detection & Setup

The integration automatically detects installed AI CLIs (Claude Code, Gemini CLI) and configures hooks with a single command. No manual config file editing required.

Importance-Based Filtering

Each conversation is analyzed and assigned an importance score from 0 to 10. Only sessions scoring 6.0 or higher are automatically stored, preventing noise and keeping your memory library focused on valuable content.

When starting a new session, Trix searches your memory library using semantic similarity and injects the most relevant memories. The system considers:

  • Your current working directory and git repository
  • Project name and context
  • Semantic similarity to your query
  • Token budget constraints (default: 2000 tokens)

Git Repository Context

The integration automatically detects git repositories and uses project context to provide more relevant memories. Working on "project_alpha"? You'll get memories specific to that project.

Async Background Processing

Session capture runs asynchronously in the background, so your workflow is never interrupted. Importance scoring and storage happen after your session ends.

How It Works

Session Capture Flow

  1. You finish an AI CLI session
  2. The SessionEnd hook triggers trix capture-session-hook
  3. The session transcript is analyzed for importance
  4. If importance ≥ 6.0, the conversation is automatically stored as a memory
  5. Topics, entities, and key information are extracted
  6. The memory is tagged and indexed for future retrieval

Context Injection Flow

  1. You start a new AI CLI session
  2. The SessionStart hook triggers trix inject-context-hook
  3. Trix detects your git repository and working directory
  4. Semantic search finds the 5 most relevant memories
  5. Memories are formatted and injected into your session context
  6. Your AI assistant has relevant background information automatically

The default configuration uses a 2000-token budget for context injection and retrieves up to 5 memories. These settings can be customized to your needs.

Quick Start

Get started with AI-CLI integration in one command:

trix integrations ai-cli setup

This automatically detects your installed AI CLIs and configures hooks for both session capture and context injection.

Ready to set it up? Head to the Setup & Configuration page.

Next Steps