golang-refactor

Refactor Go code using SOLID principles and design patterns.

Updated Oct 21, 2022
One-click install
npx skills add https://github.com/Chengxufeng1994/dotfiles --skill golang-refactor
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: golang-refactor
Source: https://github.com/Chengxufeng1994/dotfiles/tree/main/claude/skills/golang-refactor
Command: npx skills add https://github.com/Chengxufeng1994/dotfiles --skill golang-refactor

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill addresses complex code refactoring needs in Go, aiming to improve code quality, maintainability, and adherence to software design principles.

Core Features & Use Cases

  • Structured Refactoring: Applies SOLID, KISS, YAGNI, DRY, and GoF Design Patterns for robust code improvement.
  • Code Smell Detection: Identifies and rectifies issues like God Objects, excessive coupling, and duplicated logic.
  • OOA/OOD Analysis: Provides object-oriented analysis and design for better software architecture.
  • Use Case: Refactor a large, monolithic Go function with many parameters and mixed responsibilities into smaller, testable, and more maintainable units following SOLID principles.

Quick Start

Use the golang-refactor skill to refactor the file '/path/to/your/code.go'.

Frequently Asked Questions about golang-refactor

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

FAQPage Schema
How do I refactor Go code with long parameter lists and mixed responsibilities?

To refactor Go code with long parameter lists and mixed responsibilities, you can apply SOLID principles and GoF design patterns to break down monolithic functions into smaller, testable, and maintainable units. This process restructures modules to fix code smells and reduce excessive coupling.

What's the best way to fix God Objects and excessive coupling in Go software architecture?

Fixing God Objects and excessive coupling in Go software architecture involves analyzing the code for design quality and applying OOA/OOD principles. Restructuring the modules using KISS and DRY principles helps separate mixed responsibilities and rectify duplicated logic effectively.

How does applying SOLID and DRY principles improve Go code quality?

Applying SOLID and DRY principles improves Go code quality by providing structured refactoring guidance that eliminates duplicated logic and mixed responsibilities. This approach ensures the software architecture adheres to robust design patterns, resulting in more maintainable code.

Can I use design patterns to restructure large monolithic Go functions?

Yes, you can use GoF design patterns to restructure large monolithic Go functions. By analyzing the code for design quality, the refactoring process breaks down complex functions with many parameters into smaller, testable, and more maintainable units.

When do I need object-oriented analysis and design for Go refactoring?

You need object-oriented analysis and design (OOA/OOD) for Go refactoring when your code exhibits design quality issues like God Objects, excessive coupling, or mixed responsibilities. OOA/OOD provides the architectural analysis required to apply SOLID principles and restructure modules effectively.