python-typing
Migrate Python codebases to strict type checking with pyright. Use when user wants to add types, fix type errors, set up strict mode, or run a typing migration. Provides setup automation, fix patterns, discipline enforcement, and optional iteration loop support.
Best use case
python-typing is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Migrate Python codebases to strict type checking with pyright. Use when user wants to add types, fix type errors, set up strict mode, or run a typing migration. Provides setup automation, fix patterns, discipline enforcement, and optional iteration loop support.
Teams using python-typing should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/python-typing/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How python-typing Compares
| Feature / Agent | python-typing | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Migrate Python codebases to strict type checking with pyright. Use when user wants to add types, fix type errors, set up strict mode, or run a typing migration. Provides setup automation, fix patterns, discipline enforcement, and optional iteration loop support.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
Related Guides
SKILL.md Source
# Python Typing
Migrate Python codebases to strict type checking using pyright.
## Onboarding
On first invocation, run the setup flow:
### 1. Determine Strictness Level
If user explicitly said "strict typing", use strict. Otherwise ask:
```
What level of type checking?
A) strict - Maximum type safety (recommended for new projects)
B) standard - Balanced (recommended for existing codebases)
C) basic - Minimal, just obvious bugs
```
Run pyright at each level to show baselines:
```bash
npx pyright --outputjson 2>/dev/null | jq '.summary.errorCount' # strict
npx pyright -p pyrightconfig-standard.json --outputjson 2>/dev/null | jq '.summary.errorCount'
```
### 2. Choose Setup Type
```
Setup options:
A) Recommended - Full setup with tracking and rules
B) Minimal - Just pyright config and rules
C) Custom - Choose each component
```
### 3. Run Setup
**For Recommended (A):**
```bash
python3 <SKILL_PATH>/scripts/init_typing.py --level {strict|standard|basic} --full
```
This installs:
- pyrightconfig-{level}.json
- .long-task-harness/ with typing rules
- typing-findings.md
- Pre-commit hook
- long-task-harness (if not present)
- ralph-wiggum plugin (Claude Code only)
**For Minimal (B):**
```bash
python3 <SKILL_PATH>/scripts/init_typing.py --level {strict|standard|basic}
```
**For Custom (C):** Ask which components, then run with appropriate flags.
### 4. Explain What Was Installed
After setup, explain each component:
- What pyrightconfig does
- What the rules enforce and why
- What long-task-harness provides (link to docs)
- How ralph-wiggum works (if installed)
### 5. Show Fix Strategy
```
Recommended approach - fix in layers:
1. Quick wins: unused imports, missing return types, generic args
2. Annotations: parameter types, class attributes
3. Type safety: None checks, narrowing, unions
4. Structural: conditional imports, TypedDict, Protocol
5. External: missing stubs, third-party workarounds
6. Edge cases: complex generics, metaprogramming
Run analysis first:
python3 <SKILL_PATH>/scripts/analyze_typing.py
```
### 6. Offer Iteration Loop (if ralph-wiggum installed)
Show the prompt template and confirm before user runs it.
---
## Fixing Errors
### Workflow
1. Run `npx pyright` to see current errors
2. Pick 5-10 related errors (same file or type)
3. Fix properly (no shortcuts)
4. Run pyright to verify
5. Commit with descriptive message
6. Repeat
### Rules (Critical)
1. **No `# type: ignore`** - Fix the actual issue. If truly unfixable, document in typing-findings.md first.
2. **No `assert x is not None`** - Use proper patterns:
- Early return: `if x is None: return`
- Conditional: `if x is not None: x.method()`
- Raise with context: `if x is None: raise ValueError("x required")`
3. **Avoid `Any`** - Use specific types, TypeVar, Union, Protocol, or object.
4. **Avoid `cast()`** - Use isinstance() narrowing or TypeGuard.
### Common Patterns
See `references/patterns.md` for detailed fix patterns:
- Conditional imports (try/except)
- TypedDict for dict shapes
- Protocol for duck typing
- Third-party stubs
- Complex generics
### When Stuck
1. Check patterns.md for similar issues
2. Check typing-findings.md for documented workarounds
3. For third-party libs: install stubs or document limitation
4. Ask for help rather than using type:ignore
---
## Progress Tracking
### With long-task-harness
Update `.long-task-harness/long-task-progress.md` with:
- Error count at start/end of session
- Files/modules fixed
- Patterns discovered
- Decisions made
### Every 50 Errors
- Review work for consistency
- Document new patterns in typing-findings.md
- Note any recurring issues
---
## Ralph-Wiggum Loop
For unattended iteration (Claude Code only):
```
/ralph-loop "Fix pyright strict mode errors.
## Setup
Run: npx pyright
Baseline: {ERROR_COUNT} errors
## Rules (CRITICAL)
1. Do NOT use # type: ignore - fix the actual issue
2. Do NOT use assert x is not None - use proper conditionals
3. Avoid Any - use specific types
4. Avoid cast() - use isinstance() narrowing
## Workflow
1. Run pyright, note error count
2. Pick 5-10 related errors (same file or same type)
3. Fix them properly
4. Run pyright to verify
5. Commit with descriptive message
6. Repeat
## Every 50 Errors
- Review for consistency
- Document unfixable issues in typing-findings.md
- Note patterns
## If Stuck
- Check typing-findings.md for similar issues
- For third-party libs: document and use minimal workaround
- Ask for help rather than using type: ignore
## Completion
When pyright reports 0 errors: <promise>TYPING_COMPLETE</promise>" --completion-promise "TYPING_COMPLETE" --max-iterations 300
```
---
## References
- `references/patterns.md` - Common fix patterns by category
- `references/faq.md` - Detailed FAQ for common questionsRelated Skills
python-workflow
Python project workflow guidelines. Triggers: .py, pyproject.toml, uv, pip, pytest, Python. Covers package management, virtual environments, code style, type safety, testing, configuration, CQRS patterns, and Python-specific development tasks.
python-workflow-development
Develop Python scripts and modules for building AI workflows and integrations. Use when coding data ingestion, transformation, analysis, and automation pipelines in pilot projects requiring Python automation.
python-testing
Use when implementing new Python code (follow TDD), designing test suites, reviewing test coverage, setting up pytest infrastructure, writing fixtures, mocking dependencies, or performing parametrized testing
python-testing-patterns
Implement comprehensive testing strategies with pytest, fixtures, mocking, and test-driven development. Use when writing Python tests, setting up test suites, or implementing testing best practices.
python-specialist
Deliver production-quality Python solutions with framework-aware patterns and tests.
python-setup-dev-environment
Set up and run a reproducible Python dev environment with uv, ruff, mypy, and VSCode.
Python Security Scan
Comprehensive security vulnerability scanner for Python projects including Flask, Django, and FastAPI applications. Detects OWASP Top 10 vulnerabilities, injection flaws, insecure deserialization, authentication issues, hardcoded secrets, and framework-specific security problems. Audits dependencies for known CVEs and generates actionable security reports.
python-project
Scaffold and harden Python projects using vpngw-aligned defaults (pyproject/setuptools-scm, src layout, Ruff, pytest, Typer, Pydantic) plus best practices for CLI tools, systemd services, APIs/UI apps, IaC/automation, security/networking, and AI/ML workflows.
python-programmer
Python programmer specialising in functional programming, clean code, documentation, and code quality using ruff and uv.
python-pro
Master Python 3.12+ with modern features, async programming,
python
Python coding conventions and guidelines Triggers on: **/*.py
python-performance-optimization
Profile and optimize Python code using cProfile, memory profilers, and performance best practices. Use when debugging slow Python code, optimizing bottlenecks, or improving application performance.