From uitkit
Refactors a function or file to reduce cyclomatic complexity and nesting depth using guard clauses, extraction, table-driven logic, and boolean simplification.
How this command is triggered — by the user, by Claude, or both
Slash command
/uitkit:reduce-complexity [file] [function name or line number, optional]refactor/The summary Claude sees in its command listing — used to decide when to auto-load this command
Reduce the complexity of the code in $ARGUMENTS. 1. Read the target. If a specific function or line is given, focus there. Otherwise, identify the highest-complexity regions: deeply nested conditionals, long functions with many branches, guard chains that obscure the happy path. 2. Measure complexity signals: - Nesting depth > 3 levels - Function length > 40 lines with multiple responsibilities - Cyclomatic complexity > 10 (count: `if`, `else if`, `for`, `while`, `case`, `catch`, `&&`, `||` branches) - Boolean expressions with > 3 operands - Long if-else chains that could b...
Reduce the complexity of the code in $ARGUMENTS.
Read the target. If a specific function or line is given, focus there. Otherwise, identify the highest-complexity regions: deeply nested conditionals, long functions with many branches, guard chains that obscure the happy path.
Measure complexity signals:
if, else if, for, while, case, catch, &&, || branches)Apply targeted reductions:
Early returns / guard clauses:
Extract sub-functions:
isEligible(), hasPermission())Replace conditionals with data:
if/else or switch maps input values to output values, replace with a lookup table / mapFlatten nested loops:
.flatMap(), generators, or helper functions to avoid triple-nested loopsSimplify boolean logic:
const isExpired = date < now && !renewed)Do not reduce complexity by hiding it (e.g., moving a complex branch into a lambda that is immediately invoked). The goal is genuine simplification, not relocation.
Preserve all behavior exactly. Run a mental diff: every input that produced output X must still produce output X.
Output: original complexity estimate, new estimate, and a summary of each transformation applied.
npx claudepluginhub uitbreidenos/uitkit/simplifySimplifies complex code by reducing nesting, eliminating duplication, and improving clarity. Produces a report with before/after metrics, code changes, explanations, and test results.
/simplify-fnRefactors complex function to reduce cyclomatic complexity via extract method, guard clauses, loop decomposition, and polymorphism. Runs/writes tests, preserves behavior, targets score <=5, reports improvement.
/simplifySimplifies code to improve readability and maintainability by reducing nesting, extracting functions, improving naming, removing duplication, simplifying conditionals, and verifying with tests.
/code-simplifySimplifies recently changed code by reducing complexity without altering behavior — applies guard clauses, splits long functions, renames for clarity, deduplicates logic, and removes dead code with incremental test verification.