python-typing

Applies lightweight type annotations and validation patterns to Python scripts.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing typed Python scripts often leads to over-engineered models, silenced checker errors, or unsafe handling of untyped input like JSON and environment values. This Skill provides practical rules for annotating scripts correctly without project-scale type-system research. ## Core Features & Use Cases - Boundary Typing: Treats untrusted input (JSON, plist, environment values) as object and narrows it with isinstance validation instead of Any. - Minimal Data Modeling: Guides the choice between TypedDict, frozen dataclasses, Literal, enums, and plain str plus validation for small scripts. - Honest Error Handling: Discourages cast(), broad unions, and blanket # type: ignore in favor of narrowing, validation, and narrow error-code ignores. - Use Case: When writing a standalone Python script that parses CLI arguments and JSON config, use this Skill to type every function signature, validate input at the edge, and pass the configured checker cleanly. ## Quick Start Ask the AI to add type annotations to your Python script and validate its untyped JSON or CLI inputs following these typing rules.

Frequently Asked Questions about python-typing

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

FAQPage Schema
How do I type untyped JSON input in Python?

Treat JSON and other untrusted input as object, then narrow it with isinstance checks before constructing typed values. Validate the container shape and each required field, and remember that bool is an int subclass that must be rejected explicitly when a true integer is required.

When should I use TypedDict vs dataclass in Python?

Use TypedDict when validated data must remain dictionary-shaped, such as a JSON record. Use a frozen dataclass for an internal value object with behavior or useful construction semantics.

Should I add Pydantic to a small Python script?

No, avoid adding Pydantic or another runtime model dependency to a small script unless runtime schema features justify it. Prefer TypedDict, dataclasses, or plain validation for lightweight data shapes.

How do I handle Any and type: ignore without hiding errors?

Avoid cast(), broad unions, Any, and blanket type: ignore as ways to silence the checker. Contain Any from untyped dependencies in one adapter returning a validated type, and use the narrow error code with an explanation when an ignore is unavoidable.

When should I use Protocol or generics in Python typing?

Add Protocol, overloads, generics, type guards, or Self only when the implementation establishes the relationship they express. For simple scripts, precise concrete types and abstract boundary types like Sequence or Mapping are sufficient.