python-patterns

python-patterns is a skill for Claude Code, Codex from DVNghiem/FlowDeck. It costs 33 tokens per session (3,204 once invoked), scanned A, original, MIT.

A guide to common Python programming patterns, including type hints, data classes, asynchronous code, generators, and pytest testing.

In plain words
What is it for?
Use it when writing or reviewing Python modules, modeling data, building asynchronous services, setting up tests, or choosing between Python typing and data-structure options.
Why use it?
It helps avoid unclear, fragile, or non-idiomatic Python code by providing established ways to structure programs and handle common problems.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it when writing or reviewing Python modules, modeling data, building asynchronous services, setting up tests, or choosing between Python typing and data-structure options.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/dvnghiem/flowdeck/python-patterns
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add DVNghiem/FlowDeck --skill python-patterns
Clone the repo
git clone --depth 1 https://github.com/DVNghiem/FlowDeck

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for python-patterns

README.md
[![agentmods](https://agentmods.dev/badge/skills/dvnghiem/flowdeck/python-patterns/github.svg)](https://agentmods.dev/skills/dvnghiem/flowdeck/python-patterns)
Your own site
<a href="https://agentmods.dev/skills/dvnghiem/flowdeck/python-patterns"><img src="https://agentmods.dev/badge/skills/dvnghiem/flowdeck/python-patterns/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for python-patterns

Your own site · 80×15
<a href="https://agentmods.dev/skills/dvnghiem/flowdeck/python-patterns"><img src="https://agentmods.dev/badge/skills/dvnghiem/flowdeck/python-patterns.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 33 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,204 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector warn 7 Sept 2026
SkillSpector: 1 finding, up to medium

These are SkillSpector’s own severities. On a checked sample its high-severity flags on skills were ~96% false positives — a documented command, a public API, a “never do X” rule — so we show them as a caution to read, not a verdict. Why →

  • medium Data Exfiltration · line 262
    Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
    Fix: Verify the destination URL is trusted and necessary. Remove or replace with documented APIs. Ensure no secrets, tokens, or PII are transmitted.
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00033 $0.03204
Opus 5.5 $0.00013 $0.01282
Sonnet 5.5 $0.00007 $0.00641
Haiku 4.5 $0.00003 $0.00320

Measured 1mo ago against content hash 1797a60f7b97, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

python-patterns scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

src/skills/python-patterns/SKILL.md · 535 lines

How it starts

The opening of the file, as written. The whole thing — 535 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Python Patterns Skill

Idiomatic Python for production-grade code. Covers modern Python 3.10+ practices.

When to Activate

Activate when:

  • Writing new Python modules or packages
  • Reviewing Python code for correctness and idiom
  • Deciding between data modeling approaches (dataclass vs TypedDict vs Pydantic)
  • Designing async services or background workers
  • Setting up testing infrastructure

Type Hints

Python's type system (PEP 484, 526, 544) makes code self-documenting and enables static analysis with mypy or pyright.

Basic Annotations

# Variables (PEP 526)
count: int = 0
names: list[str] = []
mapping: dict[str, int] = {}

# Functions — always annotate public API
def greet(name: str, times: int = 1) -> str:
    return (f"Hello, {name}!\n" * times).rstrip()

# Optional and Union (Python 3.10+ union syntax preferred)
def find_user(user_id: int) -> "User | None":
    ...

# Use TypeAlias for reused complex types
type UserId = int          # Python 3.12+
UserId = NewType("UserId", int)  # pre-3.12

Protocols (PEP 544) — Structural Subtyping

Prefer Protocol over ABC when you don't control the implementor.

from typing import Protocol, runtime_checkable

@runtime_checkable
class Serializable(Protocol):
    def to_dict(self) -> dict[str, object]: ...

def save(obj: Serializable) -> None:
    data = obj.to_dict()
    ...

# Any class with to_dict() satisfies Serializable — no inheritance required

Generics

from typing import TypeVar, Generic

T = TypeVar("T")

class Stack(Generic[T]):
    def __init__(self) -> None:
        self._items: list[T] = []

    def push(self, item: T) -> None:
        self._items.append(item)

    def pop(self) -> T:
        return self._items.pop()

Data Modeling: Dataclass vs TypedDict vs Pydantic

Choose based on where the data lives and what guarantees you need.

Dataclass — in-memory objects with behavior

from dataclasses import dataclass, field

@dataclass
class Order:
    id: str
    items: list[str] = field(default_factory=list)
    total: float = 0.0

    def add_item(self, item: str, price: float) -> None:
        self.items.append(item)
        self.total += price

# Use @dataclass(frozen=True) for immutable value objects
@dataclass(frozen=True)
class Money:
    amount: int   # stored in cents
    currency: str = "USD"

Read the full file on GitHub · 535 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 1mo ago First seen · 535 lines · 33 tokens per session scan A 1797a60f7b97

Subscribe to this mod's changes

python-patterns is a skill published in the GitHub repository DVNghiem/FlowDeck (36 stars, last pushed 1mo ago), licensed MIT. It adds 33 tokens to every session and 3,204 once invoked, about $0.0001 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

python-testing

Guidelines for writing and running tests in the Agent Framework Python codebase. Use this when creating, modifying, or running tests.

microsoft/agent-framework · 29 tokens

temporal-python-testing

Test Temporal workflows with pytest, time-skipping, and mocking strategies. Covers unit testing, integration testing, replay testing, and local development setup. Use when implementing Temporal workflow tests or debugging test failures.

wshobson/agents · 45 tokens

swarmauri-add-community-standalone

Add a second-class standalone Swarmauri package under pkgs/community. Use when Codex needs community package scaffolding, workspace membership, pyproject metadata, README branding, entry points, second-class citizenship rows, exports, tests, and validation.

swarmauri/swarmauri-sdk · 59 tokens

no-silent-pass

Write Python whose failures are visible and checks that actually fire — distinct sentinels for success and error, filters that narrow to nothing without reading as "all clear", output never discarded on a non-zero exit, and selftest cases proven red before they are trusted (mutate the fix, mutate it the other way too…

AleksandarBisevac/claude-plugins · 143 tokens

test-generator

A generator that reads Python functions and creates pytest test-file skeletons with parameterized example inputs. Pytest is a Python testing tool, and TDD means writing tests as part of the implementation process.

bestdeejay-design/agent-skills · 0 tokens

create-pytests

Generates pytest test files for a Python codebase (or a targeted scope) that.

MarieLynneBlock/arcanum-artifex · 23 tokens