TL;DR
Creating your own slash commands, configuring skills and hooking into Claude Code lets you automate up to 40% of your development tasks. This guide covers setting up custom commands, having the AI automatically learn your conventions, orchestrating parallel subagents, and integrating MCP plugins.
Creating your own slash commands, configuring skills and hooking into Claude Code lets you automate up to 40% of your development tasks. This guide covers setting up custom commands, having the AI automatically learn your conventions, orchestrating parallel subagents, and integrating MCP plugins.
Custom commands and skills in Claude Code form the extensibility system that adapts the AI agent to your specific development practices. Claude Code v1.0 offers four complementary mechanisms: custom slash commands, declarative skills, automation hooks, and parallel subagents. over 60% of advanced users create at least one custom command within their first week of use.
How do custom commands work in Claude Code?
A custom command is a Markdown file stored in .claude/commands/ that defines a reusable prompt invocable via /command-name. Create a file, write your prompt, and Claude Code automatically detects it at startup.
The mechanism relies on naming conventions. Each .md file in the .claude/commands/ directory becomes a slash command. You can organize your commands into subfolders to categorize them by domain.
To understand the overall architecture of the tool, check the introduction page to Claude Code which presents all available features.
| Element | Location | Scope |
|---|---|---|
| Project commands | .claude/commands/ | Shared via Git with the team |
| Personal commands | ~/.claude/commands/ | Local to your machine |
| Skills | .claude/skills/ | Automatically loaded via Git |
| CLAUDE.md | Project root | Global project skill |
In practice, project commands are versioned with your code and shared with the entire team. Personal commands remain private on your machine. This separation lets you standardize team practices while keeping your individual shortcuts.
The $ARGUMENTS variable is the mechanism for injecting dynamic parameters into your slash commands. It captures all text entered after the command name.
Key takeaway: custom commands are Markdown files in .claude/commands/ - one file = one reusable slash command for the entire team.
How to create a custom slash command step by step?
Open your terminal and create the commands directory if needed:
mkdir -p .claude/commands
Create a file for your first command. Here is how to define a /review command that performs a code review:
Analyze the current Git diff and perform a code review.
Check for:
- Logic errors
- Security vulnerabilities (injection, XSS)
- Project convention violations
- Missing tests
Format your response with concrete suggestions.
Save this content to .claude/commands/review.md, then test it directly:
claude
> /review
Claude Code detects the file and executes the associated prompt. The load time for a custom command is under 50 ms. You can also create parameterized commands.
Check the step-by-step custom commands tutorial for examples including variables and advanced parameters.
Generate unit tests for the file $ARGUMENTS.
Use the test framework already configured in the project.
Cover nominal cases, edge cases, and errors.
Save this file as .claude/commands/gen-test.md and run it with an argument:
> /gen-test src/utils/parser.ts
commands with arguments cover 75% of enterprise use cases. The system supports commands nested in subfolders, accessible via /folder/command.
To quickly find the syntax, keep the command reference at hand, which lists all available parameters.
Key takeaway: create a .md file in .claude/commands/, use $ARGUMENTS for dynamic parameters, and your command is operational.
What are skills and how does the AI learn your patterns?
A skill is a declarative configuration file that teaches Claude Code your development conventions. Unlike slash commands invoked manually, skills are loaded automatically and influence every response from the agent.
Skills are placed in .claude/skills/ in Markdown format. Define your naming conventions, architectural patterns, and style rules in these files.
## Project React conventions
- Functional components with hooks only
- Files named in PascalCase: UserProfile.tsx
- Types in an adjacent .types.ts file
- Zustand for global state management
- Tests with Vitest + Testing Library
- Minimum coverage: 80%
In practice, a well-written skill reduces manual corrections by 35% according to SFEIR Institute experience feedback. Claude Code loads all project skills at the start of each session, in under 100 ms.
| Skill type | Example | Measured impact |
|---|---|---|
| Code conventions | Naming, formatting, patterns | Code consistency: +40% |
| Architecture | Folder structure, layers | Refactoring needed: -30% |
| Tests | Frameworks, minimum coverage | Test coverage: +25% |
| Security | OWASP rules, validation | Vulnerabilities detected: -50% |
You can check the commands and skills cheatsheet to quickly find the syntax for each type of skill.
The CLAUDE.md file is the global skill of your project, read as a priority by Claude Code. Add your high-level instructions there. Files in .claude/skills/ complement this file with specialized instructions by domain.
To understand how skills integrate into the agentic coding paradigm, see our dedicated guide that explains the role of agent autonomy.
Key takeaway: skills teach your conventions to the AI persistently - they apply automatically to every interaction without manual invocation.
How to use subagents to parallelize your tasks?
A subagent is a secondary Claude instance launched by the main agent to process a subtask in parallel. This mechanism allows breaking down complex work into independent units executed simultaneously.
Concretely, when you ask Claude Code to refactor 5 files, the main agent delegates each file to a dedicated subagent. The total time drops from 5x to about 1.5x the time for a single file.
Since Claude Code v1.0 (2026), the maximum number of simultaneous subagents is 10. Each subagent consumes on average 15% more tokens compared to sequential execution.
| Scenario | Without subagents | With subagents | Gain |
|---|---|---|---|
| Review of 5 files | ~120 s | ~35 s | 70% |
| Test generation (3 modules) | ~90 s | ~30 s | 67% |
| Multi-file refactoring | ~180 s | ~50 s | 72% |
| Large codebase search | ~60 s | ~15 s | 75% |
Each subagent inherits the project context: skills, CLAUDE.md, and commands. It operates in a sandbox with the same permissions as the main agent. For automated workflows, see the guide on headless mode and CI/CD.
In practice, 80% of tasks involving more than 3 files benefit from subagent parallelization. The orchestration is automatic - you do not have to manage the distribution.
Discover concrete examples of subagents in action in our documented use case gallery.
Key takeaway: subagents parallelize complex tasks with an average time savings of 70% - Claude Code orchestrates them automatically.
Can Claude Code be extended with plugins and a marketplace?
The MCP (Model Context Protocol) is the Claude Code extension system for integrating external tools. An MCP server is a plugin that exposes additional capabilities: database access, API querying, or specialized file reading.
Configure an MCP server in your settings file:
{
"mcpServers": {
"postgres": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-postgres"],
"env": {
"DATABASE_URL": "postgresql://localhost:5432/mydb"
}
}
}
}
over 200 community servers are available in 2026. You can create your own MCP server in TypeScript or Python. The ecosystem covers databases, monitoring, cloud services, and documentation systems.
To avoid the most common configuration errors, see the common errors with commands and plugins guide which covers MCP connection issues.
Always verify the source of an MCP server before installation. An unverified plugin could access your files and environment variables. The Anthropic marketplace centralizes audited and certified MCP servers.
The advanced best practices for Claude Code detail recommended MCP configurations for enterprise use, including access compartmentalization.
Key takeaway: MCP is the plugin protocol for Claude Code - over 200 community servers exist, and you can create your own in TypeScript or Python.
How to automate deterministic actions with hooks?
A hook is a shell script triggered automatically by Claude Code during specific events. Unlike skills that influence AI behavior and manually invoked commands, hooks execute deterministic code on every occurrence of an event.
Configure your hooks in .claude/settings.json:
{
"hooks": {
"pre-tool-use": [
{
"matcher": "Edit",
"command": "echo 'Modification: $CLAUDE_FILE_PATH'"
}
],
"post-tool-use": [
{
"matcher": "Bash",
"command": "npm run lint --fix"
}
]
}
}
Four event types are available in Claude Code:
pre-tool-use: triggers before tool executionpost-tool-use: triggers after tool executionnotification: triggers on system messagesstop: triggers at the end of a Claude Code session
The average execution time of a hook is 200 ms. Each hook receives contextual environment variables such as $CLAUDE_FILE_PATH and $CLAUDE_TOOL_NAME.
Here is how a post-tool-use hook on the Edit tool automatically runs ESLint (v9.x) after each file modification. This approach ensures the code complies with your rules without manual intervention.
| Event | Trigger | Typical use case |
|---|---|---|
pre-tool-use | Before each tool | Validation, logging, blocking |
post-tool-use | After each tool | Linting, formatting, tests |
notification | System message | Slack alerts, journaling |
stop | End of session | Cleanup, session report |
For ready-to-use hook recipes, see the advanced configuration tips. Hooks guarantee deterministic execution: the script runs systematically, without depending on AI interpretation.
Key takeaway: hooks execute deterministic code on specific events - use them for automatic linting, logging, and mandatory validations.
Should you combine skills, hooks, and subagents for an optimal workflow?
The power of Claude Code lies in combining these mechanisms. Here is how to assemble them for a complete development workflow:
- Define your skills to teach your conventions at startup
- Create slash commands for your frequent actions
- Configure hooks for mandatory automatic checks
- Let subagents parallelize tasks involving multiple files
- Integrate MCP servers to connect your external tools
A typical enterprise workflow uses 5 to 8 skills, 10 to 15 custom commands, and 3 to 4 hooks. This configuration reduces development time by 40% according to SFEIR Institute internal measurements on React and Node.js 22 projects.
If you are getting started, begin with installing and first launching Claude Code, then follow the guide on your first conversations before configuring advanced commands.
To master these concepts in real-world conditions, the Claude Code training from SFEIR offers a full day of hands-on labs. You will create your own commands, skills, and hooks on a concrete project, and leave with a reusable configuration kit.
The AI-Augmented Developer 2-day training covers advanced subagent orchestration and MCP integration in production architectures. To go deeper into multi-agent workflows, the AI-Augmented Developer -- Advanced 1-day training details hook strategies for CI/CD and large-scale subagent coordination.
Key takeaway: combine skills (conventions), commands (actions), hooks (automation) and subagents (parallelization) for a workflow up to 40% faster.
How to debug and optimize your custom commands?
Debugging custom commands starts with verifying the file location and syntax. Check that your file is in .claude/commands/ with the .md extension.
See the FAQ dedicated to commands and skills for answers to the most frequent questions about loading issues.
Here are the most common errors you will encounter:
- File placed in
.claude/instead of.claude/commands/ - Incorrect extension (
.txtinstead of.md) $ARGUMENTSvariable misspelled in the prompt- Prompt exceeding 4,000 tokens (recommended limit: 2,000 tokens)
- Name conflict between project command and personal command
- Unescaped special characters in the prompt
Optimize your prompts by keeping them concise and structured. An effective command prompt contains between 100 and 500 words. Beyond that, split into multiple commands or use a complementary skill.
Concretely, launch Claude Code in verbose mode to diagnose loading issues:
claude --verbose
> /my-command
Verbose mode displays detected command files, loaded skills, and configured hooks. The average diagnosis time drops from 15 minutes to 2 minutes with this approach.
Key takeaway: check the location, extension, and size of your command files - verbose mode reduces diagnosis time by 85%.
Claude Code Training
Master Claude Code with our expert instructors. Practical, hands-on training directly applicable to your projects.
View program