Agent skill

Bun Test Patterns

by shepherdjerred in shepherdjerred/monorepo

Current Bun test runner guidance for discovery, isolation, parallelism, sharding, changed tests, mocks, timers, snapshots, coverage, DOM Testing Library, and integration teardown.

GPL-3.0Auto-check passedDatabases

Install Bun Test Patterns

skills CLI
$ npx skills add shepherdjerred/monorepo --skill bun-test-patterns -a claude-code

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

GitHub CLI
$ gh skill install shepherdjerred/monorepo bun-test-patterns --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/shepherdjerred/monorepo.git skills-src && mkdir -p .claude/skills && cp -r skills-src/packages/dotfiles/dot_agents/skills/bun-test-patterns .claude/skills/bun-test-patterns && 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
bun-test-patterns
GitHub stars
112
Token cost
~2k tokens
SKILL.md length
840 words
Files
5 (incl. references)
Skills in repo
63
Repo updated
First seen
Licence
GPL-3.0

At a glance

Current Bun test runner guidance for discovery, isolation, parallelism, sharding, changed tests, mocks, timers, snapshots, coverage, DOM Testing Library, and integration teardown.

  • Configuring tests run by bun test
  • SKILL.md covers Current baseline, Execution dimensions, Discovery and exact paths and Selection and flake diagnosis, plus 10 more sections
  • Calls bun and bunx
  • Tasks that involve Database administration

What it does

Bun Test Patterns is an agent skill from shepherdjerred/monorepo. Current Bun test runner guidance for discovery, isolation, parallelism, sharding, changed tests, mocks, timers, snapshots, coverage, DOM Testing Library, and integration teardown. Use when writing, reviewing, or configuring tests run by bun test.

Its SKILL.md is about 2k tokens, which your agent loads only when the skill is triggered. The skill folder holds 5 other files, including reference files (for example `references/dom-and-integrations.md`, `references/mocks-and-types.md` and `references/releases.md`).

It sits in Databases, covering Database administration. It works with Testing Library. The repository describes itself as: Monorepo for all of my projects. The licence is GPL-3.0.

When your agent uses it

  • Configuring tests run by bun test
  • Tasks that involve Database administration

Example prompts

  • “/bun-test-patterns”

What it can do on your machine

Read from SKILL.md and the folder at commit 46ddf2f. 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
    • bunx

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

  • Network

    No URLs in SKILL.md. Its commands use bunx, which can reach the network depending on how they are called.

    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

Bun Test Patterns loads about 2k tokens when it runs, and up to ~4.9k if it reads all its reference files. Until then it costs about 67 tokens; SKILL.md has 840 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~67
When it runs · the whole SKILL.md, loaded when a task matches
~2k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~4.9k

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 shepherdjerred/monorepo at commit 46ddf2f, republished under its GPL-3.0 licence (© shepherdjerred). 840 words, ~1,960 tokens.

