Code quality

From bobmatnyc/claude-mpm-skills · View interactive version

Code quality is an AI agent skill from the GitHub repository bobmatnyc/claude-mpm-skills. 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 def

How to use this skill

Skill file

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:

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:

inherits from object fails at runtime and breaks every except clause.

(PEP 8); use is only for singletons, never for value comparison.

generic except Exception only as a last-position fallback that logs or re-raises.

name collisions, and defeat static analysis.

documented, named constants.

bug where a value was meant to be used.

Best Practices

F841 unused locals, E711/E712 singleton comparison), pylint, and mypy. Put the

lint step in CI so review effort focuses on judgment, not mechanics.

generic except Exception for a logging/re-raising last resort.

bare literal documents nothing.

Anti-Patterns (What to Avoid)

Navigation

vs compliant examples and a "how to test" note for each of the six anti-patterns.

Related Skills

parametrization, mocking. Several anti-patterns here (broad except, malformed

exception classes) directly cause flaky tests.

project-wide, severity-tagged review checklist that incorporates equivalents of these.

health and technical-debt scoring, rather than individual findings.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.