agentleFS
cwinvestmentscwinvestments/memstack/skills/shard/SKILL.md

shard

Skill425 starsChanged 5 months agoMITView on GitHub

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

3 other projects use a version of this, 1 of them edited.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

6 rules. 0 are common, 5 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 3 edited versions we read keep these.

  • 5

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    When this skill activates, output:

    line 13
  2. Distinctive:

    Keep types near consumers

    line 44
  3. Distinctive:

    Create new files with proper names

    line 48
  4. Distinctive:

    Add import/export statements

    line 50
  5. Very specific:

    Create index.ts barrel if needed for backwards compatibility

    line 51
  6. Distinctive:

    Update all imports throughout the project

    line 52

“Common” is measured: kept by at least 6 in 10 of the 3 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

💎 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

ContextStatus
User says "shard", "split file", or "refactor"ACTIVE: full protocol
Editing a file over 1000 linesACTIVE: suggest refactor
User says "refactor" for logic changes (not splitting)DORMANT: not a shard task
Discussing code organization conceptsDORMANT: do not activate
File is under 500 linesDORMANT: 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)

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.