Skip to content
Back to skills

Shard

ASecurity

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

  • 423 stars
  • 0 votes
  • 0 copies
  • 3 views
  • Added June 5, 2026
ai-agentsbashrefactoring

Security analysis

A100/100

Scanned June 5, 2026

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

Installs into .claude/skills of the current project.

Are you the author of Shard?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Shard
[![Security: A β€” Skills Directory](https://www.skillsdirectory.com/api/skills/cwinvestments-shard/badge)](https://www.skillsdirectory.com/skills/cwinvestments-shard)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
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:
   ```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)

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.