Slash commands and custom commands
Course contents (20 lessons)
- Meet Claude Code
- What Claude Code is and how it differs from a chat window
- Installing Claude Code and signing in
- Your first session: explore, ask, change
- Asking well and staying in control
- Asking for changes: context, goal, constraints and acceptance criteria
- Reading and approving edits
- Permission modes: how much freedom to give
- Project memory and slash commands
- CLAUDE.md: teaching the tool about your project
- Slash commands and custom commands
- Everyday coding workflows
- The plan-first workflow
- Understanding unfamiliar code
- Debugging with Claude Code
- Refactoring safely
- Writing tests with Claude Code
- Git, small changes, cost and security
- Git workflows: branches, commits and pull request descriptions
- Keeping changes small and reviewable
- Context and cost awareness
- Security habits: secrets, commands and untrusted input
- Extending the tool, teamwork and a final project
- Hooks and MCP servers explained
- Team practices for AI-assisted coding
- Final project: building a small app step by step
What slash commands are
Inside a session, anything you type that starts with a slash is a command to the tool itself, not a message to the model. They control the session: show help, clear context, change settings. The set of commands grows with new versions, so the reliable way to see what you have is to type /help.
The few you will use first
| Command | What it is for |
|---|---|
/help | Shows the commands and basic help for your version. |
/init | Looks at the project and creates a first CLAUDE.md. |
/clear | Clears the conversation so the next task starts with fresh context. |
/compact | Condenses a long conversation into a summary, to free up space while keeping the thread. |
There are more, for things like managing permissions, memory, MCP servers, hooks and choosing a model. I will not list them since the list changes. Use /help and the official documentation.
/clear between tasks
This is the habit I would teach first. When you finish one task, clear before starting the next. Old messages about the invoice bug do not help with the login feature, and they take up space and can confuse the tool. Commit your work, run /clear, and start fresh.
/compact in the middle of a task
If a task is long and you do not want to lose the thread, /compact summarises the conversation so far. You can usually add a note on what to keep. If you do, describe the important facts in plain words.
/compact Keep: the decision to use cursor pagination, the list of files already changed, and the failing test in OrdersApiTests.
Check the summary. If it dropped something important, restate it.
Custom commands
If you type the same long prompt often, save it as a custom command. The mechanism is simple: you put a markdown file in a commands folder inside the .claude folder of your project. The file name becomes the command name, and the text of the file becomes the prompt. A project folder is shared with your team if you commit it. A personal commands folder in your user configuration is for yourself. Check the official docs for exact locations in your version, since features here have been extended over time.
A command can also take arguments. In the file, a placeholder named $ARGUMENTS is replaced by whatever you type after the command name.
Review the changes on this branch compared with main.
Focus area: $ARGUMENTS
Check for: bugs, missing tests, error handling, security problems (input validation, secrets, injection) and style that does not match the project conventions.
Report findings as a list ordered by severity. For each: file, line, what is wrong, suggested fix. Do not edit any files.
If you save this as review.md in the commands folder, then typing /review the payment code would run it with that focus.
Why it works
The command bundles a good prompt: the scope, the checks, the report format and the "do not edit" rule. Everyone who uses it gets the same thorough review without remembering the details. You improve it once, and the whole team benefits.
Good ideas for custom commands
- A code review prompt, as above.
- A "write a pull request description" prompt that follows your team template.
- A "write tests for this file" prompt that names your test framework and style.
- A "explain this module for a new teammate" prompt.
Skills and other extensions
The tool has more ways to package reusable behaviour, including features sometimes called skills and plugins. They are newer and change faster. Read the current documentation if custom commands are not enough.
Do not over-engineer
Start with zero custom commands. After a week, look at your session history and find the prompts you typed three times. Those are the ones worth saving. A folder of fifty commands nobody remembers is just clutter.
The common mistake
The common mistake is never clearing context. A session that runs all day on five different tasks gets slower, costs more and gives worse answers. Clear between tasks.
Try it yourself
Create one custom command for a prompt you use often. Test it on a small change. Improve the text twice based on what it missed. Then run /clear and test that the command still works in a fresh session.
This course is free to read. Create a free account to enrol, save your progress and pick up where you left off.
Sign up free I already have an account