Analyze Solid Violations logo

Analyze Solid Violations

Community
dykyi-roman
analyze-solid-violations

Analyzes PHP codebase for SOLID principle violations. Detects God classes (SRP), type switches (OCP), broken contracts (LSP), fat interfaces (ISP), and concrete dependencies (DIP). Generates actionable reports with severity levels and remediation recommendations.

Overview

Publisherdykyi-roman
Repositoryawesome-claude-code
Skill nameanalyze-solid-violations
Stars
98
Forks
25
Bundled files
1
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 1 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by dykyi-roman on GitHub. Read the source before you install it.

Installation

Install the Analyze Solid Violations AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/dykyi-roman/awesome-claude-code.git /tmp/awesome-claude-code
mkdir -p .claude/skills
cp -r /tmp/awesome-claude-code/skills/analyze-solid-violations .claude/skills/analyze-solid-violations
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Analyze Solid Violations in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Analyze Solid Violations on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Analyze Solid Violations is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

SOLID Violations Analyzer

Overview

This skill analyzes PHP codebases for SOLID principle violations and generates detailed reports with severity levels and remediation recommendations.

Analysis Workflow

Step 1: Scope Identification

Determine analysis scope from user input or detect automatically:

bash
# Detect project structure
ls -la src/

# Identify key directories
find . -type d -name "Domain" -o -name "Application" -o -name "Infrastructure"

Step 2: Run Detection Patterns

Execute detection patterns for each SOLID principle.

SRP (Single Responsibility) Detection

God Class Detection

bash
# Find large classes (>500 lines)
find . -name "*.php" -path "*/src/*" -exec wc -l {} \; | awk '$1 > 500 {print "CRITICAL: " $0}'

# Find classes with many methods
for file in $(find . -name "*.php" -path "*/src/*"); do
  count=$(grep -c "public function" "$file" 2>/dev/null || echo 0)
  if [ "$count" -gt 15 ]; then
    echo "WARNING: $file has $count public methods"
  fi
done

# Classes with problematic names
grep -rn "class.*Manager\|class.*Handler\|class.*Helper\|class.*Util" --include="*.php" src/

High Dependency Count

bash
# Count constructor dependencies
grep -rn "__construct" --include="*.php" -A 20 src/ | \
  grep -E "private|readonly" | \
  awk -F: '{files[$1]++} END {for(f in files) if(files[f]>7) print "WARNING: " f " has " files[f] " dependencies"}'

Multiple Responsibility Indicators

bash
# Classes with "And" in name
grep -rn "class\s\+\w*And\w*" --include="*.php" src/

# Check for mixed concerns
grep -rn "class.*Service" --include="*.php" src/ -l | while read file; do
  if grep -q "Repository\|Mailer\|Logger" "$file"; then
    echo "INFO: $file may have mixed concerns"
  fi
done

OCP (Open/Closed) Detection

Type Switch Detection

bash
# Switch on type property
grep -rn "switch.*->type\|match.*->type\|match.*::class" --include="*.php" src/

# instanceof chains
grep -rn "if.*instanceof\|elseif.*instanceof" --include="*.php" src/

# Type-based conditionals
grep -rn "if.*getType\(\)\s*===\|if.*->type\s*===" --include="*.php" src/

# Hardcoded type maps
grep -rn "\[.*::class\s*=>" --include="*.php" src/

Extension Indicators

bash
# Classes that need frequent modification (check git history if available)
git log --since="3 months ago" --name-only --pretty=format: -- "*.php" | \
  sort | uniq -c | sort -rn | head -20

LSP (Liskov Substitution) Detection

Contract Violations

bash
# NotImplementedException throws
grep -rn "throw.*NotImplemented\|throw.*NotSupported\|throw.*UnsupportedOperation" --include="*.php" src/

# Empty method overrides
grep -rn "public function.*\{[\s]*\}" --include="*.php" src/

# Parent type checks in child classes
grep -rn "if.*parent::\|parent::.*?:" --include="*.php" src/

Precondition/Postcondition Issues

bash
# Additional validation in overrides
grep -rn "function.*override" --include="*.php" -A 10 src/ | grep "if.*throw"

# Return null where parent might not
grep -rn "return\s*null;" --include="*.php" src/

ISP (Interface Segregation) Detection

Fat Interface Detection

bash
# Count methods in interfaces
for file in $(find . -name "*.php" -path "*/src/*" -exec grep -l "^interface" {} \;); do
  count=$(grep -c "public function" "$file" 2>/dev/null || echo 0)
  if [ "$count" -gt 5 ]; then
    echo "WARNING: $file interface has $count methods"
  fi
  if [ "$count" -gt 8 ]; then
    echo "CRITICAL: $file interface has $count methods - consider splitting"
  fi
done

Unused Interface Methods

bash
# Find "// TODO" or "// not implemented" in interface implementations
grep -rn "//\s*TODO\|//\s*not implemented\|//\s*unused" --include="*.php" src/

# Empty implementations
grep -rn "function.*\{[\s]*return;\s*\}" --include="*.php" src/

Generic Interface Names

bash
# Overly generic interface names
grep -rn "interface\s\+\(Service\|Manager\|Handler\)\s*$" --include="*.php" src/

DIP (Dependency Inversion) Detection

Direct Instantiation

