Persistent memory for AI coding agents
Project description
ContextKit
Persistent memory for AI coding agents. Stop re-explaining your codebase every session.
AI coding agents such as Claude Code, Codex, Cursor, and Copilot reset completely between sessions. You lose time re-explaining architecture, conventions, forbidden patterns, and past bugs. ContextKit gives your repo a shared, evolving project brain.
How it works
ctx initsets up a.ctx/brain in your repo.ctx addadds memories manually, orctx watchextracts them automatically.ctx inject claudegenerates a fresh agent instruction file.- Every new session starts with project-specific context.
Install
pip install ctxmemory
Quickstart
cd your-project
pip install ctxmemory
ctx init
ctx add "We use Zod for all validation. Never use Yup." --type pattern
ctx add "Never mutate state directly - always use the store actions." --type forbidden
ctx inject claude
Commands
| Command | Description | Key options |
|---|---|---|
ctx init |
Create .ctx/, markdown files, and the SQLite index |
None |
ctx add <content> |
Add a memory manually | --type, --tags |
ctx list |
List stored memories | --type, --tags, --limit |
ctx remove <id> |
Remove a memory by partial id | None |
ctx inject <agent> |
Generate an agent-specific context file | --task, --file, --force |
ctx watch |
Extract memory candidates from recent activity | --since |
ctx status |
Show totals, recent memories, and generated files | None |
ctx search <query> |
Search memories by content and tags | --limit |
ctx export |
Export all memories as markdown or JSON | --format, --output |
Supported agents
| Agent | File generated |
|---|---|
| Claude Code | CLAUDE.md |
| Codex | AGENTS.md |
| Cursor | .cursor/rules |
| GitHub Copilot | .github/copilot-instructions.md |
| OpenCode | AGENTS.md |
Project brain layout
.ctx/
brain.db
decisions.md
patterns.md
forbidden.md
bugs.md
context.md
.gitignore
The markdown files are the source of truth. The SQLite database is a fast index for lookup and relevance.
Auto-extraction (ctx watch)
ctx watch uses the Anthropic API to review recent git activity, Claude session logs,
or a manual session summary and suggest memories to add to your project brain.
Set ANTHROPIC_API_KEY before using automatic extraction:
export ANTHROPIC_API_KEY=sk-ant-...
ContextKit resolves configuration in this order:
ANTHROPIC_API_KEY.envin the project root~/.contextkit/config.toml
Example global config:
[anthropic]
api_key = "sk-ant-..."
[watch]
default_since_minutes = 60
auto_approve_threshold = 0.9
[inject]
max_memories = 20
Typical workflow
pip install ctxmemory
ctx init
ctx add "We use FastAPI, not Flask. Never suggest Flask." --type forbidden --tags "framework"
ctx add "All API responses use APIResponse in core/response.py." --type pattern --tags "api,response"
ctx inject codex
ctx status
ctx search auth
ctx watch --since 480
License
MIT
Author
Built by Anas Nafees
LinkedIn: https://www.linkedin.com/in/anas-nafees/
Package name note
The product name is ContextKit, but the PyPI distribution name is ctxmemory
because contextkit is already taken on PyPI. The installed CLI command remains:
ctx
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ctxmemory-0.1.0.tar.gz.
File metadata
- Download URL: ctxmemory-0.1.0.tar.gz
- Upload date:
- Size: 18.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
775ee9910d5fbe6b20f78d86200e607418b5162ed44fa3b4317bd02c385d3b8f
|
|
| MD5 |
5c0ec11203bd119584d313fcc61dfb58
|
|
| BLAKE2b-256 |
121cb9eb95a67db102d7a1e142134f6147116a9a634e87ac776b17b731dffce8
|
Provenance
The following attestation bundles were made for ctxmemory-0.1.0.tar.gz:
Publisher:
publish-pypi.yml on AnasNafees1802/contextkit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ctxmemory-0.1.0.tar.gz -
Subject digest:
775ee9910d5fbe6b20f78d86200e607418b5162ed44fa3b4317bd02c385d3b8f - Sigstore transparency entry: 1409503546
- Sigstore integration time:
-
Permalink:
AnasNafees1802/contextkit@857008c574227b1da55c285991ad81c2d91a2cde -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/AnasNafees1802
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@857008c574227b1da55c285991ad81c2d91a2cde -
Trigger Event:
release
-
Statement type:
File details
Details for the file ctxmemory-0.1.0-py3-none-any.whl.
File metadata
- Download URL: ctxmemory-0.1.0-py3-none-any.whl
- Upload date:
- Size: 19.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
509a83a1c4c69bfbb288a4d34f7622612e06f31c799d45511d7cb28a3535f214
|
|
| MD5 |
194e8734eb8a01f47119ea88ff572a28
|
|
| BLAKE2b-256 |
86d1c4bb5ae27ac2bcbd9676383d807f78f8a853c10ff94ebddb91bd47f1d7a7
|
Provenance
The following attestation bundles were made for ctxmemory-0.1.0-py3-none-any.whl:
Publisher:
publish-pypi.yml on AnasNafees1802/contextkit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ctxmemory-0.1.0-py3-none-any.whl -
Subject digest:
509a83a1c4c69bfbb288a4d34f7622612e06f31c799d45511d7cb28a3535f214 - Sigstore transparency entry: 1409503559
- Sigstore integration time:
-
Permalink:
AnasNafees1802/contextkit@857008c574227b1da55c285991ad81c2d91a2cde -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/AnasNafees1802
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@857008c574227b1da55c285991ad81c2d91a2cde -
Trigger Event:
release
-
Statement type: