Creating Your First Script Command
Raycast includes a built-in creator that helps you get started quickly.Use the Create Script Command
Open Raycast and search for “Create Script Command”. This will guide you through creating a new script.
Choose Your Language
Select from supported languages:
- Bash
- Python
- JavaScript/Node.js
- Swift
- Ruby
- PHP
- AppleScript
- C#/.NET
If you’re writing Bash scripts, we highly recommend using ShellCheck to catch syntax errors and ensure smooth execution.
File Structure
A Script Command is a standard executable script file with special metadata comments at the top. Here’s the basic structure:Shebang Lines
The shebang line (first line starting with#!) tells the system how to execute your script. Use the appropriate shebang for your language:
| Language | Shebang |
|---|---|
| Bash | #!/bin/bash |
| Python | #!/usr/bin/env python3 |
| JavaScript | #!/usr/bin/env node |
| Swift | #!/usr/bin/swift |
| Ruby | #!/usr/bin/env ruby |
| PHP | #!/usr/bin/env php |
| AppleScript | #!/usr/bin/osascript |
| C#/.NET | #!/usr/bin/env dotnet |
For login shell execution in Bash, you can add the
-l flag: #!/bin/bash -lRaycast automatically appends /usr/local/bin to the $PATH variable, but you can extend it by adding export PATH='/some/extra/path:$PATH' at the top of your script.Metadata Comments
Metadata is defined using special comments:- Use
#for Bash, Python, Ruby, and PHP - Use
//for JavaScript, Swift, and C#
@raycast. and follow the format:
Required Metadata
Every script command must include these three parameters:Schema version for future API compatibility. Currently, only version
1 is available.Display name shown in Raycast’s root search.
How the script executes and presents output. Options: Learn more in Output Modes.
silent, compact, fullOutput, or inline.Installing Script Directories
To make your scripts available in Raycast:Scripts with
.template. in the filename won’t appear in Raycast. Remove this from the filename once you’ve configured any required values.Error Handling
If your script exits with a non-zero status code, Raycast displays an error toast. Forinline and compact modes, the last line of output becomes the error message:
Next Steps
Metadata Reference
Explore all available metadata parameters
Output Modes
Learn about different output presentation modes
Arguments
Add custom input fields to your scripts
Templates
Start from ready-made templates

