From claudient
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
/claudient: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 claudient/claudient --plugin claudient-personas