pythonic-patterns

pythonic-patterns is a skill for Claude Code from VersoXBT/claude-initial-setup. It costs 71 tokens per session (1,557 once invoked), scanned A, original, MIT.

A guide to common Python ways of writing concise and readable code, including comprehensions, generators, context managers, decorators, and dataclasses.

In plain words
What is it for?
Use it to refactor loops, process large iterables, manage resources, define simple data objects, and write reusable wrappers.
Why use it?
It helps replace repetitive code with standard Python patterns that are easier to read and maintain.

Skill for Claude Code

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

Part of the claude-initial-setup plugin — 75 skills, 15 commands, 14 agents, 2 hooks shipped together

Good fit Use it to refactor loops, process large iterables, manage resources, define simple data objects, and write reusable wrappers.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/versoxbt/claude-initial-setup/pythonic-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 VersoXBT/claude-initial-setup --skill pythonic-patterns
Clone the repo
git clone --depth 1 https://github.com/VersoXBT/claude-initial-setup

Made for: Claude Code.

Or install claude-initial-setup, the plugin that ships this one along with the rest of its 75 skills, 15 commands, 14 agents, 2 hooks.

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 pythonic-patterns

README.md
[![agentmods](https://agentmods.dev/badge/skills/versoxbt/claude-initial-setup/pythonic-patterns/github.svg)](https://agentmods.dev/skills/versoxbt/claude-initial-setup/pythonic-patterns)
Your own site
<a href="https://agentmods.dev/skills/versoxbt/claude-initial-setup/pythonic-patterns"><img src="https://agentmods.dev/badge/skills/versoxbt/claude-initial-setup/pythonic-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 pythonic-patterns

Your own site · 80×15
<a href="https://agentmods.dev/skills/versoxbt/claude-initial-setup/pythonic-patterns"><img src="https://agentmods.dev/badge/skills/versoxbt/claude-initial-setup/pythonic-patterns.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 71 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,557 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.00071 $0.01557
Opus 5.5 $0.00028 $0.00623
Sonnet 5.5 $0.00014 $0.00311
Haiku 4.5 $0.00007 $0.00156

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

Security

Grade A, and why

pythonic-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 2mo 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/pythonic-patterns/SKILL.md · 230 lines

How it starts

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

Pythonic Patterns

Write idiomatic Python that leverages the language's expressive power. Pythonic code is concise, readable, and uses built-in constructs instead of reinventing them.

When to Use

  • User writes Python loops that could be comprehensions
  • User asks for "Pythonic" or "idiomatic" Python
  • Refactoring Python code for readability
  • User works with iterables, files, or resource management
  • User defines simple data containers or wrapper functions

Core Patterns

List Comprehensions and Generator Expressions

Use comprehensions for transforming and filtering sequences. Use generator expressions for large datasets to avoid materializing the entire list in memory.

# Comprehension with filtering
active_emails = [user.email for user in users if user.is_active]

# Dict comprehension
scores_by_name = {s.name: s.score for s in students}

# Set comprehension for deduplication
unique_domains = {email.split("@")[1] for email in emails}

# Generator expression for large data -- lazy evaluation
total = sum(order.amount for order in orders if order.status == "paid")

# Nested comprehension (keep it readable -- max 2 levels)
flat = [cell for row in matrix for cell in row]

Generators and Iterators

Use generators when you need lazy evaluation, infinite sequences, or pipeline processing.

def read_chunks(file_path: str, chunk_size: int = 8192):
    """Yield file chunks without loading entire file into memory."""
    with open(file_path, "rb") as f:
        while chunk := f.read(chunk_size):
            yield chunk

def fibonacci():
    """Infinite Fibonacci generator."""
    a, b = 0, 1
    while True:
        yield a
        a, b = b, a + b

# Pipeline processing with generators
def process_pipeline(records):
    cleaned = (clean(r) for r in records)
    validated = (r for r in cleaned if is_valid(r))
    transformed = (transform(r) for r in validated)
    yield from transformed

Context Managers

Use context managers for any resource that needs setup/teardown. Prefer contextlib for simple cases.

Read the full file on GitHub · 230 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. 2mo ago First seen · 230 lines · 71 tokens per session scan A 7e995acd4d2e

Subscribe to this mod's changes

pythonic-patterns is a skill published in the GitHub repository VersoXBT/claude-initial-setup (4 stars, last pushed 6mo ago), licensed MIT. It adds 71 tokens to every session and 1,557 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-09-03.

Related

pythonic-patterns compared with skills from other repositories

pythonic-patterns next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
pythonic-patternsVersoXBT/claude-initial-setupSkill46mo agoMITA71Claude Code
fastapi-templateswshobson/agentsSkill43k6d agoMITA37Claude Code
temporal-python-testingwshobson/agentsSkill43k6d agoMITA45Claude Code
py-debugberekvolgyipeter/dotclaudeSkill2yesterdayMITA54Claude Code, Codex
python-conventionstmj-90/gafferSkill1yesterdayApache-2.0A120Claude Code, Codex
sota-pythonmartinholovsky/SOTA-skillsSkill31yesterdayCC-BY-4.0A141Claude Code
python-expertApexIQ/skillsmithSkill58mo agoMITA47Claude Code, Codex