tighten-python-types

Tightens type annotations in existing Python code with a low-churn workflow.

1|Updated Feb 25, 2026
One-click install
npx skills add https://github.com/cjthompson/claude-code-config --skill tighten-python-types-cjthompson
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: tighten-python-types
Source: https://github.com/cjthompson/claude-code-config/tree/main/plugins/python-development/skills/tighten-python-types
Command: npx skills add https://github.com/cjthompson/claude-code-config --skill tighten-python-types-cjthompson

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Existing Python codebases often contain broad Any annotations, unparameterized containers, and ambiguous optionality that weaken type-checker coverage. This Skill applies a focused workflow to make annotations precise in changed files without triggering broad refactors or formatting churn. ## Core Features & Use Cases - Scoped Type Tightening: Defaults to files already changed for the current task, expanding scope only when interfaces require it. - Evidence-Based Narrowing: Replaces broad Any and vague containers with the narrowest honest types, preferring natural narrowing, protocols, and typed boundaries over cast. - Verification Loop: Runs the repository's formatter, linter, type checker, and focused tests, then reports remaining errors and intentionally broad annotations. - Use Case: After editing a Python module, ask the agent to tighten its annotations so ty or mypy reports fewer errors while runtime behavior and public compatibility stay intact. ## Quick Start Tighten the type annotations in the Python files I just changed and run the type checker to confirm the results.

Frequently Asked Questions about tighten-python-types

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

FAQPage Schema
How do I tighten type annotations in existing Python code?

Apply a focused workflow to files already changed for your task: replace broad Any and unparameterized containers with the narrowest types supported by evidence, then run the repository's type checker and tests. Avoid unrelated refactors and formatting churn.

How to reduce Any types in a Python codebase?

Replace Any with precise types only where evidence supports it, using natural narrowing, protocols, typed boundaries, and small helpers instead of cast. For dynamic or untrusted data, validate it or keep the uncertainty visible at the boundary rather than inventing types.

Does this work with mypy or the ty type checker?

Yes, the workflow first determines the configured type checker and supported Python version before choosing syntax or commands. It then runs the repository's own checker, such as ty check, along with the formatter, linter, and focused tests.

When should I use cast instead of type narrowing in Python?

Use cast only when runtime facts cannot be expressed through natural narrowing, protocols, or typed boundaries. The workflow prefers narrowing and small typed helpers because they keep annotations honest and verifiable by the type checker.

Will tightening types change my code's runtime behavior?

No, the workflow explicitly preserves runtime behavior and public compatibility. It avoids unrelated refactors, blanket ignores, and formatting churn, and reports any annotations intentionally left broad after verification.