decompose-file
БесплатноБез исполняемых скриптовНе проверенAnalyze large source files and produce decomposition plans, optionally executing refactoring with import updates and test verification
от jmagly★ 233 звезды на GitHubОб этом скилле
decompose-file
Analyze a large source file and produce a concrete decomposition plan, optionally executing the refactoring with import updates and test verification.
Triggers
Alternate expressions and non-obvious activations (primary phrases are matched automatically from the skill description):
- "this file is too large" → file decomposition trigger
- "split into modules" → modular decomposition
Purpose
When /codebase-health identifies files exceeding agent-friendly thresholds (300 LOC warning, 500 LOC error), this skill provides guided decomposition. It analyzes file structure, identifies logical groupings, maps internal dependencies, proposes a split plan, and optionally executes the refactoring.
The doc-splitter skill handles documentation splitting. This skill handles source code splitting — a fundamentally different problem requiring dependency analysis, import rewiring, and test verification.
Behavior
When triggered, this skill:
Analyze file structure:
- Parse the file to identify logical sections (classes, function groups, export clusters)
- Measure each section's size in LOC
- Identify the file's primary language and applicable parsing strategy
- Report current file size vs. agent-friendly thresholds
Map internal dependencies:
- Trace references between identified sections
- Identify shared state (module-level variables, constants)
- Detect circular dependency risks in proposed splits
- Catalog all exports and their consumers
Propose split plan:
- Assign each section to a proposed output file
- Name output files descriptively (no generic names)
- Ensure each output file is under the warning threshold (300 LOC)
- Include shared dependencies in the most logical location
- Add a purpose statement for each proposed file
Show dependency graph:
- Visualize which proposed modules depend on which
- Verify no circular dependencies exist
- Show import direction between new modules
Execute refactoring (if
--executeor user approves):- Create new files with proper imports
- Update the original file to re-export if needed for backward compatibility
- Find and update all import statements across the codebase
- Add module-level purpose statements to each new file
- Run tests to verify no breakage
Analysis Strategies
Language-Specific Parsing
| Language | Strategy | Boundaries |
|---|---|---|
| TypeScript/JavaScript | AST via function/class/export declarations | export, class, function, const |
| Python | AST via ast module |
class, def, top-level assignments |
| Go | Package-level function/type declarations | func, type, var blocks |
| Rust | mod, fn, struct, impl blocks |
Module and impl boundaries |
| Java | Class and method declarations | class, interface, enum |
Heuristic Fallback
For unsupported languages or when AST parsing is unavailable:
- Blank line groups — consecutive blank lines often separate logical sections
- Comment blocks — section header comments (
// --- Section Name ---) - Indentation changes — top-level declarations at zero indentation
- Export clusters — groups of exports at file end
Decomposition Plan Format
Decomposition Plan for src/extensions/registry.ts (847 lines)
Current Structure:
1. Imports and type definitions (lines 1-45)
2. ExtensionRegistry class (lines 47-320)
2a. Constructor and initialization (lines 47-85)
2b. register() — registers an extension (lines 87-145)
2c. lookup() — finds extension by name (lines 147-210)
2d. listByType() — returns extensions of a type (lines 212-260)
2e. unregister() — removes an extension (lines 262-320)
3. Validation functions (lines 322-480)
3a. validateExtension() (lines 322-390)
3b. validateManifest() (lines 392-440)
3c. checkDependencies() (lines 442-480)
4. Discovery helpers (lines 482-620)
5. Deployment logic (lines 622-847)
Proposed Split:
1. src/extensions/registry.ts (185 lines)
— ExtensionRegistry class (core registration, lookup, list, unregister)
— Imports from: validation, discovery, deployment
2. src/extensions/extension-validator.ts (160 lines)
— validateExtension(), validateManifest(), checkDependencies()
— No internal dependencies
3. src/extensions/extension-discovery.ts (140 lines)
— discoverExtensions(), globForType(), resolveExtensionPath()
— Imports from: extension-validator
4. src/extensions/extension-deployer.ts (227 lines)
— deployToProvider(), buildProviderConfig(), writeDeploymentFiles()
— Imports from: registry, extension-validator
Dependency Graph:
registry → extension-validator
registry → extension-discovery
registry → extension-deployer
extension-discovery → extension-validator
extension-deployer → registry, extension-validator
Circular Dependencies: NONE ✓
All proposed file
Установить decompose-file в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл decompose-file?
Analyze large source files and produce decomposition plans, optionally executing refactoring with import updates and test verification
Как установить скилл decompose-file?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл decompose-file запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic