You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
A simple example showing how to create custom slash commands for Claude Code without needing MCP servers.
## What are Custom Commands?
Claude Code automatically recognizes any markdown file in your `.claude/commands/` directory as a slash command. This provides a simple way to create reusable prompts and workflows without any complex setup.
## Directory Structure
On Mac or Linux:
```
# User-level commands (available in all projects)
~/.claude/commands/
└── date.md # Available as /user:date
# Project-specific commands
.claude/commands/
└── date.md # Available as /project:date
```
## Creating a Simple Date Command
1.**Create the commands directory**:
```bash
mkdir -p ~/.claude/commands
```
2.**Add the `date.md` file** (included in this gist)
```bash
cd~/.claude/commands
nano date.md
```
Then paste the content of date.md
Exit.
Save.
3.**Restart Claude Code**
4.**Use the command**:
```
/user:date
```
## How It Works
- Claude Code scans for `.md` files in the commands directories
- Each file becomes a slash command
- The filename (without `.md`) becomes the command name
- Commands can include `$ARGUMENTS` to accept parameters
## Example with Arguments
```markdown
# Custom Date Format
Returns date with custom format.
## Instructions
Execute: `date "$ARGUMENTS"`
If no arguments: `date "+%Y-%m-%d %H:%M:%S"`
```
Usage: `/user:date "+%A, %B %d, %Y"`
## More Command Ideas
-`/user:timestamp` - Get Unix timestamp
-`/user:uuid` - Generate a UUID
-`/user:ip` - Check current IP address
-`/user:branch` - Create and switch to a new git branch
-`/user:serve` - Start a local server
## Benefits
- ✅ No MCP server setup required
- ✅ No npm packages or dependencies
- ✅ Simple markdown files
- ✅ Instant availability after adding
- ✅ Can be version controlled with your project
- ✅ Easy to share with your team
## Resources
-[Claude Code Best Practices](https://www.anthropic.com/engineering/claude-code-best-practices)
-[Awesome Claude Code Commands](https://github.com/hesreallyhim/awesome-claude-code)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters