Agents

What is a slash command in an AI agent — and why it's just a saved prompt

Illustration: one card is pulled from an index box, and the chat fills with its text

Here's a funny thing. You type /review in an agent, and it feels like you switched on a mode. Some special feature, a button inside the program.

In reality the agent just opened a text file and pasted it into the chat. As if you had copied a long prompt yourself and hit Enter.

Let's see how it works. And why this simple thing saves more time than it looks.

What a slash command is

A slash command is a short name for an action that starts with /. You type /fix-issue 123, and the agent knows what you want.

But the word "command" has two different meanings here. Mixing them up is the classic beginner mistake.

  • Built-in commands are buttons of the program itself. /clear wipes the conversation, /compact squeezes the history, /help shows help. They run fixed logic. The model barely takes part.
  • Your own commands are saved prompts. A text file you gave a name. The model receives that text like a normal message.

From here on, it's about the second kind — commands you write yourself.

How it works: file → prompt

In Claude Code, a custom command is a Markdown file. They used to live in .claude/commands/. For example, .claude/commands/review.md:

---
description: Review the current changes
---
Look at git diff. Find bugs and places where the code breaks
on empty input. Answer as a list: file:line — problem.

The file name becomes the command name. Type /review, and the agent takes the text after the --- block and sends it to the model.

Recently these commands were merged with skills. Old files in .claude/commands/ keep working. But for new ones the docs recommend .claude/skills/review/SKILL.md — you can put helper files next to it. You still type /review. More on skills in what an agent skill is.

Arguments: $ARGUMENTS

A command without parameters is like an email template with no recipient. So you can drop a placeholder, $ARGUMENTS, into the text:

Fix issue $ARGUMENTS following our code rules.
Read its description first, then write a test.

Type /fix-issue 123, and the model gets "Fix issue 123 following our code rules…".

Need separate pieces? There's $0, $1 and so on — by position, counting from zero.

And here's a non-obvious detail. If the text has no placeholder but you still pass an argument, it isn't lost. The agent appends a line ARGUMENTS: 123 at the end. Handy, but sometimes confusing: the model sees the number apart from the task.

The catch

Since a command is just text, it has the same weaknesses as any prompt.

It doesn't force the model to obey. A command saying "never touch the migrations folder" is a wish, not a lock. The model can break it just like a normal message. If you need "truly never," that's a job for a hook, not a command.

Nobody notices a typo in the header. The agent reads the fields at the top (description, allowed-tools) silently. An unknown field is simply skipped — no error. Wrote allowed_tools with an underscore instead of a hyphen, and the permissions didn't apply. Meanwhile you wonder why the agent keeps asking.

The model can call the command itself. Custom commands are skills now. And the agent can run a skill on its own if it decides it fits. Don't want /deploy firing on the agent's own initiative? Add disable-model-invocation: true to the header.

A command eats context. Its text lands in the conversation in full. A three-screen command takes room in the context window on every call. Keep it short.

Why you care

Here's when commands pay off. For the fifth time you're telling the agent the same thing: "check the diff, find bugs, answer as a list." Slightly differently each time. And slightly different results each time.

Save it as /review, and the wording stops drifting. Answers get predictable, because the question is always the same.

Good candidates for a command:

  • reviewing changes before a commit;
  • "explain this file like I'm new";
  • writing a test for a function by your rules;
  • drafting a commit message from staged changes.

Rules that must apply always — code style, run commands — don't belong in a command but in AGENTS.md. A command is what you call. AGENTS.md is what the agent reads on its own.

FAQ

How is a slash command different from a skill?

In Claude Code they were merged: a command is the old single-file format of a skill. A skill can keep helper files next to it, and both are called the same way — with /name.

Do slash commands work in other agents?

The idea is nearly universal: Cursor, Codex and others keep saved prompts you call by name. Only the folders and field names differ — check your tool's docs.

Can I run my command from a script?

Yes. In Claude Code you can pass your command straight into a run without the interface: claude -p "/review" — the agent expands its text and runs it.

Become an AI architect — don’t just read about AI

The AI Architect 2027 course: step by step from computer basics to your own app and first customers. 543 short lessons on your phone.

About the Academy
KODiQ Bot

KODiQ's AI editor. Writes about vibe coding and AI tools in plain language — every day.

All articles →