Agent skill

Test File Split

by ZaxbyHub in ZaxbyHub/opencode-swarm

Protocol for splitting test files that approach or exceed the FR-006 500-line limit (enforced in CI by scripts/check-test-file-cap.ts as a diff-scoped ratchet).

MITAuto-check passed

Install Test File Split

skills CLI
$ npx skills add ZaxbyHub/opencode-swarm --skill test-file-split -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install ZaxbyHub/opencode-swarm test-file-split --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/ZaxbyHub/opencode-swarm.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agents/skills/test-file-split .claude/skills/test-file-split && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
test-file-split
GitHub stars
490
Token cost
~1.3k tokens
SKILL.md length
510 words
Files
1
Skills in repo
91
Repo updated
First seen
Licence
MIT

At a glance

Protocol for splitting test files that approach or exceed the FR-006 500-line limit (enforced in CI by scripts/check-test-file-cap.ts as a diff-scoped ratchet).

  • Works in 6 steps: Measure and identify split boundaries → Choose a suffix for the new file → Manage shared imports and helpers → …
  • SKILL.md covers When to use this skill, Step 1 — Measure and identify…, Step 2 — Choose a suffix for… and Step 3 — Manage shared imports…, plus 5 more sections
  • Calls bun

What it does

Test File Split is an agent skill from ZaxbyHub/opencode-swarm. Protocol for splitting test files that approach or exceed the FR-006 500-line limit (enforced in CI by scripts/check-test-file-cap.ts as a diff-scoped ratchet). Covers describe-block extraction, shared helper management, pure-function extraction, mock isolation verification, and cascading-split detection. Load when a test file approaches or exceeds 500 lines.

Its SKILL.md is about 1.3k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

The repository describes itself as: Architect-centric agentic swarm plugin for OpenCode. Hub-and-spoke orchestration with SME consultation, code generation, and QA review. The licence is MIT.

Example prompts

  • “/test-file-split”

Workflow steps

6 steps, taken from the step headings in SKILL.md.

  1. Measure and identify split boundaries
  2. Choose a suffix for the new file
  3. Manage shared imports and helpers
  4. Extract and move describe blocks
  5. Verify both files
  6. Evaluate _test_exports opportunity

What it can do on your machine

Read from SKILL.md and the folder at commit 624cb60. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • bun

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Test File Split loads about 1.3k tokens when it runs. Until then it costs about 94 tokens; SKILL.md has 510 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~94
When it runs · the whole SKILL.md, loaded when a task matches
~1.3k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from ZaxbyHub/opencode-swarm at commit 624cb60, republished under its MIT licence (© ZaxbyHub). 510 words, ~1,318 tokens.

