home / skills / codyswanngt / lisa / plan-lower-code-complexity
This skill reduces cognitive complexity threshold by two, identifies violations, and creates a practical plan to refactor code now.
npx playbooks add skill codyswanngt/lisa --skill plan-lower-code-complexityReview the files below or copy the command above to add this skill to your agents.
---
name: plan-lower-code-complexity
description: This skill should be used when reducing the cognitive complexity threshold of the codebase. It lowers the threshold by 2, identifies functions that exceed the new limit, generates a brief with refactoring strategies, and creates a plan with tasks to fix all violations.
allowed-tools: ["Read", "Bash", "Glob", "Grep"]
---
# Lower Code Complexity
Reduces the cognitive complexity threshold by 2 and fixes all violations.
## Step 1: Gather Requirements
1. **Read current threshold** from eslint config (cognitive-complexity rule)
2. **Calculate new threshold**: current - 2 (e.g., 15 -> 13)
3. **Run lint** with the new threshold to find violations:
```bash
bun run lint 2>&1 | grep "cognitive-complexity"
```
4. **Note for each violation**:
- File path and line number
- Function name
- Current complexity score
If no violations at new threshold, report success and exit.
## Step 2: Compile Brief and Delegate
Compile the gathered information into a structured brief:
```
Reduce cognitive complexity threshold from [current] to [new].
Functions exceeding threshold (ordered by complexity):
1. [file:function] (complexity: X, target: [new]) - Line Y
2. ...
Configuration change: [eslint config path], cognitive-complexity from [current] to [new]
Refactoring strategies: extract functions, early returns, extract conditions, use lookup tables
Verification: `bun run lint 2>&1 | grep "cognitive-complexity" | wc -l` → Expected: 0
```
Invoke `/plan-execute` with this brief to create the implementation plan.This skill reduces the repository's cognitive complexity threshold by 2 and produces a concrete remediation plan to fix all resulting violations. It identifies every function that exceeds the new limit, prepares a structured brief with refactoring strategies, and generates a taskized plan suitable for delegated execution. The output is ready to feed into an execution agent or project board.
The skill reads the current cognitive-complexity value from the ESLint config, calculates newThreshold = current - 2, and runs the linter with that limit to discover violations. For each violation it records file path, line number, function name, and complexity score, then compiles a brief that lists offending functions ordered by complexity and outlines refactoring strategies. Finally it produces a step-by-step plan of tasks to fix each violation and verification steps to confirm zero remaining errors.
What happens if no functions exceed the new threshold?
The skill reports success, shows the checked threshold and zero violations, and does not create further remediation tasks.
Which refactoring strategies are recommended?
Extract helper functions, apply early returns, simplify conditional logic (extract conditions), and replace complex branches with lookup tables where appropriate.