Create custom slash commands for Claude Code workflows
✓Works with OpenClaudeYou 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_servermodule is available in your project - Check that you have a
.claudeor.clinedirectory in your project root for storing command definitions - Run
cat ~/.cline/commands.jsonto see if custom commands are already configured
Steps
- Create a
.clinedirectory in your project root if it doesn't exist:mkdir -p .cline - Create a
commands.jsonfile in.cline/that defines your custom commands with name, description, and handler function - Define each command object with required fields:
name(the slash command trigger),description(help text),pattern(regex or string match), andhandler(function reference) - In your Claude Code workspace settings or
cline.config.js, register the commands by importing and initializing them - Use the
registerSlashCommand()API to add each command to the Claude Code command registry - Test each command by typing
/your-command-namein the Claude Code chat interface - Add command aliases in the command definition using the
aliasesarray property for quick access variants - Document each command's expected arguments using the
argsschema 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
Related Claude Code Skills
Other Claude Code skills in the same category — free to download.
CLAUDE.md Writer
Write effective CLAUDE.md project configuration files for Claude Code
MCP Server Setup
Set up Model Context Protocol servers for Claude Code
Hooks Configuration
Configure Claude Code hooks for automated pre/post actions
Skills Writer
Write custom Claude Code skill files with proper format
Memory Setup
Configure Claude Code persistent memory system
Permissions Config
Configure Claude Code permission settings and tool access
Agent SDK Setup
Build custom agents with Claude Agent SDK
Context Management
Optimize context window usage in Claude Code conversations
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.