/code-quality-refactoring:refactor-method-complexity-reduce methodName and complexityThreshold, for example: CalculatePrice 15from code-quality-refactoring
Refactors a named method to reduce cognitive complexity below a requested threshold by extracting helper methods, simplifying control flow, and verifying tests pass.
Ships in code-quality-refactoring. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Reduce a named method's cognitive complexity to the requested threshold by extracting cohesive helper methods, simplifying control flow, preserving all behavior and error handling, then compiling and verifying related tests explicitly report failed=0.
${input:methodName} until complexity is under ${input:complexityThreshold}."Use $ARGUMENTS as the method name and target complexity threshold. Accept the legacy placeholders ${input:methodName} and ${input:complexityThreshold} when they appear in user-provided text, but resolve them to concrete values before editing. If either value is missing, infer from the selected code or ask for only the missing value.
Inspect the target method for these complexity sources before editing:
| Source | Refactoring move |
|---|---|
Deeply nested if/else blocks | Replace with guard clauses or extract branch handlers. |
Long switch or type dispatch | Extract case-specific methods or strategy-like handlers. |
| Repeated validation | Extract Validate* helpers that preserve exception types and messages. |
| Complex boolean expressions | Extract predicate methods with names that explain the condition. |
| Loops with inner conditions | Extract loop body or filtering predicates. |
| Repeated transformations | Extract reusable conversion or mapping helpers. |
The main method should read as a high-level flow after refactoring. Helpers should have a single responsibility and use appropriate access levels such as private, private static, or async when matching the original language and project style.
Validation is CRITICAL: tests are FAILED unless the summary proves zero failures. It is MANDATORY that related tests MUST be checked; NEVER assume pass/fail status without reading the output.
${input:methodName} and establish the baseline cognitive complexity if tooling is available.failed=0, pass/fail counts, or the framework's exact zero-failure equivalent.${input:complexityThreshold}.| Rule | Required behavior |
|---|---|
| Helper scope | Make helpers static only when they do not need instance state. |
| Parameter passing | Pass required values explicitly; do not add shared mutable state to avoid parameters. |
| Return values | Use tuples or small result objects only when they clarify multiple outputs and fit project conventions. |
| Local variables | Avoid unnecessary locals introduced only by extraction. |
| Error handling | Preserve original exception types and messages unless tests or user request demand a change. |
| Test repair | If tests fail, assume the refactor changed behavior until proven otherwise. |
failed=0; do not infer success from command exit alone.## Complexity refactor result
**Status:** complete | tests failing | blocked
**Method:** <methodName>
**Target complexity:** <complexityThreshold>
**Final complexity:** <value or "not measured">
### Refactoring summary
- <helper extracted and responsibility>
- <control-flow simplification>
### Validation
- Compile: pass | fail | not available — <evidence>
- Tests: pass | fail | not run — <command and summary containing failed=0>
- Behavior notes: <preserved validation/error/null behavior>
$ARGUMENTS, placeholders, selection, or user input.failed=0.## Output template exactly.What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub gbb-acelerators/awesome-harness-primitives --plugin code-quality-refactoring9 skills in this plugin
/dotnet-design-pattern-reviewReview C# and .NET code for design pattern quality, SOLID principles, dependency injection, repository/provider abstractions, ResourceManager usage, async practices, testability, and maintainability. Use this skill when asked for a .NET or C# design pattern review, architecture critique, or pattern-focused code review without modifying code./editorconfigGenerate or update a comprehensive .editorconfig from repository file types and formatting preferences, including indentation, line endings, charset, whitespace, final newline, language globs, and rule-by-rule explanations. Use when asked to create, standardize, or explain EditorConfig./em-dashReview and rewrite code, comments, documentation, and data files to avoid em dashes and en dashes by default. Use this skill when the user asks to remove em dashes, replace Unicode dashes with hyphens, review punctuation in code comments, or enforce ASCII-safe punctuation./quality-playbookRun a complete quality engineering audit on any codebase. Derives behavioral requirements from the code, generates spec-traced functional tests, runs a three-pass code review with regression tests, executes a multi-model spec audit (Council of Three), and produces a consolidated bug report with TDD-verified patches. Finds the 35% of real defects that structural code review alone cannot catch. Works with any language. Trigger on 'quality playbook', 'spec audit', 'Council of Three', 'fitness-to-purpose', or 'coverage theater'./refactorImprove existing code through surgical behavior-preserving refactoring. Use this skill when code is hard to understand or maintain, functions or classes are too large, code smells need addressing, adding features is difficult due to structure, or the user asks to clean up, refactor, or improve code without changing behavior./review-and-refactorReview project code against repository instructions, identify maintainability issues, make focused refactorings without splitting existing files, and validate tests when available. Use this skill when the user asks for code cleanup, maintainability review, best-practice refactoring, standards-driven improvements, or a senior engineering pass over existing code.Other plugins' skills for the same job