python-anti-patterns
Skill0 starsChanged 5 months agoApache-2.0View on GitHub
Trigger: anti-patterns, import order, file too long, split module, unrelated functions, hardcoded values, magic values, module constants, extract constants, future annotations import. Enforce battle-tested Python module-organization rules.
8 other projects use a version of this.
Adopted by
Most recently taken up by
- zebbern/pocmaptheir own version, first seen Nov 8, 2026
- ControllableModel/SWE-Skills-Benchtheir own version, first seen Nov 8, 2026
- liushikuan63/Qoder-Optimizationtheir own version, first seen Nov 1, 2026
- drzioner/gitwisetheir own version, first seen Jul 22, 2026
- NorkzYT/claude-code-autopilottheir own version, first seen Jun 11, 2026
- gabepublic/api-autonom-test-01their own version, first seen Apr 24, 2026
Other versions8 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 8
- ControllableModel/SWE-Skills-Bench★ 8same name
- zebbern/pocmap★ 7same name
- zebbern/termstack★ 4same name
- CodeWithBehnam/cc-docs★ 2same name
- liushikuan63/Qoder-Optimization★ 2same name
- NorkzYT/claude-code-autopilot★ 2same name
- drzioner/gitwise★ 1same name
- gabepublic/api-autonom-test-01★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository5 other files it gives its agents.
- AGENTS.mdAGENTS.md
- python-clean-codeSkill
- python-code-reviewSkill
- python-design-principlesSkill
- python-testing-tddSkill
The file
We split this skill into the rules it gives an agent
2 rules. 0 are common, 1 is distinctive, and 1 is very specific to this project.
0
Common
Most of the 8 edited versions we read keep these.
1
Distinctive
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 21
No reflexive
from __future__ import annotations: do not add it by default; in most modules it is noise. - Distinctive: line 24
No hardcoded values: never inline literals (URLs, paths, thresholds, column names, magic numbers/strings) in logic.
“Common” is measured: kept by at least 6 in 10 of the 8 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Python Anti-Patterns
Prescriptive module-organization rules learned in practice. These are enforced engineering standards, not style preferences: apply them on every Python file touched.
Activation Contract
Apply when writing or reviewing any Python module: checking import order, file size, module cohesion, hardcoded values, or where constants live. Flag every violation below; do not wait to be asked.
Hard Rules
- Import order (custom convention): first all
import xstatements (alphabetical), thenfrom x import ...for stdlib/third-party, then a blank line, then first-partyfrom core...imports. No blank line between theimportblock and the non-localfromblock. Seereferences/import-order.md. NOTE: ruff's isort (I) rule reverts this: disableIin the linter config or it overwrites the skill. - No reflexive
from __future__ import annotations: do not add it by default; in most modules it is noise. Keep it ONLY when load-bearing: annotations that referenceTYPE_CHECKING-guarded imports (to break import cycles) or forward references you would otherwise have to quote. Remove it everywhere else. - File length: ~300 lines is a hard smell. Split by responsibility before that. A long file almost always hides multiple concerns.
- Module cohesion: functions with no relationship to the module's purpose must be extracted to their own module. One module = one cohesive concern.
- No hardcoded values: never inline literals (URLs, paths, thresholds, column names, magic numbers/strings) in logic. Name them.
- Separate constants from logic (discriminant): domain/config constants (geometry, thresholds, URLs, column names, labels) must NOT sit atop a logic module, even if few or single-use. Move them to a dedicated
constants.py, or to aconstants/subpackage with one module per category (constants/layout.py,constants/routing.py) when they are many or span categories. EXCEPTION: a value meaningful only inside one algorithm (a private sentinel, an internal state marker) stays local: model it as a localEnumor a_privateconstant in that module, never hoisted to the shared constants surface. The deciding test: would this constant mean anything to another module? Yes, centralize it. No (algorithm-internal), keep it local and prefer anEnum.
Decision Gates
| Symptom | Fix |
| Imports mixed/misordered | Reorder per the custom convention above |
from __future__ import annotations with no TYPE_CHECKING/forward-ref need | Remove it |
| File approaching ~300 lines | Split by responsibility into separate modules |
| Function unrelated to module purpose | Extract to its own module |
| Literal inside logic | Replace with a named constant |
| Domain/config constant atop a logic module | Move to constants.py (or constants/<category>.py), import it |
| Many constants spanning categories | constants/ subpackage, one module per category |
| Private algorithm-internal value (sentinel/state) | Keep local; prefer an Enum over a bare string |
Execution Steps
- Scan the module against each gate; list every hit with
file:line. - Fix imports first (cheap, mechanical), then move domain/config constants to
constants.py(or aconstants/<category>.pysubpackage), keeping algorithm-internal values local, then split oversized/incohesive files. - Replace each hardcoded literal with an imported named constant.
- Confirm each remaining module has a single cohesive concern.
# Bad: hardcoded + local constant + mixed imports
from core.utils.logger import get_logger
import requests
TIMEOUT = 30
def fetch(): requests.get("https://api.inegi.org.mx/data", timeout=TIMEOUT)
# Good: named, centralized, ordered
# constants.py
INEGI_DATA_URL = "https://api.inegi.org.mx/data"
REQUEST_TIMEOUT_SECONDS = 30
# module.py
import requests
from core.constants import INEGI_DATA_URL, REQUEST_TIMEOUT_SECONDS
from core.utils.logger import get_logger
def fetch():
return requests.get(INEGI_DATA_URL, timeout=REQUEST_TIMEOUT_SECONDS)Output Contract
Return the corrected module(s) with imports reordered, domain/config constants moved to constants.py (or a constants/<category>.py subpackage) while algorithm-internal values stay local as Enums, hardcoded values named, and oversized/incohesive files split. Cite each violation by file:line.
References
references/import-order.md: the custom import-ordering convention with full examples.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

