Skip to content

Repository files navigation

contextkit - AI Context Engine

Generate AI context (rules + docs + conventions) from your codebase for Cursor, Claude Code, GitHub Copilot, and Continue.dev.

Stop maintaining 4 different rule files. Stop wasting tokens re-reading the same code. Let contextkit automatically extract your project's knowledge and export it to every AI coding tool your team uses.

MIT License Python 3.10+ PRs Welcome

🎯 The Problem

Your team uses multiple AI coding tools:

  • 🟦 Cursor (.cursorrules)
  • 🟧 Claude Code (CLAUDE.md)
  • πŸŸͺ GitHub Copilot (copilot-instructions.md)
  • 🟩 Continue.dev (.continue/rules/)

Every time someone joins or a new tool is adopted, rules get duplicated, drift apart, or disappear. Meanwhile, every developer keeps feeding the same codebase to the AI β€” burning tokens on every prompt.

✨ The Solution

$ cd my-project
$ contextkit init .

πŸ” Analyzing codebase...
πŸ“ Extracted 14 coding rules
πŸ“š Generated 6 doc sections
πŸ’Ύ Exported to 4 formats

✨ Done! Token savings: 71.3% (4,487 β†’ 1,288 tokens)

One command. Four formats. Zero duplication.

πŸš€ Quick Start

Install

pip install contextkit

Use

# Analyze and generate context
contextkit init .

# Watch for changes and auto-regenerate
contextkit watch .

# Validate existing context files
contextkit validate .

# Compare with last snapshot
contextkit diff .ai-context

# Health check + auto-fix
contextkit doctor . --fix

# Merge multiple rule files
contextkit merge .cursorrules CLAUDE.md --output merged.md

# Generate a config file
contextkit config

# Create team plugins
contextkit plugin create team-standards

# Set up CI/CD
contextkit hook pre-commit
contextkit hook github-action

πŸ“¦ What Gets Generated

By default, contextkit creates a .ai-context/ directory with:

.ai-context/
β”œβ”€β”€ cursor/
β”‚   β”œβ”€β”€ .cursorrules              # Single-file format
β”‚   └── .cursor/rules/            # Modular format (newer Cursor)
β”‚       β”œβ”€β”€ 00-project.md
β”‚       β”œβ”€β”€ 01-tech-stack.md
β”‚       β”œβ”€β”€ 02-conventions.md
β”‚       └── 03-architecture.md
β”œβ”€β”€ claude/
β”‚   β”œβ”€β”€ CLAUDE.md                 # For Claude Code
β”‚   └── API.md                    # (if API routes detected)
β”œβ”€β”€ copilot/
β”‚   └── .github/
β”‚       └── copilot-instructions.md
└── continue/
    └── .continue/rules/
        β”œβ”€β”€ project.md
        β”œβ”€β”€ style.md
        β”œβ”€β”€ naming.md
        β”œβ”€β”€ architecture.md
        β”œβ”€β”€ error_handling.md
        β”œβ”€β”€ testing.md
        β”œβ”€β”€ imports.md
        └── documentation.md

🎨 Use Cases

1. Onboarding new team members

# New dev clones the repo
git clone ...
contextkit init .
# Now their AI assistant "knows" the codebase from day 1

2. Migrating to a new AI tool

# Team switches from Cursor to Claude Code
contextkit init . --formats claude
cp .ai-context/claude/CLAUDE.md .
# All coding rules transferred automatically

3. Heterogeneous teams

# Half uses Cursor, half uses Claude Code
contextkit init . --formats cursor,claude,copilot
# Everyone gets the same context

4. Cost optimization

contextkit estimate .
# β†’ Token savings: 71%
# β†’ Monthly savings (10 devs): $106

πŸ”§ How It Works

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚         YOUR CODEBASE                        β”‚
β”‚  (Python, JS/TS, Go, Rust, etc.)             β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                   β”‚
        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
        β”‚  1. ANALYZER        β”‚  β†’ Detects languages, frameworks,
        β”‚                     β”‚    lint/format configs, structure
        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                   β”‚
        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
        β”‚  2. RULE EXTRACTOR  β”‚  β†’ Heuristics + optional LLM
        β”‚                     β”‚    (naming, style, error handling...)
        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                   β”‚
        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
        β”‚  3. DOC GENERATOR   β”‚  β†’ Auto-generates architecture,
        β”‚                     β”‚    setup, API surface docs
        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                   β”‚
        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
        β”‚  4. MULTI-FORMAT    β”‚  β†’ Exports to .cursorrules,
        β”‚     EXPORTER        β”‚    CLAUDE.md, copilot, continue
        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

