Skip to main content
skill CX Codex

code-quality · bobmatnyc — Claude Code skill: Python review and setup

code-quality reviews Python for exception, comparison, import, constant, and dead-local issues. Use it for pull-request review or a self-check before committing.

MIT 221 installs ★ 80 updated 2026-07-18

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add bobmatnyc/claude-mpm-skills --skill code-quality -a claude-code
Open on GitHub

What code-quality does

code-quality targets six Python review findings: custom exceptions with the wrong base class, == used with singleton values, overly broad exception handlers, wildcard imports, unexplained numeric literals, and locals that are assigned but never read. It focuses on code correctness and readability rather than test execution or whole-repository scoring.

The skill connects these checks with guidance for ruff, pylint, and mypy, so teams can enforce them in CI. Its reference file, quality-antipatterns.md, contains compliant and non-compliant examples for each category. A custom exception inheriting from object will fail when raised and cannot support the expected except handling.

It is available for Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, and OpenCode. In Claude Code, the installed skill file is ~/.claude/skills/code-quality/SKILL.md.

What it helps with

  • check custom exception inheritance
  • spot == comparisons with None, True, or False
  • replace bare and overly broad exception handlers
  • remove wildcard imports and unexplained numeric literals
  • find assigned locals that are never read

Example prompts for the agent

  • Review this Python code for the code-quality anti-patterns and explain each finding.
  • Before I open a pull request, check for broad except clauses, singleton comparisons, wildcard imports, and unused locals.
  • Suggest ruff, pylint, and mypy rules that enforce these checks in CI.

How to install code-quality

1Skills CLI (Vercel)

npx skills add bobmatnyc/claude-mpm-skills --skill code-quality -a claude-code

2Manually: put the files in place

~/.claude/skills/code-quality/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/code-quality/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about code-quality

How do I install code-quality in Claude Code?

Run npx skills add bobmatnyc/claude-mpm-skills --skill code-quality -a claude-code, then check ~/.claude/skills/code-quality/SKILL.md.

What does code-quality do?

It reviews Python for exception hierarchy errors, incorrect singleton comparisons, broad exception handling, wildcard imports, magic numbers, and dead local assignments.

How is code-quality different from pytest and code-quality-scoring?

This skill reviews individual correctness and readability issues. pytest covers testing mechanics, while code-quality-scoring scores the health and technical debt of a whole codebase.

Source text

SKILL.md · MIT
---
name: code-quality
description: "Python code-quality anti-patterns and review checks: exception-hierarchy correctness, singleton identity comparison, narrow exception handling, wildcard-import avoidance, magic-number naming, and dead-local removal. Use when reviewing or self-reviewing Python code for correctness and readability defects that linters and reviewers should catch."
user-invocable: false
disable-model-invocation: true
version: 1.0.0
updated: "2026-06-15"
category: toolchain
author: Claude MPM Team
license: MIT
progressive_disclosure:
  entry_point:
    summary: "Catch high-value Python code-quality anti-patterns in review: malformed exception classes, == None vs is None, bare except, wildcard imports, magic numbers, unused locals"
    when_to_use: "When reviewing or self-reviewing Python code for correctness/readability defects, configuring ruff/pylint rules, or writing code-quality guidance — not for testing mechanics (use pytest) or whole-codebase scoring (use code-quality-scoring)"
    quick_start: "1. Ensure custom exceptions derive from Exception 2. Compare None/True/False with is, not == 3. Catch the narrowest exception you can handle, never bare except 4. Replace wildcard imports with explicit names 5. Name magic numbers as constants 6. Remove unused locals — enforce all six with ruff/pylint/mypy in CI"
  references:
    - quality-antipatterns.md
context_limit: 600
tags:
  - python
  - code-quality
  - anti-patterns
  - code-review
  - pep8
  - ruff
  - pylint
  - static-analysis
requires_tools: []
---

# Python Code Quality

High-value Python code-quality anti-patterns to check during review or self-review.
This skill is **review-focused**: it covers correctness and readability defects that a
reviewer (or a linter) should flag, separate from testing mechanics (`pytest`) and
whole-codebase health scoring (`code-quality-scoring`).

> **Source note:** These anti-patterns are derived from CAST Highlight's Python code
> quality indicators (https://doc.casthighlight.com/), which reference **PEP 8** and the
> Python data model as primary sources. Where a rule mirrors PEP 8, the PEP is the
> authoritative source. All examples are original.

## When to Use This Skill

Use it when the task is **"is this Python code clean and correct?"** — for example:

- Reviewing a pull request and checking for the defects below.
- Self-reviewing before opening a PR.
- Configuring `ruff`/`pylint`/`mypy` rules so CI catches these automatically.
- Writing or updating a team's Python code-quality guidance.

Do **not** use it for testing mechanics (use the `pytest` skill) or for scoring a whole
codebase's health and technical debt (use the `code-quality-scoring` skill).

## Core Anti-Patterns (Summary)

Six highest-value Python anti-patterns. Each has a non-compliant/compliant example and a
"how to test" note in the reference doc:

- **Custom exceptions must derive from `Exception`** — a class meant to be raised that
  inherits from `object` fails at runtime and breaks every `except` clause.
- **Compare singletons with `is`, not `==`** — use `is`/`is not` for `None`/`True`/`False`
  (PEP 8); use `is` *only* for singletons, never for value comparison.
- **Avoid bare / overly broad `except`** — catch the narrowest type you can handle; a
  generic `except Exception` only as a last-position fallback that logs or re-raises.
- **Avoid wildcard imports** (`from x import *`) — they hide dependencies, risk silent
  name collisions, and defeat static analysis.
- **Replace magic numbers with named constants** — promote non-obvious literals to
  documented, named constants.
- **Remove unused local variables** — a dead assignment misleads readers and can hide a
  bug where a value was meant to be used.

## Best Practices

- **Gate these in CI.** Most are enforceable cheaply with `ruff` (F403/F405 wildcard,
  F841 unused locals, `E711`/`E712` singleton comparison), `pylint`, and `mypy`. Put the
  lint step in CI so review effort focuses on judgment, not mechanics.
- **Prefer specific exception handlers.** Order handlers narrowest-first; reserve a
  generic `except Exception` for a logging/re-raising last resort.
- **Name intent, not values.** A constant's *name* documents why a threshold exists; a
  bare literal documents nothing.

## Anti-Patterns (What to Avoid)

- Inheriting custom exceptions from `object` or directly from `BaseException`.
- `== None`, `== True`, or `is "some literal"`.
- Bare `except:` or `except BaseException:` that swallows control-flow signals.
- `from module import *` outside a curated `__init__.py` with explicit `__all__`.
- Unexplained numeric literals in business logic.
- Assigned-but-never-read locals left behind by a stale refactor.

## Navigation

- **[quality-antipatterns.md](references/quality-antipatterns.md)**: Full non-compliant
  vs compliant examples and a "how to test" note for each of the six anti-patterns.

## Related Skills

- **pytest** (`toolchains/python/testing/pytest`): testing mechanics — fixtures,
  parametrization, mocking. Several anti-patterns here (broad `except`, malformed
  exception classes) directly cause flaky tests.
- **code-review-standards** (`universal/process/code-review-standards`): the
  project-wide, severity-tagged review checklist that incorporates equivalents of these.
- **code-quality-scoring** (`universal/quality/code-quality-scoring`): whole-codebase
  health and technical-debt scoring, rather than individual findings.

© Claude MPM Team · MIT · bobmatnyc/claude-mpm-skills

Similar skills

All skills for Code review and refactoring →

code-quality by other authors comes first.

code-quality tursodatabase code-quality is a Claude Code skill that gives coding agents correctness rules, Rust patterns, and guidance against over-engineering in your repo. CX Codex +1 1,800installs code-quality miles990 code-quality guides AI coding agents through clean code practices, SOLID principles, and refactoring techniques during reviews. CX Codex +1 786installs code-quality cognitedata code-quality reviews TypeScript and React codebases against strict typing rules, component size limits, and lint baselines. Runs after feature work or before pull request reviews. CX Codex +1 2,000installs code-quality zernie code-quality — a skill for refactoring TypeScript and JavaScript: tightens types, removes impossible states, and separates logic from IO. CX Codex +1 392installs Python Code Performance & Quality Enhancer sivasaiyadav8143 Python Code Performance & Quality Enhancer — a review prompt for Python: adds docstrings, fixes PEP8, lists performance issues with Big O impact, and returns the full rewritten file. GP ChatGPT ★ 178,201repo stars python-anti-patterns Seth Hobson python-anti-patterns — a checklist skill for common Python mistakes. The agent runs it over your code before merge or while debugging. CX Codex +1 13,278installs python-patterns affaan-m python-patterns tells the agent how to write and review Python: idioms, type hints, exception handling, context managers. CX Codex +1 7,500installs python-code-review existential-birds The python-code-review skill inspects Python source files for PEP8 compliance, type annotations, async pitfalls, and exception patterns. It helps spot issues before opening a pull request. CX Codex +1 958installs test-anti-patterns dotnet test-anti-patterns scans test files for anti-patterns: assertions that verify nothing, swallowed exceptions, order-dependent tests, magic values. Works across languages, ranks findings by severity. CX Codex +1 5,600installs m15-anti-pattern actionbook m15-anti-pattern reviews Rust code for anti-patterns and points to idiomatic replacements. Use it during code review or when ownership and error handling become hard to reason about. CX Codex +1 9,500installs

From the same set143

The whole set →

Project sponsors

Companies that keep this analytics open