Solid srp pattern

From paulpas/agent-skill-router · View interactive version

Solid srp pattern is an AI agent skill from the GitHub repository paulpas/agent-skill-router. Implements the Single Responsibility Principle (SRP) from SOLID, ensuring a class has one reason to change.

How to use this skill

Skill file

Single Responsibility Principle (SRP)

archetypes: implementation, educational

anti_triggers: multiple responsibilities

response_profile:

verbosity: medium

directive_strength: high

abstraction_level: tactical

Implements the Single Responsibility Principle from SOLID, ensuring a class has one reason to change.

When to Use

This section should succinctly explain the scenarios where the Single Responsibility Principle is applicable:

Archetypes

Anti-Triggers

Response Profile

Core Workflow

  1. Identify Responsibilities: Analyze what duties or functionalities can be performed by a class.
  2. Refactor into Separate Classes: Create separate classes for each responsibility identified.
  3. Apply Changes Incrementally: Adjust code to utilize new classes and methods appropriately.

Implementation Patterns

SRP Example

package main

import (
    "fmt"
)

// User represents a user model
type User struct {
    Name  string
    Email string
}

// UserRepository handles user-related database operations
type UserRepository struct {}

func (UserRepository) Save(u User) {
    // Logic to save user to database
    fmt.Println("Saving user:", u)
}

// EmailService manages email notifications
type EmailService struct {}

func (EmailService) SendEmail(email string, message string) {
    // Logic to send email
    fmt.Println("Sending email to:", email, "Message:", message)
}

Example Usage

package main

func main() {
    userRepo := UserRepository{}
    emailService := EmailService{}

    user := User{Name: "John Doe", Email: "john@example.com"}
    userRepo.Save(user)
    emailService.SendEmail(user.Email, "Welcome to our service!")
}

Constraints

MUST DO

MUST NOT DO

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.