Skip to content

Build-time JavaScript evaluation for Bun that inlines macro results into the bundled output.

CCM score
52 of 100
skills.sh installs
407
GitHub stars
257
last updated
Aug 21, 2026
View on GitHub

Own this skill? Claim it

What it does

  • Covers macro syntax via with { type: "macro" } imports and their evaluation only during bun build, not bun run
  • Includes examples for env inlining, git metadata, file embedding, directory listing, platform checks, and async fetches
  • Requires macro return values to be serializable, and makes a failing requireEnv check fail the build
  • Designed for build-time code generation and constant embedding in Bun projects, with references/ files for advanced patterns and debugging

Install

$ npx -y skills add secondsky/claude-skills --skill bun-macros -y

Installs into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.

Files

Bun Macros

Bun macros run JavaScript at bundle time and inline the results into the output.

Quick Start

// src/config.ts (macro file)
export function getVersion() {
  return "1.0.0";
}

export function getBuildTime() {
  return new Date().toISOString();
}

// src/index.ts (consumer)
import { getVersion, getBuildTime } from "./config" with { type: "macro" };

// At bundle time, these become:
const version = "1.0.0";
const buildTime = "2024-01-15T12:00:00.000Z";

Macro Syntax

// Import with macro attribute
import { fn } from "./macro-file" with { type: "macro" };

// Call the macro (evaluated at build time)
const result = fn();

Common Use Cases

Environment Inlining

// macros/env.ts
export function env(key: string): string {
  return process.env[key] ?? "";
}

// src/index.ts
import { env } from "./macros/env" with { type: "macro" };

const apiUrl = env("API_URL");
// Becomes: const apiUrl = "https://api.example.com";

Git Information

// macros/git.ts
export function gitCommit(): string {
  return Bun.spawnSync(["git", "rev-parse", "HEAD"])
    .stdout.toString().trim();
}

Details

Repository
github.com/secondsky/claude-skills
Categories
Frontend & UI Code, CLI & Terminal
First seen
Jun 3, 2026

Questions

What does the bun-macros skill do?

The bun-macros skill teaches an agent to evaluate JavaScript at bundle time and inline the results into the output. It covers embedding files, inlining environment variables, and running code during the bundling process.

How do I install the bun-macros skill?

Run npx -y skills add secondsky/claude-skills --skill bun-macros -y in your project. Once installed, the agent can write macro files that Bun evaluates during bundling.

Which other skills lead the Frontend & UI Code category?

bun-macros sits in the Frontend & UI Code category alongside vercel-react-best-practices, web-design-guidelines, design-taste-frontend, vercel-composition-patterns and lark-apps. Its focus is compile-time code generation, which is narrower than the design and React guidance of those skills.

Do macros run when I start my app with bun run?

No, macros only execute during bundling, so bun build triggers them but bun run does not. The skill notes this behavior explicitly so you can plan where generated values are computed.

More from secondsky/claude-skills

All 116

Similar to Bun Macros

More Frontend & UI Code