Agent skill

Bun Test Lifecycle

by secondsky in secondsky/claude-skills

A skill your agent uses for test lifecycle hooks: beforeAll, afterAll, beforeEach, afterEach, fixtures, preload.

MITAuto-check passed

Install Bun Test Lifecycle

skills CLI
$ npx skills add secondsky/claude-skills --skill bun-test-lifecycle -a claude-code

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

GitHub CLI
$ gh skill install secondsky/claude-skills bun-test-lifecycle --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/secondsky/claude-skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/plugins/bun/skills/bun-test-lifecycle .claude/skills/bun-test-lifecycle && 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-lifecycle
GitHub stars
227
Token cost
~1.4k tokens
SKILL.md length
124 words
Files
1
Skills in repo
169
Repo updated
First seen
Licence
MIT

At a glance

A skill your agent uses for test lifecycle hooks: beforeAll, afterAll, beforeEach, afterEach, fixtures, preload.

  • Test lifecycle hooks: beforeAll
  • SKILL.md covers Lifecycle Hooks, Hook Execution Order, Nested Describe Hooks and Async Hooks, plus 7 more sections
  • Calls bun; needs API_KEY

What it does

Bun Test Lifecycle is an agent skill from secondsky/claude-skills. Use for test lifecycle hooks: beforeAll, afterAll, beforeEach, afterEach, fixtures, preload.

Its SKILL.md is about 1.4k 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: Production-ready skills for Claude Code CLI - Cloudflare, React, Tailwind v4, and AI integrations. The licence is MIT.

When your agent uses it

  • Test lifecycle hooks: beforeAll

Example prompts

  • “/bun-test-lifecycle”

Requirements

  • A credential in API_KEY

What it can do on your machine

Read from SKILL.md and the folder at commit 8837836. 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 these keys or tokens, usually read from environment variables:

    • API_KEY

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

Context cost

Bun Test Lifecycle loads about 1.4k tokens when it runs. Until then it costs about 28 tokens; SKILL.md has 124 words of instructions outside code blocks.

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

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 secondsky/claude-skills at commit 8837836, republished under its MIT licence (© secondsky). 124 words, ~1,392 tokens.

Download SKILL.mdSave it as .claude/skills/bun-test-lifecycle/SKILL.md (or your agent's skills folder).
name
bun-test-lifecycle
description
Use for test lifecycle hooks: beforeAll, afterAll, beforeEach, afterEach, fixtures, preload.
metadata.version
1.0.0
license
MIT

Bun Test Lifecycle

Bun supports Jest-compatible lifecycle hooks for test setup and teardown.

Lifecycle Hooks

typescript
import { test, expect, beforeAll, afterAll, beforeEach, afterEach } from "bun:test";

let db: Database;
let testData: any;

// Runs once before all tests in file
beforeAll(async () => {
  db = await Database.connect();
});

// Runs once after all tests in file
afterAll(async () => {
  await db.close();
});

// Runs before each test
beforeEach(() => {
  testData = { id: 1, name: "test" };
});

// Runs after each test
afterEach(() => {
  testData = null;
});

test("example", () => {
  expect(testData.name).toBe("test");
});

Hook Execution Order

beforeAll
  ├── beforeEach
  │   └── test 1
  │   └── afterEach
  ├── beforeEach
  │   └── test 2
  │   └── afterEach
afterAll

Nested Describe Hooks

typescript
import { describe, test, beforeAll, beforeEach, afterEach, afterAll } from "bun:test";

describe("outer", () => {
  beforeAll(() => console.log("1. outer beforeAll"));
  afterAll(() => console.log("6. outer afterAll"));
  beforeEach(() => console.log("2. outer beforeEach"));
  afterEach(() => console.log("5. outer afterEach"));

  describe("inner", () => {
    beforeEach(() => console.log("3. inner beforeEach"));
    afterEach(() => console.log("4. inner afterEach"));

    test("test", () => {
      console.log("test runs here");
    });
  });
});

// Output:
// 1. outer beforeAll
// 2. outer beforeEach
// 3. inner beforeEach
// test runs here
// 4. inner afterEach
// 5. outer afterEach
// 6. outer afterAll

Async Hooks

typescript
beforeAll(async () => {
  await setupDatabase();
});

beforeEach(async () => {
  await seedTestData();
});

afterEach(async () => {
  await clearTestData();
});

afterAll(async () => {
  await teardownDatabase();
});

Timeout for Hooks

typescript
// Set timeout for slow setup
beforeAll(async () => {
  await slowSetup();
}, 30000); // 30 seconds

Preload Scripts

Use --preload for global setup across all test files:

bash
bun test --preload ./setup.ts
setup.ts
typescript
import { beforeAll, afterAll } from "bun:test";

// Global setup
beforeAll(() => {
  console.log("Global setup runs before all test files");
});

// Global teardown
afterAll(() => {
  console.log("Global teardown runs after all test files");
});

// Set global variables
globalThis.testConfig = {
  apiUrl: "http://localhost:3000",
};
Configure in bunfig.toml
toml
[test]
preload = ["./test/setup.ts"]

Common Patterns

Database Setup
typescript
import { beforeAll, afterAll, beforeEach, afterEach } from "bun:test";

let db: Database;

beforeAll(async () => {
  db = await Database.connect(process.env.TEST_DB_URL);
  await db.migrate();
});

afterAll(async () => {
  await db.close();
});

beforeEach(async () => {
  await db.beginTransaction();
});

afterEach(async () => {
  await db.rollback(); // Reset state
});
Server Setup
typescript
import { beforeAll, afterAll } from "bun:test";

let server: Server;
let baseUrl: string;

beforeAll(async () => {
  server = Bun.serve({
    port: 0, // Random available port
    fetch: app.fetch,
  });
  baseUrl = `http://localhost:${server.port}`;
});

// Bun 1.2+: server.stop() returns a Promise that resolves once in-flight
// connections have closed — await it so the test process doesn't exit early.
afterAll(async () => {
  await server.stop();
});

test("api works", async () => {
  const res = await fetch(`${baseUrl}/api/health`);
  expect(res.ok).toBe(true);
});
Mock Setup
typescript
import { beforeEach, afterEach, spyOn } from "bun:test";

let fetchSpy: ReturnType<typeof spyOn>;

beforeEach(() => {
  fetchSpy = spyOn(global, "fetch").mockResolvedValue(
    new Response(JSON.stringify({ ok: true }))
  );
});

afterEach(() => {
  fetchSpy.mockRestore();
});
Environment Variables
typescript
import { beforeAll, afterAll } from "bun:test";

const originalEnv = process.env;

beforeAll(() => {
  process.env = {
    ...originalEnv,
    NODE_ENV: "test",
    API_KEY: "test-key",
  };
});

afterAll(() => {
  process.env = originalEnv;
});

Shared Fixtures

typescript
// fixtures.ts
export async function createTestUser() {
  return { id: 1, name: "Test User" };
}

export async function cleanupTestUser(user: any) {
  // cleanup logic
}

// test file
import { createTestUser, cleanupTestUser } from "./fixtures";

let user: any;

beforeEach(async () => {
  user = await createTestUser();
});

afterEach(async () => {
  await cleanupTestUser(user);
});

Hook Errors

If a hook throws, all tests in that describe block fail:

typescript
beforeAll(() => {
  throw new Error("Setup failed");
});

// All tests in this file will fail
test("will fail", () => {
  expect(true).toBe(true);
});

Common Errors

ErrorCauseFix
beforeAll timeoutSlow async setupIncrease timeout
Hook not calledWrong scopeCheck hook placement
Cleanup not runafterAll skippedEnsure no throws in tests
State leakMissing cleanupAdd proper afterEach

When to Load References

Load references/preload-scripts.md when:

  • Complex global setup
  • Multiple preload files

Load references/fixtures.md when:

  • Reusable test fixtures
  • Factory patterns

© secondsky, 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 plugins/bun/skills/bun-test-lifecycle of secondsky/claude-skills.

Open the folder on GitHubat commit 8837836

Compare with similar skills

Bun Test Lifecycle 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 Lifecycle compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Bun Test Lifecycle this skillsecondsky/claude-skills227—~1.4kAutomated safety check: PassMIT
Bun Runtimeaffaan-m/ECC274k1 repos~443Automated safety check: NotesMIT
Bun Runtimeaffaan-m/ECC274k—~428Automated safety check: NotesMIT
OpenLogi Device Fixture ContributionAprilNEA/OpenLogi23k—~1.2kAutomated safety check: PassApache-2.0
Windmill Bun Script Writerwindmill-labs/windmill18k—~9.7kAutomated safety check: PassCustom licence
Bunbastani-inc/atomic846—~2.8kAutomated safety check: PassCustom licence

Similar skills

  • Bun Runtime

    affaan-m/ECC

    Bun 作为运行时、包管理器、打包器和测试运行器。何时选择 Bun 而非 Node、迁移注意事项以及 Vercel 支持。

    274k GitHub starsUsed in 1 repo~443 tokens
    Auto-check: notes
  • Bun Runtime

    affaan-m/ECC

    ランタイムとしてのBun、パッケージマネージャー、バンドラー、テストランナー。Bun対Nodeを選択する場合、移行メモ、Vercelサポート。

    274k GitHub stars~428 tokensUpdated 2 days ago
    Auto-check: notes
  • Guides recording, privacy review and offline verification of OpenLogi device fixtures with the fixture contribute and verify commands, without treating replay as proof of hardware behavior.

    23k GitHub stars~1.2k tokensUpdated 4 days ago
    Testing & QAAuto-check passed
  • Windmill Bun Script Writer

    windmill-labs/windmill

    Guides your agent through writing Windmill scripts in TypeScript on Bun, then previewing, regenerating metadata and deploying them with the wmill CLI.

    18k GitHub stars~9.7k tokensUpdated today
    DevelopmentAuto-check passed
  • Bun

    bastani-inc/atomic

    A skill your agent uses when building, testing, and deploying JavaScript/TypeScript applications.

    846 GitHub stars~2.8k tokensUpdated today
    Testing & QAAuto-check passed
  • Bun

    brianlovin/agent-config

    Use Bun instead of Node.js, npm, pnpm, or vite. An agent skill from brianlovin/agent-config.

    375 GitHub starsUsed in 1 repo~484 tokens
    Frontend & DesignAuto-check: notes

More from secondsky/claude-skills

All 169 skills in this repo
  • Tanstack AI

    secondsky/claude-skills

    TanStack AI (alpha) provider-agnostic type-safe chat with streaming for OpenAI, Anthropic, Gemini, Ollama.

    227 GitHub starsUsed in 1 repo~3.6k tokens
    Auto-check: notes
  • Auto Animate

    secondsky/claude-skills

    AutoAnimate (@formkit/auto-animate) zero-config animations for React.

    227 GitHub stars~2.9k tokensUpdated 9 days ago
    Auto-check passed
  • Base UI React

    secondsky/claude-skills

    MUI Base UI unstyled React components with Floating UI. An agent skill from secondsky/claude-skills.

    227 GitHub stars~1.9k tokensUpdated 9 days ago
    Auto-check passed
  • Cloudflare Images

    secondsky/claude-skills

    This skill should be used when the user asks to "upload images to Cloudflare", "implement direct creator upload", "configure image transformations", "optimize WebP/AVIF", "create image variants"…

    227 GitHub stars~3.6k tokensUpdated 9 days ago
    Auto-check: notes
  • Cloudflare Nextjs

    secondsky/claude-skills

    Deploy Next.js to Cloudflare Workers via the OpenNext adapter (@opennextjs/cloudflare).

    227 GitHub stars~5.3k tokensUpdated 9 days ago
    Auto-check: notes
  • Cloudflare Sandbox

    secondsky/claude-skills

    Cloudflare Sandboxes SDK for secure code execution in Linux containers at edge.

    227 GitHub stars~4.5k tokensUpdated 9 days ago
    Auto-check passed

Questions about Bun Test Lifecycle

What does Bun Test Lifecycle do?

A skill your agent uses for test lifecycle hooks: beforeAll, afterAll, beforeEach, afterEach, fixtures, preload. Bun Test Lifecycle is an agent skill from secondsky/claude-skills. Use for test lifecycle hooks: beforeAll, afterAll, beforeEach, afterEach, fixtures, preload.

When should I use Bun Test Lifecycle?

Bun Test Lifecycle fits situations like: test lifecycle hooks: beforeAll.

How do I install Bun Test Lifecycle in Claude Code?

Run `npx skills add secondsky/claude-skills --skill bun-test-lifecycle -a claude-code`. Or copy the skill folder (plugins/bun/skills/bun-test-lifecycle in secondsky/claude-skills) into .claude/skills/bun-test-lifecycle in your project. Claude Code loads it when a task matches its description.

How do I install Bun Test Lifecycle in Codex?

Run `npx skills add secondsky/claude-skills --skill bun-test-lifecycle -a codex`. Or copy the skill folder (plugins/bun/skills/bun-test-lifecycle in secondsky/claude-skills) into .agents/skills/bun-test-lifecycle in your project. Codex loads it when a task matches its description.

Can I use Bun Test Lifecycle 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 secondsky/claude-skills --skill bun-test-lifecycle -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-lifecycle, .gemini/skills/bun-test-lifecycle, .github/skills/bun-test-lifecycle and .opencode/skills/bun-test-lifecycle in your project.

What does Bun Test Lifecycle need to run?

Going by SKILL.md and its folder, Bun Test Lifecycle needs the command-line tools its instructions call (bun) and credentials named API_KEY. Our summary lists: A credential in API_KEY.

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

Bun Test Lifecycle is published under the MIT licence (declared in SKILL.md). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Bun Test Lifecycle use?

About 1.4k tokens (SKILL.md is roughly 5.6k 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 Bun Test Lifecycle?

Skills that share tags, products or a category with Bun Test Lifecycle: Bun Runtime (affaan-m/ECC, 274k stars), Bun Runtime (affaan-m/ECC, 274k stars), OpenLogi Device Fixture Contribution (AprilNEA/OpenLogi, 23k stars) and Windmill Bun Script Writer (windmill-labs/windmill, 18k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Bun Test Lifecycle?

secondsky (a GitHub user) maintains it in secondsky/claude-skills, which has 227 GitHub stars. The repository holds 169 skills in this directory. The repository was last updated on September 28, 2026.

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