agentleFS
DoubleMLDoubleML/doubleml-for-py/.claude/skills/code-simplifier/SKILL.md

code-simplifier

Skill795 starsChanged 4 months agoBSD-3-ClauseView on GitHub

Simplify and clean up DoubleML code after changes. Reduces complexity, improves readability, ensures NumPy-style docstrings and type hints.

We split this skill into the rules it gives an agent

27 rules. 0 are common, 10 are distinctive, and 17 are very specific to this project.

  • 0

    Common

    Most of the 54 edited versions we read keep these.

  • 10

    Distinctive

    This author's own choices. Worth a look.

  • 17

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Run after completing a feature or fix to ensure code is clean, readable, and follows DoubleML patterns.

    line 12
  2. Distinctive:

    Use descriptive variable and function names

    line 23
  3. Distinctive:

    Add clarifying comments for non-obvious logic

    line 24
  4. Distinctive:

    Ensure consistent formatting (127 char line limit)

    line 25
  5. Very specific:

    Use list/dict/set comprehensions where appropriate

    line 29
  6. Very specific:

    Use with statements for resource management

    line 30
  7. Very specific:

    Use enumerate() instead of manual indexing

    line 31
  8. Very specific:

    Use zip() for parallel iteration

    line 32
  9. Distinctive:

    Use f-strings for formatting

    line 33
  10. Very specific:

    Use pathlib for file paths

    line 34
  11. Very specific:

    Use is None / is not None instead of == None

    line 35
  12. Very specific:

    Use clone() for sklearn learners instead of direct copy

    line 38
  13. Very specific:

    Use _check_learner() for learner validation

    line 39
  14. Very specific:

    Use _check_score() for score function validation

    line 40
  15. Very specific:

    Use DoubleMLResampling for sample splitting logic

    line 42
  16. Distinctive:

    Prefer numpy operations over Python loops for arrays

    line 43
  17. Very specific:

    Use built-in generics: list[int] not typing.List[int]

    line 46
  18. Very specific:

    Use X | None instead of Optional[X]

    line 47
  19. Very specific:

    Add from __future__ import annotations for forward references

    line 49
  20. Distinctive:

    Ensure all public functions have complete type hints

    line 50
  21. Very specific:

    Ensure Parameters section lists all arguments

    line 53
  22. Very specific:

    Ensure Returns section describes return value

    line 54
  23. Very specific:

    Add Raises section for exceptions

    line 55
  24. Very specific:

    Use :class: references for DoubleML types

    line 56
  25. Distinctive:

    Remove redundant code paths

    line 62
  26. Distinctive:

    Check for simplification opportunities

    line 74
  27. Distinctive:

    Run tests after each change

    line 80

“Common” is measured: kept by at least 6 in 10 of the 54 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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Code Simplifier for DoubleML

Clean up and simplify code after making changes.

When to Use

Run after completing a feature or fix to ensure code is clean, readable, and follows DoubleML patterns.

Simplification Goals

Reduce Complexity

  • Break long functions into smaller, focused ones (target: <50 lines)
  • Reduce nesting depth (max 3 levels)
  • Simplify complex conditionals
  • Extract magic numbers to named constants (e.g., DEFAULT_N_FOLDS = 5)

Improve Readability

  • Use descriptive variable and function names
  • Add clarifying comments for non-obvious logic
  • Ensure consistent formatting (127 char line limit)
  • Remove unnecessary comments

Apply Pythonic Patterns

  • Use list/dict/set comprehensions where appropriate
  • Use with statements for resource management
  • Use enumerate() instead of manual indexing
  • Use zip() for parallel iteration
  • Use f-strings for formatting
  • Use pathlib for file paths
  • Use is None / is not None instead of == None

DoubleML-Specific Patterns

  • Use clone() for sklearn learners instead of direct copy
  • Use _check_learner() for learner validation
  • Use _check_score() for score function validation
  • Consistent psi_a/psi_b naming for score elements
  • Use DoubleMLResampling for sample splitting logic
  • Prefer numpy operations over Python loops for arrays

Type Hints (Python 3.11+)

  • Use built-in generics: list[int] not typing.List[int]
  • Use X | None instead of Optional[X]
  • Use X | Y instead of Union[X, Y]
  • Add from __future__ import annotations for forward references
  • Ensure all public functions have complete type hints

NumPy-Style Docstrings

  • Ensure Parameters section lists all arguments
  • Ensure Returns section describes return value
  • Add Raises section for exceptions
  • Use :class: references for DoubleML types

Clean Up

  • Remove unused imports
  • Remove unused variables
  • Remove commented-out code
  • Remove redundant code paths
  • Consolidate duplicate logic

Workflow

  1. Identify Changed Files
     git diff --name-only origin/main...HEAD  # Branch changes compared to main
    git status --short           # Uncommitted changes
  2. Analyze Each File
    • Check for simplification opportunities
    • Prioritize high-impact improvements
  3. Apply Simplifications
    • Make incremental changes
    • Preserve original behavior
    • Run tests after each change
  4. Format and Lint
    black .
    ruff check --fix .
  5. Type Check
    mypy
  6. Verify
    pytest -m ci

Arguments

Optionally specify files or directories to simplify.

Usage:

  • /code-simplifier - Simplify recently changed files
  • /code-simplifier doubleml/plm/plr.py - Simplify specific file
  • /code-simplifier doubleml/utils/ - Simplify entire directory

Example Transformations

Loop to Comprehension

# Before
result = []
for i in range(len(items)):
    if items[i].is_valid == True:
        result.append(items[i].value)

# After
result = [item.value for item in items if item.is_valid]

Flatten Nesting

# Before
if x != None:
    if y != None:
        if z != None:
            process(x, y, z)

# After
if all(v is not None for v in (x, y, z)):
    process(x, y, z)

Modern Type Hints

# Before
from typing import List, Optional, Union, Dict

def process(items: List[int], config: Optional[Dict[str, Any]] = None) -> Union[int, None]:
    ...

# After
def process(items: list[int], config: dict[str, Any] | None = None) -> int | None:
    ...

NumPy Operations

# Before
result = []
for i in range(len(predictions)):
    result.append(predictions[i] - true_values[i])
result = np.array(result)

# After
result = predictions - true_values

DoubleML Learner Pattern

# Before
ml_l_copy = copy.deepcopy(ml_l)

# After
from sklearn.base import clone
ml_l_copy = clone(ml_l)

Score Element Naming

# Before
def _get_score_elements(self, ...):
    return {"a": psi_derivative, "b": psi_moment}

# After
def _get_score_elements(self, ...):
    return {"psi_a": psi_derivative, "psi_b": psi_moment}

Download now (ZIP)

  • Other versions58 projects use a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 58

    1. rtk-ai/rtk★ 85ksame name
    2. tisfeng/Easydict★ 15ksame name
    3. elie222/inbox-zero★ 13ksame name
    4. getsentry/skills★ 1.1ksame name
    5. Azure/azqr★ 799same name
    6. deadlock-mod-manager/deadlock-mod-manager★ 559same name
    7. microsoft/ghqr★ 528same name
    8. feiskyer/codex-settings★ 243same name
    9. taskless/cli★ 197same name
    10. wesm/middleman★ 197same name

    48 more not listed

    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.

  • Used alongsideProjects with it also use tdd-rust, comment-analyzer and 10 more.

    Other files people use alongside this one.

    Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
    • FlorianBruniauxSkill

      tdd-rust

      Also in 3 projects that use this

    • PaulKinlanSkill

      comment-analyzer

      Analyzes code comments for accuracy, completeness, and long-term maintainability. Identifies misleading comments, comment rot, and documentation gaps.

      Also in 3 projects that use this

    • ufodev-ioSkill

      security-guardian

      Comprehensive security layer for all interactions with Claude: audits code, dependencies, commands, configs, and AI-generated output for vulnerabilities. Protects against prompt injection, data leaks, unsafe advice, and social engineering. Works in Cursor, Claude Code, claude.ai, and API contexts. Use always as a background security protocol in any Claude-powered environment.

      Also in 3 projects that use this

    • SentrySkill

      find-bugs

      Find bugs, security vulnerabilities, and code quality issues in local branch changes. Use when asked to review changes, find bugs, security review, or audit code on the current branch.

      Also in 3 projects that use this

    • tossSkill

      pr-triage

      Classify and summarize a PR for efficient review

      Also in 3 projects that use this

    • AJBcodingSkill

      sql-optimization-patterns

      Master SQL query optimization, indexing strategies, and EXPLAIN analysis to dramatically improve database performance and eliminate slow queries. Use when debugging slow queries, designing database schemas, or optimizing application performance.

      Also in 3 projects that use this

  • In this repository3 other files it gives its agents.

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.