From superpowers-plus
Refactors code to fix Biome noExcessiveCognitiveComplexity errors by extracting nested logic, adding early returns, and reducing nesting depth. Bans biome-ignore suppression comments.
How this skill is triggered — by the user, by Claude, or both
Slash command
/superpowers-plus:cognitive-complexity-refactoringThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Invoke this skill when:
Invoke this skill when:
noExcessiveCognitiveComplexitybiome-ignore comments are BANNED in new code.
When Biome reports an error:
// biome-ignore to suppress the warning// ❌ NEVER DO THIS
// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: complex
function handleMessage(data: Buffer): void {
// 25 lines of nested if/else statements
}
// ✅ ALWAYS DO THIS - Extract to smaller functions
function handleMessage(data: Buffer): void {
const message = parseMessage(data)
if (message.type === 'partial') {
handlePartialResult(message)
} else if (message.type === 'final') {
handleFinalResult(message)
}
}
function handlePartialResult(message: Message): void {
if (!message.text) return
const event = createResultEvent(message, false)
emitResult(event)
}
Measures how hard a function is to understand.
Calculates based on:
Threshold: Maximum 15 (configured in biome.json)
// ✅ Complexity reduced by extraction
function processCoordinates() {
for (let x = 0; x < 10; x++) {
for (let y = 0; y < 10; y++) {
processPoint(x, y)
}
}
}
function processPoint(x: number, y: number) {
if (x % 2 !== 0) return
if (y % 2 !== 0) return
const max = x > y ? x : y
console.log(max)
}
// ✅ Complexity: 3
function validate(data: Data | null): boolean {
if (!data) return false
if (!data.isValid) return false
if (!data.hasRequiredFields()) return false
return true
}
// vs ❌ Complexity: 6
function validate(data: Data | null): boolean {
if (data) {
if (data.isValid) {
if (data.hasRequiredFields()) {
return true
}
}
}
return false
}
// ✅ Reduce nesting
const canProcess = isActive && hasPermission && !isBlocked
if (!canProcess) return
processItem()
// vs ❌ Nested ifs
if (isActive) {
if (hasPermission) {
if (!isBlocked) {
processItem()
}
}
}
Standard: <300 lines per file Exception: Cohesive state machines (~350 lines acceptable)
If file >300 lines: Refactor into smaller focused files.
pnpm lint # No Biome complexity warnings
A task is NOT complete until this passes.
| Mode | Symptom | Recovery |
|---|---|---|
| Over-refactor | New bugs introduced | Run tests after each extraction |
| Wrong extraction boundary | Makes code harder to follow | Keep related logic together |
| Extracting too aggressively | Many tiny functions obscure flow | Balance complexity score with readability |
npx claudepluginhub bordenet/superpowers-plus --plugin superpowers-plusGuides creation, editing, and verification of skills for AI coding agents using test-driven development with subagent scenarios. Use when authoring or debugging skills.