Skip to content

Bunmagic Commands

llms.txt

Usage: bunmagic <command> [arguments]

Use bunmagic help [command] or run a command with --help to view the command’s autohelp output.

CommandAliasUsageDescription
doctorbunmagic doctorCheck whether bunmagic is set up
helpbunmagic help [command]Show help for bunmagic commands
whichbunmagic which <script-name>Show the source location for a script or namespace
installbunmagic installInstall bunmagic and set up the environment
unlinkbunmagic unlink [directory]Remove a directory from the script source list
typesinit, add-typesbunmagic typesCopy bunmagic.d.ts to the current directory
editbunmagic edit [script-name]Edit scripts or open a namespace directory
removermbunmagic remove <script-name>Remove and unlink a script or namespace
execxbunmagic exec <file> [args...]Execute a file with the bunmagic context
reloadbunmagic reload [--force]Rebuild linked executables for sources
symlinkbunmagic symlinkSymlink sources and bunmagic install into a target
createnewbunmagic create <script-name>Create a new script
version-vbunmagic versionPrint bunmagic version
cleanbunmagic cleanRemove orphaned bin files
listlsbunmagic list [filter]List known scripts (optional filter)
updatebunmagic updateUpdate bunmagic to the latest version
linkbunmagic link [directory]Add a directory as a script source
exec-args-forwardingtestinternalInternal/dev command in source checkouts
cleantestinternalInternal/dev command in source checkouts

Usage: bunmagic doctor

Checks common setup issues (PATH, script sources, aliases). May run interactive follow-up steps.

Examples:

Terminal window
bunmagic doctor

Usage: bunmagic help [command]

Shows help output. When command is provided, shows help for that command.

Examples:

Terminal window
bunmagic help
bunmagic help exec
bunmagic exec --help

Usage: bunmagic which <script-name>

Prints the source path for a script or the directory for a namespace.

Parameters:

  • script-name - Script slug or namespace name

Errors:

  • Throws when script-name is not provided.
  • Throws when no script or namespace matches the input.

Examples:

Terminal window
bunmagic which my-script
bunmagic which my-namespace

Usage: bunmagic install

Installs and configures bunmagic.

Options:

  • --remove, --uninstall - Uninstall bunmagic
  • remove, uninstall - Positional uninstall mode

Behavior:

  • Creates ~/.bunmagic and ~/.bunmagic/config.json if missing.
  • Ensures ~/.bunmagic/bin is on PATH.
  • Sets up the bm alias.
  • Ensures at least one script source directory exists and reloads bins.

Examples:

Terminal window
bunmagic install
bunmagic install --uninstall
bunmagic install uninstall

Usage: bunmagic unlink [directory]

Removes a script source directory from config, then cleans and reloads linked bins.

Parameters:

  • directory - Source directory path; when omitted, may prompt to select from configured sources

Examples:

Terminal window
bunmagic unlink
bunmagic unlink ~/Projects/my-scripts

Usage: bunmagic types

Writes bunmagic.d.ts to the current directory.

Behavior:

  • Overwrites ./bunmagic.d.ts if it already exists.
  • May prompt to add bunmagic.d.ts to ./.gitignore.

Examples:

Terminal window
bunmagic types
bunmagic init
bunmagic add-types

Usage: bunmagic edit [script-name]

Opens a script file or a namespace directory in the configured editor.

Parameters:

  • script-name - Script slug or namespace name; when omitted, may prompt to open ~/.bunmagic

Behavior:

  • When the script does not exist, runs bunmagic create for the same slug.

Examples:

Terminal window
bunmagic edit
bunmagic edit my-script
bunmagic edit my-namespace

Usage: bunmagic remove <script-name>

Removes a script or namespace and optionally deletes linked binaries and source files.

Parameters:

  • script-name - Script slug or namespace name

Examples:

Terminal window
bunmagic remove my-script
bunmagic rm my-script
bunmagic remove my-namespace

Usage: bunmagic exec <file> [args...]

Executes a file with bunmagic globals available.

Options:

  • --namespace <name> - Sets BUNMAGIC_NAMESPACE for the executed script (testing)

Behavior:

  • Resolves file with path.resolve(...).
  • Shows help and exits successfully when no file is provided.
  • Throws when the resolved file does not exist.

Examples:

Terminal window
bunmagic exec ./scripts/my-script.ts
bunmagic exec ./script.ts --namespace myapp --help
bunmagic x ./script.ts

Usage: bunmagic reload [--force]

Rebuilds linked script and namespace binaries from configured source directories.

Options:

  • --force - Forces bin recreation

Examples:

Terminal window
bunmagic reload
bunmagic reload --force

Usage: bunmagic symlink

Symlinks configured sources and the bunmagic install into a target directory.

Options:

  • --target <directory> - Target directory (default: ~/.bunmagic/)
  • --remove - Removes the created symlinks

Examples:

Terminal window
bunmagic symlink
bunmagic symlink --target ~/.bunmagic
bunmagic symlink --remove

Usage: bunmagic create <script-name>

Creates a new script, ensures a linked executable exists, and opens the script in the configured editor.

Parameters:

  • script-name - Script slug; may include a namespace prefix in the input format supported by bunmagic

Behavior:

  • Prompts for a target source directory when more than one is configured.
  • Prompts for an extension when none is configured.
  • Throws when a system command already exists with the same name.

Examples:

Terminal window
bunmagic create my-script
bunmagic new my-script

Usage: bunmagic version

Prints the installed bunmagic version.

Examples:

Terminal window
bunmagic version
bunmagic -v

Usage: bunmagic clean

Removes bin files in ~/.bunmagic/bin that do not map to a known script or namespace.

Behavior:

  • Prompts before deleting each unexpected binary.

Examples:

Terminal window
bunmagic clean

Usage: bunmagic list [filter]

Lists scripts and namespaces known to bunmagic.

Parameters:

  • filter - Optional fuzzy filter

Options:

  • --info, -i - Shows extended script metadata

Examples:

Terminal window
bunmagic list
bunmagic ls
bunmagic list prisma
bunmagic list --info

Usage: bunmagic update

Updates bunmagic via bun update -g bunmagic.

Examples:

Terminal window
bunmagic update

Usage: bunmagic link [directory]

Adds a source directory to the configured script source list, then reloads linked bins.

Parameters:

  • directory - Source directory path; when omitted, prompts for a path

Behavior:

  • Prompts for an optional namespace. Namespaced sources require invoking scripts with the namespace prefix.

Examples:

Terminal window
bunmagic link
bunmagic link ~/Projects/my-scripts

These entries appear in bunmagic --help when running from a source checkout. They are not part of typical end-user workflow.

Usage: internal

Internal test harness entry point.

Usage: internal

Internal test harness entry point.

  • bunmagic --help and bunmagic help are equivalent entry points.
  • In strict mode (BUNMAGIC_STRICT=1), unknown commands fail instead of prompting script creation.