refactoring

Refactor Go packages into standardized service and adapter layers.

2.2k|199|Updated Jun 6, 2023
One-click install
npx skills add https://github.com/openmeterio/openmeter --skill refactoring-openmeterio
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: refactoring
Source: https://github.com/openmeterio/openmeter/tree/main/.agents/skills/refactoring
Command: npx skills add https://github.com/openmeterio/openmeter --skill refactoring-openmeterio

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill addresses complex and non-standard package structures within the codebase, aiming to improve maintainability and adherence to established architectural patterns.

Core Features & Use Cases

  • Service/Adapter Pattern Implementation: Guides the restructuring of packages to align with the recommended service (business logic) and adapter (data access) layers.
  • Anti-Pattern Removal: Identifies and helps eliminate common code smells like deep nesting, scattered types, and global state.
  • Use Case: Refactor the subscription package to separate its business logic from data access concerns, making it easier to manage and test.

Quick Start

Use the refactoring skill to restructure the subscription package.

Frequently Asked Questions about refactoring

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

FAQPage Schema
How do I refactor a Go package to use the service and adapter pattern?

To refactor a Go package using the service and adapter pattern, you separate business logic into a service layer and data access into an adapter layer. This standardizes code structure and eliminates anti-patterns like scattered types and global state.

What is the best way to separate business logic from data access in complex domain packages?

Separating business logic from data access in complex domain packages requires implementing specific directory layouts and interface definitions. Restructuring your code into distinct service and adapter layers makes the package easier to manage and test.

How do I eliminate code smells and anti-patterns in a non-standard package structure?

Eliminating anti-patterns in a non-standard package structure involves identifying deep nesting, scattered types, and global state. You refactor the codebase towards a standardized service and adapter pattern to improve overall maintainability.

When do I need to restructure an existing Go package towards a standardized code structure?

You need to restructure an existing Go package towards a standardized code structure when the package features complex, non-standard structures. Refactoring is necessary to separate business logic from data access and improve architectural adherence.

Does refactoring the subscription package require specific directory layouts and interface definitions?

Yes, refactoring the subscription package requires adherence to specific directory layouts and interface definitions for the service and adapter layers. This ensures the business logic is properly separated from data access concerns.