# code-session-memory: Automatic Vector Memory for AI Coding Sessions

This repository profile is provided by osrepos.com, an open source repository discovery platform.

Source: osrepos.com
Repository profile: https://osrepos.com/repo/djannot-code-session-memory
Generated for open source discovery and AI-assisted research.

code-session-memory provides automatic vector memory for various AI coding tools like OpenCode, Claude Code, Cursor, VS Code, Codex, and Gemini CLI. It indexes new messages into a vector database after each AI agent turn, enabling semantic search across all your past coding sessions. This tool ensures memory is shared across different platforms, enhancing developer productivity.

GitHub: https://github.com/djannot/code-session-memory
OSRepos URL: https://osrepos.com/repo/djannot-code-session-memory

## Summary

code-session-memory provides automatic vector memory for various AI coding tools like OpenCode, Claude Code, Cursor, VS Code, Codex, and Gemini CLI. It indexes new messages into a vector database after each AI agent turn, enabling semantic search across all your past coding sessions. This tool ensures memory is shared across different platforms, enhancing developer productivity.

## Topics

- TypeScript
- AI
- Developer Tools
- Vector Database
- LLM
- Productivity
- GitHub
- CLI

## Repository Information

Last analyzed by OSRepos: Sat Aug 15 2026 13:57:08 GMT+0100 (Western European Summer Time)
Detail views: 6
GitHub clicks: 3

## Safety Notice

OSRepos shares public repositories for knowledge and discovery only. Review source code, dependencies, licenses, and security implications before running or installing anything.

## Content

## Introduction
`code-session-memory` is an innovative open-source project that provides automatic vector memory for your AI coding sessions. It integrates seamlessly with popular AI development tools such as OpenCode, Claude Code, Cursor, VS Code, Codex, and Gemini CLI. The core idea is to prevent losing context from your past AI interactions by automatically indexing new messages into a vector database after each agent turn. This enables powerful semantic search capabilities, allowing both you and your AI agent to retrieve relevant information from previous sessions, regardless of the tool used.

## Installation
To get started with `code-session-memory`, you'll need a few prerequisites and a simple installation command.

### Prerequisites
*   Node.js ? 18
*   An OpenAI API key (for `text-embedding-3-large`)
*   At least one supported tool installed (OpenCode, Claude Code, Cursor, VS Code, Codex, or Gemini CLI)

### Install
Run the following command to set up `code-session-memory` for all detected tools on your machine:
bash
npx code-session-memory install

This command automatically configures plugins, hooks, skills, and MCP server entries for OpenCode, Claude Code, Cursor, VS Code, Codex, and Gemini CLI. All tools will share the same local SQLite database by default, located at `~/.local/share/code-session-memory/sessions.db`, and the same MCP server for querying past sessions. Remember to restart your AI coding tool to activate the changes.

### Set Your API Key
Ensure your OpenAI API key is set as an environment variable:
bash
export OPENAI_API_KEY=sk-...

It's recommended to add this to your shell profile (`.bashrc`, `.zshrc`, etc.) for persistent access.

## Examples
Once installed, memory indexing is fully automatic. Here are some ways to interact with your indexed sessions.

### Verify Installation
You can check the status of your installation and database with:
bash
npx code-session-memory status

This command provides an overview of your database, indexed chunks, tracked sessions, and the installation status for each integrated tool.

### Querying from the CLI
Search your indexed sessions directly from the terminal using natural language queries:
bash
npx code-session-memory query "authentication middleware"
npx code-session-memory query "auth flow" --source opencode
npx code-session-memory query "error handling" --from 2026-02-01 --to 2026-02-20

You can filter results by source tool, limit the number of results, and specify date ranges.

### Browsing Sessions
An interactive CLI browser allows you to inspect and manage your sessions:
bash
npx code-session-memory sessions

From here, you can print a session's full content, compact it for restarting a new session (generating a summary of context, key decisions, current state, and unresolved issues), or delete it.

### Web UI
For a comprehensive visual experience, `code-session-memory` offers a full-featured web interface:
bash
npx code-session-memory web

Open <a href="http://localhost:3333" target="_blank">http://localhost:3333</a> in your browser to access a dashboard with search, session browsing, detailed session analytics, and status information.

### Asking the Agent About Past Sessions
The installed skill teaches your AI agent when and how to use these memory tools. You can prompt your agent with questions like:
*   "How did we implement the authentication middleware last week?"
*   "Have we discussed this error before?"
*   "What was our decision about the database schema?"

## Why Use It
`code-session-memory` significantly boosts developer productivity by addressing the challenge of context loss in AI-assisted coding.

*   **Seamless Cross-Tool Memory**: It unifies your coding memory across various AI tools, ensuring that knowledge gained in one session is accessible in another, regardless of the platform.
*   **Intelligent Semantic Search**: Leverage natural language queries to semantically search through all your past interactions, quickly retrieving relevant code snippets, decisions, or discussions.
*   **Efficient Session Management**: Tools for browsing, summarizing, and deleting sessions, both via CLI and a user-friendly web interface, give you full control over your coding history.
*   **Flexible and Scalable Storage**: Choose between a local SQLite database for simplicity or a centralized PostgreSQL with `pgvector` backend for sharing memory across multiple machines or using managed services like [Supabase](https://supabase.com "Supabase" target="_blank").
*   **Optimized Performance**: Incremental indexing ensures that only new messages are processed, making each indexing pass fast and efficient, even for long sessions.
*   **Structured Analytics**: Gain insights into your coding process with detailed analytics on message counts, tool usage, and active session duration.

## Links
*   GitHub Repository: [djannot/code-session-memory](https://github.com/djannot/code-session-memory "djannot/code-session-memory on GitHub" target="_blank")