🧠 What Gets Extracted

Coding Rules (auto-detected)

  • βœ… Naming conventions (snake_case, camelCase, etc.)
  • βœ… Linters/formatters (Black, Ruff, Prettier, ESLint, etc.)
  • βœ… Framework conventions (FastAPI async/await, React hooks, Go naming)
  • βœ… Error handling patterns (HTTPException, Result types, etc.)
  • βœ… Testing rules (pytest fixtures, Jest patterns)
  • βœ… Import organization (isort, absolute imports)
  • βœ… Documentation standards (docstrings, JSDoc)

Documentation (auto-generated)

  • βœ… Project overview (from README + pyproject.toml + package.json)
  • βœ… Architecture (structure type, entry points, key components)
  • βœ… Tech stack (languages, frameworks, tooling)
  • βœ… Setup instructions (package manager-aware)
  • βœ… API surface (detected from FastAPI/Express routes)

πŸ“Š Real-World Results

Tested on 3 sample projects:

Project Language Rules Token Savings
FastAPI Task Manager Python 14 71.3%
Next.js E-commerce TypeScript 10 34.8%
Go URL Shortener Go 2 81.7%

πŸŽ›οΈ Configuration

CLI Options

contextkit init [PATH] [OPTIONS]

Options:
  -o, --output DIR       Output directory (default: .ai-context)
  -f, --formats LIST     Comma-separated: cursor,claude,copilot,continue
  --no-llm              Skip LLM analysis (faster, no API key needed)
  --llm-model MODEL     LLM model (default: claude-sonnet-4-5)
  -n, --name NAME       Override project name
  -v, --verbose         Verbose output

Environment Variables

  • ANTHROPIC_API_KEY β€” Required for LLM-powered rule extraction (optional)

πŸ€– LLM-Enhanced Mode

By default, contextkit uses heuristics (regex, AST analysis, config detection) to extract rules. This is fast, deterministic, and works offline.

For deeper insights, set ANTHROPIC_API_KEY and contextkit will additionally call Claude to extract:

  • Architecture patterns specific to your codebase
  • Non-obvious conventions
  • Domain-specific rules

The heuristics run first, then LLM-extracted rules are merged in. If the LLM call fails, the heuristics still work.

πŸ†š Comparison

Feature contextkit Cursor Mintlify Greptile
Auto-generate from code βœ… ❌ ❌ ⚠️
Multi-tool export βœ… ❌ ❌ ❌
Open source βœ… ❌ ❌ ❌
Self-hosted βœ… ❌ ❌ ⚠️
Token optimization βœ… ❌ N/A ❌
Code + Docs unified βœ… ❌ ⚠️ ❌
Watch mode βœ… ❌ ❌ ❌
Validation βœ… ❌ ❌ ❌
Snapshot diff βœ… ❌ ❌ ❌
Config file βœ… ⚠️ ❌ ❌
Plugin system βœ… ❌ ❌ ❌
CI/CD hooks βœ… ❌ ❌ ❌
Multi-source merge βœ… ❌ ❌ ❌
Health diagnostics βœ… ❌ ❌ ❌
Free βœ… ⚠️ ⚠️ ❌

πŸ—ΊοΈ Roadmap

  • v0.1 β€” MVP with heuristic extraction + multi-format export
  • v0.2 β€” Config file, validate, diff, watch, Java/C# support
  • v0.3 β€” Plugin system, hooks, doctor, merge
  • v0.4 β€” Web dashboard for team management
  • v0.5 β€” VS Code extension
  • v0.6 β€” Real-time context updates via webhooks
  • v1.0 β€” Team centralization (SSO, audit, RBAC)

πŸ› οΈ Development

# Clone
git clone https://github.com/itsurge/contextkit
cd contextkit

# Install in editable mode
pip install -e ".[dev]"

# Test on sample repos
cd ../test-repos/fastapi-sample
contextkit init . --no-llm

🀝 Contributing

We welcome PRs! Especially:

  • 🌐 More language support (Rust, Java, C#, Ruby)
  • 🧠 Smarter rule extraction
  • πŸ“¦ New export formats
  • πŸ› Bug fixes
  • πŸ“š Documentation

πŸ“„ License

MIT β€” see LICENSE

🌟 Why This Project Exists

The AI coding revolution is happening, but most teams are stuck in a messy reality:

  • Multiple AI tools in use
  • Outdated or missing rule files
  • Wasted tokens re-reading the same code
  • No standardization

contextkit fixes this with a single command that works for every tool.


Built with ❀️ by developers who got tired of writing the same .cursorrules four times.

About

No description, website, or topics provided.

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages