shard
$
npx mdskill add cwinvestments/memstack/shard*Split monolithic files into focused, maintainable modules.*
SKILL.md
.github/skills/shardView on GitHub ↗
--- name: shard description: "Use when the user says 'shard this', 'split file', or when working with files over 1000 lines." version: 1.0.0 --- # 💎 Shard — Refactoring Large File... *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 1. **Identify the target file** and count lines: ```bash wc -l <file> ``` 2. **Analyze structure:** - List all exports (functions, components, types, constants) - Identify logical groupings - Map internal dependencies (what calls what) 3. **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 4. **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 5. **Verify build:** ```bash npm run build 2>&1 | tail -20 ``` 6. **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)
More from cwinvestments/memstack
- compressUse when the user says 'headroom', 'compression', 'token savings', 'proxy status', or asks about context window usage.
- diaryUse when the user says 'save diary', 'log session', 'wrapping up', or at end of a productive session.
- echoUse when the user references past sessions, asks 'what did we do', 'do you remember', 'last session', 'recall', or 'continue from'.
- familiarUse when the user says 'dispatch', 'send familiar', 'split task', or needs work split across parallel CC sessions.
- forgeUse when the user says 'forge this', 'new skill', 'create enchantment', or wants to create a MemStack skill.
- governorUse when the user says 'new project', 'project init', 'what tier', 'scope', or discusses project maturity, complexity budget, or what's appropriate to build.
- grimoireUse when the user says 'update context', 'update claude', 'save library', or after significant project changes.
- memstack-automation-api-integrationUse this skill when the user says 'API integration', 'connect APIs', 'sync data', 'data mapping', 'rate limiting', or needs system-to-system connectors with authentication, rate limit handling, and error recovery. Generates API integration code with authentication (OAuth, API key, JWT), request/response mapping, rate limit handling, error recovery with circuit breakers, and sync monitoring. Do NOT use for visual n8n workflows or webhook receiving.
- memstack-automation-content-pipelineUse this skill when the user says 'content pipeline', 'content automation', 'auto-publish', 'repurpose content', 'multi-platform publishing', or needs end-to-end content workflow from ideation through cross-platform formatting and publishing. Do NOT use for single social media posts or individual blog posts.
- memstack-automation-cron-schedulerUse this skill when the user says 'cron job', 'scheduled task', 'run every', 'cron expression', 'recurring job', or needs production-grade scheduled jobs with overlap prevention, monitoring, and structured logging. Do NOT use for n8n workflows or event-driven webhooks.