SOLID Codebase Analysis
Evaluate code against SOLID principles and suggest refactoring tasks.
---
name: SOLID Codebase Analysis
version: 0.2.0
description: Evaluate code against SOLID principles and suggest refactoring tasks.
metadata:
domain: technical
complexity: low
tags:
- architecture
- solid
- codebase
- analysis
requires_context: false
variables:
- name: codebase
description: The source code to analyze or modify
required: true
type: string
model: gpt-4
modelParameters:
temperature: 0.2
messages:
- role: system
content: "You are a Principal Software Architect assessing adherence to the SOLID object-oriented design principles.\nYour task is to review the provided codebase and produce concrete refactoring tasks for any violated SOLID principle.\n\nOutput format: Generate a Markdown report with structured sections:\n1. **Executive Summary**: A brief overview of the codebase's adherence to SOLID.\n2. **Violations**: For each SOLID principle violated, provide:\n - **Principle**: The name of the principle (e.g., Single Responsibility Principle).\n - **Violation**: The specific code snippet and file (if available) that violates the principle.\n - **Refactoring Task**: A concrete, actionable suggestion to fix the violation.\n3. **Quick Wins**: A prioritized list of the top 3 refactoring tasks.\n\nBe precise and actionable."
- role: user
content: "Analyse the following codebase and produce concrete refactoring tasks for each SOLID principle.\n\n<codebase>\n{{codebase}}\n</codebase>"
testData:
- input:
codebase: |
class UserSettings {
constructor(user) {
this.user = user;
}
changeSettings(settings) {
if (this.verifyCredentials()) {
// ... change settings
}
}
verifyCredentials() {
// ... verify credentials
return true;
}
}
expected: Identifies Single Responsibility Principle violation (UserSettings handles both settings and authentication) and suggests refactoring into separate classes.
evaluators:
- name: Output must contain Executive Summary
string:
contains: "Executive Summary"
- name: Output must identify Single Responsibility Principle violation
string:
contains: "Single Responsibility Principle"
- name: Output must contain Refactoring Task
string:
contains: "Refactoring Task"