Using Arguments
On this page
A prompt template is a Markdown file under ~/.config/kli/prompts/ or <repo>/.kli/prompts/ that you run in a session as /<name> .... Whatever you type after the command name becomes the template's arguments. This page shows how to read those arguments inside the template body. For the file format and frontmatter, see Prompt template anatomy.
Before substitution, kli splits the text after the command name into arguments: whitespace separates them, and single or double quotes group text into one argument and are dropped. So /review src/auth.lisp "the login path" produces two arguments: src/auth.lisp and the login path. There is no escape handling, and empty arguments never appear.
Read one argument by position
Use $N to insert the Nth argument, counting from 1. The placeholder is replaced in place, so you can put it anywhere in a sentence.
Review the file $1 and focus on $2.
Run with /review src/auth.lisp "error handling" and the body expands to:
Review the file src/auth.lisp and focus on error handling.A position past the end of the supplied arguments expands to an empty string rather than an error. $0 also expands to empty.
Read a range of arguments
Use ${@:start:len} to insert a slice of the arguments, joined by single spaces. start is the 1-based position of the first argument to take; len is how many to take.
Compare these files: ${@:2:3}
Run with /diff base.lisp a.lisp b.lisp c.lisp d.lisp and the slice takes three arguments starting at the second, expanding to:
Compare these files: a.lisp b.lisp c.lisplen is optional. Drop it to take everything from start to the end:
Remaining paths: ${@:2}
If len runs past the end, the slice stops at the last argument.
Read all arguments
$ARGUMENTS and $@ both expand to every argument joined by single spaces. They are equivalent; use whichever reads better in the body.
Run the test suite for $ARGUMENTS and report failures.
Run with /test parser evaluator and the body expands to:
Run the test suite for parser evaluator and report failures.Because arguments are joined with single spaces, runs of whitespace and the quotes you typed do not survive here. /test "the parser" expands $ARGUMENTS to the parser without quotes.
Read the unsplit text
$RAW_ARGUMENTS expands to everything you typed after the command name, verbatim. It is not split into arguments and not re-joined, so original spacing, quotes, and any characters that look like placeholders are kept literally.
Commit message:
$RAW_ARGUMENTS
Run with /commit fix: handle "empty input" in $1 path and the body expands to:
Commit message:
fix: handle "empty input" in $1 pathThe double space, the quotes, and the literal $1 all survive. $RAW_ARGUMENTS is substituted after the positional, slice, and all-argument placeholders, so a $1 sitting inside the raw text is never expanded a second time.
Reach for $RAW_ARGUMENTS when the body needs the input exactly as typed, such as a commit message or a free-form instruction. Reach for $1, ${@:start:len}, $ARGUMENTS, or $@ when you want the input split into discrete arguments.