Implements modern Python type hints, structural typing with Protocols, and type safety patterns for robust code.
- GitHub stars
- 81
- Files
- 9
- Last commit
- Nov 7, 2026
- License
- MIT
- Allowed tools
- 2
What does the python-typing-ops skill do?
python-typing-ops implements modern Python type hints, structural typing with Protocols, and type safety patterns for robust code.
Summary generated from the skill's SKILL.md.
About the python-typing-ops skill
Implementing modern Python type hints and structural typing patterns is what this skill enables for developers building safe, documented codebases. It provides a comprehensive set of tools for applying type annotations, generics, and structural typing via Protocols to ensure code reliability. When an agent loads this skill, it can generate or refactor code using advanced features like TypeVar, TypedDict, and Literal types.
The skill supports Python 3.10+ syntax, including union types, and specific patterns for Python 3.11+ such as Self and TypeVarTuple. It assists in configuring and running type checkers like mypy and pyright to validate code integrity. By utilizing these patterns, developers can move beyond basic annotations to implement complex logic like TypeGuards for type narrowing and structural typing for flexible interface definitions. This makes it an essential tool for anyone aiming to reduce runtime errors through static analysis.
What an agent can do with it
- 1Implement structural typingDefine a Protocol to allow any object with a specific method to be passed into a function.
- 2Define fixed-key dictionariesCreate a TypedDict to ensure dictionary access uses specific, type-safe keys.
- 3Validate code with type checkersRun mypy or pyright commands to check for type errors in a source directory.
Written from the skill's SKILL.md. Every use case is checked against a quote from it.
How to install the python-typing-ops skill
Each command copies the skill folder into the client's skills directory. Restart the client or start a new session to load it.Install the python-typing-ops skill in Plugin
/plugin marketplace add 0xDarkMatter/claude-mods /plugin install claude-mods@claude-mods
Install the python-typing-ops skill in Claude Code
~/.claude/skills/python-typing-ops/SKILL.md
$ npx degit 0xDarkMatter/claude-mods/skills/python-typing-ops ~/.claude/skills/python-typing-opsInstall the python-typing-ops skill in Claude Code (project)
.claude/skills/python-typing-ops/SKILL.md
$ npx degit 0xDarkMatter/claude-mods/skills/python-typing-ops .claude/skills/python-typing-opsInstall the python-typing-ops skill in Codex
~/.agents/skills/python-typing-ops/SKILL.md
$ npx degit 0xDarkMatter/claude-mods/skills/python-typing-ops ~/.agents/skills/python-typing-opsInstall the python-typing-ops skill in Gemini CLI
~/.gemini/skills/python-typing-ops/SKILL.md
$ npx degit 0xDarkMatter/claude-mods/skills/python-typing-ops ~/.gemini/skills/python-typing-opsInstall the python-typing-ops skill in Claude.ai
npx degit 0xDarkMatter/claude-mods/skills/python-typing-ops python-typing-ops && zip -r python-typing-ops.zip python-typing-ops # claude.ai → Customize → Skills → + → Create skill → Upload a skill → python-typing-ops.zip
Automated checks
Ran Nov 14, 2026Full report →Passed our automated checks. That is not a security audit: read the scripts before you let an agent run them. How checks work
- Source repository linked and reachable0xdarkmatter/claude-mods/skills/python-typing-ops is public and reachablegithub.com/0xdarkmatter/claude-mods/tree/HEAD/skills/python- ↗Pass
- Open source license (OSI)MITspdx.org/licenses/MIT.html ↗Pass
- Commit or release in the last yearLast commit 2026-11-07github.com/0xdarkmatter/claude-mods/commits ↗Pass
- No download-and-run or credential theft in scripts1 script read; no download-and-run, remote eval, base64 execution or credential uploadPass
- No hidden instructions in SKILL.mdNo override phrases, safeguard switches, credential requests or hidden charactersgithub.com/0xdarkmatter/claude-mods/blob/HEAD/skills/python- ↗Pass
- Pre-approved tools are scopedPre-approved: Read, Writegithub.com/0xdarkmatter/claude-mods/blob/HEAD/skills/python- ↗Pass
SKILL.md
View on GitHubPython Typing Patterns
Modern type hints for safe, documented Python code.
Basic Annotations
# Variables
name: str = "Alice"
count: int = 42
items: list[str] = ["a", "b"]
mapping: dict[str, int] = {"key": 1}
# Function signatures
def greet(name: str, times: int = 1) -> str:
return f"Hello, {name}!" * times
# None handling
def find(id: int) -> str | None:
return db.get(id) # May return None
Collections
from collections.abc import Sequence, Mapping, Iterable
# Use collection ABCs for flexibility
def process(items: Sequence[str]) -> list[str]:
"""Accepts list, tuple, or any sequence."""
return [item.upper() for item in items]
def lookup(data: Mapping[str, int], key: str) -> int:
"""Accepts dict or any mapping."""
return data.get(key, 0)
# Nested types
Matrix = list[list[float]]
Config = dict[str, str | int | bool]
Optional and Union
# Modern syntax (3.10+)
def find(id: int) -> User | None:
pass
def parse(value: str | int | float) -> str:
pass
# With default None
def fetch(url: str, timeout: float | None = None) -> bytes:
pass
TypedDict
from typing import TypedDict, Required, NotRequired
class UserDict(TypedDict):
id: int
name: str
email: str | None
class ConfigDict(TypedDict, total=False): # All optional
debug: bool
log_level: str
class APIResponse(TypedDict):
data: Required[list[dict]]
error: NotRequired[str]
def process_user(user: UserDict) -> str:
return user["name"] # Type-safe key access
Callable
from collections.abc import Callable
# Function type
Handler = Callable[[str, int], bool]
def register(callback: Callable[[str], None]) -> None:
pass
# With keyword args (use Protocol instead)
from typing import Protocol
class Processor(Protocol):
def __call__(self, data: str, *, verbose: bool = False) -> int:
...
Generics
from typing import TypeVar
T = TypeVar("T")
def first(items: list[T]) -> T | None:
return items[0] if items else None
# Bounded TypeVar
from typing import SupportsFloat
N = TypeVar("N", bound=SupportsFloat)
def average(values: list[N]) -> float:
return sum(float(v) for v in values) / len(values)
Protocol (Structural Typing)
from typing import Protocol
class Readable(Protocol):
def read(self, n: int = -1) -> bytes:
...
def load(source: Readable) -> dict:
"""Accepts any object with read() method."""
data = source.read()
return json.loads(data)
# Works with file, BytesIO, custom classes
load(open("data.json", "rb"))
load(io.BytesIO(b"{}"))
Type Guards
from typing import TypeGuard
def is_string_list(val: list[object]) -> TypeGuard[list[str]]:
return all(isinstance(x, str) for x in val)
def process(items: list[object]) -> None:
if is_string_list(items):
# items is now list[str]
print(", ".join(items))
Literal and Final
from typing import Literal, Final
Mode = Literal["read", "write", "append"]
def open_file(path: str, mode: Mode) -> None:
pass
# Constants
MAX_SIZE: Final = 1024
API_VERSION: Final[str] = "v2"
Quick Reference
| Type | Use Case |
|---|---|
X | None |
Optional value |
list[T] |
Homogeneous list |
dict[K, V] |
Dictionary |
Callable[[Args], Ret] |
Function type |
TypeVar("T") |
Generic parameter |
Protocol |
Structural typing |
TypedDict |
Dict with fixed keys |
Literal["a", "b"] |
Specific values only |
Final |
Cannot be reassigned |
Type Checker Commands
# mypy (run inside the project env)
uv run mypy src/ --strict
# pyright
uv run pyright src/
# In pyproject.toml
[tool.mypy]
strict = true
python_version = "3.11"
Emerging: ty — Astral's Rust-based type checker (same toolchain as uv +
ruff), dramatically faster than mypy. Still in preview (pre-1.0), so mypy or
pyright remain the production default — but worth watching, and easy to try:
uvx ty check. Adopt for new projects once it stabilizes.
Additional Resources
./references/generics-advanced.md- TypeVar, ParamSpec, TypeVarTuple./references/protocols-patterns.md- Structural typing, runtime protocols./references/type-narrowing.md- Guards, isinstance, assert./references/mypy-config.md- mypy/pyright configuration./references/runtime-validation.md- Pydantic v2, typeguard, beartype./references/overloads.md- @overload decorator patterns
Scripts
./scripts/check-types.sh- Run type checkers with common options
Assets
./assets/pyproject-typing.toml- Recommended mypy/pyright config
See Also
This is a foundation skill with no prerequisites.
Related Skills:
python-pytest-ops- Type-safe fixtures and mocking
Build on this skill:
python-async-ops- Async type annotationspython-fastapi-ops- Pydantic models and validationpython-database-ops- SQLAlchemy type annotations
Files in this skill
9python-typing-ops skill questions
How do I install the python-typing-ops skill in Claude Code?
Run npx degit 0xDarkMatter/claude-mods/skills/python-typing-ops ~/.claude/skills/python-typing-ops. Claude Code loads skills from ~/.claude/skills (all projects) or .claude/skills (one project) and uses a skill when its description matches the task.
Which clients can use the python-typing-ops skill?
Any client that reads the Agent Skills format: Claude Code, Codex, Gemini CLI and claude.ai (upload as a ZIP). Scripts in the skill run only where the client allows code execution.
What Python versions are required for these patterns?
The patterns use Python 3.10+ syntax (such as X | Y union syntax), and some specific patterns like Self or TypeVarTuple require Python 3.11+.
How can I run type checkers on my project?
You can use mypy or pyright via uv, for example: 'uv run mypy src/ --strict' or 'uv run pyright src/'.
What is the difference between Callable and Protocol for function types?
Callable is used for simple function types, while Protocol is used when you need to specify keyword arguments.