Download SKILL.mdSave it as .claude/skills/bun-test-patterns/SKILL.md (or your agent's skills folder). This skill also uses 4 other files; get the full folder from GitHub.
name
bun-test-patterns
description
Current Bun test runner guidance for discovery, isolation, parallelism, sharding, changed tests, mocks, timers, snapshots, coverage, DOM Testing Library, and integration teardown. Use when writing, reviewing, or configuring tests run by `bun test`.

Bun Test Patterns

Test one coherent behavior with strong assertions, make shared state explicit, and choose concurrency, isolation, or parallel workers deliberately. A passing runtime test does not replace TypeScript type-checking.

Current baseline

Verified against Bun 1.3.14 on 2026-08-03:

bash
bun --version
bun test --help

Bun 1.3.13 added file isolation, worker-process parallelism, deterministic sharding, and Git-aware changed-test selection. Bun 1.3.14 fixed isolation/parallel crashes and a --changed false negative involving tsconfig path aliases. Use 1.3.14 or newer for those features.

Read references/releases.md for the 64-page research ledger and first-party documentation contradictions. Read references/runner-and-configuration.md for discovery, execution, retries, reporters, coverage, lifecycle, snapshots, and timers. Read references/mocks-and-types.md for mock lifecycle, module boundaries, and expectTypeOf. Read references/dom-and-integrations.md for Happy DOM, Testing Library, Prisma, servers, and resource teardown.

Execution dimensions

ModeScopeBoundary
DefaultFiles and tests sequential in one processGlobal/module state can cross file boundaries
--concurrent / test.concurrentAsync tests overlap within filesDefault maximum concurrency is 20; concurrent tests cannot use onTestFinished
--isolateFresh global per file in one processDrains microtasks and cleans sockets, timers, and subprocesses between files
--parallel=NFiles run in worker processesImplies isolation; choose N from CI resources
--shard=M/NDeterministic path-sorted round-robin partitionOne-based shard index; every shard must run

Isolation changes cross-file leak risk, but it does not excuse missing cleanup inside a test.

Discovery and exact paths

Current canonical discovery includes test, spec, and test-directory conventions across JavaScript, JSX, TypeScript, TSX, MJS, CJS, MTS, and CTS.

Positional arguments are substring filters. Prefix an exact relative path:

bash
bun test ./src/math.test.ts

Do not call a positional value a glob. Use documented config/CLI ignore patterns for path selection.

Selection and flake diagnosis

bash
bun test --changed
bun test --changed=origin/main
bun test --randomize --seed 12345
bun test --rerun-each 20
bun test --retry 1
bun test --bail=1

--changed includes staged, unstaged, and untracked Git changes or compares against a supplied ref. With watch mode, selection is rebuilt each restart.

Retries can mask flakes. Keep zero as the normal gate; use a narrow retry only with captured reporting and remediation. Reproduce randomized failures with the printed seed.

test.only() restricts the run only when bun test --only is used. Do not leave focused tests as an implicit gate.

Configuration

Current coverage threshold shape is plural and fractional:

toml
[test]
coverage = true
coverageThreshold = { lines = 0.80, functions = 0.80, statements = 0.80 }

branch is not a documented threshold field. timeout is a CLI or per-test value, not a documented [test] key.

Other current settings include root and path ignores, concurrentTestGlob, randomization and seed, retry/rerun, coverage reporters, test-file exclusion, and coverage path ignores.

Lifecycle and cleanup

Use async hooks when cleanup returns a promise. onTestFinished runs after afterEach but is unavailable in concurrent tests.

Restore timers, spies, environment, servers, clients, databases, and temporary files in the narrowest owner. The default runner shares process state between files.

Required CI configuration must fail fast. Do not use skipIf(!process.env.DATABASE_URL) to silently remove a suite CI is expected to run. process.env.CI is a string; compare explicit values rather than treating "false" as false.

Assertions

Use as many strong assertions as prove one behavior. Avoid weak truthiness when an exact value, status, state transition, or side effect is available.

Supported Bun-specific matchers include toBePositive, toContainAllKeys, toInclude, and singular toSatisfy. These claimed matchers do not exist: toIncludeAllMembers, toIncludeAnyMembers, and toSatisfyAll.

For arrays:

typescript
expect(received).toEqual(expect.arrayContaining(expected));
expect(received).toHaveLength(expected.length);
expect(received.some(predicate)).toBe(true);
expect(received.every(predicate)).toBe(true);
Show full SKILL.md (335 more words)Show less

Mocks

Mock semantics differ:

  • clearAllMocks: call history only.
  • resetAllMocks: call history and implementations.
  • restoreAllMocks / mock.restore: restore spies/functions.
  • None of these undo mock.module overrides.

Define mock signatures that match calls:

typescript
const calculate = mock((first: string, second: string) => 42);
expect(calculate("a", "b")).toBe(42);

Prefer dependency injection or a complete module mock registered before the first import. Importing the real module to spread a partial mock already executes its side effects.

Type tests

expectTypeOf is a runtime no-op. bun test can pass when an intended type relation is wrong. Put type assertions in a file included by the project checker and run:

bash
bunx tsc --noEmit

In this monorepo, use the package's focused typecheck task.

Timers and dates

Use jest.useFakeTimers, timer advancement/run/clear/count helpers, and setSystemTime for deterministic time. Always restore real timers and time in cleanup, especially in shared-process mode.

Snapshots

An empty call lets Bun insert an inline snapshot:

typescript
expect(result).toMatchInlineSnapshot();

Use property matchers for nondeterministic IDs/timestamps. Keep snapshots focused and review updates. Never update snapshots automatically merely because CI failed.

DOM interaction

Prefer the dedicated Bun Testing Library setup with explicit expect.extend(matchers) and type declaration merging. Use user-event for realistic async interactions:

typescript
const user = userEvent.setup();
await user.click(button);

Use fireEvent only for low-level events user-event cannot model.

Integration safety

  • Validate a dedicated ephemeral database identity before destructive cleanup. Do not run unrestricted deleteMany() against an environment-selected database.
  • Prefer transactions or unique per-test records.
  • Await server.stop(). Use forced stop only when tests must close active traffic immediately.
  • Close Prisma, SQL, Redis, HTTP, file, worker, and timer resources in their owner.
  • Do not skip required integration tests because an artifact or credential is missing; build/provision the prerequisite or fail with a clear error.

Review checklist

  • Verify Bun 1.3.14+ and current CLI help.
  • Use exact ./path selection and current discovery extensions.
  • Distinguish concurrent tests, file isolation, parallel workers, and sharding.
  • Keep retry zero normally and capture randomization seeds.
  • Use the current fractional coverage schema.
  • Restore timers/spies and understand that module mocks persist.
  • Type mock signatures correctly and register module mocks before import.
  • Run an actual TypeScript checker for type tests.
  • Prefer user-event and explicit jest-dom setup.
  • Protect databases and await async server/client teardown.

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

Files

SKILL.md and 4 other files (references) in packages/dotfiles/dot_agents/skills/bun-test-patterns of shepherdjerred/monorepo.

  • SKILL.md
  • references/dom-and-integrations.md
  • references/mocks-and-types.md
  • references/releases.md
  • references/runner-and-configuration.md

Open the folder on GitHubat commit 46ddf2f

Compare with similar skills

Bun Test Patterns 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.

Bun Test Patterns compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Bun Test Patterns this skillshepherdjerred/monorepo112—~2kAutomated safety check: PassGPL-3.0
Hybrid Cloud Outboxesgetsentry/sentry45k—~4.8kAutomated safety check: PassCustom licence
Sea Orm 2FlyinPancake/yoink112—~2.9kAutomated safety check: PassApache-2.0
Redis Clusteringredis/agent-skills1651 repos~1kAutomated safety check: PassMIT
DB AdminEliasOulkadi/shokunin114—~2kAutomated safety check: NotesMIT
Redis Connectionsredis/agent-skills1651 repos~1.3kAutomated safety check: PassMIT

Similar skills

  • Hybrid Cloud Outboxes

    getsentry/sentry

    Official

    Guide for creating and maintaining outbox-based eventually consistent operations in Sentry.

    45k GitHub stars~4.8k tokensUpdated today
    DatabasesAuto-check passed
  • Sea Orm 2

    FlyinPancake/yoink

    Expert guidance for SeaORM 2.0, Rust's async ORM with strongly-typed columns, nested ActiveModels, Entity Loader API, and entity-first workflow.

    112 GitHub stars~2.9k tokensUpdated 2 days ago
    DatabasesAuto-check passed
  • Redis Clustering

    redis/agent-skills

    Official

    Redis Cluster and replication guidance covering hash tags for multi-key operations, avoiding CROSSSLOT errors, and reading from replicas to scale read-heavy workloads.

    165 GitHub starsUsed in 1 repo~1k tokens
    DatabasesAuto-check passed
  • DB Admin

    EliasOulkadi/shokunin

    PostgreSQL database administration — backup/restore (pgdump, PITR, WAL archiving), health monitoring (connections, bloat, cache hit ratio, dead tuples), connection pooling (PgBouncer), replication…

    114 GitHub stars~2k tokensUpdated 2 days ago
    DatabasesAuto-check: notes
  • Redis Connections

    redis/agent-skills

    Official

    Redis client and connection guidance covering connection pooling, multiplexing, pipelining, client-side caching with RESP3, avoiding slow commands (KEYS, SMEMBERS, HGETALL), and tuning socket…

    165 GitHub starsUsed in 1 repo~1.3k tokens
    DatabasesAuto-check passed
  • Ddia Principles

    luoling8192/ai-coding-principles

    Designing Data-Intensive Applications (DDIA) distilled reference guide by Martin Kleppmann.

    173 GitHub stars~4.7k tokensUpdated 6 mo ago
    DatabasesAuto-check passed

More from shepherdjerred/monorepo

All 63 skills in this repo
  • Bun Runtime Best Practices

    shepherdjerred/monorepo

    Bun runtime APIs and current operational patterns for files, processes, modules, networking, databases, tests, and deployment.

    112 GitHub stars~2k tokensUpdated today
    Auto-check passed
  • Bun Workspaces

    shepherdjerred/monorepo

    Current Bun workspace guidance for isolated and hoisted linkers, catalogs, filters, scripts, dependency classes, lockfiles, lifecycle trust, caches, publishing, TypeScript package exports, and…

    112 GitHub stars~2.2k tokensUpdated today
    Auto-check passed
  • Deep Research

    shepherdjerred/monorepo

    This skill should be used when the user asks to "deep research", "research this topic", "investigate thoroughly", "do a deep dive on", "comprehensive research on", "find everything about", "survey…

    112 GitHub stars~4.7k tokensUpdated today
    Auto-check: notes
  • Figma Use

    shepherdjerred/monorepo

    This skill should be used when the user asks to "create a Figma design", "design in Figma", "make a Figma mockup", "create an app icon", "design UI", "render JSX to Figma", "export from Figma"…

    112 GitHub stars~946 tokensUpdated today
    Auto-check passed
  • Fish Helper

    shepherdjerred/monorepo

    Current Fish shell scripting, functions, abbreviations, completions, variables, events, configuration, plugins, testing, and safety guidance.

    112 GitHub stars~2k tokensUpdated today
    Auto-check passed
  • Gh Helper

    shepherdjerred/monorepo

    Complete GitHub operations via gh CLI - repos, issues, PRs, code search, releases, file management When user mentions GitHub, repositories, issues, PRs, gh command, code search, commits, file contents

    112 GitHub stars~4.4k tokensUpdated today
    Auto-check passed

Works with

Categories

Questions about Bun Test Patterns

What does Bun Test Patterns do?

Current Bun test runner guidance for discovery, isolation, parallelism, sharding, changed tests, mocks, timers, snapshots, coverage, DOM Testing Library, and integration teardown. Bun Test Patterns is an agent skill from shepherdjerred/monorepo. Current Bun test runner guidance for discovery, isolation, parallelism, sharding, changed tests, mocks, timers, snapshots, coverage, DOM Testing Library, and integration teardown.

When should I use Bun Test Patterns?

Bun Test Patterns fits situations like: configuring tests run by bun test; tasks that involve Database administration.

How do I install Bun Test Patterns in Claude Code?

Run `npx skills add shepherdjerred/monorepo --skill bun-test-patterns -a claude-code`. Or copy the skill folder (packages/dotfiles/dot_agents/skills/bun-test-patterns in shepherdjerred/monorepo) into .claude/skills/bun-test-patterns in your project. Claude Code loads it when a task matches its description.

How do I install Bun Test Patterns in Codex?

Run `npx skills add shepherdjerred/monorepo --skill bun-test-patterns -a codex`. Or copy the skill folder (packages/dotfiles/dot_agents/skills/bun-test-patterns in shepherdjerred/monorepo) into .agents/skills/bun-test-patterns in your project. Codex loads it when a task matches its description.

Can I use Bun Test Patterns 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 shepherdjerred/monorepo --skill bun-test-patterns -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/bun-test-patterns, .gemini/skills/bun-test-patterns, .github/skills/bun-test-patterns and .opencode/skills/bun-test-patterns in your project.

What does Bun Test Patterns need to run?

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

Does Bun Test Patterns 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 Bun Test Patterns 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 Bun Test Patterns use?

Bun Test Patterns is published under the GPL-3.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Bun Test Patterns use?

About 2k tokens (SKILL.md is roughly 7.8k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 2.9k tokens, read only when the agent opens those files.

What are the alternatives to Bun Test Patterns?

Skills that share tags, products or a category with Bun Test Patterns: Hybrid Cloud Outboxes (getsentry/sentry, 45k stars), Sea Orm 2 (FlyinPancake/yoink, 112 stars), Redis Clustering (redis/agent-skills, 165 stars) and DB Admin (EliasOulkadi/shokunin, 114 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Bun Test Patterns?

shepherdjerred (a GitHub user) maintains it in shepherdjerred/monorepo, which has 112 GitHub stars. The repository holds 63 skills in this directory. The repository was last updated on October 7, 2026.

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