Create and use custom slash commands to automate Claude Code workflows. Learn argument passing, frontmatter configuration, bash integration, and file references for building reusable prompts.
The 'Writing Slash Commands' skill enables users to create and utilize custom slash commands to streamline their workflows in Claude Code. This functionality allows you to define reusable templates for automating common tasks, which can save time and reduce manual input. By defining commands with simple syntax, you can execute predefined actions across various repositories and projects. The skill is primarily designed to enhance productivity and simplify repetitive tasks by invoking slash commands with customized arguments.
To create a custom slash command, create a file in the `.claude/commands` directory for project-specific commands or in the `~/.claude/commands` directory for personal commands. Then, write your prompt in a markdown file. For example, `echo 'Review this code for security vulnerabilities:' > ~/.claude/commands/security-review.md` creates a personal command called `/security-review`.
Yes, you can. If the command is stored in the `~/.claude/commands` directory, it will be available across all projects. However, project-specific commands stored in `.claude/commands/` will only be available within the respective project.
Yes, you can pass arguments to your slash commands. Use `$ARGUMENTS` to capture all arguments as a single string or use positional parameters like `$1`, `$2`, etc., for structured arguments. For example, a command like `/review-pr 123 high alice` would pass '123', 'high', and 'alice' as `$1`, `$2`, and `$3` respectively.
Frontmatter configuration allows you to specify optional fields such as `description`, `argument-hint`, `allowed-tools`, `model`, and `disable-model-invocation` to control the behavior of your slash command. It also helps in providing hints for autocomplete, defining tools that the command can invoke, and customizing the model used by the command.
Yes, you can execute Bash commands within your custom slash commands by using the `!` prefix. This allows you to run commands like `git status` or `git diff` before the main task in your slash command. Ensure that `Bash` is listed under `allowed-tools` for the command.
Quick Setup:
.claude/skills/Repository
CaptainCrouton89/.claude