dawiddutoit/custom-claude/architecture-validate-srp
Claude Code and agent skill by dawiddutoit/custom-claude
- community
- ext:[{"type":"hook","description":"Pre/post lifecycle hooks"}]
Checking that the SKILL.md file is still in the repository.
Detect Single Responsibility Principle (SRP) violations using multi-dimensional analysis. Use when reviewing code for "SRP", "single responsibility", "god class", "doing too much", "too many dependencies", before commits, during refactoring, or as quality gate. Analyzes Python, JavaScript, TypeScript files with AST-based detection, metrics (TCC, ATFD, WMC), and project-specific patterns. Provides actionable fix guidance with refactoring estimates.
Install
npx vskill@latest install dawiddutoit/custom-claude/architecture-validate-srpSemi-extensibleMentions customization, but needs skill-specific knowledge. Read the extensible skills standard
SKILL.md
Validate Single Responsibility Principle (SRP)
Automated detection of SRP violations using actor-driven analysis, metrics, and AST patterns.
Purpose
Detect Single Responsibility Principle violations using multi-dimensional analysis including naming patterns, class metrics, method complexity, cohesion measurements, and project-specific architectural patterns. Provides actionable fix guidance with confidence scoring and refactoring estimates.
Table of Contents
Core Sections
- Purpose - What this skill detects and validates
- Quick Start - Immediate SRP validation workflow
- When to Use This Skill - Triggers and integration points
- What This Skill Does - SRP definition and detection methods
- Instructions - Complete step-by-step validation process
- Usage Examples - Real-world validation scenarios
- Supporting Files - References and examples
Detailed Sections
- Validation Levels - Fast, thorough, and full analysis modes
- Detection Methods - 4-level validation approach
- Integration with Other Skills - code-review, validate-architecture, quality-gates
- Parameters - Configuration options
- Output Format - Text and JSON report formats
- Success Metrics - Accuracy and performance targets
- Requirements - Dependencies and installation
- Red Flags to Avoid - Common pitfalls
- Troubleshooting - Common issues and solutions
- Expected Benefits - Metrics and improvements
Quick Start
User asks: "Check if this class is doing too much" or "Validate SRP compliance"
What happens:
- Scans code for SRP violations (naming, size, complexity, dependencies)
- Calculates cohesion metrics (TCC, ATFD, WMC)
- Detects project-specific anti-patterns
- Reports violations with specific refactoring guidance
- Estimates refactoring time and effort
Result: ✅ SRP compliant OR ❌ Violations with actionable fixes
When to Use This Skill
Invoke this skill when:
- User asks: "check SRP", "single responsibility", "is this doing too much"
- User asks: "god class", "too many dependencies", "method too long"
- Before commit (as part of
code-reviewskill) - During refactoring or architectural review
- As quality gate (via
run-quality-gatesskill) - When class/method feels complex but can't articulate why
Integration triggers:
code-reviewskill Step 2: Architectural Review (SRP sub-check)validate-architectureskill: SRP at layer levelrun-quality-gatesskill: Optional SRP quality gatemulti-file-refactorskill: SRP-driven refactoring coordination
What This Skill Does
SRP Definition (Actor-Driven)
Robert C. Martin: "A module should be responsible to one, and only one, actor."
- Actor: A group of users or stakeholders who would request changes
- NOT "do one thing" (task-driven) - a class can have multiple methods
- IS "have one reason to change" (actor-driven)
Example: See examples/violation-naming-patterns.py for violation and correct implementation showing Employee class serving 3 actors (Accounting, HR, DBA) and the correct split into PayCalculator, HourReporter, and EmployeeRepository.
Detection Methods (Multi-Dimensional)
This skill uses 4 validation levels:
- Level 1 (Fast, 5s): Naming patterns via AST-grep
- Methods with "and" in name → 40% confidence violation
- Quick scan of entire codebase
- Level 2 (Fast, 10s): Size metrics via AST analysis
- Class >300 lines → Review needed
- Method >50 lines → 60% confidence violation
- >15 methods per class → Review needed
- Level 3 (Moderate, 30s): Cohesion metrics
- God Class: ATFD >5 AND WMC >47 AND TCC <0.33 → 80% confidence
- Constructor >4 params (warning), >8 params (critical) → 75% confidence
- Level 4 (Manual, 5min): Actor analysis (guided questions)
- "How many actors would request changes to this class?"
- "Can you split by actor responsibility?"
Default mode: Level 2 (Fast + Size metrics) - balance speed and accuracy
Validation Levels
| Level | Speed | Checks | Use When | |
|---|---|---|---|---|
fast | 5s | Naming patterns only | Quick pre-commit scan | |
thorough | 30s | Naming + Size + Metrics | Normal workflow (default) | |
full | 5min | All checks + Actor analysis | Deep refactoring review |
Instructions
Step 1: Determine Validation Level
Step 2: Detect Naming Violations (All Levels)
Pattern 1: Methods with "and" in name (40% confidence)
Use the validation script to detect naming violations:
Using validation script:
Or manually with MCP tools:
Example violations and fixes: See examples/violation-naming-patterns.py showing validate_and_save_user() violation and the correct split into validate_user() and save_user().
Step 3: Analyze Size Metrics (Thorough+)
Pattern 2: Class size (300+ lines → review)
Use the validation script for size analysis:
Or use God Class detection script:
Thresholds:
- Class: >300 lines = warning, >500 lines = critical
- Method: >50 lines = warning, >100 lines = critical
- Methods per class: >15 = warning, >25 = critical
Step 4: Calculate Cohesion Metrics (Thorough+)
God Class Detection (80% confidence):
- ATFD (Access to Foreign Data): >5 = excessive coupling
- WMC (Weighted Methods per Class): >47 = too complex
- TCC (Tight Class Cohesion): <0.33 = low cohesion
Formula: ATFD >5 AND WMC >47 AND TCC <0.33 → God Class
Calculate metrics using radon:
See: references/srp-principles.md for detailed metric calculations and formulas.
Step 5: Detect Constructor Dependencies (Thorough+)
Pattern 4: Constructor parameters (>4 warning, >8 critical)
Use the God Class detection script:
Thresholds (75% confidence):
- 1-4 params: ✅ Good
- 5-8 params: ⚠️ Warning (consider parameter object)
- 9+ params: ❌ Critical (God Class indicator)
Example violations and fixes: See examples/violation-god-class.py showing UserService with 9 constructor parameters and the correct split into UserAuthService, UserNotificationService, and UserAnalytics.
Step 6: Detect Project-Specific Patterns
Read CLAUDE.md for project anti-patterns:
Check for project-specific SRP violations using grep:
Common project-specific violations:
- Domain entities importing infrastructure
- Application services implementing business logic (should orchestrate only)
- Repositories containing orchestration (should be data access only)
- Optional config parameters (violates fail-fast)
See: references/srp-principles.md for actor identification guidance.
Step 7: Actor Analysis (Full Mode Only)
Guided questions for user:
- "List all actors who would request changes to this class:"
- Example: "HR department, Accounting team, DBA"
- "Can you group methods by actor?"
- Example:
calculate_pay()→ Accounting,report_hours()→ HR
- "How would you name classes split by actor?"
- Example:
PayCalculator,HourReporter,EmployeeRepository
Actor count → Violation confidence:
- 1 actor: ✅ SRP compliant
- 2 actors: ⚠️ Warning (consider split)
- 3+ actors: ❌ Violation (must split)
Step 8: Generate Report
Report structure:
Usage Examples
Example 1: Quick Pre-Commit Check
Example 2: Class Review (Default)
Example 3: Deep Refactoring Analysis
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/architecture-validate-srp/SKILL.md
Popularity
- Repository stars
- 1
- 7-day trend score
- 3
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 13 Apr 2026, 6 months ago.
Extension points
hookPre/post lifecycle hooks
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/dawiddutoit/custom-claude/architecture-validate-srp)