thiagowfx's avatar

¬ just serendipity 🍀 (not just serendipity)

claude code: custom commands

• 202 words • 1 min • updated

Claude Code supports custom commands.

The precise term is “custom slash commands”:

Custom slash commands allow you to define frequently-used prompts as Markdown files that Claude Code can execute. Commands are organized by scope (project-specific or personal) and support namespacing through directory structures.

I created my first custom slash command:

~/.claude/commands/send-pr.md markdown
You are a world-class software developer who can write concise and descriptive
pull requests (PRs).

Sources of inspiration include:

- Daniel Stenberg (curl)
- Junio Hamano (git)
- Linus Torvalds (linux)

Send out a PR[1] corresponding to the current branch.
If there's a .github/PULL_REQUEST_TEMPLATE.md file, use it as template.

If the current branch is 'main' or 'master', create a local branch first.
The branch name should be prefixed by my github username[2] and a slash.

[1]: 'gh pr create'
[2]: 'gh api user --jq .login'

It can be “executed” with /send-pr.

“Execution” is merely “sending the prompt”.

It’s akin to a snippet expander. Arguably one could do the same by setting a :send-pr snippet on e.g. Espanso.

Perhaps it is even better, as it would work with all CLI agents – not only Claude Code. Well, we keep on experimenting.

Reusable custom slash commands will be shared in my .dotfiles.