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
- Distinctive: line 12
Run after completing a feature or fix to ensure code is clean, readable, and follows DoubleML patterns.
- Distinctive: line 23
Use descriptive variable and function names
- Distinctive: line 24
Add clarifying comments for non-obvious logic
- Distinctive: line 25
Ensure consistent formatting (127 char line limit)
- Very specific: line 29
Use list/dict/set comprehensions where appropriate
- Very specific: line 30
Use with statements for resource management
- Very specific: line 31
Use enumerate() instead of manual indexing
- Very specific: line 32
Use zip() for parallel iteration
- Distinctive: line 33
Use f-strings for formatting
- Very specific: line 34
Use pathlib for file paths
- Very specific: line 35
Use is None / is not None instead of == None
- Very specific: line 38
Use clone() for sklearn learners instead of direct copy
- Very specific: line 39
Use _check_learner() for learner validation
- Very specific: line 40
Use _check_score() for score function validation
- Very specific: line 42
Use DoubleMLResampling for sample splitting logic
- Distinctive: line 43
Prefer numpy operations over Python loops for arrays
- Very specific: line 46
Use built-in generics: list[int] not typing.List[int]
- Very specific: line 47
Use X | None instead of Optional[X]
- Very specific: line 49
Add from __future__ import annotations for forward references
- Distinctive: line 50
Ensure all public functions have complete type hints
- Very specific: line 53
Ensure Parameters section lists all arguments
- Very specific: line 54
Ensure Returns section describes return value
- Very specific: line 55
Add Raises section for exceptions
- Very specific: line 56
Use :class: references for DoubleML types
- Distinctive: line 62
Remove redundant code paths
- Distinctive: line 74
Check for simplification opportunities
- Distinctive: line 80
Run tests after each change
“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.
Files
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
withstatements for resource management - Use
enumerate()instead of manual indexing - Use
zip()for parallel iteration - Use f-strings for formatting
- Use
pathlibfor file paths - Use
is None/is not Noneinstead 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_bnaming for score elements - Use
DoubleMLResamplingfor sample splitting logic - Prefer numpy operations over Python loops for arrays
Type Hints (Python 3.11+)
- Use built-in generics:
list[int]nottyping.List[int] - Use
X | Noneinstead ofOptional[X] - Use
X | Yinstead ofUnion[X, Y] - Add
from __future__ import annotationsfor forward references - Ensure all public functions have complete type hints
NumPy-Style Docstrings
- Ensure
Parameterssection lists all arguments - Ensure
Returnssection describes return value - Add
Raisessection 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
- Identify Changed Files
git diff --name-only origin/main...HEAD # Branch changes compared to main git status --short # Uncommitted changes - Analyze Each File
- Check for simplification opportunities
- Prioritize high-impact improvements
- Apply Simplifications
- Make incremental changes
- Preserve original behavior
- Run tests after each change
- Format and Lint
black . ruff check --fix . - Type Check
mypy - 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_valuesDoubleML 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}Other versions58 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 58
- rtk-ai/rtk★ 85ksame name
- tisfeng/Easydict★ 15ksame name
- elie222/inbox-zero★ 13ksame name
- getsentry/skills★ 1.1ksame name
- Azure/azqr★ 799same name
- deadlock-mod-manager/deadlock-mod-manager★ 559same name
- microsoft/ghqr★ 528same name
- feiskyer/codex-settings★ 243same name
- taskless/cli★ 197same name
- 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.
FlorianBruniauxSkilltdd-rust
Also in 3 projects that use this
PaulKinlanSkillcomment-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-ioSkillsecurity-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
SentrySkillfind-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
tossSkillpr-triage
Classify and summarize a PR for efficient review
Also in 3 projects that use this
AJBcodingSkillsql-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.
- .claude/CLAUDE.mdCLAUDE.md
- .github/copilot-instructions.mdCopilot instructions
- techdebtSkill
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.

