code-refactoring

yaleh's avatarfrom yaleh

BAIME-aligned refactoring protocol for Go hotspots (CLIs, services, MCP tooling) with automated metrics (e.g., metrics-cli, metrics-mcp) and documentation.

⭐15stars🔀1forks📁View on GitHub🕐Updated Dec 13, 2025⬇️1downloads

When & Why to Use This Skill

This Claude skill provides a professional-grade, BAIME-aligned refactoring protocol specifically engineered for Go (Golang) environments, including microservices, CLI tools, and MCP (Model Context Protocol) implementations. It targets code 'hotspots'—areas with high cyclomatic complexity—and applies a rigorous transformation process backed by automated metrics and safety checklists. By integrating tools like metrics-cli and following a TDD-based workflow, it guarantees measurable improvements in code maintainability, ensuring a significant reduction in technical debt while upholding strict test coverage requirements.

Use Cases

  • Refactoring Complex Go Microservices: Automatically detect and restructure high-complexity functions in Go services to improve readability and reduce long-term maintenance costs.
  • Standardizing MCP Tooling Development: Apply professional engineering patterns and documentation protocols to Model Context Protocol tools to ensure they meet high-quality architectural standards.
  • Automated Code Quality Audits: Generate comprehensive validation reports and metrics snapshots (e.g., cyclomatic complexity and coverage deltas) to quantify the success of refactoring iterations.
  • Safe Technical Debt Reduction: Execute complex code transformations using a structured protocol that includes safety checklists and incremental commit logic to prevent regressions in production-critical Go code.
nameCode Refactoring
descriptionBAIME-aligned refactoring protocol for Go hotspots (CLIs, services, MCP tooling) with automated metrics (e.g., metrics-cli, metrics-mcp) and documentation.
allowed-toolsRead, Write, Edit, Bash, Grep, Glob

λ(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}