Skip to content
Skill Authoring
Skill

/shard

Use when the user says 'shard this', 'split file', or when working with files over 1000 lines.

From plugin
memstack
43287 skills2 commands4 hooks

Claude Code

$ npx -y skills add cwinvestments/memstack --skill shard --agent claude-code

SKILL.md

shard.SKILL.md
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:

   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:**

   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)
Read more
@cwinvestments
Ships withmemstack

The structured skill framework for Claude Code: 131 professional skills for deployment, security, databases, content, marketing, and more. Skills activate automatically when you need them. Say "deploy this to Railway" and the right skill loads on demand.

Stars on GitHub

Momentum

stars in total
432
Star history of cwinvestments/memstack on GitHub, a chart by star-history.com

Other skills on memstack.

api-integration

api-integration

Use this skill when the user says 'API integration', 'connect APIs', 'sync data', 'data mapping', 'rate limiting', or needsโ€ฆ

content-pipeline

content-pipeline

Use this skill when the user says 'content pipeline', 'content automation', 'auto-publish', 'repurpose content', 'multi-platformโ€ฆ

cron-scheduler

cron-scheduler

Use this skill when the user says 'cron job', 'scheduled task', 'run every', 'cron expression', 'recurring job', or needsโ€ฆ

hosted-mcp-catalog

hosted-mcp-catalog

Use when the user says 'what MCP servers', 'find an MCP for', 'hosted MCP', 'list MCP servers', 'MCP catalog', 'available MCPโ€ฆ

n8n-workflow-builder

n8n-workflow-builder

Use this skill when the user says 'n8n workflow', 'build a workflow', 'automation workflow', 'connect services', or needs visualโ€ฆ

webhook-designer

webhook-designer

Use this skill when the user says 'webhook', 'webhook handler', 'webhook endpoint', 'receive events', 'HMAC verification',โ€ฆ

More skills from other plugins.

gstack-openclaw-ceo-review

gstack-openclaw-ceo-reโ€ฆ

Use when asked to review a plan, challenge a proposal, run a CEO review, poke holes in an approach, think bigger about scope, orโ€ฆ

gstack3w138k
@garrytan@garrytanInstall Skill
book-to-skill

book-to-skill

Converts books and documents (PDF, EPUB, DOCX, HTML, Markdown, plain text, RTF, MOBI/AZW with Calibre) into structured agentโ€ฆ

@virgiliojr94@virgiliojr94Install Skill
distilly

distilly

Set up the owner profile so a personal agent knows who it works for (first-run setup, \"get to know me\"), or distill colleague,โ€ฆ

@titanwings@titanwingsInstall Skill

Questions about shard.

Which coding agents can use shard?
shard installs in Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode and Windsurf with the skills CLI, using each agent's flag shown on this page. Flowy's auto-invocation, which fires a skill when your prompt matches, runs in Claude Code only.