python

A guide to modern Python programming, including type hints, asynchronous code, and common Python coding styles.

In plain words
What is it for?
Use it when writing or reviewing Python functions, data structures, typed code, or asynchronous programs.
Why use it?
It helps you write Python code that is easier to understand, check, and maintain.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/miles990/claude-software-skills/python
Any agent
npx skills add miles990/claude-software-skills --skill python
Clone the repo
git clone --depth 1 https://github.com/miles990/claude-software-skills

Made for: Claude Code, Codex.

Per session 8 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,823 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00008 $0.02823
Opus 5 $0.00004 $0.01411
Sonnet 5 $0.00002 $0.00565
Haiku 4.5 $0.00001 $0.00282

Measured 2d ago against content hash c8f21b03b568, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

python scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

programming-languages/python/SKILL.md · 475 lines

How it starts

The opening of the file, as written. The whole thing — 475 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Python

Overview

Modern Python development patterns including type hints, async programming, and Pythonic idioms.


Type Hints

Basic Types

from typing import (
    Optional, Union, List, Dict, Set, Tuple,
    TypeVar, Generic, Callable, Any,
    Literal, TypedDict, Protocol
)
from dataclasses import dataclass
from datetime import datetime

# Basic type hints
def greet(name: str) -> str:
    return f"Hello, {name}!"

# Optional (can be None)
def find_user(user_id: str) -> Optional['User']:
    return users.get(user_id)

# Union types
def process(value: Union[str, int]) -> str:
    return str(value)

# Python 3.10+ union syntax
def process_new(value: str | int | None) -> str:
    return str(value) if value else ""

# Collections
def process_items(
    items: List[str],
    mapping: Dict[str, int],
    unique: Set[str],
    pair: Tuple[str, int]
) -> None:
    pass

# Python 3.9+ built-in generics
def process_items_new(
    items: list[str],
    mapping: dict[str, int],
    unique: set[str]
) -> None:
    pass

Advanced Types

# TypeVar for generics
T = TypeVar('T')
K = TypeVar('K')
V = TypeVar('V')

def first(items: list[T]) -> T | None:
    return items[0] if items else None

# Generic classes
class Repository(Generic[T]):
    def __init__(self) -> None:
        self._items: dict[str, T] = {}

    def get(self, id: str) -> T | None:
        return self._items.get(id)

    def save(self, id: str, item: T) -> None:
        self._items[id] = item

# TypedDict for structured dicts
class UserDict(TypedDict):
    id: str
    name: str
    email: str
    age: int  # Required
    nickname: str  # Required

class PartialUserDict(TypedDict, total=False):
    nickname: str  # Optional

# Literal types
Mode = Literal["read", "write", "append"]

def open_file(path: str, mode: Mode) -> None:
    pass

# Protocol (structural typing)
class Readable(Protocol):
    def read(self) -> str: ...

def process_readable(source: Readable) -> str:
    return source.read()

# Callable types
Handler = Callable[[str, int], bool]
AsyncHandler = Callable[[str], 'Awaitable[bool]']

def register_handler(handler: Handler) -> None:
    pass

Read the full file on GitHub · 475 lines

Files

What ships with it

3 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 475 lines · 8 tokens per session scan A c8f21b03b568

Subscribe to this mod's changes

python is a skill published in the GitHub repository miles990/claude-software-skills (20 stars, last pushed 7mo ago), licensed MIT. It adds 8 tokens to every session and 2,823 once invoked, about $0.0000 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories