About clean-functions
clean-functions is a code-quality skill focused on keeping functions simple and predictable. It gives rules for reducing arguments, avoiding side effects and flags, and removing unused functions.
Key features
- 01Limit functions to three arguments
- 02Return values instead of mutating inputs
- 03Avoid boolean flag arguments
- 04Delete unused functions
Use cases
- 01Review functions with many parameters
- 02Find side effects that modify arguments
- 03Separate behavior hidden behind boolean flags
- 04Remove uncalled functions during cleanup
Install
Copy the command and run it in a terminal.
$
npx skills add https:/ / github.com/ ertugrul-dmr/ clean-code-skills --skill clean-functionsAfter installing, type/clean-functionsin Claude Code to confirm it loaded.
Details
From the project READMEClean Functions
F1: Too Many Arguments (Maximum 3)
# Bad - too many parameters
def create_user(name, email, age, country, timezone, language, newsletter):
...
# Good - use a dataclass or dict
@dataclass
class UserData:
name: str
email: str
age: int
country: str
timezone: str
language: str
newsletter: bool
def create_user(data: UserData):
...
More than 3 arguments means your function is doing too much or needs a data structure.
F2: No Output Arguments
Don't modify arguments as side effects. Return values instead.
# Bad - modifies argument
def append_footer(report: Report) -> None:
report.append("\n---\nGenerated by System")
# Good - returns new value
def with_footer(report: Report) -> Report:
return report + "\n---\nGenerated by System"
F3: No Flag Arguments
Boolean flags mean your function does at least two things.
# Bad - function does two different things
def render(is_test: bool):
if is_test:
render_test_page()
else:
render_production_page()
# Good - split into two functions
def render_test_page(): ...
def render_production_page(): ...
F4: Delete Dead Functions
If it's not called, delete it. No "just in case" code. Git preserves history.
Comments
Markdown supported