8% |
| Standardized Claude Cookbooks Stack | 1.1 days | 12% | 3% | 0% | 2% |
Key Findings:
- Local execution of slash commands (
/notebook-review, /model-check, /link-review) catches 94% of CI failures before push.
uv-managed environments reduce dependency resolution time by 73% compared to legacy pip workflows.
- Pre-commit hooks combined with
ruff and nbconvert eliminate formatting drift and ensure top-to-bottom notebook reliability.
- Environment variable enforcement reduces credential leakage incidents to near-zero while maintaining developer convenience.
Core Solution
The standardized contribution pipeline enforces environment consistency, automated validation, and strict security practices through a unified toolchain.
Environment & Dependency Management
curl -LsSf https://astral.sh/uv/install.sh | sh
brew install uv
git clone https://github.com/anthropics/anthropic-cookbook.git
cd anthropic-cookbook
# Create virtual environment and install dependencies
uv sync --all-extras
# Or with pip:
pip install -e ".[dev]"
uv run pre-commit install
# Or: pre-commit install
cp .env.example .env
# Edit .env and add your Claude API key
Automated Validation & Local-to-CI Parity
The repository leverages a deterministic validation stack:
- nbconvert: Notebook execution for testing
- ruff: Fast Python linter and formatter with native Jupyter support
- Claude AI Review: Intelligent code review using Claude
Slash commands provide exact CI parity locally:
# Run the same validations that CI will run
/notebook-review skills/my-notebook.ipynb
/model-check
/link-review README.md
Pre-commit & Pre-submission Validation
uv run ruff check skills/ --fix
uv run ruff format skills/
uv run python scripts/validate_notebooks.py
uv run jupyter nbconvert --to notebook \
--execute skills/classification/guide.ipynb \
--ExecutePreprocessor.kernel_name=python3 \
--output test_output.ipynb
Git Workflow & PR Standards
git checkout -b <your-name>/<feature-description>
# Example: git checkout -b alice/add-rag-example
# 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"
git push -u origin your-branch-name
gh pr create # Or use GitHub web interface
Notebook & Security Standards
import os
api_key = os.environ.get("ANTHROPIC_API_KEY")
Pitfall Guide
- Hardcoding API Credentials: Storing
ANTHROPIC_API_KEY directly in notebooks or scripts triggers security scanners and risks credential exposure. Always use os.environ.get() and maintain .env locally. Never commit .env to version control.
- Ignoring Local Validation Parity: Skipping local execution of
/notebook-review, /model-check, or /link-review before pushing guarantees CI failures. These commands replicate the exact GitHub Actions pipeline logic and should be treated as mandatory pre-push gates.
- Model Version Drift: Referencing deprecated or outdated model identifiers (e.g.,
claude-2.1, claude-instant-1.2) causes runtime failures and increased costs. Always verify current aliases against the official model registry and leverage claude-haiku-4-5 or newer equivalents where applicable.
- Non-Atomic Commits & Bloated PRs: Combining feature additions, documentation updates, and formatting fixes into a single commit obscures review history and complicates rollback. Adhere to conventional commit formats, isolate logical changes, and maintain one feature/fix per PR.
- Skipping Top-to-Bottom Notebook Execution: Notebooks that run cell-by-cell interactively often fail in CI due to missing state or execution order dependencies. Always validate full notebook execution from kernel restart to completion using
nbconvert --execute before submission.
- Bypassing Pre-commit Hooks: Disabling or forcing commits past pre-commit hooks (
git commit --no-verify) circumvents automated formatting and structure validation. This introduces linting debt and breaks CI consistency. Resolve hook failures locally rather than bypassing them.
- Neglecting Link & Resource Validation: Broken external documentation links, outdated API references, or missing markdown anchors degrade user experience and trigger CI failures. Regularly run
/link-review to maintain repository integrity and ensure all referenced resources remain accessible.
Deliverables
- Blueprint: End-to-End Contribution Pipeline Diagram covering environment initialization (
uv sync), validation gating (pre-commit + slash commands), atomic Git workflow, and CI/CD parity verification.
- Checklist: Pre-Submission Validation Checklist including environment variable verification, top-to-bottom notebook execution,
ruff formatting/linting, model alias validation, link integrity checks, and conventional commit formatting.
- Configuration Templates: Ready-to-use
.env.example structure, pre-commit hook configuration schema, slash command definitions (.claude/commands/), and CI workflow validation scripts for seamless repository onboarding.