Learn how to create custom slash commands and skills in Claude Code using CLAUDE.md files and the .claude/skills/ directory. This guide covers setup, usage, sharing, and advanced customization with hooks and MCP.
This guide explains how to create, manage, and use custom slash commands and skills in Claude Code. It covers the underlying mechanisms (CLAUDE.md files, hooks, and the skills directory), walks through setup steps, and provides real-world usage patterns. This guide is for developers who already have Claude Code installed and want to extend it with reusable, shareable workflows.
Before you begin, make sure you have the following:
brew upgrade claude-code or brew upgrade claude-code@latest. WinGet installations require winget upgrade Anthropic.ClaudeCode.Claude Code supports two related but distinct customization mechanisms: slash commands and skills. Both let you define reusable prompts or workflows that you can invoke with a / prefix inside a Claude Code session.
Slash commands are shortcuts that expand into a predefined prompt. When you type /my-command inside Claude Code, the system replaces it with the text you defined. This is useful for frequently used instructions like "review this code for security issues" or "write a commit message."
Slash commands are defined in a CLAUDE.md file in your project root. According to the official documentation, CLAUDE.md is a markdown file that Claude Code reads at the start of every session. You can use it to set coding standards, architecture decisions, preferred libraries, and review checklists. Slash commands are one of the things you can define in this file.
Skills are more powerful than simple slash commands. A skill packages a repeatable workflow that your team can share. For example, you could create a /review-pr skill that reviews a pull request according to your team's standards, or a /deploy-staging skill that deploys the current branch to a staging environment. Skills can include multiple steps, conditional logic, and even call external tools via the Model Context Protocol (MCP).
Skills are stored in a dedicated directory (typically .claude/skills/ in your project root) and are loaded automatically when Claude Code starts. Each skill is a file that contains the prompt or workflow definition.
The CLAUDE.md file is the primary way to give Claude Code persistent instructions. It lives in the root of your project. Claude Code reads it at the start of every session, so any instructions or slash commands you define there are available immediately.
Create a file named CLAUDE.md in your project root:
touch CLAUDE.md
Inside CLAUDE.md, you define slash commands using a specific format. The official documentation does not prescribe a strict syntax, but the community has converged on a pattern using markdown headings and code blocks. Here is a common approach:
# Project Instructions
This project uses React with TypeScript. Follow the existing patterns for components, hooks, and styles. Run `npm test` before committing.
## Slash Commands
### /review
Review the current changes for bugs, security issues, and adherence to project conventions. Provide a summary of findings and suggested fixes.
### /test
Run the test suite and report any failures. If tests pass, suggest additional edge cases to cover.
### /deploy
Deploy the current branch to the staging environment. First run the tests, then build the project, then run the deployment script.
When you type /review inside Claude Code, it will expand to the text under that heading. The text can be as long or as short as you need. You can include multiple paragraphs, code references, or even instructions that reference other files in your project.
CLAUDE.md as a living document. Update it when you adopt new tools or change conventions.Skills are more structured than slash commands. They live in a dedicated directory and can include multiple files, configuration, and even scripts.
By convention, skills are stored in .claude/skills/ in your project root. Create this directory if it does not exist:
mkdir -p .claude/skills
Each skill is a file in the skills directory. The file name becomes the command name. For example, a file named review-pr.md creates a /review-pr command.
Here is an example skill file for reviewing a pull request:
# Review Pull Request
Review the current pull request for the following:
1. **Correctness**: Does the code do what it is supposed to do? Are there any logical errors?
2. **Security**: Are there any security vulnerabilities? Check for SQL injection, XSS, CSRF, and insecure data handling.
3. **Performance**: Are there any performance bottlenecks? Look for unnecessary re-renders, large loops, or expensive operations.
4. **Style**: Does the code follow the project's coding standards? Check for consistent naming, formatting, and file structure.
5. **Testing**: Are there tests for the new code? Do the existing tests still pass?
Provide a summary of findings, categorized by severity (critical, major, minor, suggestion). For each finding, include the file and line number, a description of the issue, and a suggested fix.
When you type /review-pr inside Claude Code, it will read this file and execute the instructions.
Skills can be combined with hooks for even more power. Hooks let you run shell commands before or after Claude Code actions. For example, you could create a skill that runs linting before making changes, or auto-formats code after every file edit.
Hooks are defined in a configuration file (typically claude.json or claude.yaml in your project root). The official documentation mentions that hooks let you run shell commands before or after Claude Code actions, like auto-formatting after every file edit or running lint before a commit.
Here is an example claude.json that defines a hook to run ESLint before any file edit:
{
"hooks": {
"beforeEdit": [
"npx eslint --fix {{filePath}}"
]
}
}
And a hook to format code after every edit:
{
"hooks": {
"afterEdit": [
"npx prettier --write {{filePath}}"
]
}
}
You can reference these hooks from within a skill by including instructions that trigger them. For example, a /refactor skill could instruct Claude Code to make changes, which would automatically trigger the beforeEdit and afterEdit hooks.

