Agent skill

Bun Macros

by secondsky in secondsky/claude-skills

Evaluate JavaScript at bundle time and inline results. An agent skill from secondsky/claude-skills.

MITAuto-check passedAI & LLM Engineering

Install Bun Macros

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

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

GitHub CLI
$ gh skill install secondsky/claude-skills bun-macros --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-macros .claude/skills/bun-macros && 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-macros
GitHub stars
227
Token cost
~1.9k tokens
SKILL.md length
198 words
Files
1
Skills in repo
169
Repo updated
First seen
Licence
MIT

At a glance

Evaluate JavaScript at bundle time and inline results. An agent skill from secondsky/claude-skills.

  • Works in 5 steps: Keep macros pure - Avoid side effects → Return serializable values - Must be… → Handle errors - Throw meaningful errors… → …
  • Optimizing compile-time code generation
  • SKILL.md covers Quick Start, Macro Syntax, Common Use Cases and Return Types, plus 9 more sections
  • Calls bun; needs API_SECRET

What it does

Bun Macros is an agent skill from secondsky/claude-skills. Evaluate JavaScript at bundle time and inline results. Use when optimizing compile-time code generation, embedding files, inlining environment variables, or executing code during the bundling process.

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

It sits in AI & LLM Engineering, covering Embeddings and Secrets management. It works with JavaScript. 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

  • Optimizing compile-time code generation
  • Embedding files
  • Inlining environment variables
  • Executing code during the bundling process

Example prompts

  • “/bun-macros”

Requirements

  • A credential in API_SECRET

Workflow steps

5 steps, taken from the first numbered list in SKILL.md.

  1. Keep macros pure - Avoid side effects
  2. Return serializable values - Must be JSON-compatible
  3. Handle errors - Throw meaningful errors for build failures
  4. Document dependencies - Note what files/env vars are required
  5. Test separately - Macros can be tested as regular functions

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_SECRET

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

Context cost

Bun Macros loads about 1.9k tokens when it runs. Until then it costs about 53 tokens; SKILL.md has 198 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~53
When it runs · the whole SKILL.md, loaded when a task matches
~1.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 secondsky/claude-skills at commit 8837836, republished under its MIT licence (© secondsky). 198 words, ~1,870 tokens.

