$120 tested Claude codes · real before/after data · Full tier $15 one-timebuy --sheet=15 →
$Free 40-page Claude guide — setup, 120 prompt codes, MCP servers, AI agents. download --free →
clskills.sh — terminal v2.4 — 2,347 skills indexed● online
[CL]Skills_
Claude CodeintermediateNew

Custom Slash Commands

Share

Create custom slash commands for Claude Code workflows

Works with OpenClaude

You are a Claude Code workflow architect. The user wants to create custom slash commands that extend Claude Code's functionality for their specific workflows.

What to check first

  • Verify Claude Code is installed and the cline_mcp_server module is available in your project
  • Check that you have a .claude or .cline directory in your project root for storing command definitions
  • Run cat ~/.cline/commands.json to see if custom commands are already configured

Steps

  1. Create a .cline directory in your project root if it doesn't exist: mkdir -p .cline
  2. Create a commands.json file in .cline/ that defines your custom commands with name, description, and handler function
  3. Define each command object with required fields: name (the slash command trigger), description (help text), pattern (regex or string match), and handler (function reference)
  4. In your Claude Code workspace settings or cline.config.js, register the commands by importing and initializing them
  5. Use the registerSlashCommand() API to add each command to the Claude Code command registry
  6. Test each command by typing /your-command-name in the Claude Code chat interface
  7. Add command aliases in the command definition using the aliases array property for quick access variants
  8. Document each command's expected arguments using the args schema object with type, required, and description fields

Code

// .cline/commands.json - Command definitions
{
  "commands": [
    {
      "name": "analyze",
      "description": "Analyze code files and generate a summary report",
      "pattern": "^/analyze\\s+(.+)$",
      "aliases": ["/ann", "/check"],
      "handler": "handleAnalyzeCommand",
      "args": {
        "filePath": {
          "type": "string",
          "required": true,
          "description": "Path to file or directory to analyze"
        },
        "depth": {
          "type": "number",
          "required": false,
          "description": "Recursion depth for directory scanning"
        }
      }
    },
    {
      "name": "refactor",
      "description": "Refactor code with specified pattern or rule",
      "pattern": "^/refactor\\s+(.+)\\s+--rule\\s+(.+)$",
      "handler": "handleRefactorCommand",
      "args": {
        "target": {
          "type": "string",
          "required": true,
          "description": "Code section or file to refactor"
        },
        "rule": {
          "type": "string",
          "required": true,
          "description": "Refactoring rule to apply"
        }
      }
    },
    {
      "name": "deploy",
      "description": "Deploy current project to specified environment",
      "pattern": "^/deploy\\s+

Note: this example was truncated in the source. See the GitHub repo for the latest full version.

Common Pitfalls

  • Treating this skill as a one-shot solution — most workflows need iteration and verification
  • Skipping the verification steps — you don't know it worked until you measure
  • Applying this skill without understanding the underlying problem — read the related docs first

When NOT to Use This Skill

  • When a simpler manual approach would take less than 10 minutes
  • On critical production systems without testing in staging first
  • When you don't have permission or authorization to make these changes

How to Verify It Worked

  • Run the verification steps documented above
  • Compare the output against your expected baseline
  • Check logs for any warnings or errors — silent failures are the worst kind

Production Considerations

  • Test in staging before deploying to production
  • Have a rollback plan — every change should be reversible
  • Monitor the affected systems for at least 24 hours after the change

Quick Info

CategoryClaude Code
Difficultyintermediate
Version1.0.0
AuthorClaude Skills Hub
claude-codecommandsworkflow

Install command:

curl -o ~/.claude/skills/custom-slash-commands.md https://claude-skills-hub.vercel.app/skills/claude-code/custom-slash-commands.md

Related Claude Code Skills

Other Claude Code skills in the same category — free to download.

Want a Claude Code skill personalized to YOUR project?

This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.