Executing Prompts
Once a prompt is created and enabled, it becomes a regular command-line program that you can execute directly.
Basic Execution
Execute a prompt by calling it as a command with the required arguments:
$ echo "Hello world!" | translate --to German
Hallo WeltCommand Help
Every prompt automatically generates a help message based on its schema:
$ translate --help
Usage: translate --to <to>
Options:
--to <to> Target language
-h, --help Print helpDry Run Mode
Test a prompt without actually calling the API using the --dry flag:
$ translate --to German --dryThis shows you what would be sent to the LLM without consuming tokens or making an API call.
TIP
The --dry flag works with all execution methods: direct execution, promptcmd, and promptctl run.
Indirect Execution
There are several alternative ways for executing prompts that do not require explicit enabling first, i.e., they still work even for "disabled" prompts.
Using promptcmd
Pass the prompt name or path to the prompt file to promptcmd, together with the prompt arguments.
promptcmd promptname --arg1 --arg2
promptcmd /path/to/promptfile.prompt --arg1 --arg2Using promptctl
You can also execute prompts through promptctl run:
$ promptctl run promptname [--dry] -- --arg1 --arg2Note that when executing using promptctl the prompt arguments must be separated from promptctl run arguments via --.
Using Shebang
You can execute a prompt file as a script by adding a shebang line at the top, similar to shell scripts. The file must be made executable with chmod +x.
#!/usr/bin/env promptcmd
---
schema:
input:
message: string
---
{{message}}$ chmod +x myprompt.prompt
$ ./myprompt.prompt --help
Usage: promptcmd [OPTIONS] --message <message> [promptname]
Arguments:
[promptname]
Prompt inputs:
--message <message>INFO
The chmod +x command makes the file executable on Unix-like systems. The help output includes [promptname] because promptcmd normally expects a prompt name as its first argument, but this can be ignored when executing the file directly via shebang.