python-type-safety

python-type-safety is a skill for Claude Code, Codex from AI-Riksarkivet/ra-mcp. It costs 104 tokens per session (5,111 once invoked), scanned A, original, Apache-2.0.

A guide to modern Python type hints and strict checking with ty, Ruff, and uv. Type hints describe the kinds of values code expects, while type checking finds mismatches before the program runs.

In plain words
What is it for?
Use it when adding annotations, generics, or structural interfaces, configuring ty or Ruff, managing environments with uv, and writing Python 3.13 or newer code.
Why use it?
It helps catch incorrect data usage early and keeps Python interfaces clear as code grows.

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/ai-riksarkivet/ra-mcp/python-type-safety
Any agent
npx skills add AI-Riksarkivet/ra-mcp --skill python-type-safety
Clone the repo
git clone --depth 1 https://github.com/AI-Riksarkivet/ra-mcp

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for python-type-safety

README.md
[![agentmods](https://agentmods.dev/badge/skills/ai-riksarkivet/ra-mcp/python-type-safety.svg)](https://agentmods.dev/skills/ai-riksarkivet/ra-mcp/python-type-safety)
Your own site
<a href="https://agentmods.dev/skills/ai-riksarkivet/ra-mcp/python-type-safety"><img src="https://agentmods.dev/badge/skills/ai-riksarkivet/ra-mcp/python-type-safety.svg" alt="Measured on agentmods" height="20"></a>
Per session 104 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 5,111 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. 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.00104 $0.05111
Opus 5 $0.00052 $0.02556
Sonnet 5 $0.00021 $0.01022
Haiku 4.5 $0.00010 $0.00511

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

Security

Grade A, and why

python-type-safety scanned grade A with 1 finding 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 4d 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.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

def fetch(url: str, *, as_json: Literal[True]) -> dict: ...
packages/mcps/viewer-mcp/.claude/skills/python-type-safety/SKILL.md · 745 lines

How it starts

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

Python Type Safety (3.13+ / 3.14+)

Modern Python type safety using the Astral toolchain: ty for type checking and language server, ruff for linting (including annotation enforcement), and uv for package management. All examples target Python 3.13+ with 3.14 deferred annotations as the default.

Toolchain

Tool Role Install
ty Type checker + LSP (10-100x faster than mypy) uv tool install ty@latest
ruff Linter + formatter (replaces flake8, black, isort) uv tool install ruff
uv Package manager + env management astral.sh/uv

ty is the type checker from Astral (the creators of ruff and uv). It is written in Rust, provides a full language server (LSP) with code navigation, completions, and inlay hints, and supports advanced features like intersection types, reachability analysis, and gradual typing guarantees.

Key Python Version Features

Python 3.12

  • PEP 695 — Type parameter syntax: def first[T](items: list[T]) -> T:
  • PEP 695type statement for aliases: type Point = tuple[float, float]

Python 3.13

  • PEP 696 — TypeVar/ParamSpec/TypeVarTuple defaults: class Box[T = int]:
  • PEP 742TypeIs for proper bidirectional type narrowing
  • PEP 705ReadOnly for TypedDict items
  • PEP 702warnings.deprecated() decorator with type system support

Python 3.14

  • PEP 649/749 — Deferred evaluation of annotations (no more from __future__ import annotations, no more forward reference strings)
  • PEP 758except and except* expressions may omit brackets

Fundamental Patterns

Pattern 1: Annotate All Public Signatures

Every public function, method, and class should have type annotations. Use native generics everywhere (no typing.List, typing.Dict, etc. — those are ancient history).

from pydantic import BaseModel


class User(BaseModel):
    id: str
    name: str
    email: str | None = None


class UserRepository:
    def __init__(self, db: Database) -> None:
        self._db = db

    async def find_by_id(self, user_id: str) -> User | None:
        ...

    async def find_by_email(self, email: str) -> User | None:
        ...

    async def save(self, user: User) -> User:
        ...

Read the full file on GitHub · 745 lines

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. 4d ago First seen · 745 lines · 104 tokens per session scan A 208adbf1332e

Subscribe to this mod's changes

python-type-safety is a skill published in the GitHub repository AI-Riksarkivet/ra-mcp (21 stars, last pushed yesterday), licensed Apache-2.0. It adds 104 tokens to every session and 5,111 once invoked, about $0.0005 per session on Opus 5. A static security scan graded it A with 1 finding (makes network calls). 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

n8n-subworkflows

Build reusable, composable n8n sub-workflows. Use when extracting shared logic, building anything multi-step or reused across workflows, or any workflow over 10 nodes — and whenever the user mentions sub-workflows, Execute Workflow, reuse, shared/common logic, modular workflows, "Define Below" inputs…

czlonkowski/n8n-mcp · 121 tokens

n8n-code-tool

Write JavaScript or Python for the n8n Custom Code Tool (@n8n/n8n-nodes-langchain.toolCode) — the AI-agent-callable tool, NOT the workflow Code node. Use when building a Code Tool attached to an AI Agent, writing code that an LLM will invoke, parsing the query input, returning a string result, defining an input schema…

czlonkowski/n8n-mcp · 221 tokens

blockrun

Pay-per-call access to AI models, real-time data, media generation and multi-chain RPC over x402 micropayments (USDC on Base or Solana). No API keys, no accounts, no subscriptions. Start here when you have the BlockRun MCP installed and need to know WHICH tool answers a question, how the wallet works, or how to make a…

BlockRunAI/blockrun-mcp · 246 tokens

crypto-data

Use for any crypto data question — token/coin prices, FX, commodities, stocks, OHLC history, DEX pairs and liquidity, DeFi TVL, yield/APY pools, on-chain SQL, wallet labels and net worth, social mindshare, news, or raw JSON-RPC against a chain. Routes across five tools that overlap heavily, so it also says which one…

BlockRunAI/blockrun-mcp · 170 tokens

orchestrator-contract

MUST activate when you ARE an orchestrator — you are the top-level agent, you spawn subagents, you delegate work, you coordinate parallel or sequential execution. Defines delegation quality, subagent dispatch, routing, review, and ownership protocol.

griddynamics/rosetta · 54 tokens

implement-direct

Implement a small, well-defined issue directly — no planning phase, no task tracker.

MarcusJellinghaus/mcp-workspace · 2 tokens