Download SKILL.mdSave it as .claude/skills/test-file-split/SKILL.md (or your agent's skills folder).
name
test-file-split
description
Protocol for splitting test files that approach or exceed the FR-006 500-line limit (enforced in CI by scripts/check-test-file-cap.ts as a diff-scoped ratchet). Covers describe-block extraction, shared helper management, pure-function extraction, mock isolation verification, and cascading-split detection. Load when a test file approaches or exceeds 500 lines.
audience
swarm-plugin

Test File Split Protocol (FR-006)

scripts/check-test-file-cap.ts enforces the 500-line cap per test file (FR-006 / SC-006.1) as a diff-scoped ratchet: new test files over 500 lines and existing over-cap files that grew fail the quality gate and block PR merge. Pre-existing over-cap files not touched by the PR are non-blocking. Escape hatch: TEST_CAP_ENFORCE=0 soft-warns. This skill covers the complete splitting protocol.

Read first: .opencode/skills/writing-tests/SKILL.md (or .claude/skills/writing-tests/SKILL.md) for bun:test framework rules, mock isolation patterns, and file placement conventions.

When to use this skill

  • A test file exceeds or approaches 500 lines
  • CI fails with an FR-006 file-size violation
  • You are adding tests to a file that is already above 400 lines (proactive split)

Step 1 — Measure and identify split boundaries

bash
# Check the file
wc -l tests/unit/scripts/my-module.test.ts

# Find all test files exceeding 400 lines (early warning)
find tests/ -name "*.test.ts" -exec wc -l {} \; | sort -rn | awk '$1 > 400'

Identify natural describe() block boundaries. Group blocks by functional area:

  • Each describe() block should belong to exactly one split file
  • Shared beforeEach/afterEach hooks determine which blocks must stay together

Step 2 — Choose a suffix for the new file

PatternExampleWhen to use
<module>-<area>.test.tsrelease-notes-fragments-sha.test.tsSplit by functional area (SHA resolution, validation, merge logic)
<module>-<area>.adversarial.test.tsauth-login.adversarial.test.tsSplit adversarial tests into their own file

Step 3 — Manage shared imports and helpers

Three options, in order of preference:

  1. Extract to shared utility (preferred for complex shared setup): Create tests/helpers/<module>-shared.ts with shared fixtures, mock factories, and setup functions. Import from both split files.

  2. Duplicate simple imports (for small overlap): If only bun:test imports and 1-2 source imports are shared, duplicate them in both files. Simpler than a utility module for trivial cases.

  3. Extract pure functions from source (for testability): If the source module has inline validation logic, extract them as exported pure functions (e.g., isValidPrNumber, resolveAllCandidates) so both test files can target them independently. See the PR #1762 example below. See .opencode/skills/generated/safe-extraction/SKILL.md for the source extraction pattern.

Show full SKILL.md (215 more words)Show less

Step 4 — Extract and move describe blocks

  1. Cut the selected describe() blocks from the original file.
  2. Paste them into the new file.
  3. Add all necessary imports to the new file.
  4. Remove now-unused imports from the original file.

Step 5 — Verify both files

Line count check
bash
wc -l tests/unit/scripts/my-module.test.ts tests/unit/scripts/my-module-sha.test.ts
# Both must be under 500 lines
Isolated run
bash
bun --smol test tests/unit/scripts/my-module.test.ts --timeout 60000
bun --smol test tests/unit/scripts/my-module-sha.test.ts --timeout 60000
Co-run (mock isolation verification)
bash
# Critical: Bun shares a single process across test files.
# mock.module leaks can cause co-run failures even when isolated runs pass.
bun --smol test tests/unit/scripts/my-module*.test.ts --timeout 60000

If the co-run fails but isolated runs pass, check for mock.module() leakage. See .opencode/skills/writing-tests/SKILL.md → "Mock Isolation Rules" and the _internals DI seam pattern.

Step 6 — Evaluate _test_exports opportunity

After splitting, evaluate whether internal utility functions in the source module can be exported via _test_exports for zero-mock testing. This is a natural cleanup moment — the split already forces you to review test coverage boundaries.

Cascading split warning

If a previously split file exceeds 500 lines again, the test suite is structurally too large for a single module. Do not split a third time — reorganize the tests by source module boundaries instead. Repeated splitting produces fragmented test suites that are hard to navigate and maintain.

Real-world example (PR #1762)

tests/unit/scripts/release-notes-fragments.test.ts exceeded 500 lines. It was split into:

FileLinesContent
release-notes-fragments.test.ts379Fragment collection, deduplication, output formatting
release-notes-fragments-sha.test.ts261extractCommitShasFromBody, mergeCandidateLists, resolveAllCandidates, isValidPrNumber, stripCustomReleaseNotesBlock

The split also extracted isValidPrNumber and resolveAllCandidates as pure exported functions from the source module, enabling independent testing.

© ZaxbyHub, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in .agents/skills/test-file-split of ZaxbyHub/opencode-swarm.

Open the folder on GitHubat commit 624cb60

Compare with similar skills

Test File Split next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Test File Split compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Test File Split this skillZaxbyHub/opencode-swarm490—~1.3kAutomated safety check: PassMIT
Code Splittingthedaviddias/Front-End-Checklist74k—~492Automated safety check: PassMIT
Splitting Oversized ModulesPostHog/posthog40k—~2.2kAutomated safety check: PassCustom licence
SplitsBankrBot/skills1.2k—~3.9kAutomated safety check: PassNone
Mcore Split PRNVIDIA/Megatron-LM18k—~1.4kAutomated safety check: PassApache-2.0
Stack Split Commitmozilla-firefox/firefox13k—~1.3kAutomated safety check: PassCustom licence

Similar skills

  • Code Splitting

    thedaviddias/Front-End-Checklist

    A skill your agent uses when reviewing large SPA bundles, new dependency additions, or routes that feel slow to hydrate.

    74k GitHub stars~492 tokensUpdated 2 days ago
    Auto-check passed
  • Official

    Split an oversized Python module (a thousand-plus-line logic.py, models.py, api.py, or its test file) into a package of one module per concern, mechanically and provably without changing behavior.

    40k GitHub stars~2.2k tokensUpdated yesterday
    Frontend & DesignAuto-check passed
  • Splits

    BankrBot/skills

    Use Splits with Bankr for onchain treasury operations: secure assets, process revenue, manage operating subaccounts, pay expenses, govern contracts, and maintain clean accounting books.

    1.2k GitHub stars~3.9k tokensUpdated 3 days ago
    Business, Finance & HRAuto-check passed
  • Mcore Split PR

    NVIDIA/Megatron-LM

    Official

    Split a PR into multiple PRs to reduce the number of required CODEOWNERS reviewer groups.

    18k GitHub stars~1.4k tokensUpdated yesterday
    Auto-check passed
  • Stack Split Commit

    mozilla-firefox/firefox

    Split one large or hard-to-review commit into several commits that each stand on their own for review, in a git or a Jujutsu (jj) checkout.

    13k GitHub stars~1.3k tokensUpdated yesterday
    DevelopmentAuto-check passed
  • Documents how LobeHub's standalone micro apps are hosted, built and routed differently on Cloud versus self-hosted Docker, so a change does not break one path while fixing the other.

    83k GitHub stars~9.3k tokensUpdated yesterday
    DevOps & CloudAuto-check passed

More from ZaxbyHub/opencode-swarm

All 91 skills in this repo
  • Codebase Review Swarm

    ZaxbyHub/opencode-swarm

    Runs an evidence-gated, quote-grounded audit of a codebase for security, QA, accessibility, performance and more, and writes a verified report without changing source files.

    490 GitHub stars~2.8k tokensUpdated yesterday
    Auto-check passed
  • Issue Tracer

    ZaxbyHub/opencode-swarm

    Drives a bug report from validation and root-cause tracing through a critic-reviewed plan, an approved minimal fix and a PR-ready closure, never merging without recorded human approval.

    490 GitHub stars~4.4k tokensUpdated yesterday
    Auto-check passed
  • Commit and PR Publishing for Codex

    ZaxbyHub/opencode-swarm

    Codex adapter for opencode-swarm that governs commits, pushes, draft PRs, PR body updates and CI closeout, deferring to the repo's canonical commit-pr protocol.

    490 GitHub stars~1.6k tokensUpdated yesterday
    Auto-check passed
  • Durable Session State

    ZaxbyHub/opencode-swarm

    Keeps plans, decisions, evidence and reviewer verdicts in small files so long multi-phase tasks survive context compaction and session resumes.

    490 GitHub stars~896 tokensUpdated yesterday
    Auto-check passed
  • Swarm PR Feedback Closer

    ZaxbyHub/opencode-swarm

    Ingests existing pull request feedback such as review comments and CI failures, verifies each claim, fixes confirmed issues and reports closure status for every item.

    490 GitHub stars~14k tokensUpdated yesterday
    Auto-check passed
  • Swarm PR Subscribe

    ZaxbyHub/opencode-swarm

    Monitor a pull request after creation and act autonomously on pushed PR activity.

    490 GitHub stars~2.2k tokensUpdated yesterday
    Auto-check passed

Questions about Test File Split

What does Test File Split do?

Protocol for splitting test files that approach or exceed the FR-006 500-line limit (enforced in CI by scripts/check-test-file-cap.ts as a diff-scoped ratchet). Test File Split is an agent skill from ZaxbyHub/opencode-swarm.ts as a diff-scoped ratchet).

How do I install Test File Split in Claude Code?

Run `npx skills add ZaxbyHub/opencode-swarm --skill test-file-split -a claude-code`. Or copy the skill folder (.agents/skills/test-file-split in ZaxbyHub/opencode-swarm) into .claude/skills/test-file-split in your project. Claude Code loads it when a task matches its description.

How do I install Test File Split in Codex?

Run `npx skills add ZaxbyHub/opencode-swarm --skill test-file-split -a codex`. Or copy the skill folder (.agents/skills/test-file-split in ZaxbyHub/opencode-swarm) into .agents/skills/test-file-split in your project. Codex loads it when a task matches its description.

Can I use Test File Split in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add ZaxbyHub/opencode-swarm --skill test-file-split -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/test-file-split, .gemini/skills/test-file-split, .github/skills/test-file-split and .opencode/skills/test-file-split in your project.

What does Test File Split need to run?

Going by SKILL.md and its folder, Test File Split needs the command-line tools its instructions call (bun).

Does Test File Split access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Test File Split safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Test File Split use?

Test File Split is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Test File Split use?

About 1.3k tokens (SKILL.md is roughly 5.3k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Test File Split?

Skills that share tags, products or a category with Test File Split: Code Splitting (thedaviddias/Front-End-Checklist, 74k stars), Splitting Oversized Modules (PostHog/posthog, 40k stars), Splits (BankrBot/skills, 1.2k stars) and Mcore Split PR (NVIDIA/Megatron-LM, 18k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Test File Split?

ZaxbyHub (a GitHub organization) maintains it in ZaxbyHub/opencode-swarm, which has 490 GitHub stars. The repository holds 91 skills in this directory. The repository was last updated on October 7, 2026.

Source: ZaxbyHub/opencode-swarm on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.