Generate tailored claude.md files for coding tasks using DSPy and Anthropic's Claude.
The DSPy Context Synthesizer automatically generates rich, structured context files that help Claude understand your coding tasks better. It analyzes your task description, existing code examples, and project guidelines to create optimal context for interactive coding sessions.
- 🎯 Task-Aware Context Generation: Tailored context based on specific coding tasks
- 🔧 Code Pattern Recognition: Learns from existing code examples
- 📋 Project Guidelines Integration: Incorporates project-specific conventions
- 🖥️ CLI Interface: Easy-to-use command-line tool
- 🔄 Interactive Mode: Step-by-step context generation
-
Prerequisites: Python 3.8+ and an Anthropic API key
-
Install dependencies:
pip install -r requirements.txt
-
Install the package:
pip install -e . -
Set up your API key:
export ANTHROPIC_API_KEY="your-claude-api-key"
# Generate context for a coding task
dspy-synthesizer generate \
--task "Add JWT authentication to FastAPI app" \
--examples ./examples/code_examples.py \
--guidelines ./examples/project_guidelines.md# Launch interactive mode
dspy-synthesizer interactive# After generating context
claude --file claude.md "Implement the authentication system"The examples/ directory contains sample files to get you started:
task_example.txt- Example task descriptioncode_examples.py- Sample code to learn fromproject_guidelines.md- Project-specific guidelines
-
Generate context:
dspy-synthesizer generate \ --task "$(cat examples/task_example.txt)" \ --examples examples/code_examples.py \ --guidelines examples/project_guidelines.md \ --output my-context.md -
Review the generated context in
my-context.md -
Use with Claude:
claude --file my-context.md "Help me implement this feature"
generate- Generate a context fileinteractive- Interactive context generation
--model- Claude model to use (default: claude-3-sonnet-20240229)--task- Coding task description--examples- Path to code examples file--guidelines- Path to project guidelines file--output- Output file path (default: claude.md)--preview- Show preview of generated context
Configuration is stored in ~/.dspy-synthesizer/config.json. The tool will create default settings on first run.
dspy-synthesizer/
├── src/dspy_synthesizer/
│ ├── __init__.py
│ ├── synthesizer.py # Core DSPy module
│ ├── cli.py # CLI interface
│ └── config.py # Configuration management
├── examples/ # Example files
├── tests/ # Test files
├── requirements.txt # Dependencies
└── setup.py # Package setup
python -m pytest tests/- API Key Issues: Ensure
ANTHROPIC_API_KEYis set correctly - Model Access: Verify your API key has access to the specified Claude model
- File Permissions: Check that output directories are writable
MIT License - see LICENSE file for details.
Contributions welcome! Please read CONTRIBUTING.md for guidelines.