Version-aware BAD/GOOD pattern guides that help AI coding agents generate modern Python
Project description
modern-python-guidance
Stop your AI from writing typing.List, @validator, and setup.py. 39 version-aware BAD/GOOD pattern guides that teach AI coding agents to write modern Python — delivered via MCP, CLI, or Agent Skills.
Highlights
- Measurable impact: +14.7pp overall improvement in A/B benchmark with 38 scored items (details). Largest variant (FastAPI, 32 items): Control 60.4% → Treatment 82.3%
- 39 guides across stdlib, Pydantic, FastAPI, Django, SQLAlchemy, pytest, and toolchain
- Version-aware: auto-detects your project's Python version and filters guides accordingly
- 3 delivery methods: MCP server, CLI, Agent Skills plugin
- Not Ruff: Ruff auto-fixes syntax (
List→list). mpg guides design decisions that Ruff can't touch —TaskGroupovergather, Pydantic V2 migration, SQLAlchemy 2.0 style
Note: The tool itself requires Python 3.11+ to run. Guides cover patterns from Python 3.9 onward, and
--python-versionfilters guides for your target environment.
Quick start
MCP (for AI coding agents)
Install, then register the MCP server with your agent:
pip install modern-python-guidance
Claude Code:
claude mcp add mpg -- mpg mcp
Other MCP-compatible agents (Cursor, Windsurf, etc.) — add to your MCP config:
{
"mcpServers": {
"mpg": {
"command": "mpg",
"args": ["mcp"]
}
}
}
Your agent gets access to search_guides, retrieve_guides, list_guides, and detect_python_version.
CLI
pip install modern-python-guidance
# Search for a pattern
mpg search "pydantic validator"
# Get the full guide
mpg retrieve pydantic-v2-validators
Agent Skills (Claude Code plugin)
# Symlink into your project
SKILL_DIR=$(python -c "from pathlib import Path; import modern_python_guidance; print(Path(modern_python_guidance.__file__).parent / 'skills' / 'modern-python-guidance')")
ln -s "$SKILL_DIR" your-project/.claude/skills/modern-python-guidance
mpg is the short alias for modern-python-guidance. Both work.
CLI usage
# Search guides by keyword
mpg search "pydantic validator"
# Retrieve a specific guide (full BAD/GOOD content)
mpg retrieve use-builtin-generics
# List all guides compatible with your Python version
mpg list --python-version 3.11
# Auto-detect project Python version from pyproject.toml / .python-version
mpg detect-version
# Filter by category
mpg search "timeout" --category async
# JSON output (default when piped, explicit with --format)
mpg search "typing" --format json | jq '.[0].id'
Guide coverage
39 guides across 3 layers:
| Layer | Categories | Count | Examples |
|---|---|---|---|
| 1 — stdlib | typing, async, stdlib, data-structures | 16 | list over List, match/case, TaskGroup |
| 2 — frameworks | pydantic, fastapi, httpx, django, sqlalchemy, pytest | 18 | Pydantic V2 migration, SQLAlchemy 2.0 style, Annotated[Depends] |
| 3 — toolchain | toolchain | 5 | uv over pip, ruff over flake8, pickle avoidance |
Run mpg list to see all 39 guides, or browse them on GitHub.
Version-aware filtering
Guides specify their minimum Python version. The CLI auto-detects your project's version from (in order):
--python-versionflagpyproject.tomlrequires-python.python-versionfile- Default: 3.11
# Only shows guides compatible with Python 3.9
mpg list --python-version 3.9
# Excludes: TaskGroup (3.11+), match/case (3.10+), etc.
Development
git clone https://github.com/yottayoshida/modern-python-guidance.git
cd modern-python-guidance
uv venv && source .venv/bin/activate
uv pip install -e ".[dev]"
pytest
See CONTRIBUTING.md for project structure and guide authoring details.
License
Apache-2.0 OR MIT — see LICENSE and LICENSE-MIT.
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 modern_python_guidance-0.2.1.tar.gz.
File metadata
- Download URL: modern_python_guidance-0.2.1.tar.gz
- Upload date:
- Size: 89.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
905e8b7a0f1821d58c0fbf61d4ec36e14088fd4e8f57151f364283e6c9cdc8ed
|
|
| MD5 |
eeec3afe8ea151bd15bbf19ac3cdf7fa
|
|
| BLAKE2b-256 |
34cbde07ff6c08020cf7d8ce40a2fe82c02e48958176293a35c07e7fa5c77ed3
|
Provenance
The following attestation bundles were made for modern_python_guidance-0.2.1.tar.gz:
Publisher:
publish.yml on yottayoshida/modern-python-guidance
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
modern_python_guidance-0.2.1.tar.gz -
Subject digest:
905e8b7a0f1821d58c0fbf61d4ec36e14088fd4e8f57151f364283e6c9cdc8ed - Sigstore transparency entry: 1643497209
- Sigstore integration time:
-
Permalink:
yottayoshida/modern-python-guidance@9165a4d989a89b8b24d731cebca548060c661e4f -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/yottayoshida
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@9165a4d989a89b8b24d731cebca548060c661e4f -
Trigger Event:
release
-
Statement type:
File details
Details for the file modern_python_guidance-0.2.1-py3-none-any.whl.
File metadata
- Download URL: modern_python_guidance-0.2.1-py3-none-any.whl
- Upload date:
- Size: 64.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a5407a3749f34ec27055591005d2c45e22b5596c235e88562145415e00e04cf6
|
|
| MD5 |
16ef39c7d5babcc21724e88d0c0ce4c9
|
|
| BLAKE2b-256 |
dcfd19556bc29cb80b5ee1d0d37086497cef58c2433155bbe22c49cd9c27ff6e
|
Provenance
The following attestation bundles were made for modern_python_guidance-0.2.1-py3-none-any.whl:
Publisher:
publish.yml on yottayoshida/modern-python-guidance
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
modern_python_guidance-0.2.1-py3-none-any.whl -
Subject digest:
a5407a3749f34ec27055591005d2c45e22b5596c235e88562145415e00e04cf6 - Sigstore transparency entry: 1643497278
- Sigstore integration time:
-
Permalink:
yottayoshida/modern-python-guidance@9165a4d989a89b8b24d731cebca548060c661e4f -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/yottayoshida
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@9165a4d989a89b8b24d731cebca548060c661e4f -
Trigger Event:
release
-
Statement type: