Code Refactoring

Refactor Go hotspots to reduce cyclomatic complexity and improve maintainability.

21|2|Updated Oct 8, 2025
One-click install
npx skills add https://github.com/yaleh/meta-cc --skill code-refactoring-yaleh
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: Code Refactoring
Source: https://github.com/yaleh/meta-cc/tree/main/.claude/skills/code-refactoring
Command: npx skills add https://github.com/yaleh/meta-cc --skill code-refactoring-yaleh

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

λ(target_pkg, target_hotspot, metrics_target) → (refactor_plan, metrics_snapshot, validation_report) | ∧ configs = read_json(experiment-config.json)? ∧ catalogue = configs.metrics_targets ∨ [] ∧ require(cyclomatic(target_hotspot) > 8) ∧ require(catalogue = [] ∨ metrics_target ∈ catalogue) ∧ require(run("make " + metrics_target)) ∧ baseline = results.md ∧ iterations/ ∧ apply(pattern_set = reference/patterns.md) ∧ use(templates/{iteration-template.md,refactoring-safety-checklist.md,tdd-refactoring-workflow.md,incremental-commit-protocol.md}) ∧ automate(metrics_snapshot) via scripts/{capture-*-metrics.sh,count-artifacts.sh} ∧ document(knowledge) → knowledge/{patterns,principles,best-practices} ∧ ensure(complexity_delta(target_hotspot) ≥ 0.30 ∧ cyclomatic(target_hotspot) ≤ 10) ∧ ensure(coverage_delta(target_pkg) ≥ 0.01 ∨ coverage(target_pkg) ≥ 0.70) ∧ validation_report = validate-skill.sh → {inventory.json, V_instance ≥ 0.85}

Frequently Asked Questions about Code Refactoring

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I reduce cyclomatic complexity in Go code?▼

Cyclomatic complexity measures code decision paths; reducing it improves maintainability. This Skill applies refactoring patterns to Go hotspots like command builders and orchestration flows, targeting complexity reduction of 30% or more and final scores below 10, with automated metrics capture and validation.

What refactoring patterns work best for Go CLI services?▼

Go CLI services benefit from patterns addressing command builders, jq pipelines, and orchestration flows. This Skill provides reference patterns, iteration templates, and a TDD-refactoring workflow to guide incremental changes while maintaining test coverage and measuring impact via automated metrics.

Can I refactor Go code while keeping test coverage intact?▼

Yes. This Skill includes a refactoring-safety checklist and incremental-commit protocol to preserve or improve test coverage (minimum 1% gain or 70% baseline). Automated metrics validate each iteration, and a TDD-refactoring workflow ensures tests guide the process end-to-end.

How do I measure refactoring impact in Go projects?▼

This Skill automates metrics capture through shell scripts that extract cyclomatic complexity, code coverage, and artifact counts, storing results in a baseline snapshot and iteration logs. Validation reports track V_instance and V_meta scores to quantify maintainability improvements.

What's needed before starting a refactoring pass on Go hotspots?▼

Identify target hotspots with cyclomatic complexity above 8, define metrics targets in experiment-config.json, and establish a baseline by running the project's build. This Skill requires these prerequisites to apply patterns, measure deltas, and validate outcomes.

Does this refactoring approach work with MCP tooling in Go?▼

Yes. This Skill targets CLI services and MCP tooling in Go, covering command builders, jq pipelines, and orchestration flows with BAIME-aligned documentation, automated metrics, and validation via tests and reports.

Related Skills