AGENT0S
HomeLibraryAgentic
FeedbackLearn AI
LIVE
Agent0s · AI Intelligence Library
Share FeedbackUpdated daily · 7am PST
Library/prompt
promptbeginnerClaude Code

Creating Custom Slash Commands in Claude Code

This technique allows developers to create custom shortcuts, called slash commands, within their Claude Code AI assistant. These commands automate repetitive tasks like reviewing code for typos, creating new blog posts from a template, or checking for security issues, making the development process faster and more consistent.

AI SETUP PROMPT

Paste into Claude Code — it will scan your project and set everything up

# Set Up: Creating Custom Slash Commands in Claude Code

## What This Is
This technique allows developers to create custom shortcuts, called slash commands, within their Claude Code AI assistant. These commands automate repetitive tasks like reviewing code for typos, creating new blog posts from a template, or checking for security issues, making the development process faster and more consistent.

Source: https://cloudartisan.com/posts/2025-04-14-claude-code-tips-slash-commands/

## Before You Start

Scan my workspace and analyze:
- The project language, framework, and directory structure
- Existing agent configuration (check for .claude/, .codex/, CLAUDE.md, settings.json, commands/, skills/ directories)

Then ask me before proceeding:
1. Should this be a slash command (.claude/commands/*.md) or added to CLAUDE.md as persistent context?
2. Any project-specific values I should customize in the prompt?

## Source Access Note

The source URL (https://cloudartisan.com/posts/2025-04-14-claude-code-tips-slash-commands/) may not be directly accessible from the terminal. Use the Reference Implementation and Additional Context sections below instead. If you need more details, ask me to paste relevant content from the source.

## What to Implement

This is a **Command Template** — a reusable slash command or system prompt.

- Create the command file based on my answer above (either `.claude/commands/[name].md` or add to `CLAUDE.md`)
- Adapt any placeholder values to my project specifics
- If the command references specific tools or APIs, wire it to what I already have configured

## Additional Context

- Create a `.claude/commands/` directory in the user's current project root if it does not already exist to store project-specific commands.
- Generate a new Markdown file within the `.claude/commands/` directory (e.g., `code-review.md`). Populate it with a detailed prompt template for a common task, using `$ARGUMENTS` as a placeholder for file paths or other user inputs.
- Instruct the user to restart their Claude Code instance to load the new command. Demonstrate its usage by invoking it (e.g., `/code-review <file_to_review>`) and explain how to view all available commands by typing `/`.

## Reference Implementation

```
```markdown
Find all draft posts in the content/posts directory.

1. Use GlobTool to find all post files in the content/posts directory
2. Use GrepTool to check each file for 'draft: true' in the front matter
3. Sort the results by modification date (most recent first)
4. Display the list of draft posts with: Filename, Post title, Last modification date, Brief description

Review the file(s): $ARGUMENTS
- Check UK English spelling, grammar, acronyms...
```
```

## Guidelines

- Adapt everything to my existing project — do not assume a specific stack or directory layout
- Review any fetched code for safety before installing or executing it
- After setup, run a quick verification and show me a summary of exactly what was installed, where, and how to use it
3,017 charactersCompatible with Claude Code & Codex CLI
MANUAL SETUP STEPS
  1. 01Create a `.claude/commands/` directory in the user's current project root if it does not already exist to store project-specific commands.
  2. 02Generate a new Markdown file within the `.claude/commands/` directory (e.g., `code-review.md`). Populate it with a detailed prompt template for a common task, using `$ARGUMENTS` as a placeholder for file paths or other user inputs.
  3. 03Instruct the user to restart their Claude Code instance to load the new command. Demonstrate its usage by invoking it (e.g., `/code-review <file_to_review>`) and explain how to view all available commands by typing `/`.

CODE INTELLIGENCE

bash
```markdown
Find all draft posts in the content/posts directory.

1. Use GlobTool to find all post files in the content/posts directory
2. Use GrepTool to check each file for 'draft: true' in the front matter
3. Sort the results by modification date (most recent first)
4. Display the list of draft posts with: Filename, Post title, Last modification date, Brief description

Review the file(s): $ARGUMENTS
- Check UK English spelling, grammar, acronyms...
```

FIELD OPERATIONS

Automated Documentation Linter

Create a `/docs:lint` command that takes a directory path as an argument. The command will use GlobTool to find all Markdown files, then GrepTool to check for common documentation errors like placeholder text (e.g., 'TODO', 'FIXME'), missing alt text for images (`!\[\]\(.*?\)`), and broken relative links.

Database Migration Scaffolder

Develop a `/db:migrate <MigrationName>` command that scaffolds a new database migration file. The command `/db:migrate CreateUserTable` would generate a new file in the `db/migrations/` directory with the correct timestamped filename and boilerplate code for the specified database framework.

STRATEGIC APPLICATIONS

  • →A marketing team can use a `/blog:new` command to scaffold new blog posts in a static site generator like Hugo or Jekyll, ensuring every post starts with the correct front matter template for author, date, and SEO tags, maintaining brand consistency.
  • →A DevOps team can create a `/k8s:debug <pod_name>` command that automates the initial steps of debugging a Kubernetes pod, such as fetching logs, describing the pod's status, and checking for recent events, consolidating multiple `kubectl` commands into one action.

TAGS

#slash command#prompt engineering#automation#developer productivity#custom command
Source: WEB · Quality score: 7/10
VIEW SOURCE