Official agent skill

Refactor Method Complexity Reduce

by github in github/awesome-copilot

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

OfficialMITAuto-check passedDevelopment

Install Refactor Method Complexity Reduce

skills CLI
$ npx skills add github/awesome-copilot --skill refactor-method-complexity-reduce -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install github/awesome-copilot refactor-method-complexity-reduce --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/github/awesome-copilot.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/refactor-method-complexity-reduce .claude/skills/refactor-method-complexity-reduce && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
refactor-method-complexity-reduce
GitHub stars
40k
Used in
1 other repo
Token cost
~1.1k tokens
SKILL.md length
538 words
Files
1
Skills in repo
417
Repo updated
First seen
Licence
MIT

At a glance

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

  • Works in 6 steps: Analyze the current method to identify… → Identify extraction opportunities → Extract focused helper methods → …
  • Tasks that involve Refactoring
  • SKILL.md covers Objective, Instructions, Implementation Approach and Result, plus 2 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Refactor Method Complexity Reduce is an agent skill from github/awesome-copilot, published by the product's own GitHub organization. Refactor given method ${input:methodName} to reduce its cognitive complexity to ${input:complexityThreshold} or below, by extracting helper methods.

Its SKILL.md is about 1.1k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Development, covering Refactoring. The repository describes itself as: Community-contributed instructions, agents, skills, and configurations to help you make the most of GitHub Copilot. The licence is MIT.

When your agent uses it

  • Tasks that involve Refactoring

Example prompts

  • “/refactor-method-complexity-reduce”

Workflow steps

6 steps, taken from the first numbered list in SKILL.md.

  1. Analyze the current method to identify sources of cognitive complexity
  2. Identify extraction opportunities
  3. Extract focused helper methods
  4. Simplify the main method
  5. Preserve functionality
  6. Best practices

What it can do on your machine

Read from SKILL.md and the folder at commit 727ff2e. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md.

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Refactor Method Complexity Reduce loads about 1.1k tokens when it runs. Until then it costs about 47 tokens; SKILL.md has 538 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~47
When it runs · the whole SKILL.md, loaded when a task matches
~1.1k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from github/awesome-copilot at commit 727ff2e, republished under its MIT licence (© github). 538 words, ~1,108 tokens.

Download SKILL.mdSave it as .claude/skills/refactor-method-complexity-reduce/SKILL.md (or your agent's skills folder).
name
refactor-method-complexity-reduce
description
Refactor given method `${input:methodName}` to reduce its cognitive complexity to `${input:complexityThreshold}` or below, by extracting helper methods.

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. Best practices:

    • Make helper methods static when they don't need instance state
    • Use null checks and guard clauses early
    • Avoid creating unnecessary local variables
    • Consider using tuples for multiple return values
    • Group related helper methods together

Implementation Approach

  • Extract helper methods before refactoring the main flow
  • Test incrementally to ensure no regressions
  • Use meaningful names that describe the extracted responsibility
  • Keep extracted methods close to where they're used
  • Consider making repeated code patterns into generic methods

Result

The refactored method should:

  • Have cognitive complexity reduced to the target threshold of ${input:complexityThreshold} or below
  • Be more readable and maintainable
  • Have clear separation of concerns
  • Be easier to test and debug
  • Retain all original functionality
Show full SKILL.md (238 more words)Show less

Testing and Validation

CRITICAL: After completing the refactoring, you MUST:

  1. Run all existing tests related to the refactored method and its surrounding functionality
  2. MANDATORY: Explicitly verify test results show "failed=0"
    • NEVER assume tests passed - always examine the actual test output
    • Search for the summary line containing pass/fail counts (e.g., "passed=X failed=Y")
    • If the summary shows any number other than "failed=0", tests have FAILED
    • If test output is in a file, read the entire file to locate and verify the failure count
    • Running tests is NOT the same as verifying tests passed
    • Do not proceed until you have explicitly confirmed zero failures
  3. If any tests fail (failed > 0):
    • State clearly how many tests failed
    • Analyze each failure to understand what functionality was broken
    • Common causes: null handling, empty collection checks, condition logic errors
    • Identify the root cause in the refactored code
    • Correct the refactored code to restore the original behavior
    • Re-run tests and verify "failed=0" in the output
    • Repeat until all tests pass (failed=0)
  4. Verify compilation - Ensure there are no compilation errors
  5. Check cognitive complexity - Confirm the metric is at or below the target threshold of ${input:complexityThreshold}

Confirmation Checklist

  • Code compiles without errors
  • Test results explicitly state "failed=0" (verified by reading the output)
  • All test failures analyzed and corrected (if any occurred)
  • Cognitive complexity is at or below the target threshold of ${input:complexityThreshold}
  • All original functionality is preserved
  • Code follows project conventions and standards

© github, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in skills/refactor-method-complexity-reduce of github/awesome-copilot.

Open the folder on GitHubat commit 727ff2e

Used in 1 other repository

We found 1 copy of this SKILL.md (exact, near-identical or edited) in other folders, from 1 other GitHub owner. This page covers the copy in github/awesome-copilot, which our catalogue first saw on October 7, 2026.

Compare with similar skills

Refactor Method Complexity Reduce next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Refactor Method Complexity Reduce compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Refactor Method Complexity Reduce this skillgithub/awesome-copilot40k1 repos~1.1kAutomated safety check: PassMIT
Guidelinesakash-network/node1.1k22 repos~577Automated safety check: PassMIT
Component Refactoringlangflow-ai/langflow156k—~3.5kAutomated safety check: PassMIT
Migrate Core Code to Submodulestinyhumansai/openhuman41k—~2.6kAutomated safety check: PassGPL-3.0
ast-grep Structural Searchcode-yeongyu/oh-my-openagent70k—~3.3kAutomated safety check: PassMIT
Systematic Code Refactoringluongnv89/claude-howto42k—~3kAutomated safety check: PassMIT

Similar skills

  • Guidelines

    akash-network/node

    Behavioral guidelines to reduce common LLM coding mistakes. An agent skill from akash-network/node.

    1.1k GitHub starsUsed in 22 repos~577 tokens
    DevelopmentAuto-check passed
  • Component Refactoring

    langflow-ai/langflow

    Refactor high-complexity React components in Langflow frontend.

    156k GitHub stars~3.5k tokensUpdated today
    DevelopmentAuto-check passed
  • Migrate Core Code to Submodules

    tinyhumansai/openhuman

    Plans and carries out moving non-host-specific code and its tests from the OpenHuman core into vendored tiny submodule libraries, then releases the submodule and re-pins the host.

    41k GitHub stars~2.6k tokensUpdated yesterday
    DevelopmentAuto-check passed
  • ast-grep Structural Search

    code-yeongyu/oh-my-openagent

    Searches and rewrites code by syntax-tree shape across 25 languages with ast-grep, for codemods, structural queries and YAML lint rules, using a Python wrapper script.

    70k GitHub stars~3.3k tokensUpdated today
    DevelopmentAuto-check passed
  • Systematic Code Refactoring

    luongnv89/claude-howto

    Guides refactoring in phases based on Martin Fowler's method: research, test coverage check, planning and small tested steps, with your approval at each phase.

    42k GitHub stars~3k tokensUpdated 7 days ago
    DevelopmentAuto-check passed
  • Codex

    skills-directory/skill-codex

    A skill your agent uses when the user asks to run Codex CLI (codex exec, codex resume) or references OpenAI Codex for code analysis, refactoring, or automated editing

    1.5k GitHub starsUsed in 3 repos~1.8k tokens
    DevelopmentAuto-check passed

More from github/awesome-copilot

All 417 skills in this repo
  • Acquire Codebase Knowledge

    github/awesome-copilot

    Official

    Maps an unfamiliar codebase into seven evidence-backed documents in docs/codebase/, using a scan script and templates, for onboarding or architecture write-ups.

    40k GitHub starsUsed in 1 repo~2.3k tokens
    Auto-check passed
  • Azure Architecture Autopilot

    github/awesome-copilot

    Official

    Designs Azure infrastructure from a natural-language description, or diagrams an existing resource group, then refines the design through conversation and deploys it with Bicep.

    40k GitHub starsUsed in 1 repo~1.9k tokens
    Auto-check passed
  • Draw.io Diagram Generator

    github/awesome-copilot

    Official

    Generates, edits and validates draw.io files with correct mxGraph XML, covering flowcharts, architecture, sequence, ER and UML class diagrams.

    40k GitHub starsUsed in 1 repo~4.9k tokens
    Auto-check passed
  • Credit Risk Data Cleaning

    github/awesome-copilot

    Official

    Cleans raw credit data and screens variables before loan modeling, dropping unstable, noisy or redundant features and writing an Excel report of every step.

    40k GitHub starsUsed in 1 repo~1.5k tokens
    Auto-check passed
  • Daily Focus Board

    github/awesome-copilot

    Official

    Builds a warm, browser-based daily focus board the user updates by talking to their agent, with Eisenhower priorities, a brain-dump box and kind not-today carryover.

    40k GitHub stars~3k tokensUpdated today
    Auto-check passed
  • Python Pypi Package Builder

    github/awesome-copilot

    Official

    End-to-end skill for building, testing, linting, versioning, and publishing a production-grade Python library to PyPI.

    40k GitHub starsUsed in 1 repo~4.6k tokens
    Auto-check passed

Categories

Questions about Refactor Method Complexity Reduce

What does Refactor Method Complexity Reduce do?

Refactor given method ${input:methodName} to reduce its cognitive complexity to ${input:complexityThreshold} or below, by extracting helper methods. Refactor Method Complexity Reduce is an agent skill from github/awesome-copilot, published by the product's own GitHub organization. Refactor given method ${input:methodName} to reduce its cognitive complexity to ${input:complexityThreshold} or below, by extracting helper methods.

When should I use Refactor Method Complexity Reduce?

Refactor Method Complexity Reduce fits situations like: tasks that involve Refactoring.

How do I install Refactor Method Complexity Reduce in Claude Code?

Run `npx skills add github/awesome-copilot --skill refactor-method-complexity-reduce -a claude-code`. Or copy the skill folder (skills/refactor-method-complexity-reduce in github/awesome-copilot) into .claude/skills/refactor-method-complexity-reduce in your project. Claude Code loads it when a task matches its description.

How do I install Refactor Method Complexity Reduce in Codex?

Run `npx skills add github/awesome-copilot --skill refactor-method-complexity-reduce -a codex`. Or copy the skill folder (skills/refactor-method-complexity-reduce in github/awesome-copilot) into .agents/skills/refactor-method-complexity-reduce in your project. Codex loads it when a task matches its description.

Can I use Refactor Method Complexity Reduce in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add github/awesome-copilot --skill refactor-method-complexity-reduce -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/refactor-method-complexity-reduce, .gemini/skills/refactor-method-complexity-reduce, .github/skills/refactor-method-complexity-reduce and .opencode/skills/refactor-method-complexity-reduce in your project.

What does Refactor Method Complexity Reduce need to run?

SKILL.md names no scripts, command-line tools or credentials: Refactor Method Complexity Reduce is instructions for the agent only.

Does Refactor Method Complexity Reduce access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Refactor Method Complexity Reduce safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Refactor Method Complexity Reduce use?

Refactor Method Complexity Reduce is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Refactor Method Complexity Reduce use?

About 1.1k tokens (SKILL.md is roughly 4.4k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Refactor Method Complexity Reduce?

Skills that share tags, products or a category with Refactor Method Complexity Reduce: Guidelines (akash-network/node, 1.1k stars), Component Refactoring (langflow-ai/langflow, 156k stars), Migrate Core Code to Submodules (tinyhumansai/openhuman, 41k stars) and ast-grep Structural Search (code-yeongyu/oh-my-openagent, 70k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Refactor Method Complexity Reduce?

github (a GitHub organization, an official publisher) maintains it in github/awesome-copilot, which has 39,748 GitHub stars. The repository holds 417 skills in this directory. The repository was last updated on October 7, 2026.

Source: github/awesome-copilot on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.