component-flattening-analysis
Skill này làm gì
Skill này để AI kiểm tra cách các thư mục và module của codebase được lồng nhau, tìm các lớp nằm sai cấp và gợi ý cấu trúc gọn hơn. Phù hợp với lập trình viên muốn một codebase có trật tự trước khi refactor.
Khi nào nên dùng
- ✓Khi một codebase có các lớp lạc nằm ở cấp gốc thay vì trong một component.
- ✓Khi các component được lồng trong các component khác và bạn muốn làm phẳng chúng.
- ✓Khi bạn muốn một kế hoạch refactor để dọn dẹp hệ thống phân cấp module.
Liên kết skill
https://github.com/tech-leads-club/agent-skills/blob/main/packages/skills-catalog/skills/(architecture)/component-flattening-analysis/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Xem cấu trúc thư mục của chúng tôi, tìm các lớp nằm sai chỗ và gợi ý cách sửa.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
AI lập bản đồ các namespace, tìm các lớp mồ côi và component được xây trên component khác, rồi đề xuất các bước làm phẳng dưới dạng kế hoạch.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
Component Flattening Analysis
This skill identifies component hierarchy issues and ensures components exist only as leaf nodes in directory/namespace structures, removing orphaned classes from root namespaces.
How to Use
Quick Start
Request analysis of your codebase:
- "Find orphaned classes in root namespaces"
- "Flatten component hierarchies"
- "Identify components that need flattening"
- "Analyze component structure for hierarchy issues"
Usage Examples
Example 1: Find Orphaned Classes
User: "Find orphaned classes in root namespaces"
The skill will:
1. Scan component namespaces for hierarchy issues
2. Identify orphaned classes in root namespaces
3. Detect components built on top of other components
4. Suggest flattening strategies
5. Create refactoring plan
Example 2: Flatten Components
User: "Flatten component hierarchies in this codebase"
The skill will:
1. Identify components with hierarchy issues
2. Analyze orphaned classes
3. Suggest consolidation or splitting strategies
4. Create refactoring plan
5. Estimate effort
Example 3: Component Structure Analysis
User: "Analyze component structure for hierarchy issues"
The skill will:
1. Map component namespace structure
2. Identify root namespaces with code
3. Find components built on components
4. Flag hierarchy violations
5. Provide recommendations
Step-by-Step Process
- Scan Structure: Map component namespace hierarchies
- Identify Issues: Find orphaned classes and component nesting
- Analyze Options: Determine flattening strategy (consolidate vs split)
- Create Plan: Generate refactoring plan with steps
- Execute: Refactor components to remove hierarchy
When to Use
Apply this skill when:
- After gathering common domain components (Pattern 2)
- Before determining component dependencies (Pattern 4)
- When components have nested structures
- Finding orphaned classes in root namespaces
- Preparing for domain grouping
- Cleaning up component structure
- Ensuring components are leaf nodes only
Core Concepts
Component Definition
A component is identified by a leaf node in directory/namespace structure:
- Leaf Node: The deepest directory containing source files
- Component: Source code files in leaf node namespace
- Subdomain: Parent namespace that has been extended
Key Rule: Components exist only as leaf nodes. If a namespace is extended, the parent becomes a subdomain, not a component.
Root Namespace
A root namespace is a namespace node that has been extended:
- Extended: Another namespace node added below it
- Example:
ss.surveyextended toss.survey.templates - Result:
ss.surveybecomes a root namespace (subdomain)
Orphaned Classes
Orphaned classes are source files in root namespaces:
- Location: Root namespace (non-leaf node)
- Problem: No definable component associated with them
- Solution: Move to leaf node namespace (component)
Example:
ss.survey/ ← Root namespace (extended by .templates)
├── Survey.js ← Orphaned class (in root namespace)
└── templates/ ← Component (leaf node)
└── Template.js
Flattening Strategies
Strategy 1: Consolidate Down
- Move code from leaf nodes into root namespace
- Makes root namespace the component
- Example: Move
ss.survey.templates→ss.survey
Strategy 2: Split Up
- Move code from root namespace into new leaf nodes
- Creates new components from root namespace
- Example: Split
ss.survey→ss.survey.create+ss.survey.process
Strategy 3: Move Shared Code
- Move shared code to dedicated component
- Creates
.sharedcomponent - Example:
ss.surveyshared code →ss.survey.shared
Analysis Process
Phase 1: Map Component Structure
Scan directory/namespace structure to identify hierarchy:
Map Namespace Tree
- Build tree of all namespaces
- Identify parent-child relationships
- Mark leaf nodes (components)
Identify Root Namespaces
- Find namespaces that have been extended
- Mark as root namespaces (subdomains)
- Note which namespaces extend them
Locate Source Files
- Find all source files in each namespace
- Map files to their namespace location
- Identify files in root namespaces
Example Structure Mapping:
## Component Structure Map
ss.survey/ ← Root namespace (extended) ├─
Câu hỏi thường gặp
Nó có tự thay đổi mã không?
Đầu ra chính là một bản phân tích và kế hoạch refactor để bạn xem lại trước.
Có giống phân tích phụ thuộc không?
Không. Phân tích phụ thuộc do skill phân tích ghép nối đảm nhận.
Nó có nhóm mã theo lĩnh vực nghiệp vụ không?
Không. Việc nhóm theo lĩnh vực là một skill riêng.
Chi tiết
Mô tả gốc của tác giả
Detects misplaced classes and fixes component hierarchy problems — finds code that should belong inside a component but sits at the root level. Use when asking "clean up component structure", "find orphaned classes", "fix module hierarchy", "flatten nested components", or analyzing why namespaces have misplaced code. Do NOT use for dependency analysis (use coupling-analysis) or domain grouping (use domain-identification-grouping).
Độ phổ biến
- Sao GitHub
- 7.1k
- Vị trí xếp hạng
- #13500
- Giấy phép
- —
- Cập nhật
- 2/11/2026
Bình luận
- …
Thêm skill từ kho mã này
component-common-domain-detection
7.1kGiúp agent của bạn tìm logic nghiệp vụ bị lặp lại ở nhiều phần của codebase và gợi ý cách gộp nó lại.
component-identification-sizing
7.1kGiúp agent của bạn lập bản đồ các phần của codebase và đo kích thước của chúng, để tìm module nên tách trước.
coupling-analysis
7.1kGiúp agent của bạn kiểm tra mức độ phụ thuộc chặt chẽ giữa các phần của codebase, và nên nới lỏng những kết nối nào trước.
decomposition-planning-roadmap
7.1kGiúp agent của bạn lên kế hoạch thứ tự từng bước để chia một ứng dụng lớn thành các service riêng, với ưu tiên và các giai đoạn.
Skill tương tự
diffs
394kGiúp agent của bạn tạo một diff có thể chia sẻ về các chỉnh sửa, dưới dạng liên kết xem hoặc file ảnh, thay vì một bản tóm tắt viết tay.
coding-agent
394kGiúp agent của bạn giao một việc lập trình lớn cho Codex, Claude Code hoặc OpenCode chạy nền, rồi theo dõi tiến độ của nó.
gh-issues
394kGiúp agent của bạn tìm issue trên GitHub, chọn những issue cần xử lý và mở pull request với bản sửa, kể cả theo dõi nhận xét đánh giá.