A template library for Python library projects using Poetry and Semantic Release.
Project description
Python Library Template ๐
Enterprise-ready Python library template with security scanning, automated publishing, and comprehensive tooling.
Create production-quality Python libraries with confidence. This template provides everything you need to build, test, and publish professional Python packages.
๐ Live Dashboards
| ๐ Documentation | ๐งช Unit Tests | ๐ฌ Integration Tests | ๐ Coverage | โก Benchmarks | ๐ Security | โ๏ธ Compliance |
|---|
๐ Key Development Characteristics
| Characteristic | Details |
|---|---|
| Merge Strategy | Configurable (see .env) |
| Deployment Model | Tag-based to PyPI |
| Environments | Local โ PyPI |
| Preview Environments | N/A (library) |
| Pipeline Features | Semantic release, Auto-publish to PyPI |
| Special Considerations | 90% coverage requirement, Mutation testing |
๐ฏ Perfect For
- Open Source Libraries - Share your code with the world
- Internal Company Packages - Professional standards for private code
- Research Code - Reproducible, well-tested scientific computing
- CLI Tools - Build robust command-line interfaces
- Microservice Libraries - Shared code between services
๐ Development Workflow
graph LR
A[Create Issue] --> B[Create Branch]
B --> C[Write Tests]
C --> D[Write Code]
D --> E[Run Checks]
E --> F[Create PR]
F --> G[Auto Merge]
G --> H[Auto Release]
E -.->|Failed| C
F -.->|Review| D
style A fill:#e1f5fe
style C fill:#fff3e0
style E fill:#f3e5f5
style H fill:#e8f5e9
โก What You Get
Zero-Config CI/CD Pipeline
- Matrix testing with HTML reports
- Automated security scanning (Bandit, Safety, pip-audit, Semgrep)
- License compatibility checking and compliance reports
- Semantic versioning with automated changelog generation
Enterprise-Grade Quality
- Pre-commit hooks (Ruff, Black, conventional commits)
- Test-driven development setup with Click CLI testing
- Code coverage reporting with beautiful HTML dashboards
- API documentation auto-generated and deployed to GitHub Pages
Modern Python Stack
- Poetry dependency management with security/compliance groups
- Trusted publishing to PyPI/TestPyPI (no API keys needed)
- Optional AWS SAM integration with ephemeral test environments
- Windows/Git Bash compatibility with comprehensive guidance
Privacy-Conscious Telemetry
- Opt-in anonymous usage tracking to improve your library
๐ Documentation
For AI-optimized documentation navigation, see LINKS.md
- Community insights via Sentry integration
- Full transparency on collected data
- Easy enable/disable controls
๐ Quick Start
Get your library up and running in minutes:
graph TD
A[1. Create Repository] --> B[2. Bootstrap Project]
B --> C[3. Configure Settings]
C --> D[4. Start Developing]
style A fill:#e3f2fd
style B fill:#f3e5f5
style C fill:#fff3e0
style D fill:#e8f5e9
1๏ธโฃ Create Your Repository
# Option A: Use GitHub template (recommended)
gh repo create my-awesome-lib --template svange/augint-library --public
cd my-awesome-lib
# Option B: Clone directly
git clone https://github.com/svange/augint-library.git my-awesome-lib
cd my-awesome-lib
rm -rf .git && git init
2๏ธโฃ Bootstrap Your Project
# Stage 1: Customize template
python scripts/bootstrap-stage1.py
# - Enter your project name
# - Configure basic settings
# - Updates all references automatically
# Stage 2: AWS integration (optional)
python scripts/bootstrap-stage2.py
# - Sets up SAM pipeline
# - Configures OIDC authentication
# - Creates test environments
3๏ธโฃ Configure Repository Settings
- Enable GitHub Pages (Settings โ Pages โ Source: GitHub Actions)
- Set up branch protection for
main:- Require PR reviews
- Require status checks
- Include administrators
- Add repository secrets (if needed):
PYPI_API_TOKEN(for manual publishing)- Custom secrets for your project
4๏ธโฃ Start Developing!
# Install dependencies
poetry install
pre-commit install
# Create your first feature
git checkout -b feat/amazing-feature
# ... write code ...
pytest # All tests pass!
git add . && git commit -m "feat: add amazing feature"
git push -u origin feat/amazing-feature
๐ Detailed setup guide: Bootstrap Documentation
That's it! Your CI/CD pipeline is now running with full security scanning and automated publishing.
๐ ๏ธ Template Customization
This template includes enterprise features that may not be needed for all projects. See CUSTOMIZE.md for detailed instructions on creating minimal, standard, or enterprise versions of this template.
๐๏ธ Architecture Overview
graph TB
subgraph "Development Environment"
A[Developer] --> B[Pre-commit Hooks]
B --> C[Local Tests]
end
subgraph "CI/CD Pipeline"
C --> D[GitHub Actions]
D --> E[Matrix Testing]
D --> F[Security Scans]
D --> G[License Check]
E & F & G --> H{All Pass?}
end
subgraph "Deployment"
H -->|Yes| I[Build Package]
I --> J[Publish to PyPI]
I --> K[Deploy Docs]
K --> L[GitHub Pages]
end
subgraph "Optional AWS"
H -->|Yes| M[SAM Deploy]
M --> N[Lambda Functions]
M --> O[API Gateway]
end
style A fill:#e3f2fd
style H fill:#fff3e0
style J fill:#e8f5e9
style L fill:#e8f5e9
๐ฆ What's Included
๐ง Development Tools
- Poetry - Modern dependency management
- Pre-commit - Automated code quality checks
- Ruff - Fast Python linter and formatter
- Mypy - Static type checking
- Pytest - Testing with fixtures and coverage
๐ก๏ธ Security & Compliance
- Bandit - Security vulnerability scanning
- Safety - Dependency vulnerability checks
- pip-audit - Supply chain security
- Semgrep - Custom security rules
- License checking - Automated compliance reports
๐ Quality Assurance
- 90%+ test coverage requirement
- Mutation testing - Test quality validation
- Benchmarking - Performance tracking
- HTML test reports - Beautiful test dashboards
- Renovate - Automated dependency updates
๐ CI/CD Features
- Matrix testing - Python 3.9, 3.10, 3.11, 3.12
- Semantic versioning - Automated releases
- Trusted publishing - Secure PyPI uploads
- GitHub Pages - Documentation hosting
- PR auto-merge - For passing builds
๐ฏ Optional Features
- AWS SAM - Serverless deployment
- Feature flags - Gradual rollouts
- Telemetry - Anonymous usage tracking
- Docker support - Containerized development
๐ฏ Common Use Cases
๐ Creating a Python Library
# src/mylib/core.py
"""Core functionality for mylib."""
def process_data(data: list[dict]) -> list[dict]:
"""Process data with validation.
Args:
data: List of dictionaries to process
Returns:
Processed data
Example:
>>> process_data([{"value": 1}])
[{"value": 1, "processed": True}]
"""
return [{"processed": True, **item} for item in data]
# tests/test_core.py
import pytest
from mylib.core import process_data
def test_process_data():
result = process_data([{"value": 1}])
assert result[0]["processed"] is True
assert result[0]["value"] == 1
๐ฅ๏ธ Building a CLI Tool
# src/mylib/cli.py
import click
from .core import process_data
@click.command()
@click.argument('input_file', type=click.Path(exists=True))
@click.option('--output', '-o', help='Output file')
def cli(input_file, output):
"""Process INPUT_FILE and save results."""
# Load data
with open(input_file) as f:
data = json.load(f)
# Process
result = process_data(data)
# Output
if output:
with open(output, 'w') as f:
json.dump(result, f)
click.echo(f"โ Saved to {output}")
else:
click.echo(json.dumps(result, indent=2))
๐ Creating a Plugin System
# src/mylib/plugins.py
from typing import Protocol
class ProcessorPlugin(Protocol):
"""Protocol for processor plugins."""
def process(self, data: dict) -> dict:
"""Process a single item."""
...
def load_plugins() -> dict[str, ProcessorPlugin]:
"""Dynamically load all plugins."""
# Implementation here
pass
๐ฏ Project Planning (Recommended First Step)
Why Plan First?
Research shows that projects with documented requirements are 97% more likely to succeed. Poor requirements gathering causes 39% of software project failures. Take 15-30 minutes to plan your project properlyโit will save hours of development time.
Generate Your Project Requirements
Before coding, create comprehensive planning documents using Claude Code's interactive planning workflow:
# Launch the interactive planning workflow
# Note: Specify guides/ directory for output to avoid conflicts with pdoc
claude /plan
What this creates:
- Product Requirements Document (PRD) - Clear project vision, user needs, and success criteria
- Technical Specification - Architecture approach, technology decisions, and implementation plan
- User Stories (if applicable) - Detailed scenarios and acceptance criteria
- Development Roadmap - Feature prioritization and implementation phases
Planning Workflow Features
- Research-backed methodology - Based on 2024-2025 software project success factors
- Adaptive questioning - Adjusts based on project type (library, API, CLI tool, web app)
- Comprehensive coverage - Business requirements, technical approach, and implementation planning
- Living documents - Easy to update as requirements evolve
- AI optimization - Provides Claude with complete project context for better assistance
Project Types Supported
- Python Libraries - Package development with clear API design
- CLI Tools - Command-line applications with user workflow planning
- REST APIs - Service development with endpoint specification
- Web Applications - Full-stack projects with user experience planning
Sample Planning Session
$ claude /plan
๐ฏ Let's plan your project for maximum success!
Phase 1: Project Discovery
What is the name of your project? my-data-processor
In one sentence, what does this project do? Transforms messy CSV data into clean, validated datasets
Who will use this project? Data analysts and Python developers working with CSV files
[Interactive session continues...]
โ
Generated comprehensive planning documents:
- guides/PRD.md
- guides/TECHNICAL_SPECIFICATION.md
- guides/USER_STORIES.md
> **๐ Important**: Planning documents are saved in `guides/` to avoid conflicts with pdoc-generated API documentation in `docs/`. This also ensures maximum context inclusion for Claude Code.
๐ Ready to start development with clear requirements!
When to Use Planning
- โ Always recommended - 15-30 minutes of planning saves hours of development
- โ New projects - Essential for getting started on the right track
- โ Complex features - Break down complicated requirements into manageable pieces
- โ Team projects - Ensure everyone understands the vision and approach
- โ Client work - Professional documentation and clear expectations
๐ Prerequisites
Required Tools:
- Python 3.9+ and Poetry
- Git and GitHub CLI (optional)
- For AWS features: AWS CLI and SAM CLI
- For secret management: chezmoi and age
PyPI Setup (Important - Do This First!):
- Reserve your package name on PyPI and TestPyPI
- Set up Trusted Publishing:
- Publisher: GitHub Actions
- Repository:
your-account/your-repo - Workflow:
pipeline.yaml - Environment:
pypi
Windows Users:
# Install tools
winget install Python.Python.3.11
winget install twpayne.chezmoi
winget install --id FiloSottile.age
# Set environment for Claude Code
$env:CLAUDE_CODE_GIT_BASH_PATH="C:\gitbash\bin\bash.exe"
AWS Setup (Optional - One Time Per Account):
# Enable GitHub Actions OIDC
aws iam create-open-id-connect-provider \
--url https://token.actions.githubusercontent.com \
--client-id-list sts.amazonaws.com
๐๏ธ Project Setup
This template uses a two-stage bootstrap process that eliminates common setup friction:
| Stage | Purpose | When to Run |
|---|---|---|
| Stage 1 | Template customization | Immediately after cloning |
| Stage 2 | AWS integration | After sam pipeline bootstrap |
Why two stages? This approach prevents dependency conflicts and handles the interactive SAM setup gracefully.
See the Bootstrap Guide for complete setup instructions.
๐ Guides
๐ Complete Guides Index - Organized access to all project guides and instructional content
Quick Links
- Setup: Bootstrap Guide | Contributing Guide
- Development: Claude Development Guide | Automation Testing
- Troubleshooting: Claude Code on Windows
๐ Documentation Best Practices
API Documentation (Google-style docstrings):
def process_data(data: list[str], format: str = "json") -> dict:
"""Process input data and return formatted results.
Args:
data: List of strings to process.
format: Output format ("json" or "xml").
Returns:
Processed data in specified format.
Example:
>>> process_data(["item1", "item2"])
{"processed": ["item1", "item2"]}
"""
Library vs CLI Design:
- Use
__all__to control public API surface - Keep CLI commands in separate modules
- Document both library and CLI usage in module docstrings
๐ ๏ธ Development Workflow
Using Make (Recommended)
# Daily development - clean, simple commands
make test # Run unit tests (excludes slow/CI-only)
make test-all # Run all tests including slow ones
make lint # Lint and auto-fix with ruff
make format # Format code with ruff
make security # Run security scans
make docs # Generate documentation
make clean # Remove all build artifacts
# See all available commands
make help
Using Poetry Directly
# If you prefer direct commands
poetry run pytest # Run tests
poetry run pytest -m "" # Run all tests including slow
poetry run ruff check --fix # Lint and fix
poetry run ruff format . # Format code
# Security and compliance
poetry install --with security,compliance
poetry run bandit -r src/
poetry run safety check
poetry run pip-licenses
๐ Telemetry (Optional)
Help improve your library by enabling anonymous usage telemetry:
# Check status
ai-test-script telemetry status
# Enable with consent prompt
ai-test-script telemetry enable
# Test configuration
ai-test-script telemetry test
See Telemetry Documentation for details on privacy guarantees and configuration.
๐ก Pro Tips
- Repository Setup: See
.github/REPOSITORY_SETUP.mdfor branch protection, linear history, and Renovate configuration - Renovate: Auto-merge is configured for safe updates (patch/minor)
- Security Scans: Only run on main/dev branches to keep feature branches fast
- Windows Users: All commands work in Git Bash, PowerShell, and CMD (see troubleshooting guide)
- Claude Code: See the Claude Development Guide for AI-assisted development
๐ฅ๏ธ MCP Server Setup
- Add MCP Servers: Use
claude mcp add <server-name>to add servers for GitHub, AWS, and more.- GitHub MCP Server Setup:
- Ensure CLAUDE_GITHUB_PAT is set as an env var
- Run this command:
claude mcp add-json github "{ `"command`": `"docker`", `"args`": [ `"run`", `"-i`", `"--rm`", `"-e`", `"GITHUB_PERSONAL_ACCESS_TOKEN`", `"ghcr.io/github/github-mcp-server`" ], `"env`": { `"GITHUB_PERSONAL_ACCESS_TOKEN`": `"$($env:CLAUDE_GITHUB_PAT)`" } }"
- Context7:
claude mcp add --transport sse context7 https://mcp.context7.com/sse
claude mcp add --transport sse context7 https://mcp.context7.com/sse
- GitHub MCP Server Setup:
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 augint_library-1.31.0.tar.gz.
File metadata
- Download URL: augint_library-1.31.0.tar.gz
- Upload date:
- Size: 70.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1b0dd3dc3566dc978e4179c84cf2d6f9409f5b959beaebb324abdcd385bfed4a
|
|
| MD5 |
e313311a9d81c815853a9aefd0d40131
|
|
| BLAKE2b-256 |
b1ec43a49c4050b7f9ff2d809b160c32c038a0735874cb0810d66c59fcdcdc56
|
Provenance
The following attestation bundles were made for augint_library-1.31.0.tar.gz:
Publisher:
pipeline.yaml on svange/augint-library
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
augint_library-1.31.0.tar.gz -
Subject digest:
1b0dd3dc3566dc978e4179c84cf2d6f9409f5b959beaebb324abdcd385bfed4a - Sigstore transparency entry: 377271605
- Sigstore integration time:
-
Permalink:
svange/augint-library@0526c06fe9e3886a11d8ccfa7882f08bc056ebf1 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/svange
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pipeline.yaml@0526c06fe9e3886a11d8ccfa7882f08bc056ebf1 -
Trigger Event:
push
-
Statement type:
File details
Details for the file augint_library-1.31.0-py3-none-any.whl.
File metadata
- Download URL: augint_library-1.31.0-py3-none-any.whl
- Upload date:
- Size: 67.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a0ee8469ceda9df4151ad9f20248d8de20d600908cddd81bc620e01918bf6915
|
|
| MD5 |
eb729dc83d7d09f0d973f7f6023238a4
|
|
| BLAKE2b-256 |
5df42c0e465cd972bb58823063dfa478c04d430341432c46ae4495c2a7b52ebc
|
Provenance
The following attestation bundles were made for augint_library-1.31.0-py3-none-any.whl:
Publisher:
pipeline.yaml on svange/augint-library
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
augint_library-1.31.0-py3-none-any.whl -
Subject digest:
a0ee8469ceda9df4151ad9f20248d8de20d600908cddd81bc620e01918bf6915 - Sigstore transparency entry: 377271618
- Sigstore integration time:
-
Permalink:
svange/augint-library@0526c06fe9e3886a11d8ccfa7882f08bc056ebf1 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/svange
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pipeline.yaml@0526c06fe9e3886a11d8ccfa7882f08bc056ebf1 -
Trigger Event:
push
-
Statement type: