Skip to content

Instantly share code, notes, and snippets.

@zeeneddie
Forked from acebytes/README.md
Created September 20, 2025 06:55
Show Gist options
  • Select an option

  • Save zeeneddie/1522a434f28a6f8b74daa03fc8b625d8 to your computer and use it in GitHub Desktop.

Select an option

Save zeeneddie/1522a434f28a6f8b74daa03fc8b625d8 to your computer and use it in GitHub Desktop.

Revisions

  1. @acebytes acebytes created this gist Jun 18, 2025.
    91 changes: 91 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,91 @@
    # Claude Code Custom Commands

    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)
    - [Claude Command Suite](https://github.com/qdhenry/Claude-Command-Suite)

    ---

    *This approach is much simpler than creating MCP servers for basic utilities!*
    38 changes: 38 additions & 0 deletions date.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,38 @@
    # Get Date with Custom Format

    Returns the current date and time with optional custom formatting.

    ## Instructions

    Check if arguments were provided:

    If arguments are provided, execute:
    ```bash
    date "$ARGUMENTS"
    ```

    If no arguments are provided, use the default format:
    ```bash
    date "+%Y-%m-%d %H:%M:%S"
    ```

    ## Format Examples

    User can call this command with custom formats:
    - `/user:date-custom "+%A, %B %d, %Y"` → Wednesday, June 18, 2025
    - `/user:date-custom "+%Y/%m/%d"` → 2025/06/18
    - `/user:date-custom "+%s"` → Unix timestamp
    - `/user:date-custom "+%T"` → 14:30:45
    - `/user:date-custom "+%F %T %Z"` → 2025-06-18 14:30:45 PST

    ## Common Format Specifiers

    - `%Y` - Year (4 digits)
    - `%m` - Month (01-12)
    - `%d` - Day (01-31)
    - `%H` - Hour (00-23)
    - `%M` - Minute (00-59)
    - `%S` - Second (00-59)
    - `%A` - Full weekday name
    - `%B` - Full month name
    - `%Z` - Timezone