Skip to content
Back to skills

Stack Python

ASecurity

Python development guidelines — style, patterns, virtual environments, and testing with pytest, fixtures, and mocking

  • 3 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added November 6, 2026
ai-agentspythonexpresstestingrefactoringdatabase

Security analysis

A100/100

Pro scans all 3 files and shows the line behind each finding

Scanned November 20, 2026

npx -y skills add Snakeblack/ospec-workflow --skill stack-python --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Stack Python?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Stack Python
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/snakeblack-stack-python/badge)](https://www.skillsdirectory.com/skills/snakeblack-stack-python)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: stack-python
description: "Python development guidelines — style, patterns, virtual environments, and testing with pytest, fixtures, and mocking"
license: MIT AND Commons-Clause
metadata:
  author: "affaan-mustafa, manuel-retamozo-garcia"
  version: "1.0"
capabilities: [python]
---

# Python Development Patterns

Idiomatic Python patterns and best practices for building robust, efficient, and maintainable applications.

## When to Activate

- Writing new Python code
- Reviewing Python code
- Refactoring existing Python code
- Designing Python packages/modules
- Writing or reviewing pytest tests, fixtures, or mocks

## Core Rules

1. **Readability Counts**: Prioritize clarity over cleverness. Write explicit code and use f-strings and type hints.
2. **EAFP Style**: Prefer catching exceptions (`try-except`) rather than checking pre-conditions (`LBYL`), but always target specific exceptions and chain them correctly (`raise ... from e`).
3. **Resource Management**: Use context managers (`with` statement) for managing files, database connections, and locks.
4. **Data Classes**: Use `@dataclass` for data containers, implementing `__post_init__` for field validations.
5. **Memory and Iterators**: Use generators and generator expressions for lazy evaluation of large datasets. Avoid string concatenation inside loops.
6. **Testing** (`references/testing.md`): pytest with fixtures in `conftest.py` and `@pytest.mark.parametrize` for cases; `patch(..., autospec=True)` at external boundaries; `tmp_path` for files; 80%+ coverage, 100% on critical paths.

## References

Load on demand, only the file the task needs:
* [Python Coding Patterns & Examples](references/patterns.md)
* [Python Testing](references/testing.md) — pytest fundamentals, fixtures and scopes, parametrization, markers, mocking, async tests

Files in this skill

  • SKILL.md1.8 KB
  • references/patterns.md16.1 KB
  • references/testing.md18.3 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.