A code button is a script the runtime executes every time you press it. The script lives as a file inside the button folder, so you can edit it the same way you edit any other file.Documentation Index
Fetch the complete documentation index at: https://docs.buttons.sh/llms.txt
Use this file to discover all available pages before exploring further.
The default flow: scaffold, edit, press
The simplest way to create a button is to let Buttons scaffold a placeholder script you can fill in. Declare the args you’ll need up front — they’re part of the button spec and can’t be added later without recreating the button:main.sh — it has a shebang, a TODO comment, and a hint about where args arrive:
Args are declared at create time and stored in
button.json. If you need to change them, delete and recreate the button — your main.sh is at the same path each time, so you can copy your edits over.Scaffold in Python or Node
Pass--runtime to scaffold with the right shebang and extension:
| Flag value | Interpreter used | File written |
|---|---|---|
shell (default) | /bin/sh | main.sh |
python | python3 | main.py |
node | node | main.js |
Shortcuts for when you already know the code
Three shortcuts let you skip the edit step when the script is trivial or already on disk.--code 'one-liner'
Pass a one-line script inline. Useful when the body is a single command and quoting isn’t painful:
--file.
--file ./path/to/script.sh
Copy an existing script into the button folder. The file is copied (not symlinked) so the button is self-contained:
--runtime. Without a shebang and without --runtime, Buttons defaults to /bin/sh.
Argument injection
Arguments are never interpolated into the script body. They arrive as environment variables namedBUTTONS_ARG_<NAME> (uppercased):
Where the code lives
Afterbuttons create, the button folder contains:
main.sh any time. Changes take effect on the next press — no recreate needed.
Example: wrap a deploy script
Related
- Prompt buttons — attach an instruction to any button for the consuming agent
- Arguments — declare and pass typed args
- JSON output — capture results programmatically
- Folder structure — what lives inside a button folder