bash
# New in methods (excluding exceptions, DateTime, stdClass)
grep -rn "new\s\+[A-Z]" --include="*.php" src/ | \
  grep -v "Exception\|DateTime\|stdClass\|DateTimeImmutable\|ArrayObject\|SplQueue"

# Static method calls to concrete classes
grep -rn "[A-Z][a-z]*::[a-z]" --include="*.php" src/ | \
  grep -v "self::\|static::\|parent::\|Uuid::\|Money::"

Concrete Type Hints

bash
# Constructor with concrete types (not interfaces)
grep -rn "__construct" --include="*.php" -A 15 src/ | \
  grep -E "(private|readonly)\s+[A-Z][a-z]*[A-Z][a-z]*\s+\\\$" | \
  grep -v "Interface\|Abstract\|Contract"

Service Locator Anti-pattern

bash
# Container/locator usage
grep -rn "container->get\|app()->make\|\\\$this->get(" --include="*.php" src/

Report Generation

Analysis Output Format

markdown
# SOLID Violations Report

## Summary

| Principle | Critical | Warning | Info |
|-----------|----------|---------|------|
| SRP | X | X | X |
| OCP | X | X | X |
| LSP | X | X | X |
| ISP | X | X | X |
| DIP | X | X | X |

## Critical Violations

### SRP-001: God Class
- **File:** `src/Service/UserManager.php`
- **Lines:** 847
- **Issue:** Class exceeds 500 lines with 23 public methods
- **Recommendation:** Extract into focused classes
- **Skills:** `create-use-case`, `create-domain-service`

### OCP-001: Type Switch
- **File:** `src/Payment/PaymentProcessor.php:45`
- **Issue:** Switch on payment type requires modification for new types
- **Recommendation:** Apply Strategy pattern
- **Skills:** `create-strategy`

## Warning Violations

### ISP-001: Fat Interface
- **File:** `src/Repository/UserRepository.php`
- **Methods:** 12
- **Issue:** Interface too large, clients forced to depend on unused methods
- **Recommendation:** Segregate into UserReader, UserWriter, UserStats

## Remediation Priority

1. **Immediate:** God classes blocking testing
2. **High:** Type switches preventing extension
3. **Medium:** Fat interfaces causing coupling
4. **Low:** Minor DIP violations

Severity Classification

SeverityCriteriaAction
CRITICAL>500 LOC, >10 deps, NotImplementedExceptionImmediate refactoring
WARNING300-500 LOC, 7-10 deps, type switchesPlan refactoring
INFO200-300 LOC, minor issuesMonitor in next iteration

Remediation Skills

ViolationRecommended Skill
God Classcreate-use-case
Type Switchcreate-strategy
No Interfacecreate-repository
Domain Logiccreate-domain-service
Value Extractioncreate-value-object
Factory Missingcreate-factory
Decorator Needcreate-decorator

Quick Analysis Commands

bash
# Full analysis
echo "=== SRP ===" && \
find . -name "*.php" -path "*/src/*" -exec wc -l {} \; | awk '$1 > 400' && \
echo "=== OCP ===" && \
grep -rn "switch.*type\|match.*::class" --include="*.php" src/ && \
echo "=== LSP ===" && \
grep -rn "NotImplemented\|NotSupported" --include="*.php" src/ && \
echo "=== ISP ===" && \
for f in $(find . -name "*.php" -exec grep -l "^interface" {} \;); do \
  c=$(grep -c "public function" "$f"); [ $c -gt 5 ] && echo "$f: $c methods"; \
done && \
echo "=== DIP ===" && \
grep -rn "new\s\+[A-Z]" --include="*.php" src/ | grep -v "Exception\|DateTime" | head -20

Integration with solid-knowledge

This analyzer uses detection patterns from solid-knowledge. For detailed principle explanations and patterns, refer to:

  • solid-knowledge/references/srp-patterns.md
  • solid-knowledge/references/ocp-patterns.md
  • solid-knowledge/references/lsp-patterns.md
  • solid-knowledge/references/isp-patterns.md
  • solid-knowledge/references/dip-patterns.md
  • solid-knowledge/references/antipatterns.md

Report Template

See assets/report-template.md for the full report format.

When This Is Acceptable

  • Doctrine entities — Entities may appear to violate SRP due to persistence concerns mixed with domain logic (framework requirement)
  • DTOs/Value Objects — Data classes with many properties don't violate SRP (single responsibility = data transfer)
  • Framework controllers — Slim controllers with inject+validate+delegate are acceptable

False Positive Indicators

  • Class is a DTO, Value Object, or Request/Response object
  • Class is a Doctrine entity with only getters/setters + domain methods
  • Apparent SRP violation is actually framework convention

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Analyze Solid Violations AI skill do?

Analyzes PHP codebase for SOLID principle violations. Detects God classes (SRP), type switches (OCP), broken contracts (LSP), fat interfaces (ISP), and concrete dependencies (DIP). Generates actionable reports with severity levels and remediation recommendations.

Why use Analyze Solid Violations on TypingMind?

Because you install it once and use it with any model. Analyze Solid Violations is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Analyze Solid Violations in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/dykyi-roman/awesome-claude-code/tree/master/skills/analyze-solid-violations. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Analyze Solid Violations?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Analyze Solid Violations?

As many as you like. As long as a model supports skills, you can use Analyze Solid Violations with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Analyze Solid Violations AI skill free?

Yes. It is published on GitHub by dykyi-roman under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