Slash commands are commands that start with a slash, like /help or /clear. You type them in the agent chat and it executes a known action or sends a ready-made instruction to the model.

The format is familiar to anyone who has used Slack or Discord, and it has been adopted by several code agent tools.

How it works

When you type the slash, the app recognizes that it is not a normal message. It looks for a command with that name and does what was defined.

There are two types. Built-in commands are part of the tool and control things like clearing the conversation, switching models or showing help. Custom commands are created by you.

In the case of custom ones, each command is usually a text file with a saved prompt. The file name becomes the command name. Some accept arguments that are inserted into the text.

Folder and format details vary by tool, so check the official documentation for the one you use.

Practical example

You always ask the agent to review code before opening a pull request, with the same list of criteria. Instead of typing everything again, save a command.

Markdown · .claude/commands/revisar.md
Revise as mudanças atuais do repositório.
Verifique: nomes claros, testes cobrindo casos de borda,
erros tratados e nenhuma chave secreta no código.
Liste os problemas por ordem de gravidade.

Then just type /revisar. The path above is an example and may vary between tools.

What it's for

Slash commands are used to standardize repetitive tasks and save typing. Teams can share the same commands, ensuring everyone asks for things the same way.

They are also used to control the tool itself, like switching models or seeing the session cost, without leaving the conversation.

In flows with multiple agents, standardized commands help give the same type of instruction to each of them.

Difference between slash commands and hooks

Slash command depends on you typing it. Hook runs on its own in response to an event, like the end of an edit. Use the first for on-demand requests and the second for rules that always apply.