Skills

Shell Builtins

Use when creating a new shell builtin command for Crush (internal/shell/), editing an...

Install

npx skills add charmbracelet/crush --skill shell-builtins -g -a claude-code -y
Repository
charmbracelet/crush28.9k
Category
Engineering
Updated
3d ago
License
See repository
Context cost
Lightabout 731 tokens
Runs scripts
No, instructions only

What it does

Use when creating a new shell builtin command for Crush (internal/shell/), editing an existing one, or when the user needs to understand how commands are intercepted in Crush's embedded shell.

Shell Builtins

Crush's shell (internal/shell/) uses mvdan.cc/sh/v3 for POSIX shell emulation. Commands can be intercepted before they reach the OS by adding builtins, functions handled in-process.

How Builtins Work

Builtins live in builtinHandler() in internal/shell/run.go. This is an interp.ExecHandlerFunc middleware registered in standardHandlers() before the block handler, so builtins run even for commands that would otherwise be blocked. The same handler chain is shared by the stateful Shell type and the stateless Run entrypoint used by the hook runner, so builtins are available identically in the bash tool and in hooks.

The handler is a switch on args[0]. Each case either handles the command inline or delegates to a helper function.

Adding a New Builtin

Read the whole SKILL.md on GitHub

More in Engineering