Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
afaneor avatar

Strict Python Mode

  • 1 installs
  • 77 repo stars
  • Updated January 8, 2026
  • afaneor/fastapi-docker-boilerplate

strict-python-mode is a Claude Code skill that enforces mandatory type hints, docstrings, modern Python syntax and ruff/mypy checks on Python code.

About

strict-python-mode is a Claude Code skill that enforces strict Python coding conventions while writing or refactoring code. It requires type hints on every parameter and return, Google-style docstrings, modern Python 3.12+ syntax, and passing ruff and mypy checks before finishing. A developer uses it to keep FastAPI and other Python code type-safe and production-ready. It includes FastAPI-specific rules for endpoint signatures and response models.

  • Enforces mandatory type hints and Google-style docstrings
  • Requires modern Python 3.12+ syntax (list[str], X | None)
  • Gates code on ruff format, ruff check and mypy

Strict Python Mode by the numbers

  • 1 all-time installs (skills.sh)
  • Ranked #240 of 290 Python skills by installs in the Skillselion catalog
  • Data as of Jul 24, 2026 (Skillselion catalog sync)
At a glance

strict-python-mode capabilities & compatibility

Capabilities
type checking · linting · python refactoring · docstring enforcement
Use cases
refactoring · code review · api development
IDEs
vscode · pycharm
Pricing
Free
From the docs

What strict-python-mode says it does

Enforces type hints, docstrings, and Python best practices.
SKILL.md
Type hints are mandatory
SKILL.md
npx skills add https://github.com/afaneor/fastapi-docker-boilerplate --skill strict-python-mode

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs1
repo stars77
Last updatedJanuary 8, 2026
Repositoryafaneor/fastapi-docker-boilerplate

What it does

Enforce type hints, docstrings and ruff/mypy checks when writing or refactoring Python and FastAPI code.

Who is it for?

Python and FastAPI developers who want type-safe, lint-clean, documented code by default

Skip if: Non-Python codebases or teams not using ruff, mypy or type hints

When should I use this skill?

Writing or refactoring Python code, creating new functions, or when the user asks for production-ready or type-safe code

What you get

Type-annotated, docstring-covered Python that passes ruff and mypy before it is shown

  • type-annotated python code
  • docstring coverage
  • lint and type-check pass

By the numbers

  • 5-item pre-commit validation checklist
  • targets Python 3.12+

Files

SKILL.mdMarkdownGitHub ↗

Strict Python Mode

Core Principles

When writing Python code in this project, ALWAYS follow these rules:

1. Type hints are mandatory

  • Every function parameter must have a type hint
  • Every function must have a return type annotation
  • Use from collections.abc import for generic types (list, dict, set)
  • Never use Any type - if type is unknown, use object or create proper Protocol

2. Docstrings are required

  • Every public function/method needs a docstring
  • Use Google-style docstrings format
  • Include Args, Returns, Raises sections

3. Modern Python syntax (3.12+)

  • Use list[str] instead of List[str] from typing
  • Use dict[str, int] instead of Dict[str, int]
  • Use X | None instead of Optional[X]
  • Use X | Y for Union types

Code Quality Checks

Before finishing ANY code changes, run these checks:

# 1. Format with Ruff
poetry run ruff format .

# 2. Lint with Ruff
poetry run ruff check . --fix

# 3. Type check with mypy (if available)
poetry run mypy app/ --ignore-missing-imports

Example: Good vs Bad

❌ Bad (will be rejected)

def get_user(id):
    user = db.get(id)
    return user

✅ Good (approved)

def get_user(user_id: int) -> User | None:
    """Fetch user by ID from database.
    
    Args:
        user_id: The unique identifier of the user
        
    Returns:
        User object if found, None otherwise
        
    Raises:
        DatabaseError: If database connection fails
    """
    user = db.get(user_id)
    return user

FastAPI-Specific Rules

Endpoint Signatures

# Always use dependency injection
@router.get("/users/{user_id}")
async def get_user(
    user_id: int,
    db: DatabaseSession = Depends(get_db),
    current_user: User = Depends(get_current_user),
) -> UserResponse:
    """Get user by ID."""
    ...

Response Models

# Always define explicit response models
class UserResponse(BaseModel):
    id: int
    username: str
    email: EmailStr
    created_at: datetime

    class Config:
        from_attributes = True

Validation Rules

Before ANY commit: 1. All new functions have type hints 2. All public functions have docstrings 3. Ruff format passes with no changes needed 4. Ruff check passes with no errors 5. If mypy is available, it passes with no errors

If any check fails, FIX IT before showing me the code.

Related skills

FAQ

What checks does strict-python-mode run?

ruff format, ruff check --fix and mypy before any code is finalized.

Which Python version does it target?

Modern Python 3.12+ syntax such as list[str] and X | None instead of typing generics.

Pythonbackend

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.