Self-healing Python packages powered by Claude AI.
This template provides GitHub Actions workflows that automatically detect and fix compatibility issues when dependencies update. No more bitrot!
Scientific and mathematical Python packages frequently break because:
- NumPy/SciPy/etc. change APIs
- Deprecation warnings become errors
- Transitive dependencies conflict
- Maintainers move on, packages rot
This template includes a monthly maintenance workflow that:
- Tests your package with the latest versions of all dependencies
- If tests fail, invokes Claude AI to diagnose and fix the issues
- Creates a PR with the fixes for your review
- If Claude can't fix it, creates an issue for manual intervention
Your package essentially maintains itself.
Click "Use this template" on GitHub, or:
gh repo create my-package --template igorrivin/claude-maintained-template# Get a key from https://console.anthropic.com/
gh secret set ANTHROPIC_API_KEY --repo your-username/my-package- Rename
src/my_package/to your package name - Update
pyproject.tomlwith your package info - Write your tests in
tests/ - Update dependencies in
pyproject.toml
The workflows will:
- Run CI on every push/PR
- Run monthly maintenance on the 1st of each month
- Auto-fix issues and create PRs
Standard CI that runs on pushes and PRs:
- Tests multiple Python versions (3.10, 3.11, 3.12)
- Uses pinned dependencies from your
pyproject.toml
The magic happens here:
┌─────────────────────────────────────────────────────────────┐
│ 1st of Month: Scheduled Run │
├─────────────────────────────────────────────────────────────┤
│ 1. Install LATEST versions of all dependencies │
│ 2. Run test suite │
│ │
│ Tests Pass? │
│ ├─ YES → Log success, done │
│ └─ NO → Continue to Claude fix │
│ │
│ 3. Install Claude Code CLI │
│ 4. Give Claude the test output + codebase │
│ 5. Claude diagnoses and fixes issues │
│ 6. Run tests again │
│ │
│ Fixed? │
│ ├─ YES → Create PR with fixes │
│ └─ NO → Create Issue for manual review │
└─────────────────────────────────────────────────────────────┘
Edit .github/workflows/monthly-maintenance.yml:
on:
schedule:
# Run weekly instead of monthly
- cron: '0 0 * * 0' # Every Sunday at midnightUpdate pyproject.toml:
dependencies = [
"numpy",
"scipy",
"your-dependency",
]Edit the test step in the workflows:
- name: Run tests
run: |
pytest tests/ -v --tb=long
# Add more test commands hereIf your package needs Rust (like many modern Python packages), the template includes Rust installation. See the commented sections in ci.yml.
The better your tests, the better Claude can diagnose issues:
- Test core functionality
- Test edge cases
- Test with various input types
- Include integration tests
Fewer dependencies = fewer potential breakages:
- Only add dependencies you truly need
- Prefer standard library when possible
- Consider vendoring stable, small dependencies
In pyproject.toml, you can set bounds:
dependencies = [
"numpy>=1.20,<3", # Allow minor updates, not major
]Claude's fixes are usually correct, but always review:
- Check the changes make sense
- Ensure no unintended modifications
- Run additional manual tests if needed
The Claude API calls are minimal (only when tests fail). Typical cost: < $1/month for most packages.
The workflow creates a GitHub Issue with the full test output, so you can diagnose manually.
Yes:
gh workflow run monthly-maintenance.ymlOr click "Run workflow" in the GitHub Actions UI.
The pattern can be adapted for any language. The key components are:
- Test with latest dependencies
- Capture failure output
- Give output to Claude
- Apply fixes
Packages using this pattern:
- tl-tensor-examples - Knot theory computations
Improvements welcome! Ideas:
- Support for other languages
- Smarter dependency update strategies
- Integration with Dependabot/Renovate
- Notification systems (Slack, Discord, email)
MIT - Use freely, maintain effortlessly.
"The best code is code that maintains itself."