Agent skill · Code Review & Quality

refactor-method-complexity-reduce

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

GitHub68,948★ · +463/wk · 2 repos on radarProfile →
copilotMIT
Install
npx skills add github/awesome-copilot --skill refactor-method-complexity-reduce --agent copilot

Same command for any agent — swap --agent for claude-code, codex, cursor.

Facts
Files in the skill folder: 1
SKILL.md size: 4 KB
Bundled scripts: none
Path: skills/refactor-method-complexity-reduce/SKILL.md
Open the folder on GitHub →
Where it comes from
Stars: 37,432 · +281 this week
Language: Python

Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.

From the SKILL.md

# 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

What's inside
Steps it walks through
  1. Objective
  2. Instructions
  3. Implementation Approach
  4. Result
  5. Testing and Validation
  6. Confirmation Checklist
More from awesome-copilot
All skills →
About this skill
What does the refactor-method-complexity-reduce skill do?

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

How do I install it?

Run `npx skills add github/awesome-copilot --skill refactor-method-complexity-reduce --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.

Where does this skill come from?

From github/awesome-copilot, a repository with 37,432 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.

Is a popular skill a good skill?

Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.

Keep going