principle-soc

tikazyq's avatarfrom tikazyq

实现关注点分离,确保不同职责模块化和边界清晰。当需要架构分层设计、模块职责划分、横切关注点处理时使用。覆盖层次分离、功能分离、横切关注点三大维度,提供分离检查清单和耦合问题的诊断修复方法。

⭐0stars🔀0forks📁View on GitHub🕐Updated Jan 3, 2026

When & Why to Use This Skill

This Claude skill facilitates the implementation of the Separation of Concerns (SoC) principle, ensuring modularity and clear boundaries within software projects. It assists in architectural layering, functional decomposition, and the management of cross-cutting concerns through diagnostic checklists and coupling repair strategies, ultimately reducing technical debt and improving system maintainability.

Use Cases

  • Architectural Layering: Decoupling presentation, business logic, and data access layers to ensure that UI changes do not impact core business rules.
  • Module Boundary Definition: Establishing clear interfaces and responsibilities for different modules to minimize inter-module dependencies and enhance code reusability.
  • Cross-cutting Concern Management: Isolating non-functional requirements such as logging, security, and transaction management from the primary business logic using AOP or middleware patterns.
  • Coupling Diagnosis & Refactoring: Analyzing existing codebases to identify tight coupling issues and providing actionable recommendations for modularization and structural improvement.
nameprinciple-soc
description实现关注点分离,确保不同职责模块化和边界清晰。当需要架构分层设计、模块职责划分、横切关注点处理时使用。覆盖层次分离、功能分离、横切关注点三大维度,提供分离检查清单和耦合问题的诊断修复方法。
stageCOMMON
level_supported[L1-STREAMLINED, L2-BALANCED, L3-RIGOROUS]

Separation of Concerns Skill

Scope: COMMON(全阶段通用)

版本: 0.1.0(占位)| 创建日期: 2025-11-27


概述

SoC(Separation of Concerns)是软件架构的基础原则:

┌─────────────────────────────────────────────────────┐
│              🧩 Separation of Concerns              │
├─────────────────────────────────────────────────────┤
│  "Let me not be so vain to think that I am the     │
│   sole author of my work... We are all but         │
│   standing on the shoulders of giants."            │
│                              — Edsger W. Dijkstra  │
└─────────────────────────────────────────────────────┘

关注点分离维度

层次分离

  • 表现层 / 业务层 / 数据层 清晰分离
  • UI 不包含业务逻辑
  • 数据访问不混入业务规则

功能分离

  • 每个模块有明确的职责边界
  • 模块间通过接口通信
  • 跨模块依赖最小化

横切关注点

  • 日志、安全、事务等是否独立处理
  • 是否使用 AOP 或中间件
  • 基础设施代码与业务代码分离

数据与行为分离

  • DTO/Entity 职责清晰
  • 数据传输与业务对象分离
  • 配置与代码分离

常见模式

模式 关注点分离方式
MVC/MVVM Model / View / Controller
分层架构 Presentation / Business / Data
微服务 按业务域分离
六边形架构 核心 / 端口 / 适配器

分级检查策略

L1-STREAMLINED

  • 每维度检查 1 个核心点(共 4 项)
  • 关注明显的职责混淆
  • 通过标准:4 项中 3 项通过(≥75%)

L2-BALANCED

  • 每维度检查 2-3 个关键点(共 8-12 项)
  • 依赖图可视化分析
  • 通过标准:8 项中 7 项通过(≥87.5%)

L3-RIGOROUS

  • 全面检查所有子项(12+ 项)
  • 耦合度量化(目标:低耦合高内聚)
  • 记录边界违反和重构建议
  • 通过标准:12 项中 11 项通过(≥91.7%)

>> 命令

>>soc_check_l1       # SoC 快速检查
>>soc_layer_review   # 层次分离审查
>>soc_boundary       # 边界识别

相关 Skills

  • 同类: principle-solid, principle-dry, principle-kiss(设计原则家族)
  • 应用: layer-design, component-boundary(架构分离)
  • 验证: vertical-slice(每个切片的关注点)
  • 扩展: microservice-thinking(微服务级别的 SoC)

TODO: 待细化各架构模式的 SoC 检查规则