Python 3.14+ Development

VerifiedSafe

Skill for idiomatic Python 3.14+ development, prioritizing stdlib solutions, strict type hints (no Any), Protocol over ABC, and flat control flow. Uses uv/ruff toolchain for dependency management, linting, and formatting. Ideal for writing scripts, CLI tools, and services with minimal external dependencies.

Sby Skills Guide Bot
DevelopmentIntermediate
6/2/2026
Claude Code
#python#type-hints#protocols#guard-clauses#modern-python

Recommended for

Automated summary

This skill provides guidelines and patterns for writing idiomatic Python code, emphasizing the standard library, type hints, protocols, and flat control flow.

Strengths

  • Promotes use of standard library and minimal dependencies.
  • Enforces strict type hints with Python 3.14, improving robustness.
  • Provides concrete patterns like protocols and pattern matching.
  • Reduces complexity with flat control flow and guard clauses.

Limitations

  • May be too prescriptive for cases requiring dynamic flexibility.
  • Assumes Python 3.14+ and is not suited for legacy codebases.
  • Does not cover all Python development aspects (e.g., async, performance).
When to use it

When writing new Python projects or refactoring to modern, typed practices.

When not to use it

For projects requiring compatibility with Python <3.14 or using heavily dynamic patterns.

Security analysis

Safe
Quality score85/100

The skill provides guidance on writing Python code and does not instruct any destructive or exfiltrating actions. Allowed tools (Read, Bash, Grep, Glob) are standard for code development and carry minimal inherent risk when used as directed.

No concerns found

How this analysis is made

Examples

Refactor to flat control flow
Refactor this Python function to use guard clauses and type hints, avoiding nested conditionals.
Implement protocol-based injection
Create a Python service class that uses a Protocol for its dependency, and implement a concrete class satisfying that protocol.
Rewrite with pattern matching
Rewrite this event handler to use Python pattern matching instead of if-elif chains.

name: writing-python description: Idiomatic Python 3.14+ development. Use when writing Python code, CLI tools, scripts, or services. Emphasizes stdlib, type hints, uv/ruff toolchain, and minimal dependencies. allowed-tools: Read, Bash, Grep, Glob

Python Development (3.14+)

Core Philosophy

  1. Stdlib and Mature Libraries First

    • Always prefer Python stdlib solutions
    • External deps only when stdlib insufficient
    • Prefer dataclasses over attrs, pathlib over os.path
  2. Type Hints Everywhere (No Any)

    • Python 3.14 has lazy annotations by default
    • Use Protocol for structural typing (duck typing)
    • Avoid Any—use concrete types or generics
    • NEVER use typing.Optional. Use Type | None instead (e.g., str | None).
  3. Protocol Over ABC

    • Protocol for implicit interface satisfaction
    • ABC only when runtime isinstance() needed
    • Protocols are more flexible and Pythonic
  4. Flat Control Flow

    • Guard clauses with early returns
    • Pattern matching to flatten conditionals
    • Maximum 2 levels of nesting
  5. Explicit Error Handling

    • Custom exception hierarchy for domain errors
    • Raise early, handle at boundaries
    • except ValueError | TypeError: (no parens)

Quick Patterns

Protocol-Based Dependency Injection

from typing import Protocol

# Protocol at consumer (like Go interfaces)
class UserStore(Protocol):
    def get(self, id: str) -> User | None: ...
    def save(self, user: User) -> None: ...

class UserService:
    def __init__(self, store: UserStore):
        self.store = store  # accepts any matching impl

Flat Control Flow (No Nesting)

# GOOD: guard clauses, early returns
def process(user: User | None) -> Result:
    if user is None:
        raise ValueError("user required")
    if not user.email:
        raise ValueError("email required")
    if not is_valid_email(user.email):
        raise ValueError("invalid email")
    return do_work(user)  # happy path at end

# BAD: nested conditions
def process(user: User | None) -> Result:
    if user is not None:
        if user.email:
            if is_valid_email(user.email):
                return do_work(user)
    raise ValueError("invalid")

Pattern Matching

# Flatten complex conditionals with match
match event:
    case {"type": "click", "x": x, "y": y}:
        handle_click(x, y)
    case {"type": "key", "code": code}:
        handle_key(code)
    case _:
        raise ValueError(f"Unknown event: {event}")

Type Hints (No Any)

# GOOD: concrete types
def process_users(users: list[User], limit: int | None = None) -> list[Result]:
    ...

# GOOD: generics when needed
from typing import TypeVar
T = TypeVar("T")
def first(items: list[T]) -> T | None:
    return items[0] if items else None

# BAD: unnecessary Any
def process(data: Any) -> Any:  # Don't do this
    ...

Error Handling

# except without parens (3.14)
except ValueError | TypeError:
    handle_error()

# Custom exceptions
class NotFoundError(AppError):
    def __init__(self, resource: str, id: str):
        self.resource = resource
        self.id = id
        super().__init__(f"{resource} not found: {id}")

Python 3.14 Features

  • Deferred annotations: No from __future__ import annotations
  • Template strings (t""): t"Hello {name}" returns Template
  • except without parens: except ValueError | TypeError:
  • concurrent.interpreters: True parallelism
  • compression.zstd: Zstandard in stdlib
  • Free-threaded build: No GIL (opt-in)

References

Tooling

uv sync                    # Install deps
ruff check --fix .         # Lint and autofix
ruff format .              # Format
pytest -v                  # Test
mypy .                     # Type check

From the file to a first result

The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.

View the source and supporting files

This download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.

1. Download the file

Download SKILL.md

From the root of a test project, save the file as .skill-downloads/python-3-14-development-mm5t8aqz/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.

Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.

mkdir -p '.skill-downloads/python-3-14-development-mm5t8aqz' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/python-3-14-development-mm5t8aqz/download' --output '.skill-downloads/python-3-14-development-mm5t8aqz/SKILL.md.part' && mv '.skill-downloads/python-3-14-development-mm5t8aqz/SKILL.md.part' '.skill-downloads/python-3-14-development-mm5t8aqz/SKILL.md'

2. Check prerequisites

Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.

Tools declared by the author (check availability in your agent): Read, Bash, Grep, Glob

No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.

The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.

3. Load the skill

After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.

Claude Code
test -f '.skill-downloads/python-3-14-development-mm5t8aqz/SKILL.md' && test -s '.skill-downloads/python-3-14-development-mm5t8aqz/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/writing-python' && cp -R '.skill-downloads/python-3-14-development-mm5t8aqz' '.claude/skills/writing-python'

OpenSkills

OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.

Official OpenSkills installation
openskills install './.skill-downloads/python-3-14-development-mm5t8aqz'

openskills read 'python-3-14-development-mm5t8aqz'

Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.

For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.

openskills sync

Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.

4. Try a first task

Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:

Read .skill-downloads/python-3-14-development-mm5t8aqz/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.

Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.

Related skills