python-type-safety

python-type-safety is a skill for Claude Code 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 Code

Written for Claude Code: installed under .claude/.

Good fit 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.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/ai-riksarkivet/ra-mcp/python-type-safety
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.

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.

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/github.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/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for python-type-safety

Your own site · 80×15
<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="Reviewed on agentmods" width="80" 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. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
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.1 $0.00104 $0.05111
Opus 5.5 $0.00042 $0.02044
Sonnet 5.5 $0.00021 $0.01022
Haiku 4.5 $0.00010 $0.00511

Measured 1mo ago against content hash 208adbf1332e, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, 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 1mo 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 695 — type statement for aliases: type Point = tuple[float, float]

Python 3.13

  • PEP 696 — TypeVar/ParamSpec/TypeVarTuple defaults: class Box[T = int]:
  • PEP 742 — TypeIs for proper bidirectional type narrowing
  • PEP 705 — ReadOnly for TypedDict items
  • PEP 702 — warnings.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 758 — except 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. 1mo 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 (27 stars, last pushed 2d ago), licensed Apache-2.0. It adds 104 tokens to every session and 5,111 once invoked, about $0.0004 per session on Opus 5.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

python-package-management

Guide for managing packages in the Agent Framework Python monorepo, including creating new connector packages, versioning, and the lazy-loading pattern. Use this when adding, modifying, or releasing packages.

microsoft/agent-framework · 43 tokens

python-feature-lifecycle

Guidance for package and feature lifecycle in the Agent Framework Python codebase, including stage meanings, feature-stage decorators, feature enums, and how to move APIs from one stage to the next.

microsoft/agent-framework · 43 tokens

python-code-quality

Code quality checks, linting, formatting, and type checking commands for the Agent Framework Python codebase. Use this when running checks, fixing lint errors, or troubleshooting CI failures.

microsoft/agent-framework · 40 tokens

python-development

Coding standards, conventions, and patterns for developing Python code in the Agent Framework repository. Use this when writing or modifying Python source files in the python/ directory.

microsoft/agent-framework · 35 tokens

effect-v4

Write, review, or upgrade Effect v4 code in the Composio CLI, cli-keyring, and json-schema-to-effect-schema packages, all pinned exactly to [email protected] — Context.Service and explicit layers, Schema.TaggedError and typed recovery, the effect/cli command surface, and the vendored effect source oracle. Use when writing…

ComposioHQ/composio · 157 tokens

adk-agent-builder

Builds ADK (Agent Development Kit) Python agents: LLM agents with tools, graph workflows of function and agent nodes, conditional routing, fan-out and join, schema-validated delegation between agents, human-in-the-loop pauses, and pytest coverage for all of it. Use when asked to create an agent or a workflow, add a…

google/adk-python · 177 tokens