From memstack
Splits large files over 1000 lines into focused modules (100-300 lines each). Analyzes exports and dependencies, proposes plan, creates files with updated imports and barrels, verifies npm build. Triggers on 'shard this' or 'split file'.
npx claudepluginhub cwinvestments/memstack --plugin memstackThis skill uses the workspace's default tool permissions.
*Split monolithic files into focused, maintainable modules.*
Splits large markdown documents into smaller organized files by level 2 sections using npx @kayvan/markdown-tree-parser. Useful for managing large docs; activates on 'perform shard document'.
Mandates invoking relevant skills via tools before any response in coding sessions. Covers access, priorities, and adaptations for Claude Code, Copilot CLI, Gemini CLI.
Share bugs, ideas, or general feedback.
Split monolithic files into focused, maintainable modules.
When this skill activates, output:
๐ Shard โ Refactoring large file...
Then execute the protocol below.
| Context | Status |
|---|---|
| User says "shard", "split file", or "refactor" | ACTIVE โ full protocol |
| Editing a file over 1000 lines | ACTIVE โ suggest refactor |
| User says "refactor" for logic changes (not splitting) | DORMANT โ not a shard task |
| Discussing code organization concepts | DORMANT โ do not activate |
| File is under 500 lines | DORMANT โ not worth splitting |
Identify the target file and count lines:
wc -l <file>
Analyze structure:
Propose the split โ present to user BEFORE executing:
Execute the refactor:
Verify build:
npm run build 2>&1 | tail -20
Present result โ new file structure with line counts
User: "shard infrastructure/page.tsx โ it's 1100 lines"
๐ Shard โ Refactoring large file...
infrastructure/page.tsx (1,110 lines) โ 6 files:
page.tsx (~120 lines) โ Main page, tab switcher
RailwayTab.tsx (~200 lines) โ Railway monitoring
HetznerTab.tsx (~180 lines) โ Hetzner monitoring
HeadroomTab.tsx (~250 lines) โ Headroom + setup guide
types.ts (~80 lines) โ Shared interfaces
constants.ts (~60 lines) โ Status configs
Build check: โ passed