Labsco
fyrsmithlabs logo

Contextd

ā˜… 5

from fyrsmithlabs

Reasoning Bank and Context folding. Let your agents learn and self-improve

šŸ”„šŸ”„šŸ”„āœ“ VerifiedFreeQuick setup

ContextD

Cross-session memory and context management for AI agents.

ContextD helps AI coding assistants remember what works, learn from mistakes, and maintain context across sessions. It's designed for developers who want their AI tools to get smarter over time.


āš ļø Alpha Status

This project is in active alpha development. Features and APIs change frequently as we refine the product based on user feedback.

  • āœ… Core functionality is stable and tested
  • āš ļø Breaking changes are generally avoided but can still occur
  • šŸ“ We document all changes in release notes
  • šŸš€ Expect rapid iteration and improvements

If you encounter issues, please report them on GitHub.


What It Does

FeatureDescription
Cross-session MemoryRecord and retrieve learnings across sessions with semantic search
CheckpointsSave and resume context snapshots before hitting limits
Context-FoldingIsolate complex sub-tasks with dedicated token budgets
Error RemediationTrack error patterns and fixes - never solve the same bug twice
Repository SearchSemantic code search over your indexed codebase
Self-ReflectionAnalyze behavior patterns and improve documentation
Secret ScrubbingAutomatic detection and removal via gitleaks

Data Privacy & Security

All data stays local on your machine.

  • No data is sent to external servers
  • Memories and checkpoints stored in ~/.config/contextd/
  • Embeddings generated locally using ONNX (no API calls)
  • Secrets automatically scrubbed from all tool responses using gitleaks
  • Git integration uses local repository info only (remote URL for project identification)

First Run Behavior

On first run, contextd automatically downloads required dependencies:

ONNX runtime not found. Downloading v1.23.0...
Downloaded to ~/.config/contextd/lib/libonnxruntime.so
Downloading fast-bge-small-en-v1.5...

This one-time download (~100MB) happens automatically. Subsequent runs start instantly.


Project Identification

ContextD automatically identifies your project using git:

  1. Tenant ID - Derived from git remote URL (e.g., github.com/username)
  2. Project ID - Derived from repository name

This means:

  • Different repositories have isolated memories
  • Forked repos share tenant but have separate project memories
  • Non-git directories use a fallback identifier

No configuration needed - it works automatically based on your current directory.


Daily Workflow

After installation, here's how to use contextd:

1. Session Start
   └─→ Memories auto-searched, checkpoints listed
   └─→ Resume from checkpoint if offered

2. During Work
   └─→ /contextd-search <topic>     Find relevant memories
   └─→ /contextd-diagnose <error>   Get help with errors
   └─→ Semantic search with repository_search()

3. Task Complete
   └─→ /contextd-remember           Record what you learned

4. Context High (70%+)
   └─→ /contextd-checkpoint         Save session state
   └─→ /clear                       Reset context
   └─→ Resume with /contextd-checkpoint

5. New Project
   └─→ /contextd-init               Setup new project

Plugin Commands

Note: As of v0.4.0, plugin commands are in fyrsmithlabs/marketplace. Install with claude plugins add fyrsmithlabs/marketplace

CommandDescription
/contextd-initInitialize contextd for a new project
/contextd-checkpointSave session checkpoint
/contextd-searchSearch memories and remediations
/contextd-rememberRecord a learning or insight
/contextd-diagnoseAI-powered error diagnosis
/contextd-reflectAnalyze behavior patterns and improve docs
/contextd-statusShow contextd status
/contextd-consensus-reviewMulti-agent code review
/contextd-helpShow available commands and skills

Plugin Skills

SkillUse When
using-contextdStarting any session - overview of all tools
session-lifecycleSession start/end protocols
cross-session-memoryLearning loop (search → do → record → feedback)
checkpoint-workflowContext approaching 70% capacity
error-remediationResolving errors systematically
repository-searchSemantic code search
self-reflectionReviewing behavior patterns, improving docs
writing-claude-mdCreating effective CLAUDE.md files
secret-scrubbingUnderstanding secret detection
project-onboardingOnboarding to new projects
consensus-reviewMulti-agent code review with specialized reviewers

MCP Tools

ContextD exposes 25 tools to Claude Code, organized by category:

Memory

ToolPurpose
memory_searchFind relevant strategies from past sessions
memory_recordSave a new learning or strategy
memory_feedbackRate whether a memory was helpful
memory_outcomeReport task success/failure after using a memory
memory_consolidateMerge related memories into refined summaries
memory_consolidate_sessionConsolidate specific memories by ID

Checkpoints

ToolPurpose
checkpoint_saveSave current context for later
checkpoint_listList available checkpoints
checkpoint_resumeResume from a saved checkpoint