Download SKILL.mdSave it as .claude/skills/bun-macros/SKILL.md (or your agent's skills folder).
name
bun-macros
description
Evaluate JavaScript at bundle time and inline results. Use when optimizing compile-time code generation, embedding files, inlining environment variables, or executing code during the bundling process.
metadata.version
1.0.0
license
MIT

Bun Macros

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

Quick Start

typescript
// 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

typescript
// 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
typescript
// 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
typescript
// macros/git.ts
export function gitCommit(): string {
  return Bun.spawnSync(["git", "rev-parse", "HEAD"])
    .stdout.toString().trim();
}

export function gitBranch(): string {
  return Bun.spawnSync(["git", "branch", "--show-current"])
    .stdout.toString().trim();
}

// src/index.ts
import { gitCommit, gitBranch } from "./macros/git" with { type: "macro" };

const BUILD_INFO = {
  commit: gitCommit(),
  branch: gitBranch(),
};
// Inlined at build time
File Embedding
typescript
// macros/embed.ts
export function embedFile(path: string): string {
  return Bun.file(path).text();
}

export function embedJSON(path: string): unknown {
  return Bun.file(path).json();
}

// src/index.ts
import { embedFile, embedJSON } from "./macros/embed" with { type: "macro" };

const license = embedFile("./LICENSE");
const config = embedJSON("./config.json");
Build Constants
typescript
// macros/constants.ts
export function isDev(): boolean {
  return process.env.NODE_ENV !== "production";
}

export function buildDate(): number {
  return Date.now();
}

export function randomId(): string {
  return Math.random().toString(36).slice(2);
}

// src/index.ts
import { isDev, buildDate, randomId } from "./macros/constants" with { type: "macro" };

if (isDev()) {
  console.log("Development mode");
}

const BUILD_ID = randomId();
Directory Listing
typescript
// macros/files.ts
import { readdirSync } from "fs";

export function listRoutes(): string[] {
  return readdirSync("./src/routes")
    .filter(f => f.endsWith(".tsx"))
    .map(f => f.replace(".tsx", ""));
}

// src/router.ts
import { listRoutes } from "./macros/files" with { type: "macro" };

const routes = listRoutes();
// Becomes: const routes = ["home", "about", "users"];
Code Generation
typescript
// macros/codegen.ts
export function generateTypes(schema: string): string {
  // Parse schema and generate types at build time
  const types = parseSchemaToTypes(schema);
  return types;
}

export function generateAPI(spec: string): string {
  const openapi = JSON.parse(Bun.file(spec).text());
  // Generate API client code
  return generateClientFromOpenAPI(openapi);
}

Return Types

Macros can return:

typescript
// Primitives
export function getString(): string { return "hello"; }
export function getNumber(): number { return 42; }
export function getBoolean(): boolean { return true; }
export function getNull(): null { return null; }

// Objects (serializable)
export function getObject(): object {
  return { key: "value", nested: { a: 1 } };
}

// Arrays
export function getArray(): string[] {
  return ["a", "b", "c"];
}

// Response (for bundler plugins)
export function getResponse(): Response {
  return new Response("content", {
    headers: { "Content-Type": "text/plain" },
  });
}

Async Macros

typescript
// macros/fetch.ts
export async function fetchSchema(): Promise<object> {
  const response = await fetch("https://api.example.com/schema.json");
  return response.json();
}

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

const schema = await fetchSchema();
// Fetched at build time, inlined as object literal

Parameters

typescript
// macros/parameterized.ts
export function repeat(str: string, count: number): string {
  return str.repeat(count);
}

export function formatDate(format: string): string {
  return new Date().toLocaleDateString("en-US", {
    dateStyle: format as any,
  });
}

// src/index.ts
import { repeat, formatDate } from "./macros/parameterized" with { type: "macro" };

const separator = repeat("-", 20);
const date = formatDate("long");

Conditional Code

typescript
// macros/platform.ts
export function platform(): "node" | "bun" | "browser" {
  if (typeof Bun !== "undefined") return "bun";
  if (typeof process !== "undefined") return "node";
  return "browser";
}

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

if (platform() === "bun") {
  // This block is kept or removed at build time
  console.log("Running on Bun");
}

Bundle-Only Execution

Macros ONLY run during bundling:

bash
# Macros executed
bun build src/index.ts --outdir=dist

# Macros NOT executed (runtime)
bun run src/index.ts

Error Handling

typescript
// macros/safe.ts
export function requireEnv(key: string): string {
  const value = process.env[key];
  if (!value) {
    throw new Error(`Missing required env var: ${key}`);
  }
  return value;
}

// Build fails if env var missing
import { requireEnv } from "./macros/safe" with { type: "macro" };
const secret = requireEnv("API_SECRET");

Debugging Macros

typescript
// macros/debug.ts
export function debug(label: string, value: unknown): unknown {
  console.log(`[MACRO] ${label}:`, value);
  return value;
}

// See output during build
bun build src/index.ts --outdir=dist
// [MACRO] config: { ... }

Best Practices

  1. Keep macros pure - Avoid side effects
  2. Return serializable values - Must be JSON-compatible
  3. Handle errors - Throw meaningful errors for build failures
  4. Document dependencies - Note what files/env vars are required
  5. Test separately - Macros can be tested as regular functions

Common Errors

ErrorCauseFix
Cannot find moduleWrong import pathCheck macro file location
Not serializableFunction/class returnedReturn plain data
Macro failedRuntime error in macroDebug macro separately
Not evaluatedMissing with { type: "macro" }Add import attribute

When to Load References

Load references/advanced-patterns.md when:

  • Complex code generation
  • Plugin integration
  • Build pipelines Retrieve and present patterns for custom macro implementations, integration examples with build systems, and advanced bundler plugin workflows.

Load references/debugging.md when:

  • Macro not evaluating
  • Unexpected output
  • Performance issues Retrieve debugging techniques, provide step-by-step diagnostics, and offer optimization strategies tied to the user's specific issue.

© 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-macros of secondsky/claude-skills.

Open the folder on GitHubat commit 8837836

Compare with similar skills

Bun Macros 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 Macros compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Bun Macros this skillsecondsky/claude-skills227—~1.9kAutomated safety check: PassMIT
Framework Wrapperslive-codes/livecodes1.5k—~2.8kAutomated safety check: PassMIT
Getting Startedlive-codes/livecodes1.5k—~1.6kAutomated safety check: PassMIT
Configuring Agent BrainSpillwaveSolutions/agent-brain120—~7kAutomated safety check: NotesMIT
Langgraph Project Setupsoba-labs/langchain-agent-skills107—~2.4kAutomated safety check: NotesMIT
Pi AgentK-Dense-AI/scientific-agent-skills48k1 repos~2.1kAutomated safety check: PassMIT

Similar skills

  • Framework Wrappers

    live-codes/livecodes

    Use SDK with React, Vue, Svelte, Solid, Preact, and Web Components.

    1.5k GitHub stars~2.8k tokensUpdated today
    AI & LLM EngineeringAuto-check passed
  • Getting Started

    live-codes/livecodes

    Quick start for standalone app at livecodes.io, embedding playgrounds with CDN or npm, and self-hosting basics.

    1.5k GitHub stars~1.6k tokensUpdated today
    AI & LLM EngineeringAuto-check passed
  • Configuring Agent Brain

    SpillwaveSolutions/agent-brain

    Installation and configuration skill for Agent Brain document search system.

    120 GitHub stars~7k tokensUpdated 17 days ago
    AI & LLM EngineeringAuto-check: notes
  • Langgraph Project Setup

    soba-labs/langchain-agent-skills

    Initialize and configure LangGraph projects with proper structure, langgraph.json configuration, environment variables, and dependency management.

    107 GitHub stars~2.4k tokensUpdated 1 mo ago
    AI & LLM EngineeringAuto-check: notes
  • Pi Agent

    K-Dense-AI/scientific-agent-skills

    Builds with and operates Pi, the minimal terminal coding harness.

    48k GitHub starsUsed in 1 repo~2.1k tokens
    AI & LLM EngineeringAuto-check passed
  • Sap Cloud SDK AI

    secondsky/sap-skills

    Integrates SAP Cloud SDK for AI into JavaScript/TypeScript and Java applications.

    460 GitHub stars~3.2k tokensUpdated 2 days ago
    AI & LLM EngineeringAuto-check passed

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

Works with

Questions about Bun Macros

What does Bun Macros do?

Evaluate JavaScript at bundle time and inline results. An agent skill from secondsky/claude-skills. Bun Macros is an agent skill from secondsky/claude-skills. Evaluate JavaScript at bundle time and inline results.

When should I use Bun Macros?

Bun Macros fits situations like: optimizing compile-time code generation; embedding files; inlining environment variables; executing code during the bundling process.

How do I install Bun Macros in Claude Code?

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

How do I install Bun Macros in Codex?

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

Can I use Bun Macros 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-macros -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-macros, .gemini/skills/bun-macros, .github/skills/bun-macros and .opencode/skills/bun-macros in your project.

What does Bun Macros need to run?

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

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

Bun Macros 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 Macros use?

About 1.9k tokens (SKILL.md is roughly 7.5k 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 Macros?

Skills that share tags, products or a category with Bun Macros: Framework Wrappers (live-codes/livecodes, 1.5k stars), Getting Started (live-codes/livecodes, 1.5k stars), Configuring Agent Brain (SpillwaveSolutions/agent-brain, 120 stars) and Langgraph Project Setup (soba-labs/langchain-agent-skills, 107 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Bun Macros?

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.