Token导航 LogoToken导航

Agent Skill · 研究检索

architecture-validate-srp(架构验证 SRP)

architecture-validate-srp 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

architecture-validate-srp 是研究检索类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为调用外部服务;许可证信息还不明确,第三方扫描已通过,按安装量在研究检索类的 73,675 个 Skill 里排第 67,439。

总安装 245周安装 10GitHub Stars 1下载 79核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
unknown

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:architecture-validate-srp(架构验证 SRP)
来源仓库:https://github.com/dawiddutoit/custom-claude
仓库路径:skills/architecture-validate-srp
安装命令:
npx skills add https://github.com/dawiddutoit/custom-claude --skill architecture-validate-srp
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/dawiddutoit/custom-claude --skill architecture-validate-srp

这个 Skill 是做什么的

研究检索类 Skill 主要解决「找资料、核对事实、把来源整理清楚」的问题,通常会让助手先检索再总结。

该技能自动化检测单一职责原则(SRP)违反情况,基于命名、复杂度与 AST 模式分析。适用于代码质量监控,识别类与方法层面的职责混杂问题并提供修复指引。通过多维度度量与项目特定模式匹配,输出置信度评分与重构工作量估算。安装需确认是否允许解析源代码与生成检测报告,建议集成到 CI 流程定期运行。

不提供自动重构,输出为问题列表与建议,需开发者手动实施调整。

来源仓库内路径:skills/architecture-validate-srp

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/dawiddutoit/custom-claude --skill architecture…;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它需要调用外部服务,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

architecture-validate-srp 怎么安装?

在终端执行 npx skills add https://github.com/dawiddutoit/custom-claude --skill architecture-validate-…。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

architecture-validate-srp 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

architecture-validate-srp 需要什么权限?

权限级别是调用外部服务。该 Skill 可能调用第三方服务、云服务或外部模型 API,使用前需要确认账号、额度、数据发送范围和服务条款。

architecture-validate-srp 是免费的吗?

公开资料没有标注明确许可证,收费和商用限制都无法确认。正式使用前请到来源仓库核对授权说明。

architecture-validate-srp 用的人多吗?

公开数据是累计安装 245 次,近一周安装 10 次,下载 79 次,GitHub 1 星。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

architecture-validate-srp 安全吗?

第三方扫描结果为通过,但这只覆盖已知的静态检查项,不能替代自己读一遍源码和安装命令。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。
  • 第三方扫描已通过,常见的高风险行为没有命中。

先想清楚的地方

  • 许可证没有明确标注,能不能商用、能不能再分发都不确定。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理研究检索类任务、又不想每次都手写提示词的人。

不太适合

  • 需要明确授权才能用到公司项目里的场景。
  • 需要厂商级技术支持和 SLA 的生产系统。

研究检索类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
find-skills

寻找技能 · Codex、Claude

31,199,81316,486操作浏览器MIT有提醒
self-improving-agent

自我改进 Agent · OpenClaw

16,464,0023,396接触敏感数据MIT-0通过
soultrace

灵魂追踪 · Codex、Claude

7,588,94412需要联网未明确有提醒
self-improving

自我完善 · OpenClaw

6,829,2841,046需要联网MIT-0通过
microsoft-foundry

微软代工厂 · Codex、Claude

6,614,144764调用外部服务未明确有提醒
architecture-validate-srp

架构验证 SRP · 本页

2451调用外部服务未明确通过

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

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

Detailed Sections

Quick Start

User asks: "Check if this class is doing too much" or "Validate SRP compliance"

What happens:

  1. Scans code for SRP violations (naming, size, complexity, dependencies)
  2. Calculates cohesion metrics (TCC, ATFD, WMC)
  3. Detects project-specific anti-patterns
  4. Reports violations with specific refactoring guidance
  5. 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-review skill)
  • During refactoring or architectural review
  • As quality gate (via run-quality-gates skill)
  • When class/method feels complex but can't articulate why

Integration triggers:

  • code-review skill Step 2: Architectural Review (SRP sub-check)
  • validate-architecture skill: SRP at layer level
  • run-quality-gates skill: Optional SRP quality gate
  • multi-file-refactor skill: 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:

  1. Level 1 (Fast, 5s): Naming patterns via AST-grep

