python-modernization-sweep

python-modernization-sweep is a skill for Claude Code, Codex from chen3feng/agent-skills. It costs 37 tokens per session (4,798 once invoked), scanned A, original, Apache-2.0.

A plan for updating an older Python codebase to use modern Python 3 syntax and type hints after support for an older interpreter has ended. It divides the work into small mechanical pull requests rather than one large change.

In plain words
What is it for?
Use it to replace older Python patterns such as explicit superclass calls and old string formatting, adopt newer generics or language features, and add type hints without introducing bug fixes.
Why use it?
A single modernization change can be difficult to review and may mix style updates with bug fixes. Splitting the work makes each change easier to check and keeps the sweep focused on syntax and annotations.

Skill for Claude CodeCodex

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

Good fit Use it to replace older Python patterns such as explicit superclass calls and old string formatting, adopt newer generics or language features, and add type hints without introducing bug fixes.

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

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-modernization-sweep

README.md
[![agentmods](https://agentmods.dev/badge/skills/chen3feng/agent-skills/python-modernization-sweep/github.svg)](https://agentmods.dev/skills/chen3feng/agent-skills/python-modernization-sweep)
Your own site
<a href="https://agentmods.dev/skills/chen3feng/agent-skills/python-modernization-sweep"><img src="https://agentmods.dev/badge/skills/chen3feng/agent-skills/python-modernization-sweep/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-modernization-sweep

Your own site · 80×15
<a href="https://agentmods.dev/skills/chen3feng/agent-skills/python-modernization-sweep"><img src="https://agentmods.dev/badge/skills/chen3feng/agent-skills/python-modernization-sweep.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 37 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 4,798 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. 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.00037 $0.04798
Opus 5.5 $0.00015 $0.01919
Sonnet 5.5 $0.00007 $0.00960
Haiku 4.5 $0.00004 $0.00480

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

Security

Grade A, and why

python-modernization-sweep scanned grade A with 1 finding 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.

Runs shell commandslowCapability

Expected in a hook, worth knowing in a rule or an instructions file.

# PLW1510 on a subprocess.run that returns returncode.
skills/python-modernization-sweep/SKILL.md · 401 lines

How it starts

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

Python modernization sweep

When to use

You own a Python codebase that has just dropped support for an old interpreter (Py2, or <3.10), and you want to actually use the newer language features that dropping support unlocked: f-strings, super(), PEP 585 generics, match statements, type hints, etc.

Signals this skill applies:

  • The user says "全面拥抱 Py3 新特性", "modernize this codebase", "clean up the Py2 shim residue", or similar.
  • The repo still has super(Cls, self), class X(object):, '%s' % x, u'...' literals, IOError/EnvironmentError, etc.
  • There is no (or patchy) type-hint coverage, and the user wants to start adding hints.

This is different from [python-code-audit-sweep] (which finds latent bugs with pyflakes + grep and splits them into bug / dead-code / style PRs). A modernization sweep introduces no bug fixes; every change is either a pure AST-level rewrite or a new type annotation.

Problem

The naive approach is one giant "modernize.py" PR that does everything at once:

  • f-string rewrites for every % and .format() call (often hundreds of sites).
  • super() call modernization.
  • Dropping (object) base class.
  • Adding type hints to every public function.
  • Killing deps=[] mutable-default args.
  • Turning except IOError into except OSError.

Reviewers cannot tell what is mechanical and what is semantic. The type-hint portion alone needs slow review; the f-string portion is 300 identical rewrites that no human should read line by line. They merge into one blob, one reviewer blocks on the hardest single line, and the whole modernization stalls for weeks.

A second failure mode: guessing what's in the repo. Without a tool-assisted census, you don't know whether f-string rewrites are 20 sites or 400, whether there are 3 mutable-default anti-patterns or 167, whether super() rewrites are AST-safe or whether something is calling a sibling class's __init__ manually. Picking tools before counting is how you end up writing manual sed scripts for something pyupgrade --py310-plus would do in one command.

Read the full file on GitHub · 401 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 · 401 lines · 37 tokens per session scan A 6ebb4a8a8317

Subscribe to this mod's changes

python-modernization-sweep is a skill published in the GitHub repository chen3feng/agent-skills (5 stars, last pushed 5mo ago), licensed Apache-2.0. It adds 37 tokens to every session and 4,798 once invoked, about $0.0001 per session on Opus 5.5. A static security scan graded it A with 1 finding (runs shell commands). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

cuga-contributor-workflows

Run CUGA contributor workflows: Conventional Commits, create pull requests against origin with gh and PR templates, and ruff check/format via uv. Use when the user says commit, create a commit, create PR, pull request, open a PR, ruff check, ruff format, or conventional commits.

cuga-project/cuga-agent · 71 tokens

git-workflow

Git operations: commits, branches, PRs, and conflict resolution.

vstorm-co/pydantic-deepagents · 17 tokens

refactoring-python

Use when refactoring or modernizing existing Python code without changing behavior: splitting a long function or module, removing drifted duplication, isolating I/O behind a port to make code testable, replacing Java-style classes with idiomatic Python, or judging whether an interface is over-engineering. Triggers…

fgmacedo/agent-skills · 122 tokens

marketing-council-pack-conventions

Development conventions and patterns for marketing-council-pack. Python project with conventional commits.

imMamdouhaboammar/marketing-council-pack · 25 tokens

marimo-pair

Work inside the user's live marimo notebook from the code editor: run Python in the same kernel the user does, inspect live notebook state, and commit durable notebook changes through code mode. Use whenever you create, analyze, or improve the user's marimo notebook.

marimo-team/marimo · 57 tokens

safety

Check secret handling, staged changes and push targets, destructive Git operations, Docker image hygiene, and new dependencies before consequential coding actions. Use for commits, pushes, container builds or publishes, dependency additions, and explicit safety reviews.

langchain-ai/deepagents · 48 tokens