improving-python-code-quality

improving-python-code-quality is a skill for Claude Code, Codex from CHENyiru3/AI-Skills-Collections. It costs 71 tokens per session (937 once invoked), scanned A, original, MIT.

A guide to improving the maintainability of Python code with formatting, lint checks, type annotations, and targeted refactoring. It uses Ruff and mypy to find style, type, and common code problems.

In plain words
What is it for?
Use it to lint and format Python projects, add or repair type hints, configure static analysis, and remove Python patterns that can cause bugs.
Why use it?
It catches many mistakes before they reach users and makes code easier to read and change. Clearer types and consistent checks also reduce uncertainty when working in a shared codebase.

Skill for Claude CodeCodex

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

Good fit Use it to lint and format Python projects, add or repair type hints, configure static analysis, and remove Python patterns that can cause bugs.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/chenyiru3/ai-skills-collections/code-quality
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 CHENyiru3/AI-Skills-Collections --skill code-quality
Clone the repo
git clone --depth 1 https://github.com/CHENyiru3/AI-Skills-Collections

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 improving-python-code-quality

README.md
[![agentmods](https://agentmods.dev/badge/skills/chenyiru3/ai-skills-collections/code-quality/github.svg)](https://agentmods.dev/skills/chenyiru3/ai-skills-collections/code-quality)
Your own site
<a href="https://agentmods.dev/skills/chenyiru3/ai-skills-collections/code-quality"><img src="https://agentmods.dev/badge/skills/chenyiru3/ai-skills-collections/code-quality/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 improving-python-code-quality

Your own site · 80×15
<a href="https://agentmods.dev/skills/chenyiru3/ai-skills-collections/code-quality"><img src="https://agentmods.dev/badge/skills/chenyiru3/ai-skills-collections/code-quality.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 937 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.00071 $0.00937
Opus 5.5 $0.00028 $0.00375
Sonnet 5.5 $0.00014 $0.00187
Haiku 4.5 $0.00007 $0.00094

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

Security

Grade A, and why

improving-python-code-quality 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 6d 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.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

def fetch(url: str, timeout: int | None = None) -> bytes: ...
skills-market/programming/python/code-quality/SKILL.md · 136 lines

How it starts

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

Python Code Quality

Quick Reference

Tool Purpose Command
ruff Lint + format ruff check src && ruff format src
mypy Type check mypy src

Ruff Configuration

Minimal config in pyproject.toml:

[tool.ruff]
line-length = 88
target-version = "py310"

[tool.ruff.lint]
select = ["E", "W", "F", "I", "B", "C4", "UP"]

For full configuration options, see RUFF_CONFIG.md.

MyPy Configuration

[tool.mypy]
python_version = "3.10"
disallow_untyped_defs = true
warn_return_any = true

For strict settings and overrides, see MYPY_CONFIG.md.

Type Hints Patterns

# Basic
def process(items: list[str]) -> dict[str, int]: ...

# Optional
def fetch(url: str, timeout: int | None = None) -> bytes: ...

# Callable
def apply(func: Callable[[int], str], value: int) -> str: ...

# Generic
T = TypeVar("T")
def first(items: Sequence[T]) -> T | None: ...

For protocols and advanced patterns, see TYPE_PATTERNS.md.

Common Anti-Patterns

# Bad: Mutable default
def process(items: list = []):  # Bug!
    ...

# Good: None default
def process(items: list | None = None):
    items = items or []
    ...
# Bad: Bare except
try:
    ...
except:
    pass

# Good: Specific exception
try:
    ...
except ValueError as e:
    logger.error(e)

Pythonic Idioms

# Iteration
for item in items:           # Not: for i in range(len(items))
for i, item in enumerate(items):  # When index needed

# Dictionary access
value = d.get(key, default)  # Not: if key in d: value = d[key]

# Context managers
with open(path) as f:        # Not: f = open(path); try: finally: f.close()

# Comprehensions (simple only)
squares = [x**2 for x in numbers]

Module Organization

src/my_library/
├── __init__.py      # Public API exports
├── _internal.py     # Private (underscore prefix)
├── exceptions.py    # Custom exceptions
├── types.py         # Type definitions
└── py.typed         # Type hint marker

Read the full file on GitHub · 136 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. 6d ago First seen · 136 lines · 71 tokens per session scan A 86458d38ad93

Subscribe to this mod's changes

improving-python-code-quality is a skill published in the GitHub repository CHENyiru3/AI-Skills-Collections (1 stars, last pushed 7d ago), licensed MIT. It adds 71 tokens to every session and 937 once invoked, about $0.0003 per session on Opus 5.5. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-10-02.