- Methods with "and" in name → 40% confidence violation - Quick scan of entire codebase

  1. 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

  1. 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

  1. 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

LevelSpeedChecksUse When
fast5sNaming patterns onlyQuick pre-commit scan
thorough30sNaming + Size + MetricsNormal workflow (default)
full5minAll checks + Actor analysisDeep refactoring review

Instructions

Step 1: Determine Validation Level

# User request → Validation level
"quick check" → fast
"review this class" → thorough (default)
"plan refactoring" → full

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:

./scripts/validate-srp.sh <path> --level=fast

Or manually with MCP tools:

mcp__ast-grep__find_code(
    pattern="def $NAME_and_$REST",
    project_folder="/path/to/project",
    language="python"
)

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:

./scripts/validate-srp.sh <path> --level=thorough

Or use God Class detection script:

./scripts/check-god-class.sh <file.py>

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:

# If radon available
uv run radon cc src/ -a -nb  # Cyclomatic complexity (WMC proxy)
uv run radon raw src/        # Raw metrics

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:

./scripts/check-god-class.sh <file.py>

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:

# Pattern 1: Optional config parameters (project anti-pattern)
grep -rn "config.*Optional\|config.*None.*=" src/

# Pattern 2: Domain entities doing I/O (layer violation)
grep -r "import.*requests\|import.*database" domain/

# Pattern 3: Application services with business logic
grep -r "def calculate\|def compute" application/services/

# Pattern 4: Repositories with orchestration
grep -A 10 "class.*Repository" infrastructure/repositories/

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:

  1. "List all actors who would request changes to this class:"

- Example: "HR department, Accounting team, DBA"

  1. "Can you group methods by actor?"

- Example: calculate_pay() → Accounting, report_hours() → HR

  1. "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:

SRP Validation Report
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

✅ Passed: X/Y classes (Z%)

❌ Violations Found: N

[CRITICAL] God Class: ClassName (path/file.py:line)
  - Lines: X (threshold: 300)
  - Methods: Y (threshold: 15)
  - Constructor params: Z (threshold: 4)
  - ATFD: A, WMC: B, TCC: C
  - Actors detected: N (actor1, actor2, actor3)
  - Fix: Split into Class1 (actor1), Class2 (actor2), Class3 (actor3)
  - Estimated refactoring: A-B hours

[WARNING] Method Name Violation: method_and_other (path/file.py:line)
  - Method name contains 'and'
  - Confidence: 40%
  - Fix: Split into method() and other()
  - Estimated refactoring: 15-30 minutes

[WARNING] Long Method: process_request (path/file.py:line)
  - Lines: X (threshold: 50)
  - Cyclomatic complexity: Y (threshold: 10)
  - Confidence: 60%
  - Fix: Extract 2-3 smaller methods
  - Estimated refactoring: 30-60 minutes

Summary:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
- X critical violations (must fix)
- Y warnings (should fix)
- Total estimated refactoring time: A-B hours
- Top priority: ClassName (god class)

Usage Examples

Example 1: Quick Pre-Commit Check

# User: "Quick SRP check before commit"

# Skill runs level: fast (5s)
→ Scans for method names with "and"
→ Reports 2 violations

Output:
⚠️ 2 SRP warnings found:

1. validate_and_save_user (src/services/user.py:45)
   - Method name contains 'and'
   - Fix: Split into validate_user() and save_user()

2. fetch_and_transform_data (src/utils/data.py:78)
   - Method name contains 'and'
   - Fix: Split into fetch_data() and transform_data()

Run with --thorough for complete analysis.

Example 2: Class Review (Default)

# User: "Review UserService for SRP compliance"

# Skill runs level: thorough (30s)
→ Naming patterns
→ Size metrics
→ Cohesion metrics
→ Constructor analysis

Output:
❌ UserService violates SRP (src/application/services/user_service.py:12)

Violations:
- Lines: 487 (threshold: 300) ❌
- Methods: 23 (threshold: 15) ⚠️
- Constructor params: 9 (threshold: 4) ❌
- ATFD: 12 (threshold: 5) ❌
- WMC: 89 (threshold: 47) ❌
- TCC: 0.21 (threshold: 0.33) ❌

Detected actors (3):
1. Authentication (login, logout, verify_token)
2. Profile Management (update_profile, get_profile, delete_account)
3. Notifications (send_welcome_email, send_reset_email)

Recommended split:
- UserAuthService: authentication methods
- UserProfileService: profile management
- UserNotificationService: notification methods

Estimated refactoring: 4-6 hours

Example 3: Deep Refactoring Analysis

# User: "Plan refactoring for PaymentProcessor - full SRP analysis"

# Skill runs level: full (5 min with user interaction)
→ All automated checks
→ Actor analysis questions
→ Refactoring plan

Questions asked:
1. "List actors who request changes to PaymentProcessor"
   User: "Finance team, Fraud detection, Customer support, Compliance"

2. "Group methods by actor"
   User provides grouping...

Output:
❌ PaymentProcessor is a God Class (4 actors detected)

Actor breakdown:
1. Finance (3 methods): process_payment, refund_payment, calculate_fees
2. Fraud Detection (2 methods): check_fraud_score, block_suspicious
3. Customer Support (2 methods): get_transaction_history, dispute_charge
4. Compliance (2 methods): log_transaction, generate_audit_report

Refactoring plan:
Phase 1 (2 hours): Extract PaymentProcessor (Finance actor)
Phase 2 (1.5 hours): Extract FraudDetectionService
Phase 3 (1.5 hours): Extract TransactionHistoryService (Support)
Phase 4 (1 hour): Extract ComplianceReporter
Phase 5 (1 hour): Integration tests and validation

Total estimated time: 7 hours
Recommended approach: Incremental (1 phase per day)

Integration with Other Skills

With code-review

The code-review skill invokes SRP validation in Step 2 (Architectural Review) as a sub-check. When SRP violations are detected, they are reported as warnings in the overall code review report.

Integration point: Automatic invocation during code review workflow with level="fast" for speed.

With validate-architecture

The validate-architecture skill checks SRP compliance at the layer level, while this skill checks at the class/method level. Domain layers should have high cohesion (TCC > 0.5), and this skill can detect low cohesion violations.

Integration point: Cross-layer validation to ensure architectural boundaries maintain SRP.

With run-quality-gates

SRP validation can be added as an optional quality gate in .claude/quality-gates.json:

{
  "optional_gates": ["srp_validation"],
  "srp_threshold": "warning"
}

Set threshold to "critical" to block commits on violations.

With multi-file-refactor

When refactoring God Classes that span multiple files, use multi-file-refactor skill to coordinate changes. This skill identifies God Classes and provides refactoring guidance; multi-file-refactor executes the split.

Parameters

ParameterTypeDefaultDescription
pathstringsrc/File or directory to validate
levelenumthoroughValidation depth: fast, thorough, full
output_formatenumtextOutput format: text, json
thresholdenumwarningReport threshold: warning, critical
include_metricsbooltrueInclude cohesion metrics in report

Usage:

# Default (thorough mode on src/)
Skill(command: "validate-srp")

# Custom path and level
Skill(command: "validate-srp --path=src/application --level=full")

# JSON output for tooling integration
Skill(command: "validate-srp --output_format=json")

Output Format

Text Output (Default)

See Step 8 in Instructions for complete example.

JSON Output

{
  "summary": {
    "total_classes": 45,
    "violations": 7,
    "warnings": 12,
    "passed": 26,
    "compliance_rate": 0.58
  },
  "violations": [
    {
      "severity": "critical",
      "type": "god_class",
      "class": "UserService",
      "file": "src/application/services/user_service.py",
      "line": 12,
      "metrics": {
        "lines": 487,
        "methods": 23,
        "constructor_params": 9,
        "atfd": 12,
        "wmc": 89,
        "tcc": 0.21
      },
      "actors": ["Authentication", "Profile", "Notifications"],
      "confidence": 0.80,
      "fix": "Split into UserAuthService, UserProfileService, UserNotificationService",
      "estimated_hours": 5.0
    }
  ],
  "warnings": [
    {
      "severity": "warning",
      "type": "method_naming",
      "method": "validate_and_save_user",
      "file": "src/services/user.py",
      "line": 45,
      "confidence": 0.40,
      "fix": "Split into validate_user() and save_user()",
      "estimated_minutes": 20
    }
  ]
}

Supporting Files

References

Examples

Scripts

Success Metrics

