component-common-domain-detection
它能做什么
这个技能让 AI 扫描代码库,找出在不同组件中重复出现的相同业务规则,然后建议在哪里统一它们。适合计划重构、希望减少重复逻辑的开发者。
适用场景
- ✓当你想知道相同的业务逻辑在多个服务或模块中重复出现在哪里时。
- ✓当你正在规划重构,并想知道哪些内容可以合并时。
- ✓当你希望查看多个组件共享了哪些类时。
技能链接
https://github.com/tech-leads-club/agent-skills/blob/main/packages/skills-catalog/skills/(architecture)/component-common-domain-detection/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请找出我们各个服务中重复的业务逻辑,并建议应该先合并哪些内容。”
每周 5 个新技能,1 分钟读完。
工作原理
AI 会梳理各个组件,查找共享的类和相似的规则,评估合并后对耦合的影响,并提出统一的方案。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Common Domain Component Detection
This skill identifies common domain functionality that is duplicated across multiple components and suggests consolidation opportunities to reduce duplication and improve maintainability.
How to Use
Quick Start
Request analysis of your codebase:
- "Find common domain functionality across components"
- "Identify duplicate domain logic that should be consolidated"
- "Detect shared classes used across multiple components"
- "Analyze consolidation opportunities for common components"
Usage Examples
Example 1: Find Common Functionality
User: "Find common domain functionality across components"
The skill will:
1. Scan component namespaces for common patterns
2. Detect shared classes used across components
3. Identify duplicate domain logic
4. Analyze coupling impact of consolidation
5. Suggest consolidation opportunities
Example 2: Detect Duplicate Notification Logic
User: "Are there multiple notification components that should be consolidated?"
The skill will:
1. Find all components with notification-related names
2. Analyze their functionality and dependencies
3. Calculate coupling impact if consolidated
4. Recommend consolidation approach
Example 3: Analyze Shared Classes
User: "Find classes that are shared across multiple components"
The skill will:
1. Identify classes imported/used by multiple components
2. Classify as domain vs infrastructure functionality
3. Suggest consolidation or shared library approach
4. Assess impact on coupling
Step-by-Step Process
- Scan Components: Identify components with common namespace patterns
- Detect Shared Code: Find classes/files used across components
- Analyze Functionality: Determine if functionality is truly common
- Assess Coupling: Calculate coupling impact before consolidation
- Recommend Actions: Suggest consolidation or shared library approach
When to Use
Apply this skill when:
- After identifying and sizing components (Pattern 1)
- Before flattening components (Pattern 3)
- When planning to reduce code duplication
- Analyzing shared domain logic across the codebase
- Preparing for component consolidation
- Identifying candidates for shared services or libraries
Core Concepts
Domain vs Infrastructure Functionality
Domain Functionality (candidates for consolidation):
- Business processing logic (notification, validation, auditing, formatting)
- Common to some processes, not all
- Examples: Customer notification, ticket auditing, data validation
Infrastructure Functionality (usually not consolidated here):
- Operational concerns (logging, metrics, security)
- Common to all processes
- Examples: Logging, authentication, database connections
Common Domain Patterns
Common domain functionality often appears as:
Namespace Patterns: Components ending in same leaf node
*.notification,*.audit,*.validation,*.formatting- Example:
TicketNotification,BillingNotification,SurveyNotification
Shared Classes: Same class used across multiple components
- Example:
SMTPConnectionused by 5 different components - Example:
AuditLoggerused by multiple domain components
- Example:
Similar Functionality: Different components doing similar things
- Example: Multiple components sending emails with slight variations
- Example: Multiple components writing audit logs
Consolidation Approaches
Shared Service:
- Common functionality becomes a separate service
- Other components call this service
- Good for: Frequently changing logic, complex operations
Shared Library:
- Common code packaged as library (JAR, DLL, npm package)
- Components import and use the library
- Good for: Stable functionality, simple utilities
Component Consolidation:
- Merge multiple components into one
- Good for: Highly related functionality, low coupling impact
Analysis Process
Phase 1: Identify Common Namespace Patterns
Scan component namespaces for common leaf node names:
Extract leaf nodes from all component namespaces
- Example:
services/billing/notification→notification - Example:
services/ticket/notification→notification
- Example:
Group by common leaf nodes
- Find components with same leaf node name
- Example: All components ending in
.notification
Filter out infrastructure patterns
- Exclude:
.util,.helper,
- Exclude:
常见问题
它能找到复制粘贴的代码行吗?
不能。这类任务更适合使用代码检查工具。该技能关注的是组件之间共享的业务逻辑。
它会修改我的代码吗?
它的任务是分析并建议合并方案,而不是自己进行改动。
它用于依赖检查吗?
不是。依赖检查由另一个单独的耦合分析技能处理。
详情
作者的原始描述
Finds duplicate business logic spread across multiple components and suggests consolidation. Use when asking "where is this logic duplicated?", "find common code between services", "what can be consolidated?", "detect shared domain logic", or analyzing component overlap before refactoring. Do NOT use for code-level duplication detection (use linters) or dependency analysis (use coupling-analysis).
热度
- GitHub 星标
- 7.1k
- 排名
- #13499
- 许可证
- —
- 更新时间
- 2026/11/2
评论
- …
同一仓库的更多技能
component-flattening-analysis
7.1k帮你的智能体找出位置不当的代码,并整理杂乱的组件文件夹结构,让每个部分都放在应在的位置。
component-identification-sizing
7.1k帮你的智能体梳理代码库的各个组成部分并测量其规模,以找出应首先拆分的模块。
coupling-analysis
7.1k帮你的智能体检查代码库各部分之间的依赖有多紧密,并找出应优先放松的连接。
decomposition-planning-roadmap
7.1k帮你的智能体规划把大型应用拆分为独立服务的分步顺序,包括优先级和阶段。