Skip to main content

Advanced Slash Commands

Module: Navigation & Shortcuts | Lesson: 4 of 4 | Time: ~10 minutes

What You Will Learn

  • How to use /review for code review
  • How to use /pr-comments to address PR feedback
  • How to create custom slash commands

Prerequisites

Beyond the Basics

In the previous lesson, you learned the essential slash commands for everyday use. Now we will cover the advanced commands that unlock more powerful workflows — code reviews, pull request management, debugging, and even creating your own custom commands.

Some commands require setup

Several commands in this lesson work with Git and GitHub. If you have not used Git before, that is fine — you will learn all about it in Module 06: Git Integration. For now, just read through these sections to know what is available.


/review — Code Review on Demand

The /review command asks Claude to review the code changes in your current working directory. It looks at what you have changed (your Git diff) and provides feedback on potential issues, improvements, and best practices.

/review

Claude will examine your uncommitted changes and give you feedback like:

  • Bugs: Potential logic errors or edge cases you missed.
  • Style: Inconsistencies with your project's coding conventions.
  • Security: Possible vulnerabilities (like hardcoded secrets or SQL injection).
  • Performance: Inefficient patterns that could be improved.

When to use /review:

  • Before committing your changes to Git.
  • When you have been working for a while and want a second opinion.
  • Before submitting code for someone else to review.
You: /review
Claude: I've reviewed your changes. Here are my findings:

1. **Bug**: In `app.js` line 42, the `userId` variable could be
undefined if the user is not logged in. Add a null check.

2. **Style**: The new function `calculateTotal()` uses var instead
of const/let, which doesn't match the rest of your codebase.
...

/pr-comments — Address Pull Request Feedback

When someone reviews your pull request on GitHub and leaves comments, the /pr-comments command fetches those comments and helps you address them.

/pr-comments

Claude will:

  1. Fetch the latest comments from your open pull request.
  2. Show you each comment and the code it refers to.
  3. Help you make the requested changes.

When to use /pr-comments:

  • After a teammate reviews your pull request and requests changes.
  • When you want to quickly address all feedback without switching between GitHub and your editor.
Save time on reviews

Instead of reading each comment on GitHub, switching to your editor, making the change, and going back — just run /pr-comments and let Claude walk you through everything in one session.


/config — View Your Configuration

The /config command shows your current Claude Code configuration settings.

/config

This displays things like:

  • Your current permission settings (what Claude is allowed to do automatically).
  • Your theme and display preferences.
  • Your API key configuration.
  • Any custom settings you have applied.

When to use /config:

  • When you are not sure what permissions Claude currently has.
  • When troubleshooting unexpected behavior.
  • When you want to review your setup before changing something.

/debug — Diagnose Problems

If something is not working right in Claude Code — a command fails, a tool does not behave as expected, or you get an error — the /debug command helps you investigate.

/debug

Claude will examine the recent interaction, look at error messages, and help you understand what went wrong and how to fix it.

When to use /debug:

  • When a command or tool fails and you do not understand why.
  • When Claude's response does not match what you expected.
  • When you want to understand an error message.

/simplify — Clean Up Code

The /simplify command asks Claude to review recently changed code and look for opportunities to simplify it — reducing duplication, improving readability, and making the code more maintainable.

/simplify

Claude will analyze your recent changes and suggest (or make) improvements like:

  • Extracting repeated code into reusable functions.
  • Replacing complex logic with clearer alternatives.
  • Removing unnecessary code.

When to use /simplify:

  • After you get something working and want to clean it up.
  • When you notice your code has gotten messy during a long session.
  • As a final step before committing changes.

/batch — Process Multiple Items

The /batch command lets you run the same operation on multiple items — files, functions, or other targets.

/batch Rename all .txt files in the /docs folder to .md

When to use /batch:

  • When you need to apply the same change to many files.
  • When performing bulk operations like renaming, reformatting, or updating.

/loop — Repeat a Command on an Interval

The /loop command runs a prompt or slash command repeatedly on a set interval. This is useful for monitoring or polling tasks.

/loop 5m /cost

This would run the /cost command every 5 minutes. You can specify the interval in minutes (e.g., 5m, 10m). If you do not specify an interval, it defaults to 10 minutes.