MetricTargetBenefit
Detection accuracy>85%Minimal false positives
God class detection100%Catch all critical violations
False positive rate<15%High signal-to-noise ratio
Execution time<30sFast enough for workflow
Actionability100%Every violation has specific fix
Refactoring estimate accuracy±30%Reliable planning

Utility Scripts

validate-srp.sh

Main validation script with multi-level analysis:

# Fast check (naming patterns only - 5 seconds)
./scripts/validate-srp.sh src/ --level=fast

# Thorough check (naming + size + constructors - 30 seconds)
./scripts/validate-srp.sh src/ --level=thorough

# Full analysis (with actor questions - 5 minutes)
./scripts/validate-srp.sh src/ --level=full

# JSON output for CI/CD integration
./scripts/validate-srp.sh src/ --output-format=json

check-god-class.sh

Focused God Class detection for single files:

# Check specific file
./scripts/check-god-class.sh src/services/user_service.py

# Returns:
# - Constructor parameter count
# - Method count
# - File size
# - God Class recommendation

Requirements

Minimum:

  • Python 3.10+ (for AST analysis)
  • Read, Grep, Bash, Glob tools
  • Source code in supported language (Python/JS/TS)
  • Validation scripts in scripts/ directory

Optional:

  • radon for accurate metrics: uv pip install radon
  • mcp__ast-grep__* tools for precise AST analysis
  • mcp__project-watch-mcp__search_code for context

Installation:

# Make scripts executable
chmod +x scripts/*.sh

# Optional: Install radon for accurate metrics
uv pip install radon

# Verify installation
uv run radon --version

Red Flags to Avoid

Architectural Violations

  1. God Classes - ATFD >5, WMC >47, TCC <0.33
  2. Constructor Dependencies - >8 parameters
  3. Method Naming - Methods with "and" in name
  4. File Size - >500 lines per file

Detection Anti-Patterns

  1. Ignoring warnings - Small violations compound into big issues
  2. Not validating fixes - Re-run after refactoring
  3. Skipping actor analysis - Metrics alone miss context
  4. Assuming SRP = "one method" - SRP is actor-driven, not task-driven

Process Mistakes

  1. Refactoring without tests - Always have test coverage first
  2. Big bang refactoring - Incremental refactoring safer
  3. Not estimating effort - Plan time for refactoring
  4. Skipping after major changes - Validation most critical after refactoring

Troubleshooting

Issue: Too Many False Positives

Symptom: Small helper methods flagged as violations

Fix: Adjust thresholds in .claude/srp-config.json:

{
  "thresholds": {
    "class_lines": 400,
    "method_lines": 75,
    "constructor_params": 6
  }
}

Issue: Metrics Not Calculated

Symptom: "Metrics unavailable" in report

Fix: Install radon:

uv pip install radon

Or use simplified heuristics (less accurate but faster).

Issue: Can't Identify Actors

Symptom: Actor analysis unclear

Fix: Ask targeted questions:

  1. "Who would request changes to this class?"
  2. "Can you group methods by job role?"
  3. "What teams interact with this code?"

Expected Benefits

MetricWithout SRP ValidationWith SRP ValidationImprovement
God classes in codebase15-250-295% reduction
Time to understand class20-45 min5-10 min75% faster
Bugs per class8-12 per year1-3 per year85% reduction
Refactoring costHigh (embedded violations)Low (caught early)80% reduction
Test coverage40-60% (hard to test)80-95% (easy to test)50% increase
Code review time30-60 min10-20 min66% faster

See Also

  • validate-architecture - Layer-level architecture validation
  • code-review - Comprehensive pre-commit review (includes SRP)
  • run-quality-gates - Quality gate orchestration
  • multi-file-refactor - Coordinate SRP-driven refactoring
  • @code-review-expert - Agent for code review guidance
  • @architecture-guardian - Agent for architectural decisions
  • ARCHITECTURE.md - Project architecture documentation

Last Updated: 2025-11-02 Version: 1.0.0

平台分布

Codex

38.37%
按下载量换算30

Claude

28.8%
按下载量换算23

Cursor

21.42%
按下载量换算17

Gemini CLI

9.37%
按下载量换算7

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

调用外部服务

该 Skill 可能调用第三方服务、云服务或外部模型 API,使用前需要确认账号、额度、数据发送范围和服务条款。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。目前只有一个公开来源,建议同时核对源仓库。

继续浏览同类 Skills