Python Clean Code logo

Python Clean Code

Community
ertugrul-dmr
python-clean-code

Use when writing, fixing, editing, reviewing, or refactoring any Python code. Enforces Robert Martin's complete Clean Code catalog—naming, functions, comments, DRY, and boundary conditions.

Overview

Publisherertugrul-dmr
Repositoryclean-code-skills
Skill namepython-clean-code
Stars
203
Forks
35
Bundled files
Instructions only
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by ertugrul-dmr on GitHub. Read the source before you install it.

Installation

Install the Python Clean Code AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/ertugrul-dmr/clean-code-skills/tree/main/skills/python/python-clean-code
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/ertugrul-dmr/clean-code-skills.git /tmp/clean-code-skills
mkdir -p .claude/skills
cp -r /tmp/clean-code-skills/skills/python/python-clean-code .claude/skills/python-clean-code
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Python Clean Code in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Python Clean Code on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Python Clean Code is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Clean Python: Complete Reference

Enforces all Clean Code principles from Robert C. Martin's Chapter 17, adapted for Python.

Comments (C1-C5)

  • C1: No metadata in comments (use Git)
  • C2: Delete obsolete comments immediately
  • C3: No redundant comments
  • C4: Write comments well if you must
  • C5: Never commit commented-out code

Environment (E1-E2)

  • E1: One command to build (pip install -e ".[dev]")
  • E2: One command to test (pytest)

Functions (F1-F4)

  • F1: Maximum 3 arguments (use dataclasses for more)
  • F2: No output arguments (return values)
  • F3: No flag arguments (split functions)
  • F4: Delete dead functions

General (G1-G36)

  • G1: One language per file
  • G2: Implement expected behavior
  • G3: Handle boundary conditions
  • G4: Don't override safeties
  • G5: DRY - no duplication
  • G6: Consistent abstraction levels
  • G7: Base classes don't know children
  • G8: Minimize public interface
  • G9: Delete dead code
  • G10: Variables near usage
  • G11: Be consistent
  • G12: Remove clutter
  • G13: No artificial coupling
  • G14: No feature envy
  • G15: No selector arguments
  • G16: No obscured intent
  • G17: Code where expected
  • G18: Prefer instance methods
  • G19: Use explanatory variables
  • G20: Function names say what they do
  • G21: Understand the algorithm
  • G22: Make dependencies physical
  • G23: Prefer polymorphism to if/else
  • G24: Follow conventions (PEP 8)
  • G25: Named constants, not magic numbers
  • G26: Be precise
  • G27: Structure over convention
  • G28: Encapsulate conditionals
  • G29: Avoid negative conditionals
  • G30: Functions do one thing
  • G31: Make temporal coupling explicit
  • G32: Don't be arbitrary
  • G33: Encapsulate boundary conditions
  • G34: One abstraction level per function
  • G35: Config at high levels
  • G36: Law of Demeter (no train wrecks)

Python-Specific (P1-P3)

These adapt the Java-specific rules (J1-J3) to Python conventions:

  • P1: No wildcard imports (from x import *) — opposite of Java, per PEP 8
  • P2: Use Enums, not magic constants — same principle as J3
  • P3: Type hints on public interfaces — Python's equivalent of Java's static typing

Names (N1-N7)

  • N1: Choose descriptive names
  • N2: Right abstraction level
  • N3: Use standard nomenclature
  • N4: Unambiguous names
  • N5: Name length matches scope
  • N6: No encodings
  • N7: Names describe side effects

Tests (T1-T9)

  • T1: Test everything that could break
  • T2: Use coverage tools
  • T3: Don't skip trivial tests
  • T4: Ignored test = ambiguity question
  • T5: Test boundary conditions
  • T6: Exhaustively test near bugs
  • T7: Look for patterns in failures
  • T8: Check coverage when debugging
  • T9: Tests must be fast (< 100ms each)

Quick Reference Table

CategoryRuleOne-Liner
CommentsC1No metadata (use Git)
C3No redundant comments
C5No commented-out code
FunctionsF1Max 3 arguments
F3No flag arguments
F4Delete dead functions
GeneralG5DRY—no duplication
G9Delete dead code
G16No obscured intent
G23Polymorphism over if/else
G25Named constants, not magic numbers
G30Functions do one thing
G36Law of Demeter (one dot)
NamesN1Descriptive names
N5Name length matches scope
TestsT5Test boundary conditions
T9Tests must be fast

Anti-Patterns (Don't → Do)

❌ Don't✅ Do
Comment every lineDelete obvious comments
Helper for one-linerInline the code
from x import *Explicit imports
Magic number 86400SECONDS_PER_DAY = 86400
process(data, True)process_verbose(data)
Deep nestingGuard clauses, early returns
obj.a.b.c.valueobj.get_value()
100+ line functionSplit by responsibility

AI Behavior

When reviewing code, identify violations by rule number (e.g., "G5 violation: duplicated logic"). When fixing or editing code, report what was fixed (e.g., "Fixed: extracted magic number to SECONDS_PER_DAY (G25)").

Frequently asked questions

What does the Python Clean Code AI skill do?

Use when writing, fixing, editing, reviewing, or refactoring any Python code. Enforces Robert Martin's complete Clean Code catalog—naming, functions, comments, DRY, and boundary conditions.

Why use Python Clean Code on TypingMind?

Because you install it once and use it with any model. Python Clean Code is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Python Clean Code in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/ertugrul-dmr/clean-code-skills/tree/main/skills/python/python-clean-code. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Python Clean Code?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Python Clean Code?

As many as you like. As long as a model supports skills, you can use Python Clean Code with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Python Clean Code AI skill free?

Yes. It is published on GitHub by ertugrul-dmr under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