Navigation
Copy page

Write Your First Prompt Template

On this page

A prompt template is a Markdown file that becomes a slash command. You type /name in a session, and kli sends the file's text to the model as your message. In this tutorial you'll write one template and run it. No code, just a file.

We'll build a /review command that asks kli to review the changes you've staged in git.

Create the prompts directory

kli reads prompt templates from a prompts/ folder inside your project's .kli/ directory. Move into the root of any git project and create it:

sh
mkdir -p .kli/prompts

Write the template

Create the file .kli/prompts/review.md:

sh
$EDITOR .kli/prompts/review.md

Put this in it:

markdown
---
description: Review my staged changes
argument-hint: [focus]
---

Run `git diff --staged` and review the changes.

Look for bugs, missing error handling, and anything that would
break existing behavior. If I gave a focus area, pay attention
to it: $ARGUMENTS

Report what you find. Don't change any files yet.

The filename sets the command name: review.md becomes /review. Everything below the closing --- is the body, the text kli sends to the model when you run the command.

Two things in the frontmatter shape how the command shows up:

  • description is the one-line summary kli displays next to the command.
  • argument-hint is the placeholder kli shows for whatever you type after /review.

$ARGUMENTS is a placeholder in the body. kli replaces it with whatever you type after the command name. Run /review with nothing and it expands to an empty string; run /review error handling and it expands to error handling.

Save the file.

Run it

Start kli from the project root:

sh
kli

kli finds your template at startup and registers /review. Type a single / in the prompt, and the completion list appears with review among the commands, your description beside it and [focus] as the hint.

Stage a change first so there's something to review:

sh
git add -A

Back in the session, run the command:

text
/review

kli expands the template body and sends it as your message. The model runs git diff --staged, reads the changes, and reports what it found. You wrote no code, and the diff review is now one command away.

Try it with a focus:

text
/review concurrency

This time $ARGUMENTS expands to concurrency, and the model weights its review toward that.

What you built

You have a working slash command in .kli/prompts/review.md. It lives in the project, so anyone who clones the repo and runs kli gets the same /review. Edit the file and start a fresh session to change what the command does.

From here, put the same file under ~/.config/kli/prompts/ to get the command in every project. For the full placeholder syntax, including arguments by position, see Prompt Template Arguments.