Agent skill

Clean Tests

by ertugrul-dmr in ertugrul-dmr/clean-code-skills

A skill your agent uses when writing, fixing, editing, or refactoring Python tests.

MITAuto-check passedDevelopment

Install Clean Tests

skills CLI
$ npx skills add ertugrul-dmr/clean-code-skills --skill clean-tests -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install ertugrul-dmr/clean-code-skills clean-tests --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/ertugrul-dmr/clean-code-skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/python/clean-tests .claude/skills/clean-tests && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
clean-tests
GitHub stars
197
Token cost
~1.3k tokens
SKILL.md length
252 words
Files
1
Skills in repo
14
Repo updated
First seen
Licence
MIT

At a glance

A skill your agent uses when writing, fixing, editing, or refactoring Python tests.

  • Refactoring Python tests
  • SKILL.md covers T1: Insufficient Tests, T2: Use a Coverage Tool, T3: Don't Skip Trivial Tests and T4: An Ignored Test Is a…, plus 7 more sections
  • Calls pytest
  • Tasks that involve Code quality

What it does

Clean Tests is an agent skill from ertugrul-dmr/clean-code-skills. Use when writing, fixing, editing, or refactoring Python tests. Enforces Clean Code principles—fast tests, boundary coverage, one assert per test.

Its SKILL.md is about 1.3k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Development, covering Code quality and Refactoring. It works with Python. The licence is MIT.

When your agent uses it

  • Refactoring Python tests
  • Tasks that involve Code quality
  • Tasks that involve Refactoring

Example prompts

  • “/clean-tests”

Requirements

  • Python 3

What it can do on your machine

Read from SKILL.md and the folder at commit 1b6b3cc. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • pytest

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Clean Tests loads about 1.3k tokens when it runs. Until then it costs about 40 tokens; SKILL.md has 252 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~40
When it runs · the whole SKILL.md, loaded when a task matches
~1.3k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from ertugrul-dmr/clean-code-skills at commit 1b6b3cc, republished under its MIT licence (© ertugrul-dmr). 252 words, ~1,341 tokens.

