Skip to main content

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

  1. ctx init sets up a .ctx/ brain in your repo.
  2. ctx add adds memories manually, or ctx watch extracts them automatically.
  3. ctx inject claude generates a fresh agent instruction file.
  4. 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:

  1. ANTHROPIC_API_KEY
  2. .env in the project root
  3. ~/.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

Metadata

Release files for ctxmemory 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ctxmemory 0.1.0
File Size Uploaded
ctxmemory-0.1.0.tar.gz 18.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ctxmemory 0.1.0
File Interpreter ABI Platform
ctxmemory-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 38.1 kB

Release files / ctxmemory-0.1.0.tar.gz

Download URL ctxmemory-0.1.0.tar.gz
Size 18.8 kB
Tags Source
SHA-256 checksum
How to use checksums
775ee9910d5fbe6b20f78d86200e607418b5162ed44fa3b4317bd02c385d3b8f
BLAKE2b-256 checksum
How to use checksums
121cb9eb95a67db102d7a1e142134f6147116a9a634e87ac776b17b731dffce8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 30, 2026.

Transparency log

Release files / ctxmemory-0.1.0-py3-none-any.whl

Download URL ctxmemory-0.1.0-py3-none-any.whl
Size 19.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
509a83a1c4c69bfbb288a4d34f7622612e06f31c799d45511d7cb28a3535f214
BLAKE2b-256 checksum
How to use checksums
86d1c4bb5ae27ac2bcbd9676383d807f78f8a853c10ff94ebddb91bd47f1d7a7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 30, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page