xiaohongshu
xiaohongshu
architecture-single-responsibility-principle
Automated SRP validation using multi-dimensional detection. Use when reviewing code for SRP compliance, checking "is this doing too much", validating architectural boundaries, before commits, or during refactoring. Detects God classes, method naming violations, complexity issues.
Full skill instructions
Quick Start → When to Use | Triggers | What It Does | Examples
How to Implement → Detection Process | Validation Levels | Expected Output
Patterns & Scripts → Detection Patterns | Detection Script | Project Patterns
Help → Troubleshooting | Requirements | Integration
Reference → SRP Principles | Detection Patterns | Quick Reference
MANDATORY in these situations:
Trigger with phrases like:
Automatically detect Single Responsibility Principle violations using multi-dimensional analysis: naming patterns, class metrics, method complexity, and project-specific architectural patterns. Provides actionable fix guidance with confidence scoring.
See usage-examples.md for complete examples with expected output.
Basic usage:
Skill(command: "single-responsibility-principle")Skill(command: "single-responsibility-principle --level=fast")Skill(command: "single-responsibility-principle --path=src/services/")Skill(command: "single-responsibility-principle --format=json")Choose based on context:
Execute multi-dimensional detection:
Naming Analysis (ast-grep):
Size Metrics (AST or line count):
Dependency Analysis (constructor params):
8 params → critical (90% confidence)
Complexity Metrics (radon if available):
Project-Specific Patterns:
Assign confidence levels:
For each violation:
Format results:
Single Responsibility Principle Validation Report
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Scope: path/to/code
Level: thorough
Files Analyzed: X
Classes Analyzed: Y
✅ Passed: Z/Y classes (P%)
❌ Violations Found: N
[CRITICAL] God Class: ClassName (path/file.py:45)
- Lines: 450 (threshold: 300)
- Methods: 23 (threshold: 15)
- Constructor params: 9 (threshold: 4)
- Complexity metrics: ATFD=8, WMC=52, TCC=0.28
- Actors identified: 3 (persistence, validation, coordination)
- Fix: Split into:
* ClassNamePersistence (handles database operations)
* ClassNameValidator (handles validation logic)
* ClassNameCoordinator (orchestrates workflow)
- Estimated effort: 4-6 hours
[WARNING] Method Name Violation: validate_and_save_user (path/file.py:120)
- Method name contains 'and' (40% confidence)
- Fix: Split into:
* validate_user() -> ServiceResult[User]
* save_user(user: User) -> ServiceResult[None]
- Estimated effort: 30 minutes
[WARNING] Long Method: process_data (path/file.py:200)
- Lines: 75 (threshold: 50)
- Cyclomatic complexity: 14 (threshold: 10)
- Fix: Extract helper methods for each logical section
- Estimated effort: 1-2 hours
Summary:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Critical: X violations
Warnings: Y violations
Reviews needed: Z items
Total estimated refactoring time: A-B hours
Next Steps:
1. Address critical violations first (God classes, architecture)
2. Refactor method name violations
3. Break down long methods
4. Review class sizes for potential splits
See usage-examples.md for complete usage examples including:
All examples include expected output and timing information.
mcp__ast-grep__find_code: AST-based pattern detectionRead: File analysisBash: Metrics calculation (radon if available)Grep: Quick pattern matchingGlob: File discoveryradon: Python complexity metrics (pip install radon)
pylint: Additional metrics (pip install pylint)
# Install optional metrics tools
uv pip install radon pylint
# Verify installation
radon --version
pylint --version
The skill uses multi-dimensional detection patterns. See detection-patterns.md for complete AST patterns and metrics thresholds.
Quick detection using provided script:
# Run all detection patterns
./scripts/detect-patterns.sh all /path/to/project
# Run specific pattern
./scripts/detect-patterns.sh method-and /path/to/project
./scripts/detect-patterns.sh god-class /path/to/project
./scripts/detect-patterns.sh constructor-params /path/to/project
./scripts/detect-patterns.sh optional-config /path/to/project
See detect-patterns.sh for implementation details.
Add SRP validation as Step 2 sub-check:
## Step 2: Single Responsibility Review
- [ ] Run `single-responsibility-principle --level=fast`
- [ ] Address critical violations
- [ ] Document acceptable warnings
Include SRP at layer level:
# Check domain entities don't do I/O
# Check application services don't contain business logic
# Check repositories only do data access
Add as quality gate:
# In check_all.sh or quality gate hook
Skill(command: "single-responsibility-principle --level=fast")
# Block commit if critical violations found
Coordinate SRP refactoring across files:
# Identify all God classes
# Plan extraction strategy
# Use MultiEdit for atomic refactoring
Solution: Install with uv pip install radon or skip complexity metrics (use --level=fast)
Solution: Adjust thresholds in detection patterns or focus on critical violations only
Solution: Use --level=fast or --path=specific/directory to narrow scope
Solution: Use --level=full for comprehensive analysis including actor identification
xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience