Intelligently package project directories into a single markdown file for AI analysis
Project description
Context Packer - The Webpack for AI Context
๐ฏ One file, full context - Package your entire project into a single markdown file optimized for LLMs and documentation.
๐ Why Context Packer?
In the age of AI-powered development, we face a critical challenge: Large Language Models need complete project context, but sharing multiple files is cumbersome and inefficient.
Just as webpack revolutionized JavaScript bundling and esbuild transformed build speeds, Context Packer transforms how we share code with AI models and documentation systems.
The Problem
- ๐ LLMs work best with single-file contexts - No need to manage multiple uploads
- ๐ Modern documentation systems (like Next.js) support single-file downloads for offline viewing
- ๐ค AI code reviews require complete project understanding in one shot
- ๐ Knowledge sharing becomes complex with scattered files
The Solution
Context Packer intelligently bundles your entire project into a single, AI-optimized markdown file - complete with structure visualization, smart filtering, and symlink support for complex project organization.
โจ Key Features
- ๐ Advanced Symlink Support: Organize complex projects with symbolic links - perfect for selective file inclusion
- ๐ฏ AI-Optimized Output: Formatted specifically for LLM consumption with clear structure and syntax highlighting
- ๐ Smart Filtering: Automatically excludes build artifacts, dependencies, and binary files
- ๐ณ Visual Project Tree: Instant understanding of project structure with status indicators
- โก Lightning Fast: Efficient processing even for large codebases
- ๐ง Highly Configurable: Fine-tune output with extensive options
๐ Quick Start
Installation
# Using pip
pip install context-packer
# Using uv (10-100x faster)
uv pip install context-packer
# Using pipx (isolated environment)
pipx install context-packer
Basic Usage
# Pack current directory
ctxpack .
# Pack specific project
ctxpack /path/to/project -o project_context.md
# Pack with custom settings
ctxpack . --max-size 20 --ignore "*.test.js" "docs/*"
๐จ Advanced: The Symlink Workflow
Context Packer's symlink support enables a powerful workflow for complex projects where you need fine-grained control over what gets packed.
Scenario: Selective Project Packing
Instead of using complex ignore patterns, create a "packing directory" with symlinks to exactly what you need:
# Create a packing directory
mkdir my-project-pack
cd my-project-pack
# Symlink specific files and directories
ln -s ../src/core core
ln -s ../src/utils/helpers.js helpers.js
ln -s ../config config
ln -s ../package.json package.json
ln -s ../README.md README.md
# Pack only what you've selected
ctxpack . -o ../my-project-context.md
Real-World Example: Multi-Module Project
# You have a monorepo with multiple packages
project/
โโโ packages/
โ โโโ frontend/ # React app
โ โโโ backend/ # Node.js API
โ โโโ shared/ # Shared utilities
โ โโโ mobile/ # React Native app
# Create a context for AI review of web platform only
mkdir web-platform-context
cd web-platform-context
# Link only web-related packages
ln -s ../packages/frontend frontend
ln -s ../packages/backend backend
ln -s ../packages/shared shared
ln -s ../docker-compose.yml docker-compose.yml
ln -s ../.env.example .env.example
# Generate context
ctxpack . -o web-platform.md --follow-symlinks
This approach gives you surgical precision in creating contexts for different purposes:
- ๐ฏ Code Review Context: Only the files changed in a PR
- ๐๏ธ Architecture Context: High-level structure without implementation details
- ๐ Debug Context: Specific module with its dependencies
- ๐ Documentation Context: README files and examples only
๐ Output Format
Context Packer generates a structured markdown file with:
1. Project Structure Visualization
MyProject
โโโ src/
โ โโโ index.js โ
# High-priority file
โ โโโ utils/ ๐๐ # Symlinked directory
โ โ โโโ helper.js โ๏ธ # Included file
โ โโโ tests/ โญ๏ธ # Ignored directory
โโโ package.json โ
# Configuration file
โโโ README.md โ
# Documentation
2. Status Indicators
- โ High-priority files (configs, README)
- โ๏ธ Source code files
- ๐ Symbolic links
- ๐๐ Symlinked directories
- โ ๏ธ Circular reference detected
- ๐ Large files (truncated)
- โญ๏ธ Ignored files
3. Complete File Contents
Each file is presented with:
- Relative path
- Syntax highlighting
- Smart truncation for large files
- Clear section separators
๐ฏ Perfect For
๐ค AI Development
# Prepare context for AI analysis
ctxpack . -o for_claude.md --max-size 30
# Get AI to review your architecture
ctxpack src/ -o architecture_review.md --max-depth 2
๐ Documentation
# Create offline documentation bundle
ctxpack docs/ -o documentation.md --ignore "*.png" "*.jpg"
๐ Code Review
# Package PR changes for review
ctxpack . -o pr_context.md --ignore "node_modules" "*.test.*"
๐ Learning & Teaching
# Create educational material
ctxpack examples/ -o tutorial_code.md --max-files 20
๐ ๏ธ Command Line Options
| Option | Description | Default |
|---|---|---|
project_path |
Directory to pack | Required |
-o, --output |
Output file path | {project}_context_{timestamp}.md |
--ignore |
Additional ignore patterns | None |
--max-size |
Maximum total size (MB) | 10 |
--max-files |
Maximum number of files | 100 |
-L, --max-depth |
Maximum directory depth | Unlimited |
--follow-symlinks |
Follow symbolic links | Yes |
--no-follow-symlinks |
Don't follow symbolic links | No |
-v, --verbose |
Show detailed progress | No |
โก Performance Tips
- Large Codebases: Use
--verboseto monitor progress - Selective Packing: Use symlinks for precise control
- Size Management: Adjust
--max-sizebased on LLM limits - Speed Optimization: Use
--max-depthto limit traversal
๐ Security & Best Practices
- Automatic Exclusions:
.env,.git,node_modulesare ignored by default - Gitignore Respect: Honors your
.gitignorepatterns - Size Limits: Prevents accidental huge outputs
- Review Before Sharing: Always check output before sending to third parties
๐งโ๐ป Development
Setting up with UV (Recommended)
# Install uv
curl -LsSf https://astral.sh/uv/install.sh | sh
# Clone and setup
git clone https://github.com/MarkShawn2020/context-packer.git
cd context-packer
# Install in development mode
uv pip install -e .
uv pip install -r requirements-dev.txt
# Run tests
uv run pytest
Quick Commands
make test # Run tests
make lint # Check code quality
make format # Format code
make build # Build package
make publish # Publish to PyPI
๐ฆ Publishing
With PyPI token configured:
# One-command publish (with version bump)
make release VERSION=patch # or minor, major
# Or manual steps
python bump_version.py patch
git commit -am "Bump version"
git tag v1.2.3
git push --tags
make publish
๐ Ecosystem
Context Packer is part of the modern AI development workflow:
- Use with Claude, GPT-4, Gemini for code analysis
- Integrate with CI/CD for automatic documentation
- Combine with AI editors like Cursor, Windsurf
- Works with documentation systems like Docusaurus, Next.js
๐ค Contributing
We welcome contributions! Context Packer is designed to be the definitive solution for project context packaging.
Ideas for Contribution
- ๐จ GUI interface (planned)
- ๐ Plugin system for custom processors
- ๐ Web service API
- ๐ Context analytics
- ๐ Incremental packing
๐ License
MIT License - see LICENSE file for details.
๐ Acknowledgments
Created by MarkShawn2020 to solve the real-world challenge of sharing complete project context with AI models. Inspired by the elegance of webpack and the speed of esbuild, Context Packer brings the same innovation to AI-assisted development.
๐ Transform how you share code with AI
Documentation โข Issues โข PyPI โข Releases
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 context_packer-1.1.5.tar.gz.
File metadata
- Download URL: context_packer-1.1.5.tar.gz
- Upload date:
- Size: 12.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0537d89f4df375b370fd4b593c02152632bb4b6683474ee48dbd7652d6e6ca61
|
|
| MD5 |
4d37d285d3c337c699d864aec1434085
|
|
| BLAKE2b-256 |
83fce9e76048a38ff00b584519893e4cfa5b1d71df2ed484ec2f909c2b8fc10e
|
File details
Details for the file context_packer-1.1.5-py3-none-any.whl.
File metadata
- Download URL: context_packer-1.1.5-py3-none-any.whl
- Upload date:
- Size: 12.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8fa08eb713e5f79affe30122b9560813ecf8d71a2dc7cb3e94ae17c7c97d8da8
|
|
| MD5 |
3792425037b6ad3007855a92e03ca201
|
|
| BLAKE2b-256 |
49deafc97e8958445ea994724d97545766d635b943f4c5e891be5a5b2f03df23
|