Agent skill · software engineering · github

refactor-method-complexity-reduce

Refactor given method `${input:methodName}` to reduce its cognitive complexity to `${input:complexityThreshold}` or below, by extracting helper methods.

Why this skill is useful

Adds specific refactoring techniques and best practices for reducing cognitive complexity that the AI wouldn't reliably generate on its own.

What it needs

About 3k tokens when loaded. Last updated 2026-08-07. 37,534 stars on the source repository.

What this skill does

Refactor Method to Reduce Cognitive Complexity Objective Refactor the method ${input:methodName}, to reduce its cognitive complexity to ${input:complexityThreshold} or below, by extracting logic into focused helper methods. Instructions 1. Analyze the current method to identify sources of cognitive complexity: Nested conditional statements Multiple if-else or switch chains Repeated code blocks Multiple loops with conditions Complex boolean expressions 2. Identify extraction opportunities: Validation logic that can be extracted into a separate method Type-specific or case-specific processing that repeats Complex transformations or calculations Common patterns that appear multiple times 3. Extract focused helper methods: Each helper should have a single, clear responsibility Extract validation into separate Validate methods Extract type-specific logic into handler methods Create utility methods for common operations Use appropriate access levels (static, private, async) 4. Simplify the main method: Reduce nesting depth Replace massive if-else chains with smaller orchestrated calls Use switch statements where appropriate for cleaner dispatch Ensure the main method reads as a high-level flow 5. Preserve functionality: Maintain the same input/output behavior Keep all validation and error handling Preserve exception types and error messages Ensure all parameters are properly passed to helpers 6. …

How to use it

Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:

@skills github/refactor-method-complexity-reduce

View the source on GitHub

Browse the @skills marketplace