New Tool Radar

AI Agents & Automation

How to Create a Custom Slash Command in Claude Code

Create a custom slash command in Claude Code so a repeated workflow is saved as one command.

Schematic with three steps: Create the command file; Run the command on a real task; Share it through the repo.

Every Markdown file in a project’s .claude/commands folder becomes a slash command in Claude Code, so a workflow you repeat can be saved once and run with one short command. Write the command file with the steps, the checks and the output format, and keep it focused on one job. A command that tries to do everything becomes a second system prompt that nobody trusts.

What you need

  • Claude Code installed and a project folder open
  • A workflow you repeat, written down as steps
  • A short name for the command

Step 1: Create the command file

In the project’s .claude/commands folder, create a Markdown file named after the command, and write the workflow inside: what to do, in what order, what to check, and what the output should look like.

Step 2: Run the command on a real task

Type the slash command in a Claude Code session and confirm it runs the workflow you wrote. If it skips a step or invents one, the file needs tightening.

Step 3: Share it through the repo

Commit the commands folder so teammates get the same command, and ask one of them to run it and tell you where it confused them.

Worked example: synthetic command test

The table below is a synthetic example. It shows the expected result of a custom command; no command was created.

Check Expected Result
Command appears in session Yes Pass
All steps run in order Yes Pass
Output matches the format Yes Pass

Expected result (UNTESTED). the command appears in the session, runs every step in order, and produces output in the format the file defines. This check was not run live; the table shows the expected result for the synthetic example.

Limits

  • A command file is a saved workflow, so review it like code when the workflow changes.
  • Keep one command to one job; a command that tries to do everything gets ignored in the parts that matter.
  • Custom subagents live in .claude/agents, not .claude/commands; do not mix the two folders.

Sources

See all