π Shard: Refactoring Large File...
SkillFiles & storageUse when the user says 'shard this', 'split file', or when working with files over 1000 lines.
Available today. Use it from your connected AI after setup.
No other account needed.
Connect ahel once, and every AI you use reads what you have installed.
Then ask your AI: use the π Shard: Refactoring Large File... skill
What this skill tells your AI
The instructions your AI receives, as published by cwinvestments/memstack in skills/shard/SKILL.md and read by ahelβs review.
Split monolithic files into focused, maintainable modules.
Activation
When this skill activates, output:
π Shard: Refactoring large file...
Then execute the protocol below.
Context Guard
| 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 |
Protocol
-
Identify the target file and count lines:
wc -l <file> -
Analyze structure:
- List all exports (functions, components, types, constants)
- Identify logical groupings
- Map internal dependencies (what calls what)
-
Propose the split: present to user BEFORE executing:
- Target: 100-300 lines per new file
- Group related functionality
- Keep types near consumers
- Shared utilities in separate file
-
Execute the refactor:
- Create new files with proper names
- Move code to appropriate files
- Add import/export statements
- Create index.ts barrel if needed for backwards compatibility
- Update all imports throughout the project
-
Verify build:
npm run build 2>&1 | tail -20 -
Present result: new file structure with line counts
Inputs
- File path to refactor
- Optional: preferred split strategy or target file count
Outputs
- Multiple smaller files replacing the original
- Updated imports throughout project
- Build verification
Example Usage
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
Level History
- Lv.1: Base: File analysis and splitting with import updates. (Origin: MemStack v1.0, Feb 2026)
- Lv.2: Enhanced: Added YAML frontmatter, context guard, propose-before-execute, activation message. (Origin: MemStack v2.0 MemoryCore merge, Feb 2026)
Signals
- GitHub stars
- 419
- Forks
- 44
- Last commit
- Sep 2026
Advanced
- Catalog kind
- skill
- Gateway key
shard- Source
- github.com/cwinvestments/memstack