python-type-safety

Add type annotations, generics, and protocols to Python code.

6|Updated Feb 25, 2026
One-click install
npx skills add https://github.com/archibate/archibate-skills --skill python-type-safety-archibate
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: python-type-safety
Source: https://github.com/archibate/archibate-skills/tree/main/old-skills/redundant-skills/python-type-safety
Command: npx skills add https://github.com/archibate/archibate-skills --skill python-type-safety-archibate

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Prevent runtime type errors and ambiguous APIs by making types explicit, enabling static analysis to find issues before they reach production.

Core Features & Use Cases

  • Type annotations: Add and maintain annotations for functions, methods, and public interfaces to improve readability and tooling support.
  • Generics & TypeVars: Create reusable, type-preserving containers and APIs that maintain correctness across type parameters.
  • Protocols & Structural Typing: Define interface-like contracts without inheritance for flexible, testable designs.
  • Type narrowing & guards: Guide checkers to refine union types and eliminate unsafe assumptions.
  • Configuration: Provide mypy and pyright guidance for enabling strict mode in CI and incremental adoption in large codebases.
  • Use Case: Annotate an existing service layer to enable mypy --strict in CI, introduce a generic Result type, and add protocols for external adapters.

Quick Start

Add type annotations to the selected module, implement generics and protocols where appropriate, and produce a mypy/pyright configuration that enables strict checking.

Frequently Asked Questions about python-type-safety

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add static type checking to an existing Python codebase?

Static type checking for Python code is applied by adding type annotations to functions and modules, then configuring checkers like mypy or pyright in CI to detect type errors. This enables incremental adoption across large codebases.

What is type narrowing in Python and when do I need it?

Type narrowing in Python refines union types to eliminate unsafe assumptions during static analysis. You need it when guiding checkers to understand a variable has a specific type within a code block, preventing invalid attribute access.

How do I create type-preserving generic containers in Python?

To create type-preserving generic containers in Python, you implement Generics and TypeVars with bounds. This maintains type correctness across parameters, allowing static analysis tools to track specific types through reusable APIs.

Can I define structural interfaces in Python without inheritance?

Yes, you can define structural interfaces in Python without inheritance by using Protocols. Protocols define interface-like contracts for flexible designs, allowing static type checkers to verify compatibility based on shape rather than explicit subclassing.

Does this approach support both mypy and pyright configurations?

Yes, this approach supports both mypy and pyright configurations for enabling strict mode. It provides guidance for setting up static type checking in CI pipelines and supports incremental adoption for large Python codebases.

What's the best way to enforce strict typing in Python CI pipelines?

The best way to enforce strict typing in Python CI pipelines is by configuring mypy or pyright in strict mode. This involves annotating service layers, implementing generic Result types, and adding protocols for external adapters.