component-flattening-analysis
하는 일
이 스킬은 AI가 코드베이스의 폴더와 모듈이 어떻게 중첩되어 있는지 확인하고, 잘못된 단계에 있는 클래스를 찾아 더 깔끔한 구조를 제안하게 합니다. 리팩터링 전에 코드를 정돈하려는 개발자를 위한 것입니다.
사용하는 경우
- ✓코드베이스의 루트 단계에 제자리를 벗어난 클래스가 있을 때.
- ✓컴포넌트가 다른 컴포넌트 안에 중첩되어 있어서 평평하게 만들고 싶을 때.
- ✓모듈 계층을 정리하는 리팩터링 계획이 필요할 때.
스킬 링크
https://github.com/tech-leads-club/agent-skills/blob/main/packages/skills-catalog/skills/(architecture)/component-flattening-analysis/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“우리 폴더 구조를 살펴보고, 잘못된 위치에 있는 클래스를 찾아 고치는 방법을 제안해 주세요.”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
AI는 네임스페이스를 정리하고, 고아 클래스와 다른 컴포넌트 위에 만들어진 컴포넌트를 찾은 다음, 평평하게 만드는 단계를 계획으로 제안합니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.
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) ├─
자주 묻는 질문
코드를 자동으로 바꾸나요?
주된 결과물은 분석과 리팩터링 계획이며, 사용자가 먼저 검토할 수 있습니다.
의존성 분석과 같은 건가요?
아니요. 의존성 분석은 결합 분석 스킬이 담당합니다.
비즈니스 도메인별로 묶나요?
아니요. 도메인 묶기는 별도의 스킬이 담당합니다.
상세 정보
작성자의 원본 설명
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).
인기도
- GitHub 스타
- 7.1k
- 순위
- #13500
- 라이선스
- —
- 업데이트
- 2026. 11. 2.
댓글
- …
이 저장소의 다른 스킬
component-common-domain-detection
7.1k에이전트가 코드베이스의 여러 부분에 반복되는 비즈니스 로직을 찾아, 그것을 어떻게 합칠지 제안하도록 돕습니다.
component-identification-sizing
7.1k에이전트가 코드베이스의 부품을 파악하고 크기를 재어, 먼저 나눠야 할 모듈을 찾도록 돕습니다.
coupling-analysis
7.1k에이전트가 코드베이스의 부분들이 서로 얼마나 단단히 묶여 있는지 확인하고, 먼저 느슨하게 만들 연결을 알려 주도록 돕습니다.
decomposition-planning-roadmap
7.1k에이전트가 큰 앱을 별도 서비스로 나누는 단계별 순서를 우선순위와 단계와 함께 계획하도록 돕습니다.