Download SKILL.mdSave it as .claude/skills/clean-tests/SKILL.md (or your agent's skills folder).
name
clean-tests
description
Use when writing, fixing, editing, or refactoring Python tests. Enforces Clean Code principles—fast tests, boundary coverage, one assert per test.
when_to_use
Also trigger on: slow or flaky tests, `@pytest.mark.skip` without a clear reason, tests that only cover the happy path, tests with multiple assertions about…

Clean Tests

T1: Insufficient Tests

Test everything that could possibly break. Use coverage tools as a guide, not a goal.

python
# Bad - only tests happy path
def test_divide():
    assert divide(10, 2) == 5

# Good - tests edge cases too
def test_divide_normal():
    assert divide(10, 2) == 5

def test_divide_by_zero():
    with pytest.raises(ZeroDivisionError):
        divide(10, 0)

def test_divide_negative():
    assert divide(-10, 2) == -5

T2: Use a Coverage Tool

Coverage tools report gaps in your testing strategy. Don't ignore them.

bash
# Run with coverage
pytest --cov=myproject --cov-report=term-missing

# Aim for meaningful coverage, not 100%

T3: Don't Skip Trivial Tests

Trivial tests document behavior and catch regressions. They're worth more than their cost.

python
# Worth having - documents expected behavior
def test_user_default_role():
    user = User(name="Alice")
    assert user.role == "member"

T4: An Ignored Test Is a Question About an Ambiguity

Don't use @pytest.mark.skip to hide problems. Either fix the test or delete it.

python
# Bad - hiding a problem
@pytest.mark.skip(reason="flaky, fix later")
def test_async_operation():
    ...

# Good - either fix it or document why it's skipped
@pytest.mark.skip(reason="Requires Redis, see CONTRIBUTING.md for setup")
def test_cache_invalidation():
    ...

T5: Test Boundary Conditions

Bugs congregate at boundaries. Test them explicitly.

python
def test_pagination_boundaries():
    items = list(range(100))
    
    # First page
    assert paginate(items, page=1, size=10) == items[0:10]
    
    # Last page
    assert paginate(items, page=10, size=10) == items[90:100]
    
    # Beyond last page
    assert paginate(items, page=11, size=10) == []
    
    # Page zero (invalid)
    with pytest.raises(ValueError):
        paginate(items, page=0, size=10)
    
    # Empty list
    assert paginate([], page=1, size=10) == []

T6: Exhaustively Test Near Bugs

When you find a bug, write tests for all similar cases. Bugs cluster.

python
# Found bug: off-by-one in date calculation
# Now test ALL date boundaries
def test_month_boundaries():
    assert last_day_of_month(2024, 1) == 31  # January
    assert last_day_of_month(2024, 2) == 29  # Leap year February
    assert last_day_of_month(2023, 2) == 28  # Non-leap February
    assert last_day_of_month(2024, 4) == 30  # 30-day month
    assert last_day_of_month(2024, 12) == 31 # December

T7: Patterns of Failure Are Revealing

When tests fail, look for patterns. They often point to deeper issues.

python
# If all async tests fail intermittently,
# the problem isn't the tests—it's the async handling

T8: Test Coverage Patterns Can Be Revealing

Look at which code paths are untested. Often they reveal design problems.

python
# If you can't easily test a function, it probably does too much
# Refactor for testability

T9: Tests Should Be Fast

Slow tests don't get run. Keep unit tests under 100ms each.

python
# Bad - hits real database
def test_user_creation():
    db = connect_to_database()  # Slow!
    user = db.create_user("Alice")
    assert user.name == "Alice"

# Good - uses mock or in-memory
def test_user_creation():
    db = InMemoryDatabase()
    user = db.create_user("Alice")
    assert user.name == "Alice"

Test Organization

F.I.R.S.T. Principles
  • Fast: Tests should run quickly
  • Independent: Tests shouldn't depend on each other
  • Repeatable: Same result every time, any environment
  • Self-Validating: Pass or fail, no manual inspection
  • Timely: Written before or with the code, not after
One Concept Per Test
python
# Bad - testing multiple things
def test_user():
    user = User("Alice", "alice@example.com")
    assert user.name == "Alice"
    assert user.email == "alice@example.com"
    assert user.is_valid()
    user.activate()
    assert user.is_active

# Good - one concept each
def test_user_stores_name():
    user = User("Alice", "alice@example.com")
    assert user.name == "Alice"

def test_user_stores_email():
    user = User("Alice", "alice@example.com")
    assert user.email == "alice@example.com"

def test_new_user_is_valid():
    user = User("Alice", "alice@example.com")
    assert user.is_valid()

def test_user_can_be_activated():
    user = User("Alice", "alice@example.com")
    user.activate()
    assert user.is_active

Quick Reference

RulePrinciple
T1Test everything that could break
T2Use coverage tools
T3Don't skip trivial tests
T4Ignored test = ambiguity question
T5Test boundary conditions
T6Exhaustively test near bugs
T7Look for patterns in failures
T8Check coverage when debugging
T9Tests must be fast (<100ms)

© ertugrul-dmr, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in skills/python/clean-tests of ertugrul-dmr/clean-code-skills.

Open the folder on GitHubat commit 1b6b3cc

Compare with similar skills

Clean Tests next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Clean Tests compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Clean Tests this skillertugrul-dmr/clean-code-skills197—~1.3kAutomated safety check: PassMIT
Dignified Python Standardsdocling-project/docling69k—~1.5kAutomated safety check: PassApache-2.0
Odoo Workflowunclecatvn/agent-skills143—~4.7kAutomated safety check: PassMIT
Code Refactor Masteryennanliu/CS_basics142—~3.3kAutomated safety check: PassNone
Code Revieweralirezarezvani/claude-skills28k1 repos~1.6kAutomated safety check: PassMIT
Code ReviewerLeoYeAI/openclaw-master-skills2.2k1 repos~1.2kAutomated safety check: PassMIT

Similar skills

  • Dignified Python Standards

    docling-project/docling

    Applies opinionated production Python conventions chosen by the project's Python version: modern type syntax, pathlib, explicit checks and interface guidance.

    69k GitHub stars~1.5k tokensUpdated yesterday
    DevelopmentAuto-check passed
  • Odoo Workflow

    unclecatvn/agent-skills

    Mandatory pre-code gate and definition-of-done for ANY Odoo change (add field, override method, inherit view/xpath, OWL/JS patch, wizard, cron, controller, report, security, migration, bug fix…

    143 GitHub stars~4.7k tokensUpdated 15 days ago
    DevelopmentAuto-check passed
  • Code Refactor Master

    yennanliu/CS_basics

    Code refactoring expert for improving code quality, readability, maintainability, and performance.

    142 GitHub stars~3.3k tokensUpdated today
    DevelopmentAuto-check passed
  • Code Reviewer

    alirezarezvani/claude-skills

    Code review automation for TypeScript, JavaScript, Python, Go, Swift, Kotlin, C, .NET, Java, C, C++, Rust, Ruby, PHP, and Dart/Flutter.

    28k GitHub starsUsed in 1 repo~1.6k tokens
    DevelopmentAuto-check passed
  • Code Reviewer

    LeoYeAI/openclaw-master-skills

    Code review automation for TypeScript, JavaScript, Python, Go, Swift, Kotlin.

    2.2k GitHub starsUsed in 1 repo~1.2k tokens
    DevelopmentAuto-check passed
  • Code Smell Detector

    ArabelaTso/Skills-4-SE

    Identify and report code smells indicating poor design or maintainability issues in Python code, including duplicate code, magic numbers, hardcoded values, God classes, feature envy, inappropriate…

    253 GitHub stars~3.9k tokensUpdated 1 mo ago
    DevelopmentAuto-check passed

More from ertugrul-dmr/clean-code-skills

All 14 skills in this repo
  • Boy Scout

    ertugrul-dmr/clean-code-skills

    A skill your agent uses when fixing, editing, changing, debugging, or working with any Python code.

    197 GitHub stars~978 tokensUpdated 5 mo ago
    Auto-check passed
  • Boy Scout

    ertugrul-dmr/clean-code-skills

    A skill your agent uses when fixing, editing, changing, debugging, or working with any TypeScript code.

    197 GitHub stars~996 tokensUpdated 5 mo ago
    Auto-check passed
  • Clean General

    ertugrul-dmr/clean-code-skills

    A skill your agent uses when writing, fixing, editing, or reviewing Python code quality.

    197 GitHub stars~666 tokensUpdated 5 mo ago
    Auto-check passed
  • Clean General

    ertugrul-dmr/clean-code-skills

    A skill your agent uses when writing, fixing, editing, or reviewing TypeScript code quality.

    197 GitHub stars~847 tokensUpdated 5 mo ago
    Auto-check passed
  • Clean Names

    ertugrul-dmr/clean-code-skills

    A skill your agent uses when naming, renaming, or fixing names of variables, functions, classes, or modules in Python.

    197 GitHub stars~919 tokensUpdated 5 mo ago
    Auto-check passed
  • Clean Names

    ertugrul-dmr/clean-code-skills

    A skill your agent uses when naming, renaming, or fixing names of variables, functions, classes, interfaces, or modules in TypeScript.

    197 GitHub stars~1k tokensUpdated 5 mo ago
    Auto-check passed

Works with

Categories

Questions about Clean Tests

What does Clean Tests do?

A skill your agent uses when writing, fixing, editing, or refactoring Python tests. Clean Tests is an agent skill from ertugrul-dmr/clean-code-skills. Use when writing, fixing, editing, or refactoring Python tests.

When should I use Clean Tests?

Clean Tests fits situations like: refactoring Python tests; tasks that involve Code quality; tasks that involve Refactoring.

How do I install Clean Tests in Claude Code?

Run `npx skills add ertugrul-dmr/clean-code-skills --skill clean-tests -a claude-code`. Or copy the skill folder (skills/python/clean-tests in ertugrul-dmr/clean-code-skills) into .claude/skills/clean-tests in your project. Claude Code loads it when a task matches its description.

How do I install Clean Tests in Codex?

Run `npx skills add ertugrul-dmr/clean-code-skills --skill clean-tests -a codex`. Or copy the skill folder (skills/python/clean-tests in ertugrul-dmr/clean-code-skills) into .agents/skills/clean-tests in your project. Codex loads it when a task matches its description.

Can I use Clean Tests in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add ertugrul-dmr/clean-code-skills --skill clean-tests -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/clean-tests, .gemini/skills/clean-tests, .github/skills/clean-tests and .opencode/skills/clean-tests in your project.

What does Clean Tests need to run?

Going by SKILL.md and its folder, Clean Tests needs the command-line tools its instructions call (pytest). Our summary lists: Python 3.

Does Clean Tests access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Clean Tests safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Clean Tests use?

Clean Tests is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Clean Tests use?

About 1.3k tokens (SKILL.md is roughly 5.4k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Clean Tests?

Skills that share tags, products or a category with Clean Tests: Dignified Python Standards (docling-project/docling, 69k stars), Odoo Workflow (unclecatvn/agent-skills, 143 stars), Code Refactor Master (yennanliu/CS_basics, 142 stars) and Code Reviewer (alirezarezvani/claude-skills, 28k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Clean Tests?

ertugrul-dmr (a GitHub user) maintains it in ertugrul-dmr/clean-code-skills, which has 197 GitHub stars. The repository holds 14 skills in this directory. The repository was last updated on April 21, 2026.

Source: ertugrul-dmr/clean-code-skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.