Python Claude Code Starter Template
A modern Python project template optimized for development with Claude Code. This template provides a comprehensive foundation for Python applications with integrated AI assistance, modern tooling, and best practices.
π Features
- Claude Code Integration: Pre-configured CLAUDE.md with Python-specific guidelines
- Modern Python Setup: Support for Python 3.8+ with type hints and async capabilities
- Testing Framework: pytest with coverage reporting and fixtures
- Code Quality: Black, isort, flake8, mypy, and pre-commit hooks
- Documentation: Sphinx-ready documentation with Google-style docstrings
- Dependency Management: Poetry or pip with requirements files
- CI/CD Ready: GitHub Actions workflows for testing and deployment
- Development Tools: Justfile for common tasks and development workflows
π Prerequisites
- Python 3.8 or higher
- pip or Poetry for dependency management
- git for version control
- (Optional) just command runner for using the Justfile
π οΈ Quick Start
Clone this template:
git clone <your-repo-url>
cd <your-project-name>
Set up Python environment:
# Using venv
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Or using Poetry
poetry install
Install dependencies:
# Using pip
pip install -r requirements.txt
pip install -r requirements-dev.txt
# Or using Poetry
poetry install --with dev
Run initial setup:
# Install pre-commit hooks
pre-commit install
# Run tests to verify setup
pytest
π Project Structure
python-project/
βββ src/ # Source code
β βββ your_package/ # Your Python package
β βββ __init__.py
β βββ main.py # Entry point
β βββ modules/ # Additional modules
βββ tests/ # Test files
β βββ __init__.py
β βββ conftest.py # pytest fixtures
β βββ test_*.py # Test modules
βββ docs/ # Documentation
βββ scripts/ # Utility scripts
βββ .claude/ # Claude Code configuration
β βββ commands/ # Custom commands
βββ .github/ # GitHub Actions workflows
βββ pyproject.toml # Poetry configuration (if using Poetry)
βββ requirements.txt # Production dependencies
βββ requirements-dev.txt # Development dependencies
βββ setup.py # Package setup (if distributing)
βββ .gitignore
βββ .pre-commit-config.yaml
βββ CLAUDE.md # Claude Code guidelines
βββ Justfile # Development commands
βββ README.md # This file
π§° Available Commands
If you have just installed, you can use these commands:
just test # Run all tests
just lint # Run linters (black, isort, flake8, mypy)
just format # Format code with black and isort
just coverage # Run tests with coverage report
just docs # Build documentation
just clean # Clean up temporary files
just install # Install all dependencies
Without just, you can run the underlying commands directly:
# Testing
pytest
pytest --cov=src --cov-report=html
# Linting and formatting
black src tests
isort src tests
flake8 src tests
mypy src
# Documentation
cd docs && make html
π€ Claude Code Integration
This template includes a comprehensive CLAUDE.md file that provides:
- Python-specific coding guidelines and best practices
- Common patterns and anti-patterns
- Testing and documentation standards
- Performance and security considerations
- Example prompts for effective AI assistance
When using Claude Code with this template, Claude will automatically follow these guidelines to generate high-quality, consistent Python code.
π§ͺ Testing
The project uses pytest for testing:
# Run all tests
pytest
# Run with coverage
pytest --cov=src --cov-report=term-missing
# Run specific test file
pytest tests/test_main.py
# Run with verbose output
pytest -v
π Code Style
This template enforces consistent code style using:
- Black: Opinionated code formatter
- isort: Import statement organizer
- flake8: Style guide enforcement
- mypy: Static type checker
Pre-commit hooks automatically run these tools before each commit.
π§ Configuration Files
pyproject.toml: Project metadata and tool configuration (if using Poetry)
setup.cfg: Configuration for setuptools and tools like flake8
.pre-commit-config.yaml: Pre-commit hook configuration
pytest.ini or pyproject.toml: pytest configuration
.gitignore: Git ignore patterns for Python projects
π Deployment
The template includes GitHub Actions workflows for:
- Running tests on multiple Python versions
- Checking code quality
- Building and publishing packages
- Deploying to various platforms
π Documentation
Documentation is set up using Sphinx:
# Build documentation
cd docs
make html
# View documentation
open _build/html/index.html # On macOS
# Or start a local server
python -m http.server -d _build/html
π€ Contributing
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature)
- Make your changes
- Run tests and linting (
just test && just lint)
- Commit your changes (
git commit -m 'Add amazing feature')
- Push to the branch (
git push origin feature/amazing-feature)
- Open a Pull Request
π License
This template is provided as-is for use in your own projects. Customize the license as needed for your specific use case.
π Acknowledgments
- Built with best practices from the Python community
- Optimized for Claude Code AI assistance
- Inspired by modern Python project templates
Happy coding! πβ¨