Remediation

ToolPurpose
remediation_searchFind fixes for similar errors
remediation_recordRecord a new error fix
remediation_feedbackRate whether a fix was helpful
troubleshoot_diagnoseAI-powered error diagnosis
ToolPurpose
semantic_searchSmart search with semantic understanding + grep fallback
repository_indexIndex a codebase for semantic search
repository_searchSemantic search over indexed code

Context-Folding

ToolPurpose
branch_createCreate isolated context branch with token budget
branch_returnReturn from branch with scrubbed results
branch_statusGet branch status and budget usage

Conversation

ToolPurpose
conversation_indexIndex Claude Code conversation files
conversation_searchSearch past conversations for decisions and context

Reflection

ToolPurpose
reflect_reportGenerate self-reflection report on memories and patterns
reflect_analyzeAnalyze behavioral patterns across sessions

How It Works

ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”
│                       Claude Code                            │
│                           │                                  │
│                      MCP Protocol                            │
│                           │                                  │
│  ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā–¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”    │
│  │                     ContextD                         │    │
│  │                                                      │    │
│  │  ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”  ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”  ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”  │    │
│  │  │  Reasoning  │  │ Checkpoint  │  │ Remediation │  │    │
│  │  │    Bank     │  │   Service   │  │   Service   │  │    │
│  │  ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”¬ā”€ā”€ā”€ā”€ā”€ā”€ā”˜  ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”¬ā”€ā”€ā”€ā”€ā”€ā”€ā”˜  ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”¬ā”€ā”€ā”€ā”€ā”€ā”€ā”˜  │    │
│  │         │                │                │         │    │
│  │         ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜         │    │
│  │                          │                          │    │
│  │                   ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā–¼ā”€ā”€ā”€ā”€ā”€ā”€ā”                   │    │
│  │                   │   chromem   │  (embedded)       │    │
│  │                   │   Vectors   │  or Qdrant        │    │
│  │                   ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜                   │    │
│  │                                                      │    │
│  │  + FastEmbed (local ONNX embeddings)                │    │
│  │  + gitleaks (secret scrubbing)                      │    │
│  ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜    │
ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜

Key components:

  • chromem - Embedded vector database (zero external dependencies)
  • FastEmbed - Local ONNX embeddings (no API calls required)
  • gitleaks - Secret detection and scrubbing
  • Optional Qdrant - External vector database for larger deployments

Multi-Tenancy

ContextD uses payload-based tenant isolation to ensure data separation between organizations, teams, and projects.

How It Works

  • All documents stored in shared collections with tenant metadata
  • Queries automatically filtered by tenant context
  • Missing tenant context returns an error (fail-closed security)

Tenant Hierarchy

ScopeDescriptionExample
TenantIDOrganization/user identifiergithub.com/acme-corp
TeamIDTeam within organizationplatform
ProjectIDProject within teamcontextd

Security Guarantees

BehaviorDescription
Fail-closedOperations without tenant context return errors
Filter injection blockedUsers cannot override tenant filters
Metadata enforcedTenant fields always set from authenticated context

Automatic Detection

ContextD automatically detects tenant context from git:

  1. TenantID - Derived from git remote URL (e.g., github.com/username)
  2. ProjectID - Derived from repository name

No manual configuration needed for single-user deployments.


Data & Backup

Data is stored in ~/.config/contextd/ by default:

~/.config/contextd/
ā”œā”€ā”€ vectorstore/          # Memories, checkpoints, remediations
ā”œā”€ā”€ lib/                  # ONNX runtime (auto-downloaded)
└── config.yaml           # Optional config file

Backup:

tar czf contextd-backup.tar.gz ~/.config/contextd/

Restore:

tar xzf contextd-backup.tar.gz -C ~/

CLI Tools

ContextD includes two binaries:

BinaryPurpose
contextdMCP server (run with --mcp --no-http)
ctxdCLI utility for manual operations

ctxd Commands

# MCP Configuration (NEW)
ctxd mcp install         # Auto-configure MCP server settings
ctxd mcp status          # Verify MCP configuration
ctxd mcp uninstall       # Remove MCP configuration

# Statusline
ctxd statusline install  # Configure Claude Code statusline
ctxd statusline run      # Run statusline (used by Claude Code)

# Utilities
ctxd health              # Check server health
ctxd scrub <file>        # Scrub secrets from a file
ctxd init                # Initialize dependencies (ONNX runtime)
ctxd migrate             # Migrate data from Qdrant to chromem

Building from Source

git clone https://github.com/fyrsmithlabs/contextd.git
cd contextd

# Build with FastEmbed (requires CGO)
make build

# Or install to $GOPATH/bin
make go-install

# Run tests
make test

Documentation