tylores/dotfiles/python-paradigms
Claude Code and agent skill by tylores/dotfiles
- community
Checking that the SKILL.md file is still in the repository.
Enforces global Python execution, type safety, deterministic resource cleanup, defensive error handling, and modern best practices. Use when writing, reviewing, or refactoring Python code (*.py), tests, pyproject.toml, or virtual environments.
Install
npx vskill@latest install tylores/dotfiles/python-paradigmsSKILL.md
The same SKILL.md was published earlier as tylores/dotfiles/python-paradigms.
Global Python Execution & Type Safety
Context
Guidelines for building modern, modular, production-ready Python applications. Every line of Python must prioritize type safety, deterministic resource cleanup, robust exception hierarchies, and clear concurrency boundaries.
Trigger Conditions
Activated automatically when reading, writing, or editing Python source files (*.py), tests, configuration, or package metadata.
Directives
1. Strict Type Hinting & Static Analysis
- Mandatory Annotations: Every function and method signature must include explicit type hints for all parameters and return values (e.g., use modern union syntax
int | Nonerather thanOptional[int]). - No Untyped Generics: Do not use raw container types. Always specify child types (e.g.,
list[str],dict[str, int]). - Avoid `Any`: Use precise types,
TypeVar(generics),Protocol(structural subtyping/interfaces), or abstract base classes (abc.ABC) to resolve design requirements without resorting toAny. - Explicit Casting: If external library boundaries lack types, use
typing.castexplicitly rather than suppressing checker warnings.
2. Defensive State & Resource Management
- No Mutable Defaults: Never define default arguments as mutable objects (e.g.,
def func(x=[])). UseNoneas the default and initialize the object inside the function body. - Immutability by Default: Prefer
frozen=Truedataclasses,NamedTuple, or read-only properties for configuration and value objects to avoid unintended side effects. - Deterministic Cleanup: Force the use of context managers (
withorasync withblocks) for all I/O operations (file reads/writes, HTTP requests, database transactions, sockets). Never rely on garbage collection for closing resources.
3. Error Handling & Logging
- No Bare Exceptions: Never write
except:orexcept Exception:. Catch the specific exceptions that are expected (e.g.,ValueError,KeyError,FileNotFoundError). - Exception Chaining: Always use
raise CustomError(...) from errwhen wrapping or translating exceptions to preserve the stack trace. - Structured Logging: Use a structured logger (
loggingorstructlog) with appropriate levels (DEBUG,INFO,WARNING,ERROR). Do not useprint()statements for diagnostic logs.
4. Asynchronous & Concurrency Guidelines
- Non-blocking Event Loops: In
async defroutines, never call synchronous blocking calls (e.g.,time.sleep, synchronous database drivers, file system reads/writes) directly. Offload these calls to a separate executor usingasyncio.to_threadorloop.run_in_executor. - Explicit Task Lifecycles: Always await tasks or use Task Groups (PEP 654 / Python 3.11+) to run tasks concurrently. Avoid "fire-and-forget" tasks unless they are explicitly managed by an active background task tracker.
5. Pythonic Style & Modern APIs
- Docstring Standards: Follow Google style docstrings for all classes, methods, and modules. Include a brief summary, arguments with types, return descriptions, and exceptions raised.
- Standard Library Over Custom Code: Leverage specialized standard library tools (e.g.,
collections.dequefor queues,collections.Counterfor counting,pathlib.Pathfor file path manipulation,enum.Enumfor constants). - Generator Expressions: Prefer generators or
yieldfor memory-efficient stream processing over generating massive lists in-memory.
6. Testing & Testability
- Modular Testing with Pytest: Design functions with dependency injection (e.g., pass db connections/clients as arguments) to facilitate simple mocking.
- Avoid Global Mocks: Prefer
pytestfixtures for setup/teardown and scope isolation. Useunittest.mockcleanly and narrow its scope to the execution boundary of the test.
7. Environment & Dependency Management
- Tool Detection: Prioritize project-specific dependency managers by detecting lockfiles:
- If
uv.lockis present, always useuvcommands (e.g.,uv pip install,uv run). - If
poetry.lockis present, always usepoetrycommands. - If
requirements.txtis present, use standardpipwithin a virtual environment. - Declarative Configuration: Define dependencies, metadata, and tool settings in
pyproject.toml(following PEP 518 / PEP 621) rather than legacysetup.pyor multiple standalone config files.
Quick Reference / Cheat Sheet
Directive | Standard Pattern | Anti-Pattern --- | --- | --- Type Hints | def func(val: int | None) -> list[str]: | def func(val=None): Default Args | def func(data: list[str] | None = None): | def func(data=[]): Resource Cleanup | with open(p) as f: or async with session: | f = open(p) (no cleanup) Exceptions | raise CustomError("msg") from err | except Exception: pass Async Offloading | await asyncio.to_thread(sync_func) | Blocking call in async def Dependency Execution | uv run pytest / poetry run pytest | Unscoped global python execution
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingbotfiles/.gemini/antigravity-cli/skills/python-paradigms/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/tylores/dotfiles/python-paradigms)