Claude Code Skills: Custom commands and capabilities that extend Claude Code beyond basic prompting, including slash commands, MCP integrations, and workflow automation.
You’ve learned to prompt Claude Code. Now learn to command it.
Skill 1: Custom Slash Commands
Create reusable commands for common operations.
Creating Commands
In your project’s .claude/commands/ directory:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<!-- .claude/commands/security-review.md -->
# /security-review
Review the current changes for security vulnerabilities.
Check for:
- IDOR vulnerabilities in data access
- Authentication bypass opportunities
- Input validation gaps
- SQL/NoSQL injection
- XSS in rendered content
- Hardcoded secrets
- Missing rate limiting on auth endpoints
Provide findings in this format:
- Severity: Critical/High/Medium/Low
- Location: file:line
- Issue: Description
- Fix: Recommended remediation
Now you can run /security-review anytime.
More Useful Commands
1
2
3
4
5
6
7
8
9
10
11
<!-- .claude/commands/add-tests.md -->
# /add-tests
Add comprehensive tests for the specified file or function.
Requirements:
- Use existing test patterns in the project
- Cover happy paths, error cases, edge cases
- Include type assertions where applicable
- Mock external dependencies
- Use descriptive test names
1
2
3
4
5
6
7
8
9
10
11
12
13
<!-- .claude/commands/document.md -->
# /document
Generate documentation for the specified code.
Include:
- Brief description
- Parameters with types
- Return value
- Usage examples
- Error cases
Format as TSDoc/JSDoc comments.
1
2
3
4
5
6
7
8
9
10
11
12
<!-- .claude/commands/refactor.md -->
# /refactor
Refactor the specified code following project patterns.
Guidelines:
- Break down large functions
- Extract repeated logic
- Improve naming
- Add types where missing
- Remove dead code
- Maintain existing behavior
Skill 2: MCP Servers
Model Context Protocol (MCP) lets Claude Code connect to external systems.
Using Built-in MCP Servers
Claude Code ships with MCP servers for common tools:
#!/bin/bash
# auto-fix-pr.sh# Get PR diffDIFF=$(gh pr diff $1)# Have Claude review and fixclaude --no-interactive "
Review this PR diff for issues and fix them:
$DIFFFocus on:
- Security vulnerabilities
- Type errors
- Missing error handling
Apply fixes directly to the files.
"# Commit fixesgit add -A
git commit -m "Auto-fix PR issues"git push
# .github/workflows/claude-review.ymlname:Claude Code Reviewon:pull_request:types:[opened, synchronize]jobs:review:runs-on:ubuntu-lateststeps:- uses:actions/checkout@v4- name:Install Claude Coderun:npm install -g @anthropic-ai/claude-code- name:Run Security Reviewenv:ANTHROPIC_API_KEY:${{ secrets.ANTHROPIC_API_KEY }}run:| claude --no-interactive "
Review the changes in this PR for security issues.
Output findings as GitHub PR comments.
" > review.md- name:Post Reviewuses:actions/github-script@v6with:script:| const fs = require('fs');
const review = fs.readFileSync('review.md', 'utf8');
github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: review
});
Chaining Operations
1
2
3
4
5
6
7
8
9
# Complex workflow: migrate database and update codeclaude --no-interactive "
Step 1: Read the current Prisma schema
Step 2: Create a migration for adding user preferences
Step 3: Update the User type to include preferences
Step 4: Add a getPreferences method to UserService
Step 5: Create tests for the new method
Step 6: Run the tests and fix any failures
"
<!-- .claude/commands/new-api.md -->
# /new-api <name>
Create a new API route using the api-route template.
1. Read .claude/templates/api-route/
2. Replace {{name}} with the provided name
3. Create app/api/{{name}}/route.ts
4. Create app/api/{{name}}/route.test.ts
5. Add the route to the API documentation
Skill 5: Context Management
Master how Claude Code manages context for better results.
Explicit Context Loading
1
2
3
4
5
6
Read and understand these files before we start:
- lib/auth.ts
- types/user.ts
- app/api/users/route.ts
I'll be adding user impersonation for admin users.
Context Checkpoints
For long sessions:
1
Save current context as "before-refactor".
Later:
1
2
Compare current state to "before-refactor" checkpoint.
What changed?
Focused Context
For large codebases:
1
2
3
4
5
6
Focus only on the payment module:
- lib/payments/
- app/api/payments/
- types/payment.ts
Ignore other parts of the codebase for this session.
Skill 6: Output Formatting
Control how Claude presents information.
Structured Output
1
2
3
4
List all API routes in this format:
| Route | Method | Auth Required | Description |
|-------|--------|---------------|-------------|
Code-Only Output
1
2
Generate the implementation. Output only the code,
no explanations. Use code blocks with filenames.
Diff Output
1
Show changes as git diff format so I can review before applying.
Skill 7: Error Recovery
When things go wrong:
Undo Operations
1
2
The last change broke the auth flow. Undo all changes
from the last operation and restore previous state.
Partial Application
1
2
Apply only the changes to lib/auth.ts from the last suggestion.
Skip the other file changes.
Debug Mode
1
2
The test is failing. Walk through the logic step by step
and explain what's happening at each stage.
FAQ
How do I learn which MCP servers are available?
Run claude mcp list for built-in servers. Community servers are on GitHub. You can build custom servers for any API you need.
Can I use Claude Code without the terminal?
Not directly. Claude Code is CLI-first. For IDE integration, use Cursor which uses Claude’s models but with a different interface.
How do I share custom commands with my team?
Commit the .claude/commands/ directory to your repo. Team members get your commands automatically when they clone the project.
What's the context limit for Claude Code?
Claude Code uses Claude 3.5 Sonnet with ~200K token context. For very large codebases, use focused context to stay within limits.
Conclusion
Key Takeaways
Custom slash commands create reusable operations
MCP servers connect Claude to external systems (GitHub, databases, APIs)
CLI automation enables CI/CD integration
Templates standardize code generation
Context management improves output for large projects