Shard

From cwinvestments/memstack · View interactive version

Shard is an AI agent skill from the GitHub repository cwinvestments/memstack. Use when the user says 'shard this', 'split file', or when working with files over 1000 lines.

How to use this skill

Skill file

💎 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>

```

  1. Analyze structure:
  1. Propose the split: present to user BEFORE executing:
  1. Execute the refactor:
  1. Verify build:

```bash

npm run build 2>&1 | tail -20

```

  1. Present result: new file structure with line counts

Inputs

Outputs

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

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.