Chalk Labs
Need help deploying Bun Macros?
Chalk Labs sets up agents like this inside real teams: connected to your tools, tested on your data, with a human in the loop where it matters.
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/jarle-bun-macros
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/bun-macros
What's inside
- Skill name
Bun Macros- Description
- Run JavaScript functions at bundle-time with Bun macros
- License
- MIT
- Instructions
- 325 lines in SKILL.md · view on GitHub
Before installing
- Instructions call the network
Agent Skills spec issues
- name: only lowercase letters, digits and single hyphens allowed
- name: "Bun Macros" does not match folder "bun-bundler-macros"
Files (1)
- SKILL.md
SKILL.md (first lines)
# Macros
> Run JavaScript functions at bundle-time with Bun macros
Macros are a mechanism for running JavaScript functions at bundle-time. The value returned from these functions are directly inlined into your bundle.
As a toy example, consider this simple function that returns a random number.
```ts title="random.ts" icon="https://mintcdn.com/bun-1dd33a4e/nIz6GtMH5K-dfXeV/icons/typescript.svg?fit=max&auto=format&n=nIz6GtMH5K-dfXeV&q=85&s=5d73d76daf7eb7b158469d8c30d349b0" theme={"theme":{"light":"github-light","dark":"dracula"}}
export function random() {
return Math.random();
}
```
This is just a regular function in a regular file, but we can use it as a macro like so:
```tsx title="cli.tsx" icon="https://mintcdn.com/bun-1dd33a4e/nIz6GtMH5K-dfXeV/icons/typescript.svg?fit=max&auto=format&n=nIz6GtMH5K-dfXeV&q=85&s=5d73d76daf7eb7b158469d8c30d349b0" theme={"theme":{"light":"github-light","dark":"dracula"}}
import { random } from "./random.ts" with { type: "macro" };
console.log(`Your random number is ${random()}`);
```
<Note>
Macros are indicated using import attribute syntax. If you haven't seen this syntax before, it's a Stage 3 TC39
proposal that lets you attach additional metadata to import statements.
</Note>
Now we'll bundle this file with `bun build`. The bundled file will be printed to stdout.
```bash terminal icon="terminal" theme={"theme":{"light":"github-light","dark":"dracula"}}
bun build ./cli.tsx
```
```js theme={"theme":{"light":"github-light","dark":"dracula"}}
console.log(`Your random number is ${0.6805550949689833}`);
```
As you can see, the source code of the `random` function occurs nowhere in the bundle. Instead, it is executed during bundling and function call (`random()`) is replaced with the result of the function. Since the source code will never be included in the bundle, macros can safely perform privileged operations like reading from a database.
## When to use macros
If you have several build scripts for small things where you would otherwise have a one-off build script, bundle-time code execution can be easier to maintain. It lives with the rest of your code, it runs with the rest of the build, it is automatically parallelized, and if it fails, the build fails too.
If you find yourself running a lot of code at bundle-time though, consider running a server instead.
## Import attributes
Bun Macros are import statements annotated using either:
* `with { type: 'macro' }` — an import attribute, a Stage 3 ECMA Script proposal
* `assert { type: 'macro' }` — an import assertion, an earlier incarnation of import attributes that has now been abandoned (but is already supported by a number of browsers and runtimes)
## Security considerations
Macros must explicitly be imported with `{ type: "macro" }` in order to be executed at bundle-time. These imports have no effect if they are not called, unlike regular JavaScript imports which may have side effects.
You can disable macros entirely by passing the `--no-macros` flag to Bun. It produces a build error like this:
```
error: Macros are disabled
foo();
^
./hello.js:3:1 53
```
To reduce the potential attack surface for malicious packages, macros cannot be invoked from inside `node_modules/**/*`. If a package attempts to invoke a macro, you'll see an error like this:
```
error: For security reasons, macros cannot be run from node_modules.
beEvil();
^
node_modules/evil/index.js:3:1 50
```
Your application code can still import macros from `node_modules` and invoke them.
```ts title="cli.tsx" icon="https://mintcdn.com/bun-1dd33a4e/nIz6GtMH5K-dfXeV/icons/typescript.svg?fit=max&auto=format&n=nIz6GtMH5K-dfXeV&q=85&s=5d73d76daf7eb7b158469d8c30d349b0" theme={"theme":{"light":"github-light","dark":"dracula"}}
import { macro } from "some-package" with { type: "macro" };
macro();
```
## Export condition "macro"
When shipping a library containing a macro to npm or another package registry, use the `"macro"` export condition to provide a special version of your package exclusively for the macro environment.
```json title="package.json" icon="file-json" theme={"theme":{"light":"github-light","dark":"dracula"}}
{
"name": "my-package",
"exports": {
"import": "./index.js",
"require": "./index.js",
"default": "./index.js",
"macro": "./index.macro.js"
}
}
```
With this configuration, users can consume your package at runtime or at bundle-time using the same import specifier:
```ts title="index.ts" icon="https://mintcdn.com/bun-1dd33a4e/nIz6GtMH5K-dfXeV/icons/typescript.svg?fit=max&auto=format&n=nIz6GtMH5K-dfXeV&q=85&s=5d73d76daf7eb7b158469d8c30d349b0" theme={"theme":{"light":"github-light","dark":"dracula"}}
import pkg from "my-package"; // runtime import
import { macro } from "my-package" with { type: "macro" }; // macro import
```
The first import will resolve to `./node_modules/my-package/index.js`, while the second will be resolved by Bun's bundler to `./node_modules/my-package/index.macro.js`.
## Execution
When Bun's transpiler sees a macro import, it calls the function inside the transpiler using Bun's JavaScript runtime and converts the return value from JavaScript into an AST node. These JavaScript functions are called at bundle-time, not runtime.
Macros are executed synchronously in the transpiler during the visiting phase—before plugins and before the transpiler generates the AST. They are executed in the order they are imported. The transpiler will wait for the macro to finish executing before continuing. The transpiler will also await any Promise returned by a macro.
Bun's bundler is multi-threaded. As such, macros execute in parallel inside of multiple spawned JavaScript "workers".
## Dead code eliminationFrom jarle/bun-skills, MIT.
More from jarle/bun-skills
- 0.459score
Bun HTML & static sites
jarle
Build static sites, landing pages, and web applications with Bun's bundler
SkillDFreshness: D★ 9Claude Code +9 - 0.459score
Bun Plugins
jarle
Universal plugin API for extending Bun's runtime and bundler
SkillDFreshness: D★ 9Claude Code +9 - 0.459score
Bun Bytecode Caching
jarle
Speed up JavaScript execution with bytecode caching in Bun's bundler
SkillDFreshness: D★ 9Claude Code +9 - 0.459score
Bun Standalone HTML
jarle
Bundle a single-page app into a single self-contained .html file with no external dependencies
SkillDFreshness: D★ 9Claude Code +9 - 0.456score
Bun Convert an ArrayBuffer to a Uint8Array
jarle
Convert an ArrayBuffer to a Uint8Array
SkillDFreshness: D★ 9Claude Code +9 - 0.456score
Bun Feedback
jarle
Share feedback, bug reports, and feature requests
SkillDFreshness: D★ 9Claude Code +9 - 0.456score
Bun Hot reloading
jarle
Hot Module Replacement (HMR) for Bun's development server
SkillDFreshness: D★ 9Claude Code +9 - 0.456score
Bun Convert an ArrayBuffer to an array of numbers
jarle
Convert an ArrayBuffer to an array of numbers
SkillDFreshness: D★ 9Claude Code +9 - 0.456score
Bun esbuild
jarle
Migration guide from esbuild to Bun's bundler
SkillDFreshness: D★ 9Claude Code +9 - 0.456score
Bun Loaders
jarle
Built-in loaders for the Bun bundler and runtime
SkillDFreshness: D★ 9Claude Code +9 - 0.456score
Bun Convert an ArrayBuffer to a Blob
jarle
Convert an ArrayBuffer to a Blob
SkillDFreshness: D★ 9Claude Code +9 - 0.456score
Bun Convert an ArrayBuffer to a Buffer
jarle
Convert an ArrayBuffer to a Buffer
SkillDFreshness: D★ 9Claude Code +9
Signals
- Stars
- 9
- Forks
- 1
- Open issues
- 0
- Last commit (this folder)
- Feb 21, 2026 (8 months ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/jarle/bun-skills
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from jarle
- 0.559score
service-components
jarle
How to design application services with the Service Component pattern.
SkillBFreshness: B★ 3Claude Code +9 - 0.553score
service-component-testing
jarle
How to write tests for services built with Service Components.
SkillBFreshness: B★ 3Claude Code +9 - 0.459score
Bun Plugins
jarle
Universal plugin API for extending Bun's runtime and bundler
SkillDFreshness: D★ 9Claude Code +9 - 0.459score
Bun HTML & static sites
jarle
Build static sites, landing pages, and web applications with Bun's bundler
SkillDFreshness: D★ 9Claude Code +9 - 0.459score
Bun Bytecode Caching
jarle
Speed up JavaScript execution with bytecode caching in Bun's bundler
SkillDFreshness: D★ 9Claude Code +9 - 0.459score
Bun Standalone HTML
jarle
Bundle a single-page app into a single self-contained .html file with no external dependencies
SkillDFreshness: D★ 9Claude Code +9
Done for you
Rather not set it up yourself?
Chalk Labs scopes, builds and runs agents for your team: the task audit, the eval harness, the integrations and the weekly ops report. Fixed scope, priced before we start.
See how we build AI agents →Read the case studies
Chalk Labs is a two-founder AI and growth studio. We build AI agents, CRMs and MVPs for Web3 and AI companies, and have shipped 50+ product and token launches.
- launches shipped
- 50+
- launches shipped
- media placements
- 500+
- media placements
- founders on every account
- 2
- founders on every account
Press we've placed: Forbes · CoinDesk · Decrypt · Cointelegraph · The Block
Rahil Jain, Co-founder, Chalk Labs. Ex-Goldman Sachs engineer. You talk to the person who builds it.
Get Bun Macros running in your business
Tell us what you want to automate. A founder replies within one working day with a plan, not a pitch deck.
Cite this page
Bun Macros skill. Agent Mart. https://agentmart.dev/skills/jarle-bun-macros (last updated 2026-10-24)