Simplify and refactor code while preserving functionality and library constraints.
Simplify and refactor $ARGUMENTS.
.claude/docs/libraries/For each complexity issue:
Apply changes following these patterns:
Early Return:
# Before
def process(value):
if value is not None:
if value > 0:
return do_something(value)
return None
# After
def process(value):
if value is None:
return None
if value <= 0:
return None
return do_something(value)
Extract Function:
# Before
def main():
# 50 lines of mixed concerns
...
# After
def main():
data = load_data()
result = process_data(data)
save_result(result)
Run the project's verification commands to confirm no regressions:
# Python files
uv run ruff check --fix {file}
uv run ruff format {file}
# PowerShell files
pwsh -NoProfile -Command "Invoke-ScriptAnalyzer -Path '{file}' -Severity Warning,Error"
# General: run project-defined test/check commands
# Check pyproject.toml, package.json, or Makefile for test commands