acc-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.
Best use case
acc-analyze-solid-violations is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
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.
Teams using acc-analyze-solid-violations should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/acc-analyze-solid-violations/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How acc-analyze-solid-violations Compares
| Feature / Agent | acc-analyze-solid-violations | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this 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.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# 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:** `acc-create-use-case`, `acc-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:** `acc-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
| Severity | Criteria | Action |
|----------|----------|--------|
| CRITICAL | >500 LOC, >10 deps, NotImplementedException | Immediate refactoring |
| WARNING | 300-500 LOC, 7-10 deps, type switches | Plan refactoring |
| INFO | 200-300 LOC, minor issues | Monitor in next iteration |
## Remediation Skills
| Violation | Recommended Skill |
|-----------|-------------------|
| God Class | `acc-create-use-case` |
| Type Switch | `acc-create-strategy` |
| No Interface | `acc-create-repository` |
| Domain Logic | `acc-create-domain-service` |
| Value Extraction | `acc-create-value-object` |
| Factory Missing | `acc-create-factory` |
| Decorator Need | `acc-create-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 acc-solid-knowledge
This analyzer uses detection patterns from `acc-solid-knowledge`. For detailed principle explanations and patterns, refer to:
- `acc-solid-knowledge/references/srp-patterns.md`
- `acc-solid-knowledge/references/ocp-patterns.md`
- `acc-solid-knowledge/references/lsp-patterns.md`
- `acc-solid-knowledge/references/isp-patterns.md`
- `acc-solid-knowledge/references/dip-patterns.md`
- `acc-solid-knowledge/references/antipatterns.md`
## Report Template
See `assets/report-template.md` for the full report format.Related Skills
30-analyze-impact-150
[30] ANALYZE. Understand how changes impact the system — what's the core, what's affected, what depends on what. Use when planning changes, analyzing systems, debugging issues, or anytime you need to see the full picture of cause and effect. Triggers on "what's affected", "impact analysis", "dependencies", "scope mapping", or when you need to understand ripple effects.
solidstart-optimistic-ui
SolidStart optimistic UI: use useSubmissions to show pending data immediately, combine server data with pending submissions, filter by pending state, handle rollback on errors.
figma-analyze
Analyze Figma designs for code implementation readiness and design-code parity. Use when working with Figma URLs, analyzing component designs, or checking token consistency.
ai-file-analyzer
Analyze Adobe Illustrator (.ai) files to extract design information including text content, fonts, color palettes, vector paths, and generate high-resolution preview images. Use when analyzing logo files, design assets, or any Adobe Illustrator documents that need programmatic inspection.
31-analyze-think-150
[31] ANALYZE. Universal deep thinking methodology for any situation requiring quality reasoning. Use when solving problems, debugging, making decisions, analyzing code, planning, reviewing, or anytime you need thorough thinking instead of surface-level responses. Triggers on "think deeply", "analyze thoroughly", "reason carefully", "deep thinking", "understand completely", or any task requiring careful thought.
solid-core-stores
SolidJS stores: createStore for complex state, direct property access, path syntax for updates, produce for immutable mutations, reconcile for diffing, createMutable for proxy-based stores, unwrap for raw data.
pdf-analyzer
Analyze PDF, DOCX, and spreadsheet documents using vision models. Converts documents to images and extracts insights with layout preservation. Uses VT Code's native document processor (no container skills required).
excel-field-analyzer
分析Excel/CSV字段结构,AI自动生成中英文映射,验证翻译质量,输出统计报告。用于电子表格分析、数据字典创建、字段映射场景。
analyze-us-bank-credit-deposit-decoupling
分析銀行貸款與存款之間的「信貸創造脫鉤」現象,追蹤存款的絕對收縮與回升軌跡,用以辨識聯準會緊縮政策在銀行體系內部的真實傳導效果。
analyze-silver-miner-metal-ratio
以「銀礦股價格 ÷ 白銀價格」的相對比率衡量礦業股板塊相對於金屬本體的估值區間(偏貴/偏便宜),並用歷史分位數與類比區間推導「底部/頂部」訊號與情境推演。
analyze-jgb-insurer-superlong-flow
從日本保險公司對超長期(10年以上)JGB 的淨買賣時間序列,自動產出「本月是否創紀錄淨賣出、連續淨賣出月數、期間累積淨賣出」等結論。
analyze-japan-debt-service-tax-burden
以日本公債殖利率變化為觸發,量化「政府利息支出 / 稅收」負擔(含情境壓力測試),並判斷是否進入債務利息螺旋風險區。