python-patterns
Python best practices including type hints, async patterns, testing, and project structure
npx skills add cosmicstack-labs/mercury-agent-skills --skill python-patterns --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
# Python Patterns Write Python that is type-safe, testable, and a joy to maintain. ## Core Principles ### 1. Explicit Over Implicit Use type hints. Avoid `*args` and `**kwargs` when named parameters work. Favor clear interfaces over dynamic flexibility. ### 2. Composition Over Inheritance Python's multiple inheritance is powerful but dangerous. Prefer composition and protocols over deep class hierarchies. ### 3. Async Done Right Async is a tool for I/O-bound workloads, not a universal default. Use synchronous code for CPU-bound tasks, async for network calls and file I/O. ### 4. Test-First for Critical Paths Your business logic should be testable without mocks. Use dependency injection. Keep I/O at the boundaries. --- ## Python Maturity Model | Level | Typing | Async | Testing | Structure | |-------|--------|-------|---------|-----------| | **1: Script** | No type hints | sync only | Manual testing | Single file | | **2: Module** | Basic types (str, int) | Basic asyncio | pytest, some coverage | Package with `__init__.py` | | **3: Package** | Full type hints with mypy | Async with proper patterns | pytest + fixtures + mocking | src-layout, entry points | | **4: Service** | Generics
- Core Principles
- 1. Explicit Over Implicit
- 2. Composition Over Inheritance
- 3. Async Done Right
- 4. Test-First for Critical Paths
- Python Maturity Model
- Actionable Guidance
- Type Hints
- Async Patterns
- Project Structure
- Testing Patterns
- Error Handling
- Common Mistakes
What does the python-patterns skill do?
Python best practices including type hints, async patterns, testing, and project structure
How do I install it?
Run `npx skills add cosmicstack-labs/mercury-agent-skills --skill python-patterns --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From cosmicstack-labs/mercury-agent-skills, a repository with 364 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.