This file provides instructions for AI coding agents (like OpenCode) working in this repository.
This is a modern Python project template using:
- Python 3.14+ with type hints
- uv for dependency management
- FastAPI for the web API
- Typer for the CLI
- Ruff for linting and formatting
- ty for type checking
- pytest with 90% coverage requirement
- Semantic Release for automated versioning
# Install dependencies
just install
# Setup development environment (install + pre-commit hooks)
just setup
# Run development server
just dev
# Run CLI
just cli --help# Run all tests with coverage
just test
# Run unit tests only
just test-unit
# Run integration tests only
just test-integration
# Quick test run (no coverage)
just test-quick# Run linter with auto-fix
just lint
# Format code
just format
# Type check
just typecheck
# Run all quality checks
just check
# Run all checks and tests
just check-all# Serve docs locally
just docs
# Build docs
just docs-build# Build container image
just container-build
# Run container
just container-run- Line length: 100 characters
- Quotes: Double quotes for strings
- Imports: Sorted with isort (via ruff)
- Type hints: Required for all function signatures
- Docstrings: Google style, required for public functions/classes
"""Module description."""
from typing import Optional
from pydantic import BaseModel
class User(BaseModel):
"""User model representing an application user.
Attributes:
name: The user's display name.
email: The user's email address.
"""
name: str
email: str
age: Optional[int] = None
def greet_user(user: User) -> str:
"""Generate a greeting message for a user.
Args:
user: The user to greet.
Returns:
A personalized greeting string.
"""
return f"Hello, {user.name}!"- Files:
snake_case.py - Classes:
PascalCase - Functions/Methods:
snake_case - Constants:
UPPER_SNAKE_CASE - Private: Prefix with
_
- Use specific exception types
- Include context in error messages
- Log errors appropriately
from python_template.core.config import settings
def process_data(data: dict) -> dict:
"""Process input data with validation."""
if not data:
raise ValueError("Data cannot be empty")
try:
result = transform(data)
except TransformError as e:
raise ProcessingError(f"Failed to transform data: {e}") from e
return resulttests/unit/- Fast, isolated unit teststests/integration/- Tests involving multiple componentstests/conftest.py- Shared fixtures
import pytest
@pytest.mark.unit
def test_something_fast():
"""Unit test - fast and isolated."""
pass
@pytest.mark.integration
def test_something_with_dependencies():
"""Integration test - may use external services."""
pass- Minimum: 90% coverage required
- Exclude:
__init__.py, type checking blocks
Use conventional commits:
<type>(<scope>): <description>
[optional body]
[optional footer]
feat: New featurefix: Bug fixdocs: Documentation changesstyle: Code style changes (formatting)refactor: Code refactoringperf: Performance improvementstest: Test additions/changesbuild: Build system changesci: CI/CD changeschore: Maintenance tasks
feat(api): add user authentication endpoint
fix(cli): handle missing config file gracefully
docs(readme): update installation instructions
test(core): add unit tests for config validation
python-template-project/
├── src/python_template/
│ ├── __init__.py # Package init with version
│ ├── cli.py # Typer CLI application
│ ├── api/
│ │ ├── __init__.py
│ │ └── app.py # FastAPI application
│ └── core/
│ ├── __init__.py
│ └── config.py # Settings management
├── tests/
│ ├── conftest.py # Shared fixtures
│ ├── unit/ # Unit tests
│ └── integration/ # Integration tests
├── docs/ # MkDocs documentation
├── .opencode/ # OpenCode agent configs
│ ├── agents/ # Custom agents
│ └── skills/ # Reusable skills
├── .github/ # GitHub Actions workflows
├── pyproject.toml # Project configuration
├── justfile # Task automation
├── Containerfile # Container build
└── AGENTS.md # This file
This project supports OpenCode AI agents with:
- Custom agents in
.opencode/agents/ - Reusable skills in
.opencode/skills/
test-generator: Generate pytest tests from code
reviewer: Code review agent with read-only access
- Always run
just check-allbefore committing - Ensure tests pass with 90% coverage
- Follow conventional commit format
- Type hints are mandatory
- Update documentation when adding features