Once you have defined slash commands in CLAUDE.md and skills in .claude/skills/, using them is straightforward.
Open your terminal in the project directory and start Claude Code:
cd /path/to/your/project
claude
You will see the Claude Code prompt with the version, current model, and working directory shown above it.
Type / to see all available commands and skills. The list includes built-in commands (like /help, /clear, /exit) and any custom slash commands or skills you have defined.
To invoke a custom command, type its name after the slash. For example:
/review
Claude Code will expand the command and execute the associated instructions.
Use Tab for command completion. Start typing /rev and press Tab to auto-complete to /review if that is the only match. This saves time and prevents typos.
Press the Up arrow key to cycle through your command history. This includes both built-in commands and custom commands you have used in the current session.
When a skill or slash command triggers file edits, Claude Code's behavior depends on your permission mode. Press Shift+Tab to cycle through modes:
acceptEdits mode: Claude auto-approves file edits without asking.plan mode: Claude proposes changes without editing, so you can review the plan first.auto mode (some accounts): Claude runs a background safety check and blocks risky actions, returning to prompts only after repeated blocks.Choose the mode that matches your comfort level. For automated workflows like /deploy-staging, you might want acceptEdits mode to avoid constant prompts.
One of the key benefits of skills is that they are file-based and can be committed to version control. This makes them easy to share with your team.
Add the .claude/skills/ directory to your repository:
git add .claude/skills/
git commit -m "Add custom skills for review, test, and deploy workflows"
When team members pull the latest changes, they will have access to the same skills. This ensures consistency across the team.
Similarly, commit CLAUDE.md to your repository. This file can contain team-wide coding standards, architecture decisions, and shared slash commands. Every team member who starts Claude Code in the project will automatically get these instructions.
If different team members need slightly different configurations, you can use environment variables or conditional logic in your skills. For example, a /deploy skill could check for a DEPLOY_TARGET environment variable to decide whether to deploy to staging or production.
The Model Context Protocol (MCP) is an open standard for connecting AI tools to external data sources. With MCP, Claude Code can read your design docs in Google Drive, update tickets in Jira, pull data from Slack, or use your own custom tooling.
You can combine MCP with skills to create powerful workflows. For example, a /triage-bug skill could:
To set up MCP, follow the MCP quickstart guide linked from the official documentation. Once your MCP servers are configured, you can reference them in your skills by instructing Claude Code to use the connected tools.
Claude Code also builds auto memory as it works. It saves learnings like build commands and debugging insights across sessions without you writing anything. This means that over time, Claude Code becomes more efficient at working with your project.
Auto memory complements custom slash commands and skills. While skills define explicit workflows, auto memory captures implicit knowledge. For example, if you always run npm run build:dev before testing, Claude Code will learn this and suggest it automatically.

If a slash command you defined in CLAUDE.md does not appear when you type /, check the following:
CLAUDE.md is in the root of your project directory, not in a subdirectory.CLAUDE.md (case-sensitive on some file systems).### /command-name. The heading must be at the third level (###) and the command name must start with a slash.CLAUDE.md at the start of each session. If you added the command after starting the session, type /clear to reset the conversation or exit and restart Claude Code.If a skill file in .claude/skills/ is not loading:
.claude/skills/ in the project root..md extension. Other extensions may not be recognized.If a hook defined in claude.json is not firing:
claude.json (or claude.yaml) and is in the project root.beforeEdit and afterEdit, but there may be others. Refer to the hooks documentation for the complete list.If Claude Code is not asking for approval when you expect it to, or is asking too often:
/mode or looking at the session header.Shift+Tab to cycle through modes until you find the one that matches your workflow.auto mode (available on some accounts) runs background safety checks and may block risky actions silently.Once you have mastered custom slash commands and skills, explore these advanced topics from the official documentation:
@Claude in Slack with a bug report and get a pull request back.claude --teleport.For a complete reference of all shell commands and session commands, see the CLI reference and the commands reference in the official documentation.
Learn how to run Claude Code in CI/CD pipelines without interactive prompts. Covers authentication, permission configuration, GitHub Actions and GitLab CI integration, and troubleshooting common issues.
Learn how to install, configure, and start using Claude Code to automate desktop tasks, fix bugs, manage Git workflows, and build features directly from your terminal, IDE, or desktop app.
Complete guide to Claude Code settings, permissions, and configuration scopes. Learn how to manage user, project, local, and managed settings, use the /config command, and handle invalid entries.
Learn to use the Claude Message Batches API for cost-effective, high-throughput processing of multiple prompts. Covers setup, batch creation, monitoring, result retrieval, and troubleshooting with practical examples.
Learn how to connect Claude Code to your database using the Model Context Protocol (MCP). This guide covers setup, configuration, querying, and advanced usage with real-world examples.
Learn how to set up Claude Code with GitHub Actions for automated code review, issue triage, and CI/CD workflows. Covers workflow configuration, authentication, CLI flags, and best practices.
Workflows from the Neura Market marketplace related to this Claude resource