Documentation

Learn how to use ContextFS to give your AI agents persistent memory.

Installation

Install ContextFS using pip:

pip install contextfs

Requires Python 3.9 or higher.

Quick Start

1. Initialize a repository

$ contextfs index init

2. Save a memory

$ contextfs memory save "API uses JWT auth" --type fact

3. Search memories

$ contextfs memory search "authentication"

4. Index your codebase

$ contextfs index index

Basic Usage

Saving Memories

Save facts, decisions, errors, and procedures that your AI agents can recall later:

# Save a fact
contextfs memory save "Database uses PostgreSQL" --type fact

# Save a decision with rationale
contextfs memory save "Chose React over Vue for component library" --type decision

# Save an error resolution
contextfs memory save "Fixed CORS by adding middleware" --type error

Searching Memories

Use semantic search to find relevant memories:

# Search by topic
contextfs memory search "database configuration"

# Search with type filter
contextfs memory search "auth" --type decision

# Limit results
contextfs memory search "API" --limit 5

Auto-Recall

Automatically load relevant context at session start:

$ contextfs memory auto-recall

CLI Commands

CommandDescription
memory saveSave a new memory
memory searchSearch memories semantically
memory listList recent memories
memory auto-recallAuto-load relevant context
index initInitialize repository for indexing
index indexIndex repository files and commits
index statusCheck indexing status
cloud syncSync memories to cloud

Configuration

Config File Location

ContextFS stores configuration in ~/.contextfs/config.yaml

Example Configuration

# ~/.contextfs/config.yaml
embedding_backend: auto  # auto, fastembed, or sentence_transformers
auto_index: true         # Auto-index on session start
max_results: 10          # Default search result limit

# Cloud sync settings
cloud:
  api_url: https://api.contextfs.ai
  auto_sync: false

Environment Variables

CONTEXTFS_API_KEY=your-api-key    # For cloud sync
CONTEXTFS_DATA_DIR=~/.contextfs   # Data directory

Claude Desktop Integration

Add ContextFS to your Claude Desktop configuration:

{
  "mcpServers": {
    "contextfs": {
      "command": "uvx",
      "args": ["contextfs"]
    }
  }
}

Restart Claude Desktop after updating the configuration.

MCP Tools

ContextFS exposes the following MCP tools for AI agents:

ToolDescription
contextfs_saveSave a memory with type, tags, and content
contextfs_searchSemantic search across all memories
contextfs_listList recent memories
contextfs_recallRecall a specific memory by ID
contextfs_evolveUpdate a memory with version history
contextfs_linkCreate relationships between memories
contextfs_syncSync memories with cloud

Custom MCP Clients

ContextFS can be integrated with any MCP-compatible client. Here are examples for different tools:

Claude Code

# In your .mcp.json or claude_desktop_config.json
{
  "mcpServers": {
    "contextfs": {
      "command": "uvx",
      "args": ["contextfs"]
    }
  }
}

Cursor

# In Cursor settings, add MCP server:
Command: uvx
Args: contextfs

Programmatic Access

from contextfs import ContextFS

ctx = ContextFS()
ctx.save("API uses JWT", type="fact")
results = ctx.search("authentication")

Cloud Sync Setup

1. Login to ContextFS Cloud

$ contextfs cloud login

This will open a browser to authenticate with your ContextFS account.

2. Sync Your Memories

# Push local memories to cloud
contextfs cloud sync --direction push

# Pull cloud memories to local
contextfs cloud sync --direction pull

# Two-way sync (default)
contextfs cloud sync

3. Check Sync Status

$ contextfs cloud status

Multi-Device Sync

ContextFS Cloud enables seamless memory synchronization across all your development machines.

How It Works

  • Each device registers with your ContextFS account
  • Memories are encrypted locally before upload
  • Changes sync automatically in the background
  • Conflict resolution preserves both versions

Register a New Device

# On your new device
contextfs cloud login

# Device is automatically registered
contextfs cloud sync

View Connected Devices

$ contextfs cloud devices

Memory Types

fact

General facts and knowledge

decision

Architectural and design decisions

code

Code snippets and patterns

error

Error resolutions and fixes

commit

Git commit information

workflow

Multi-step process definitions

task

Individual task tracking

agent_run

Agent execution records

Full Documentation

View the complete documentation on GitHub.

View on GitHub