Thank you for your interest in contributing to the Claude Cookbooks! This guide will help you get started with development and ensure your contributions meet our quality standards.
Install uv (recommended package manager):
curl -LsSf https://astral.sh/uv/install.sh | sh
Or with Homebrew:
brew install uv
Clone the repository:
git clone https://github.com/anthropics/anthropic-cookbook.git
cd anthropic-cookbook
Set up the development environment:
# Create virtual environment and install dependencies
uv sync --all-extras
# Or with pip:
pip install -e ".[dev]"
Install pre-commit hooks:
uv run pre-commit install
# Or: pre-commit install
Set up your API key:
cp .env.example .env
# Edit .env and add your Claude API key
This repository uses automated tools to maintain code quality:
Note: Notebook outputs are intentionally kept in this repository as they demonstrate expected results for users.
This repository includes slash commands that work in both Claude Code (for local development) and GitHub Actions CI. These commands are automatically available when you work in this repository with Claude Code.
Available Commands:
/link-review - Validate links in markdown and notebooks/model-check - Verify Claude model usage is current/notebook-review - Comprehensive notebook quality checkUsage in Claude Code:
# Run the same validations that CI will run
/notebook-review skills/my-notebook.ipynb
/model-check
/link-review README.md
These commands use the exact same validation logic as our CI pipeline, helping you catch issues before pushing. The command definitions are stored in .claude/commands/ for both local and CI use.
Run quality checks:
uv run ruff check skills/ --fix
uv run ruff format skills/
uv run python scripts/validate_notebooks.py
Test notebook execution (optional, requires API key):
uv run jupyter nbconvert --to notebook \
--execute skills/classification/guide.ipynb \
--ExecutePreprocessor.kernel_name=python3 \
--output test_output.ipynb
Pre-commit hooks will automatically run before each commit to ensure code quality:
If a hook fails, fix the issues and try committing again.
Use environment variables for API keys:
import os
api_key = os.environ.get("ANTHROPIC_API_KEY")
Use current Claude models:
claude-haiku-4-5-20251001 (Haiku 4.5)Keep notebooks focused:
Test your notebooks:
Create a feature branch:
git checkout -b <your-name>/<feature-description>
# Example: git checkout -b alice/add-rag-example
Use conventional commits:
# Format: <type>(<scope>): <subject>
# Types:
feat # New feature
fix # Bug fix
docs # Documentation
style # Formatting
refactor # Code restructuring
test # Tests
chore # Maintenance
ci # CI/CD changes
# Examples:
git commit -m "feat(skills): add text-to-sql notebook"
git commit -m "fix(api): use environment variable for API key"
git commit -m "docs(readme): update installation instructions"
Keep commits atomic:
Push and create PR:
git push -u origin your-branch-name
gh pr create # Or use GitHub web interface
Run the validation suite:
# Check all notebooks
uv run python scripts/validate_notebooks.py
# Run pre-commit on all files
uv run pre-commit run --all-files
Our GitHub Actions workflows will automatically:
External contributors will have limited API testing to conserve resources.
By contributing, you agree that your contributions will be licensed under the same license as the project (MIT License).