# Prompt Template Examples


Copy any file below into a prompts directory and it becomes a slash command. The filename minus `.md` is the command name, and the body is the prompt sent to the agent when you run it.

kli reads templates from two directories, both non-recursive:

- `~/.config/kli/prompts/` for commands available in every project.
- `<repo>/.kli/prompts/` for commands scoped to one repository.

The global directory is read first, so a project file with the same name extends or shadows the global set. The command registers when the prompts extension loads. For the full placeholder grammar and frontmatter fields, see [Prompt template anatomy](/kli/extend/prompt-templates/anatomy).

## Write a code review command

Save this as `~/.config/kli/prompts/review.md`. It runs as `/review`.

```markdown
---
description: Review the staged diff for bugs and unclear code
---

Review the currently staged changes.

Run `git diff --staged` and read the result. For each change, check for:

- Logic errors, off-by-one mistakes, and unhandled edge cases.
- Error paths that swallow or misreport failures.
- Names and comments that no longer match the code.

Report findings grouped by file, most serious first. If a change is
correct, say so briefly rather than padding the review. Do not edit
any files; this is a read-only review.
```

The `description` line is what appears next to `/review` in the command list. Without frontmatter, kli falls back to the first non-empty body line (truncated past 60 characters), so an explicit description keeps the listing readable.

## Write a commit-message command

Save this as `~/.config/kli/prompts/commit.md`. It runs as `/commit`.

```markdown
---
description: Draft a Conventional Commits message for the staged diff
---

Read the staged changes with `git diff --staged --stat` and
`git diff --staged`.

Write one Conventional Commits message for them:

- A `type(scope): summary` subject line, imperative mood, under 72
  characters.
- A body that explains why the change was made, wrapped at 72 columns,
  only when the diff needs it.

Print the message in a fenced block. Do not run `git commit` yourself.
```

Both commands above are fixed prompts: they take no input from the command line. Running `/review` sends the whole body to the agent verbatim.

## Pass arguments to a template

Trailing text after the command name becomes arguments. Whitespace separates them, and single or double quotes group text into one argument (the quotes are dropped). Reference positional arguments in the body with `$1`, `$2`, and so on, counted from 1. To pass every argument as one string, use `$ARGUMENTS`. The reference covers the rest of the placeholder grammar.

Save this template as `~/.config/kli/prompts/explain.md`. The `argument-hint` field shows the expected input next to the command name in the listing.

```markdown
---
description: Explain a symbol and where it is used
argument-hint: <symbol> [path]
---

Explain the symbol `$1` in this codebase.

Search for its definition and its call sites (limit the search to `$2`
if that path is given). Then describe, in two or three sentences:

- What `$1` does and what it returns.
- Who calls it and what would break if it changed.

Keep the explanation concrete and tied to the code you found.
```

Run it with arguments after the command name:

```text
/explain parseFrontmatter src/config
```

Here `$1` expands to `parseFrontmatter` and `$2` to `src/config`. A positional placeholder with no matching argument expands to an empty string, so `/explain parseFrontmatter` leaves the path clause empty rather than erroring.

When you want the trailing text passed through with no parsing, use `$RAW_ARGUMENTS`, which expands to the exact text after the command name. It is substituted last, so any placeholder-looking content inside it stays literal.

When you run any of these commands, the agent receives the expanded body as your message. Your transcript keeps the command line you typed (`/review`), while the model sees only the expansion.

Next steps:

- [Prompt template anatomy](/kli/extend/prompt-templates/anatomy) for the complete placeholder grammar and frontmatter fields.
- [/kli/extend/skills](/kli/extend/skills) for reusable instructions the agent loads on its own rather than commands you invoke.
