python-patterns

python-patterns is a skill for Claude Code from komluk/scaffolding. It costs 73 tokens per session (1,349 once invoked), scanned A, original, MIT.

A set of recommended ways to structure Python backend code, including separate parts for web requests, business rules, database access, data models, and validation. It also covers asynchronous operations, which let a program handle waiting tasks efficiently.

In plain words
What is it for?
Building Python routes, database models, request and response schemas, services, and asynchronous backend operations.
Why use it?
It helps keep backend code organized and makes each part easier to understand and change. Separating responsibilities can prevent request handling, business logic, and database code from becoming tangled.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the scaffolding plugin — 39 skills, 9 commands, 13 agents shipped together

Good fit Building Python routes, database models, request and response schemas, services, and asynchronous backend operations.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/komluk/scaffolding/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 komluk/scaffolding --skill python-patterns
Clone the repo
git clone --depth 1 https://github.com/komluk/scaffolding

Made for: Claude Code.

Or install scaffolding, the plugin that ships this one along with the rest of its 39 skills, 9 commands, 13 agents.

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/komluk/scaffolding/python-patterns/github.svg)](https://agentmods.dev/skills/komluk/scaffolding/python-patterns)
Your own site
<a href="https://agentmods.dev/skills/komluk/scaffolding/python-patterns"><img src="https://agentmods.dev/badge/skills/komluk/scaffolding/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/komluk/scaffolding/python-patterns"><img src="https://agentmods.dev/badge/skills/komluk/scaffolding/python-patterns.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 73 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,349 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.
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.00073 $0.01349
Opus 5.5 $0.00029 $0.00540
Sonnet 5.5 $0.00015 $0.00270
Haiku 4.5 $0.00007 $0.00135

Measured 1mo ago against content hash 0c7dbe8e3f82, 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.

skills/python-patterns/SKILL.md · 208 lines

How it starts

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

Python Backend Patterns Skill

Purpose

Best practices for Python backend development: layered architecture, async I/O, dependency injection, and clear separation between HTTP handling, business logic, and data access. The concrete examples below use FastAPI, SQLAlchemy, and Pydantic, but the patterns apply to any Python web framework, ORM, and validation library.

Auto-Invoke Triggers

  • Creating backend routes / endpoints
  • Working with ORM models
  • Implementing async operations
  • Creating request/response validation schemas

Layer Responsibilities

Layer Responsibility
Endpoints HTTP handling, request/response
Services Business logic, orchestration
Repositories Data access, queries
Models Database schema
Schemas Data validation, serialization

These layers are framework-agnostic — keep HTTP concerns, business rules, and data access in separate modules regardless of which framework/ORM you use.


Example: FastAPI + SQLAlchemy + Pydantic (illustrative)

Illustrative — this is one concrete stack shown as an example. Substitute your framework's equivalents (any ASGI/WSGI framework, ORM, and validation library). The layering and separation-of-concerns patterns above are the reusable part.

Project Structure

app/
└── backend/
    ├── app/
    │   ├── main.py              # FastAPI app initialization
    │   ├── config.py            # Settings (pydantic-settings)
    │   ├── api/v1/endpoints/    # Route handlers
    │   ├── core/                # Security, exceptions
    │   ├── models/              # SQLAlchemy models
    │   ├── schemas/             # Pydantic schemas
    │   ├── services/            # Business logic
    │   ├── repositories/        # Data access
    │   └── db/session.py        # Database session
    ├── tests/
    ├── alembic.ini
    └── requirements.txt

Async Database Patterns

Session Management

  • Use async_sessionmaker for async sessions
  • Use dependency injection for session
  • Commit in dependency, rollback on exception
  • Use expire_on_commit=False for response data

Read the full file on GitHub · 208 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 · 208 lines · 73 tokens per session scan A 0c7dbe8e3f82

Subscribe to this mod's changes

python-patterns is a skill published in the GitHub repository komluk/scaffolding (15 stars, last pushed yesterday), licensed MIT. It adds 73 tokens to every session and 1,349 once invoked, about $0.0003 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 Clean Architecture

This skill should be used when the user asks to "scaffold a FastAPI project", "set up clean architecture", "refactor to clean architecture", "add a new endpoint", "add a router", "add an operation", "add a repository", "review my code structure", "apply design patterns in Python", "decouple my code", "improve code…

MKToronto/python-clean-architecture · 112 tokens

python-backend

Production Python async patterns including asyncio TaskGroup, FastAPI dependency injection and middleware, SQLAlchemy 2.0 async sessions, and database connection pool tuning. Python 3.11+ runtime concerns such as ExceptionGroup, cancellation semantics, and session rollback. Use when building async services, wiring…

yonatangross/orchestkit · 82 tokens

cloudflare-workers-multi-lang

Multi-language Workers development with Rust, Python, and WebAssembly. Use when building Workers in languages other than JavaScript/TypeScript, or when integrating WASM modules for performance-critical code.

secondsky/claude-skills · 45 tokens

functions-development

Build serverless Go or Python functions for Falcon Foundry apps. TRIGGER when user asks to "create a function", "write a serverless function", "build backend logic", runs foundry functions create, or needs help with FDK handler patterns, function testing, or collection integration from functions. Also TRIGGER when…

CrowdStrike/foundry-skills · 195 tokens

python-services

Python patterns for CLI tools, async parallelism, and backend services. Use when building CLI apps, async/parallel Python, FastAPI services, background jobs, or configuring Python project tooling (uv, ruff, ty).

iliaal/whetstone · 48 tokens

litestar

Auto-activate for Litestar, Controller, Router, @get/@post, FromPath, MsgspecDTO, OpenAPIConfig, Provide, FromDishka, Guard, ASGIMiddleware, HTTPException, ChannelsPlugin, or WebSocket. Not for standalone libs.

litestar-org/litestar-skills · 58 tokens