python-clean-code
Skill0 starsChanged 5 months agoApache-2.0View on GitHub
Trigger: clean code, readable Python, refactor, naming, comments, magic numbers, data classes, code smells, DRY, KISS, YAGNI. Make Python read like prose at the line and function level.
8 other projects use a version of this.
Adopted by
Most recently taken up by
- phanijapps/memextheir own version, first seen Oct 17, 2026
- ramybarsoum/claude-skillstheir own version, first seen Oct 13, 2026
- dathuynh1108/agent-skillstheir own version, first seen Oct 11, 2026
- FlorianBruniaux/google-search-console-mcptheir own version, first seen Oct 10, 2026
- Praveensenpai/karakuritheir own version, first seen Sep 13, 2026
- CasLubbers/code-design-skillstheir own version, first seen Aug 25, 2026
Other versions8 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 8
- ertugrul-dmr/clean-code-skills★ 193same name
- FlorianBruniaux/google-search-console-mcp★ 22same name
- dathuynh1108/agent-skills★ 4same name
- jenreh/appkit★ 4same name
- CasLubbers/code-design-skills★ 2same name
- phanijapps/memex★ 0same name
- Praveensenpai/karakuri★ 0same name
- ramybarsoum/claude-skills★ 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-anti-patternsSkill
- python-code-reviewSkill
- python-design-principlesSkill
- python-testing-tddSkill
The file
We split this skill into the rules it gives an agent
5 rules. 0 are common, 4 are distinctive, and 1 is very specific to this project.
0
Common
Most of the 8 edited versions we read keep these.
4
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
- Distinctive: line 21
Delete comments that restate code or hold dead code.
- Very specific: line 22
Use a function, not a class, when there is no state to hold.
- Distinctive: line 40
Read the smell; name which gate above it hits.
- Distinctive: line 42
Keep behavior identical; if tests exist, they must stay green.
- Distinctive: line 43
Stop at KISS: do not introduce abstraction the current code does not need.
“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 Clean Code
Line- and function-level readability: naming, classes-vs-functions, comments, data types, plus DRY/KISS/YAGNI.
Activation Contract
Apply when code is hard to read, a function does too much, names are cryptic, comments restate code, primitives model structured data, or the user asks to refactor/clean up Python. For class/module structure and SOLID, use python-design-principles instead.
Hard Rules
- Name by intent:
verb_nounfor functions,is_/has_for booleans, named constants for magic numbers. A good name removes the need for a comment. - Delete comments that restate code or hold dead code. Keep only why (rationale) and docstrings.
- Use a function, not a class, when there is no state to hold. Use
@dataclass/Enum/NamedTupleinstead of tuples or raw dicts for structured data. - Flatten nesting with guard clauses (early return). Extract long functions into named steps.
- Replace repeated blocks with one parameterized abstraction (DRY): but only after the third repeat, never speculative (YAGNI). Prefer the simplest construct that works (KISS).
Decision Gates
| Symptom | Fix |
| Magic number / cryptic name | Named constant / intention-revealing name |
| Comment explains what | Delete it; improve the name |
| Class with no state, only methods | Plain functions |
| Tuple/dict passed around as a record | @dataclass or NamedTuple |
| 4+ params | Parameter Object (@dataclass) |
Deep if nesting | Guard clauses |
| Copy-pasted block (3rd time) | Extract shared function |
Execution Steps
- Read the smell; name which gate above it hits.
- Show a tight
# Bad→# Gooddiff: change one smell at a time. - Keep behavior identical; if tests exist, they must stay green.
- Stop at KISS: do not introduce abstraction the current code does not need.
# Bad
d = 86400
def process(u):
if u:
if u.active:
return charge(u)
# Good
SECONDS_IN_DAY = 86400
def charge_if_active(user: User) -> Receipt | None:
if not user or not user.active:
return None
return charge(user)Output Contract
Return the refactored Python, one smell per diff, with a one-line rationale per change. Never expand scope beyond the smell asked about.
References
references/naming-and-comments.md: naming and comment rules with examples.references/data-and-smells.md: data-type modeling, code smells, DRY/KISS/YAGNI.
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.

