Skip to main content

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

  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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ctxmemory-0.1.0.tar.gz (18.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ctxmemory-0.1.0-py3-none-any.whl (19.3 kB view details)

Uploaded Python 3

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

Hashes for ctxmemory-0.1.0.tar.gz
Algorithm Hash digest
SHA256 775ee9910d5fbe6b20f78d86200e607418b5162ed44fa3b4317bd02c385d3b8f
MD5 5c0ec11203bd119584d313fcc61dfb58
BLAKE2b-256 121cb9eb95a67db102d7a1e142134f6147116a9a634e87ac776b17b731dffce8

See more details on using hashes here.

Provenance

The following attestation bundles were made for ctxmemory-0.1.0.tar.gz:

Publisher: publish-pypi.yml on AnasNafees1802/contextkit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for ctxmemory-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 509a83a1c4c69bfbb288a4d34f7622612e06f31c799d45511d7cb28a3535f214
MD5 194e8734eb8a01f47119ea88ff572a28
BLAKE2b-256 86d1c4bb5ae27ac2bcbd9676383d807f78f8a853c10ff94ebddb91bd47f1d7a7

See more details on using hashes here.

Provenance

The following attestation bundles were made for ctxmemory-0.1.0-py3-none-any.whl:

Publisher: publish-pypi.yml on AnasNafees1802/contextkit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page