python

A general Python engineering guide for writing, testing, profiling, optimizing, and structuring Python code.

In plain words
What is it for?
Writing scripts, diagnosing CPU or memory problems, creating unit, integration, asynchronous, or property-based tests, and choosing between composition, inheritance, and dependency injection.
Why use it?
It provides patterns for finding performance bottlenecks, creating reliable pytest tests, and keeping components simple and maintainable.

Skill for Claude CodeCodex

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.

agentmods
npx agentmods add skills/secondlifes/code-intel/python
Any agent
npx skills add SecondLifes/code-intel --skill python
Clone the repo
git clone --depth 1 https://github.com/SecondLifes/code-intel

Made for: Claude Code, Codex.

Per session 67 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 763 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin 100% copy Near-identical to another mod 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 $0.00067 $0.00763
Opus 5 $0.00034 $0.00381
Sonnet 5 $0.00013 $0.00153
Haiku 4.5 $0.00007 $0.00076

Measured yesterday against content hash 85ae1ce2af1d, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

python 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 yesterday.

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.

Origin

This is a copy

100% identical to python — 0 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

.agents/skills/python/SKILL.md · 47 lines

How it starts

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

Python

Consolidated from three separately-sourced skills (wshobson/agents: python-performance-optimization, python-testing-patterns, python-design-patterns — reviewed for correctness, no issues found) into one, per this workspace's "one skill per topic" policy.

When to Use

  • Writing an ad-hoc Python script to accomplish a task (data processing, file manipulation, automation, validation)
  • Identifying and fixing performance bottlenecks (CPU, memory, I/O)
  • Writing or reviewing tests (unit, integration, async, property-based)
  • Designing a new component/service or refactoring a tangled one
  • Deciding between inheritance and composition, or whether to add an abstraction

Usage

You say What happens
"Write a script to parse these CSVs" / ad-hoc helper script request Applies the Golden Rules directly (simplicity first, single responsibility) — no reference file needed for a small script.
"This function is slow, why?" / "Bu kodu optimize et" Loads references/performance.md — profiles with cProfile/py-spy first, then applies the matching optimization pattern.
"Write tests for this" / "Şunun için pytest yaz" Loads references/testing.md — fixtures, mocking, async tests, property-based testing as the case requires.
"Refactor this class" / "Composition mi inheritance mi kullanmalıyım?" Loads references/design-patterns.md — SRP, composition-over-inheritance, Rule of Three, dependency injection.

Golden Rules

  • Profile before optimizing. Measure with cProfile/py-spy first — don't guess at bottlenecks.
  • Simplicity first (KISS). Choose the simplest solution that works; complexity must be justified by concrete requirements.
  • Single Responsibility. Each function/class has one reason to change — separate HTTP parsing, business logic, and data access.
  • Compose, don't inherit for flexibility and testability; inject dependencies through constructors.
  • Rule of Three — don't abstract until you have three real instances of the duplication; a wrong abstraction is worse than repetition.
  • Test in isolation. Fakes/mocks for external dependencies; never hit a real database in unit tests.
  • Use built-ins and generators for large datasets; prefer dict/set lookups over list scans.

Read the full file on GitHub · 47 lines

Files

What ships with it

3 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

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. yesterday First seen · 47 lines · 67 tokens per session scan A 85ae1ce2af1d

Subscribe to this mod's changes

python is a skill published in the GitHub repository SecondLifes/code-intel (2 stars, last pushed 21d ago), licensed Apache-2.0. It adds 67 tokens to every session and 763 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. It is 100% identical to python, differing in 0 lines, and is treated as a copy.

Related

Other skills, from other repositories

systematic-debugging

Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes.

obra/superpowers · 21 tokens

next-cache-components-adoption

Turn on Cache Components in a Next.js app and resolve the blocking routes it surfaces. Use when the user wants to enable, adopt, or migrate to Cache Components, flip the cacheComponents flag, work through a flood of blocking-prerender / instant validation errors, run the cache-components-instant-false codemod, or…

vercel/next.js · 95 tokens

babysit-pr

Babysit a GitHub pull request after creation by continuously polling review comments, CI checks/workflow runs, and mergeability state until the PR is merged/closed or user help is required. Diagnose failures, retry likely flaky failures up to 3 times, auto-fix/push branch-related issues when appropriate, and keep…

openai/codex · 114 tokens

imagegen

Generate or edit raster images when the task benefits from AI-created bitmap visuals such as photos, illustrations, textures, sprites, mockups, or transparent-background cutouts. Use when Codex should create a brand-new image, transform an existing image, or derive visual variants from references, and the output…

openai/codex · 113 tokens

cpu-profile-analysis

Analyze V8/Chrome CPU profiles (.cpuprofile) and DevTools trace files (Trace-.json). Use when: profiling performance, investigating slow functions, comparing code paths, finding bottlenecks, analyzing timeToRequest, understanding call trees from sampling profiler data, analyzing layout/paint/rendering, investigating…

microsoft/vscode · 71 tokens

next-cache-components-optimizer

Drive a Next.js route to instant navigation by setting up an agentic loop, under Cache Components / PPR, on initial load (hard navigation) and client-side navigation (soft navigation). Encode the goal as a failing @next/playwright instant() e2e and work it to green, one verified route at a time; the shipped test then…

vercel/next.js · 170 tokens