Skip to content

Instantly share code, notes, and snippets.

@zeeneddie
Forked from acebytes/README.md
Created September 20, 2025 06:55
Show Gist options
  • Save zeeneddie/1522a434f28a6f8b74daa03fc8b625d8 to your computer and use it in GitHub Desktop.
Save zeeneddie/1522a434f28a6f8b74daa03fc8b625d8 to your computer and use it in GitHub Desktop.
Simple way for Claude Code to know the correct date/time

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:

    mkdir -p ~/.claude/commands
  2. Add the date.md file (included in this gist)

    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

# 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


This approach is much simpler than creating MCP servers for basic utilities!

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:

date "$ARGUMENTS"

If no arguments are provided, use the default format:

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment