Skip to main content

Generate LLM context files for codebases

Project description

cdd-context

Generate and maintain a PROJECT_CONTEXT.md file that gives Claude (or any LLM) immediate orientation on a codebase.

Status: v0.3.0 (draft) | Built with CDD spec 1.1.5

Problem

When working with Claude across multiple sessions, you repeatedly share the same files. Claude can't remember what it saw yesterday. The friction isn't the mechanics of sending a file—it's the repetition and the feeling that Claude should already know this.

Solution

A local tool that scans your codebase, generates summaries of each file, and assembles them into a single context document. Paste once at session start, Claude is oriented. File details come on-demand.

Quick Start

# Install from source
git clone https://github.com/thegdyne/cdd-context.git
cd cdd-context
pip install -e .

# Go to any project
cd ~/your-project

# Generate context
cdd-context build

# Output: PROJECT_CONTEXT.md created

Workflow

New session:

cdd-context build --clip   # Generates + copies to clipboard

Paste into Claude. Claude now knows your project structure.

Mid-session after edits:

cdd-context build --changes --clip   # Just the delta

Paste the changes. Claude catches up without re-reading everything.

Check what's cached:

cdd-context status
# Cache entries: 47
# Context file: PROJECT_CONTEXT.md (6200 bytes)

Something weird? Reset:

cdd-context clear-cache
cdd-context build

Commands

cdd-context build                    # Generate PROJECT_CONTEXT.md
cdd-context build --clip             # Generate and copy to clipboard
cdd-context build --dry-run          # Show what would be summarized (no changes)
cdd-context build --changes          # Show changes since last build (list + summaries)
cdd-context build --changes=list     # List only (added/modified/deleted)
cdd-context build --changes=summaries # Summaries only (added/modified)
cdd-context build --changes --clip   # Copy delta to clipboard
cdd-context status                   # Show cache state
cdd-context clear-cache              # Clear cache (keeps PROJECT_CONTEXT.md)
cdd-context watch                    # Watch for changes and rebuild (planned)

How It Works

  1. Scanner walks your directory tree, respects .gitignore and .contextignore
  2. Summarizer generates concise summaries (heuristic-based, LLM integration planned)
  3. Cache stores summaries keyed by file hash + prompt hash + backend
  4. Generator assembles everything into a structured markdown file
  5. Manifest tracks last build state for --changes diffs

Only changed files are re-summarized. Typical projects stay under 8k tokens.

Changes Output Example

cdd-context build --changes
# Project Changes: my-project

> Since scan: a1b2c3d4 → e5f6g7h8 | Mode: git

## Modified
### src/engine.py
**Role:** entrypoint

Main synthesis engine with updated MIDI routing...

**Provides:** start_engine, stop_engine
**Consumes:** os, sys, generators

## Added
### src/new_feature.py
**Role:** library

New feature implementation...

## Deleted
- src/old_module.py

Output Example

# Project Context: my-project

> Files: 47 | Cache: 42/47 hits | Mode: git | Hash: a1b2c3d4

## Directory Structure

my-project/
├── src/
│   ├── engine.py
│   └── generators/
├── tests/
└── README.md

## Key Files

### src/engine.py
**Role:** entrypoint

Main synthesis engine coordinating generators and MIDI input...

**Provides:** start_engine, stop_engine, process_midi
**Consumes:** os, sys, generators

## Other Files

| File | Role | Summary |
|------|------|---------|
| src/generators/crystalline.py | library | Ice structure generator... |

What Gets Ignored

  1. Everything in .gitignore (if in a git repo)
  2. Plus .contextignore patterns you add
  3. Plus built-in defaults:
.env, .env.*, *.pem, *.key, secrets.*
node_modules/, __pycache__/, .git/
*.log, *.pyc, .DS_Store
dist/, build/, *.egg-info/

Configuration

Create .contextignore in your project root to exclude additional files:

# Secrets
.env
*.pem

# Large files
*.pdf
data/

# Noise
*.log
vendor/

Requirements

  • Python 3.10+

Suggested Aliases

Add to ~/.zshrc or ~/.bashrc:

alias ctx='cdd-context build --clip'           # Full context → clipboard
alias ctxd='cdd-context build --changes --clip' # Delta → clipboard  
alias ctxl='cdd-context build --changes=list'   # Quick list of changes
alias ctxs='cdd-context status'                 # Check cache state
alias ctx-reset='cdd-context clear-cache'       # Reset cache

Then: ctx for new sessions, ctxd mid-session after edits.

Development

This project is built using Contract-Driven Development.

# Setup after clone
python tests/setup_fixtures.py

# Run all tests
python tests/test_scanner.py
python tests/test_cache.py
python tests/test_summarizer.py
python tests/test_generator.py
python tests/test_cli.py

Components

Component Status Description
scanner ✓ implemented Directory walking, git/contextignore filtering
cache ✓ implemented Content-addressed summary storage + build manifest
summarizer ✓ implemented Heuristic file summarization (LLM integration planned)
generator ✓ implemented PROJECT_CONTEXT.md assembly
cli ✓ implemented Command-line interface with --changes support

Roadmap

  • LLM integration (Claude Haiku for better summaries)
  • Watch mode (auto-rebuild on file changes)
  • PyPI publish (pip install cdd-context)

License

MIT

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

cdd_context-0.3.0.tar.gz (27.9 kB view details)

Uploaded Source

Built Distribution

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

cdd_context-0.3.0-py3-none-any.whl (22.9 kB view details)

Uploaded Python 3

File details

Details for the file cdd_context-0.3.0.tar.gz.

File metadata

  • Download URL: cdd_context-0.3.0.tar.gz
  • Upload date:
  • Size: 27.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for cdd_context-0.3.0.tar.gz
Algorithm Hash digest
SHA256 33a843214f0d50639e07bc768df84b63cdec8dd47a7abcf5ccdc78a2b95ad1bc
MD5 ca6b7166b9c850c661f0af5ae0004a07
BLAKE2b-256 72443dd5defd071c5e17f32ed1d1d0197f90cc2eacb20cc44983f8834ee0060f

See more details on using hashes here.

File details

Details for the file cdd_context-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: cdd_context-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 22.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for cdd_context-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cab86d9754338d38924616332d1de2fbecee42749e987d3475baece17c7b7073
MD5 7464b0949c718e20fa204690c3241cc7
BLAKE2b-256 e63d6a9f93bad1883564db348a32be47beb27fe33153f70e471cd2bab37c8f73

See more details on using hashes here.

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