shard

shard is a skill for Claude Code from cwinvestments/memstack. It costs 28 tokens per session (687 once invoked), scanned A, original, MIT.

A code-organization helper for splitting very large files into smaller modules with related code grouped together. A monolithic file is one large file containing many different responsibilities.

In plain words
What is it for?
Use it when a file is over 1,000 lines or when you explicitly need to split a monolithic file into focused files, with shared utilities separated from feature-specific code.
Why use it?
Large files are harder to understand and maintain. This helper provides a process for analyzing their contents, proposing a split, and moving code while preserving internal dependencies.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the memstack plugin — 87 skills, 2 commands, 6 hooks shipped together

Good fit Use it when a file is over 1,000 lines or when you…

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/cwinvestments/memstack/shard
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add cwinvestments/memstack --skill shard
Clone the repo
git clone --depth 1 https://github.com/cwinvestments/memstack

Made for: Claude Code.

Or install memstack, the plugin that ships this one along with the rest of its 87 skills, 2 commands, 6 hooks.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for shard

README.md
[![agentmods](https://agentmods.dev/badge/skills/cwinvestments/memstack/shard.svg)](https://agentmods.dev/skills/cwinvestments/memstack/shard)
Your own site
<a href="https://agentmods.dev/skills/cwinvestments/memstack/shard"><img src="https://agentmods.dev/badge/skills/cwinvestments/memstack/shard.svg" alt="Measured on agentmods" height="20"></a>
Per session 28 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 687 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00028 $0.00687
Opus 5 $0.00014 $0.00344
Sonnet 5 $0.00006 $0.00137
Haiku 4.5 $0.00003 $0.00069

Measured 3d ago against content hash c8eadd7a09fd, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

shard scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/shard/SKILL.md · 92 lines

How it starts

The opening of the file, as written. The whole thing — 92 lines — stays where its author put it; the contents beside it link to each section on GitHub.

💎 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

Read the full file on GitHub · 92 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3d ago Changed c8eadd7a09fd
  2. 3d ago First seen · 92 lines · 28 tokens per session scan A 9a191784d328

Subscribe to this mod's changes

shard is a skill published in the GitHub repository cwinvestments/memstack (419 stars, last pushed today), licensed MIT. It adds 28 tokens to every session and 687 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.

Related

Other skills, from other repositories

atomic-review

Compressed code review comments. Cuts noise from PR feedback while preserving the actionable signal. Each comment is one line: location, problem, fix. Use when user says "review this PR", "code review", "review the diff", or invokes /atomic-review. Auto-triggers when reviewing pull requests.

damusix/atomic-claude · 63 tokens

react-senior-code-review

Senior-level review of a React feature, by theSeniorDev — structure & boundaries, state & data flow, performance & rendering, types/forms/testability/a11y, and styling architecture & motion. Recommends design patterns by name when one fits. Produces prioritized findings (Critical → Nit) with file:line, why, and a…

the-senior-dev/senior-dev-skills · 127 tokens

stack-changes

Splits a large change into small, single-purpose units of review — PRs, diffs, or CLs — each making one argument (one diff, one thesis) and each buildable and testable on its own. Use when a change is too big to review, when a feature builds on existing code, when working in a large monorepo with stacked diffs, or…

Ishtiaqhossain/claude_stack_changes · 123 tokens

code-review

Reviews code following team development standards. Use when reviewing code, checking PRs, or before merging.

lodetomasi/claude-code-training-lab · 23 tokens

sdd-tasks

Break an SDD change into implementation tasks. Trigger: orchestrator launches task planning for a change.

Gentleman-Programming/gentle-ai · 25 tokens

pre-landing-review

Pre-landing PR review. Analyzes diff against the base branch for SQL safety, LLM trust boundary violations, conditional side effects, and other structural issues. Use when explicitly asked for the specialized pre-landing workflow. Product /review requests are handled by OpenBitFun's unified Review mechanism instead.…

GCWing/BitFun · 75 tokens