本文へ移動
cccskills
無料GitHub で公開

python3-typing

Auto-selects and enforces the strongest valid Python typing lane for the detected Python version and dependencies — no user input required. Use when adding or tightening type annotations, eliminating Any usage in internal code, designing boundary validators or parsers, choosing between stdlib typing (TypedDict, Protocol, dataclasses), Pydantic models, or Hypothesis property tests, addressing ty or mypy failures, or applying version-specific features (TypeIs, ReadOnly, PEP 695 generics, PEP 649 deferred evaluation). Enforces boundary isolation — raw payloads validated immediately at ingress and returned as typed internal objects.

インストール方法を見る

含まれるファイル(12)

  • SKILL.md4.1 KB
  • references/hypothesis-boundaries.md1.4 KB
  • references/modernization-guide.md17.7 KB
  • references/mypy-docs/additional_features.rst6.2 KB
  • references/mypy-docs/generics.rst17.6 KB
  • references/mypy-docs/protocols.rst9.6 KB
  • references/mypy-docs/type_narrowing.rst9.4 KB
  • references/mypy-docs/typed_dict.rst5.9 KB
  • references/pydantic-boundaries.md1.2 KB
  • references/type-patterns.md3.3 KB
  • references/type-safety-mypy.md11.9 KB
  • references/typing-policy.md3.2 KB

SKILL.md(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

Python Typing

Choose the strongest valid lane automatically. Do not ask the user to pick a typing philosophy.

Consult references/typing-policy.md for the full policy document.

Required Policy

  • Forbid Any, broad object, and unchecked cast() in normal internal code
  • Allow them only at explicit boundaries where unknown-shape data enters
  • Isolate boundary code in dedicated validator, parser, adapter, or boundary modules
  • Validate immediately and return strongly typed internal objects
  • Do not let raw payloads cross into the typed core
  • Allow narrow lint exceptions for Any only in approved boundary modules

Lane Selection

1. Python 3.10 Constrained or stdlib-only

  • Use only compatibility-safe stdlib typing features
  • Prefer dataclasses, TypedDict, Protocol, Literal, TypeGuard, NewType
  • Validate with explicit runtime checks in dedicated boundary wrappers
  • No third-party type assumptions

2. Python 3.11+ stdlib-only

  • Use modern stdlib typing features supported by the interpreter
  • Use Self, assert_type, and reveal_type where useful during refactoring
  • TypedDict with NotRequired

3. Python 3.11+ with Pydantic

  • Use Pydantic models for ingress contracts
  • Prefer strict mode where coercion would hide upstream errors
  • Use TypeAdapter for annotated types that do not need full models
  • See references/pydantic-boundaries.md

4. Python 3.11+ with Hypothesis

  • Property-test boundaries, validators, parsers, and invariants
  • Prefer from_type() where practical
  • See references/hypothesis-boundaries.md

5. Python 3.12+

  • Use type statement for explicit type aliases: type JSONValue = str | int | ...
  • Use PEP 695 generic parameter syntax for new generic helpers

6. Python 3.13+

  • Use TypeIs for clearer custom narrowing helpers (replaces TypeGuard where bidirectional narrowing needed)
  • Use ReadOnly in TypedDict fields that must not mutate after validation

7. Python 3.14+

  • Keep annotation-reading infrastructure compatible with deferred evaluation (PEP 649)
  • Use annotationlib.get_annotations() in infrastructure that inspects annotations at runtime

Boundary Implementation Standard

Use dedicated wrappers named like:

  • parse_*
  • validate_*
  • decode_*
  • coerce_*
  • *_from_raw

Boundary modules should return typed objects only.

Example: stdlib-only boundary

from typing import TypedDict, NotRequired
from dataclasses import dataclass


class _RawIncoming(TypedDict):
    user_id: int
    email: str
    metadata: NotRequired[dict[str, str]]


@dataclass(frozen=True, slots=True)
class IncomingPayload:
    user_id: int
    email: str
    metadata: dict[str, str]


def parse_incoming(data: _RawIncoming) -> IncomingPayload:
    return IncomingPayload(user_id=data["user_id"], email=data["email"], metadata=data.get("metadata", {}))

Example: Pydantic boundary

from pydantic import BaseModel, TypeAdapter


class IncomingPayload(BaseModel):
    user_id: int
    email: str
    metadata: dict[str, str] = {}
    model_config = {"strict": True}


def parse_incoming(data: dict[str, object]) -> IncomingPayload:
    return IncomingPayload.model_validate(data)

References

  • references/typing-policy.md — full boundary validation policy
  • references/pydantic-boundaries.md — Pydantic model and TypeAdapter patterns
  • references/hypothesis-boundaries.md — property-based testing for validators

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

同じリポジトリのスキル

概要と使いどころ

Add automated documentation updater to any Claude skill. Creates a Python sync script that downloads upstream docs, processes markdown for AI consumption, and maintains local cache with configurable refresh. Collects template variables, then delegates implementation through 5-phase workflow. Use when adding auto-updating reference documentation to plugins or skills.

日本語の概要は準備中です。原文の説明を表示しています。

Jamie-BitFlight/claude_skills672026年10月9日 更新

SAM-style feature initiation workflow — discovery through codebase analysis, architecture spec, task decomposition, validation, and context manifest. Use when a user asks to add a feature, plan a feature, or convert an idea into an executable SAM plan.

日本語の概要は準備中です。原文の説明を表示しています。

Jamie-BitFlight/claude_skills672026年10月9日 更新

Browser automation for AI agents using the agent-browser CLI and Playwright. Use when navigating pages, filling forms, clicking buttons, taking screenshots, extracting data, testing web apps, logging into sites, or automating any browser task. Triggers on "open a website", "fill out a form", "click a button", "scrape data", "test this web app", "automate browser actions", or any programmatic web interaction request.

日本語の概要は準備中です。原文の説明を表示しています。

Jamie-BitFlight/claude_skills672026年10月9日 更新

Browser automation CLI for AI agents. Use when the user needs to interact with websites, including navigating pages, filling forms, clicking buttons, taking screenshots, extracting data, testing web apps, or automating any browser task. Triggers include requests to "open a website", "fill out a form", "click a button", "take a screenshot", "scrape data from a page", "test this web app", "login to a site", "automate browser actions", or any task requiring programmatic web interaction.

日本語の概要は準備中です。原文の説明を表示しています。

Jamie-BitFlight/claude_skills672026年10月9日 更新

Runs the description-drift experiment — spawns all Claude Code agents simultaneously to collect self-reported capabilities, then compares them against static frontmatter descriptions to reveal how reliable orchestrator routing based on descriptions actually is. Use when measuring description drift across the agent fleet, re-running the capability collection experiment, analyzing a specific agent's self-reported capabilities, or auditing whether frontmatter descriptions accurately reflect agent behavior.

日本語の概要は準備中です。原文の説明を表示しています。

Jamie-BitFlight/claude_skills672026年10月9日 更新

Create or adapt Claude Code agent definitions. Use when creating an agent, changing subagent configuration, selecting agent scope, or designing a specialized delegation role.

日本語の概要は準備中です。原文の説明を表示しています。

Jamie-BitFlight/claude_skills672026年10月9日 更新

Jamie-BitFlight のスキルをすべて見る

このスキルの問題を報告する