When to use /loop:

  • Monitoring a long-running build or deployment.
  • Periodically checking status of something.
  • Automating repetitive checks.

/schedule — Set Up Automated Tasks

The /schedule command lets you create, manage, and run scheduled tasks (called triggers) that execute on a cron schedule — even when you are not actively using Claude Code.

/schedule

This opens an interactive flow to set up a scheduled task. For example, you could schedule Claude to review your repository for security issues every Monday morning.

When to use /schedule:

  • Automating recurring tasks like weekly code reviews.
  • Setting up regular maintenance checks.
  • Running reports on a schedule.
Advanced feature

/schedule is a more advanced feature that requires some familiarity with cron expressions and remote execution. If you are new to these concepts, start with the other commands in this lesson and come back to /schedule later.


Creating Custom Slash Commands

One of the most powerful features in Claude Code is the ability to create your own slash commands. Custom commands are reusable prompts that you save and invoke with a short name.

Where Custom Commands Live

Custom commands are stored as Markdown files in the .claude/commands/ directory inside your project:

my-project/
.claude/
commands/
review-security.md
add-tests.md
document-function.md

Creating a Custom Command

  1. Create the .claude/commands/ directory in your project (or ask Claude to create it).
  2. Create a Markdown file with the command name as the file name.
  3. Write the prompt you want the command to execute.

For example, create .claude/commands/review-security.md:

Review the current codebase for security vulnerabilities. Check for:
- Hardcoded secrets or API keys
- SQL injection vulnerabilities
- Cross-site scripting (XSS) risks
- Insecure file permissions
- Unvalidated user input

Provide a summary with severity levels (high, medium, low) for each finding.

Now you can run this command any time with:

/project:review-security

Custom Commands with Arguments

Custom commands can accept arguments using the $ARGUMENTS placeholder:

Create .claude/commands/add-tests.md:

Write unit tests for the following file: $ARGUMENTS

Include:
- At least 3 test cases
- One test for the happy path
- One test for edge cases
- One test for error handling

Use it with:

/project:add-tests src/utils/calculator.js

Claude will replace $ARGUMENTS with src/utils/calculator.js and execute the full prompt.

Share commands with your team

Since custom commands live in your project's .claude/commands/ directory, you can commit them to Git. This means your entire team can use the same custom commands, ensuring consistent workflows.


Quick Reference

CommandWhat It DoesTypical Use Case
/reviewReviews your code changesBefore committing
/pr-commentsFetches and addresses PR feedbackAfter a code review
/configShows current configurationTroubleshooting settings
/debugDiagnoses problemsWhen something fails
/simplifyCleans up and simplifies codeAfter getting code working
/batchProcesses multiple items at onceBulk operations
/loopRepeats a command on an intervalMonitoring and polling
/scheduleSets up automated recurring tasksWeekly reviews, reports
/project:<name>Runs a custom commandReusable team workflows

Try It Yourself

  1. Open Claude Code in your practice project folder.
  2. Make a small change to one of your files (add a comment, change a variable name, etc.).
  3. Run /review and read Claude's feedback on your change.
  4. Run /simplify and see if Claude suggests any improvements.
  5. Create a custom command:
    • Ask Claude: Create a .claude/commands/explain.md file that contains: "Explain the following file in simple terms, as if to a beginner: $ARGUMENTS"
  6. Test your custom command:
    /project:explain index.html
  7. Run /config to see your current Claude Code configuration.

What You Learned

  • /review examines your code changes and provides feedback on bugs, style, and security.
  • /pr-comments fetches pull request comments so you can address feedback without leaving Claude Code.
  • /config shows your current settings and /debug helps diagnose problems.
  • /simplify cleans up code by reducing duplication and improving readability.
  • /batch, /loop, and /schedule handle bulk operations, repeated tasks, and automation.
  • Custom slash commands are Markdown files in .claude/commands/ that create reusable prompts.
  • Custom commands can accept $ARGUMENTS for flexible, parameterized workflows.

Help Us Improve

How was this lesson? Take 2 minutes to share your feedback — it helps us make the tutorials better for everyone.

Give Feedback →

Next Up

Next: Capstone: Speed Run Challenge