If you’ve been following along from Part 1, you know how to run Claude Code and execute basic workflows. But here’s where things get really interesting: slash commands and memory are the features that transform Claude Code from a useful tool into your personal AI copilot.
Think of slash commands as your custom shortcuts—quick invocations that trigger Claude with context-specific instructions. And memory? That’s how you teach Claude about your project, your coding style, and your preferences so it remembers them across every session. Together, they create a workflow tailored entirely to you.
Let me walk you through both, using real examples I’ve built in my own projects.
Slash Commands: Custom Shortcuts at Your Fingertips
What Are Slash Commands?
Slash commands are user-defined shortcuts you invoke with a forward slash—like /optimize or /pr—that trigger Claude Code with predefined instructions. They’re stored as Markdown files in your .claude/commands/ directory.
When you type a slash command, Claude Code loads the corresponding .md file, which contains:
- A description of what the command does
- The prompt instructions Claude should follow
- Optional template variables you can pass in
This is fundamentally different from running general prompts. You’re bundling expertise into reusable packages.
Creating Your First Command: /optimize
Let’s say you’re constantly reviewing code for performance improvements. Instead of explaining the optimization task every time, you can create an /optimize command once and use it everywhere.
Here’s how:
Step 1: Create the command file
mkdir -p .claude/commands
touch .claude/commands/optimize.md
Step 2: Write the command with a clear prompt
# Optimize Code Performance
Analyze the provided code for performance improvements. Focus on:
- Time complexity issues
- Unnecessary allocations or loops
- Caching opportunities
- Algorithm optimization
Provide:
1. Specific bottlenecks you identified
2. Concrete improvements with code examples
3. Performance impact (e.g., "reduces from O(n²) to O(n log n)")
4. Risk assessment (is this change safe? do we need tests?)
Keep the tone technical but clear for other developers to understand.
Step 3: Use it in Claude Code
claude code /optimize
# Claude now runs with your optimization instructions
You can also pass context:
claude code /optimize src/utils/sorting.js
Claude Code will read your sorting utility, understand it should optimize it, and deliver analysis without you explaining the task each time.
Practical Examples for Your Workflow
Here are commands I’ve created that I use weekly:
Pull Request Descriptions (/pr)
# Generate PR Description
Analyze the git diff and create a clear PR description. Include:
## What Changed
Brief summary of the changes (2-3 sentences).
## Why
Explain the motivation. Is this a bug fix? Feature? Refactor?
## Testing
What tests should reviewers run? Any manual QA steps?
## Checklist
- Tests pass
- No console errors
- Documentation updated (if applicable)
Code Review Feedback (/review)
# Code Review
Review the provided code for:
1. Correctness - will this work as intended?
2. Readability - is it clear to other developers?
3. Performance - any red flags?
4. Security - any vulnerabilities?
5. Maintainability - will this be easy to modify later?
Format feedback as:
- **Issue**: What's the problem?
- **Impact**: Why does it matter?
- **Suggestion**: How would you fix it?
Be constructive. Assume good intent.
Generate API Docs (/generate-api-docs)
# Generate API Documentation
Create comprehensive API documentation for the provided code. Include:
## Overview
What does this API do?
## Methods
For each public method:
- Full signature
- Parameters with types
- Return value
- Example usage
## Errors
What exceptions can this raise?
## Examples
Provide 2-3 realistic usage examples.
Use clear, professional language. Target developers who haven't seen this code.
Tips for Effective Commands
Keep them focused. A command should handle one specific task. Don’t try to make /review do code review, optimization, security checks, and documentation. Separate concerns.
Use template variables. If your command needs specific filenames or parameters, you can include them:
# Optimize {{filename}}
Review {{filename}} for performance bottlenecks...
Then invoke: claude code /optimize src/utils/sorting.js
Version your commands. As you refine what works, update your commands. Your future self will thank you for commands that get better over time.
Document the intent, not just the task. Include context about why the command exists: “This is for initial code reviews where speed matters—be thorough but concise.”
Memory: Teaching Claude About Your Project
Slash commands are about how you work. Memory is about what Claude needs to know—your coding standards, your architecture, your preferences.
Three Levels of Memory
Claude Code supports three memory scopes:
1. Project Memory (./CLAUDE.md)
Lives in your project root. This is shared context for everyone on the team.
# ZenoLab Frontend Standards
## Architecture
We use Next.js with:
- App Router (not Pages Router)
- Server Components by default
- Client Components only when needed
- TailwindCSS for styling
## Code Style
- TypeScript strict mode required
- Prefer `const` over `let`
- No `var`
- Named exports, not defaults
## Testing
- Jest + React Testing Library
- Aim for 80%+ coverage
- Test user behavior, not implementation details
## Preferred Libraries
- React Query for data fetching
- Zustand for state (not Redux)
- next/link for navigation
## Common Gotchas
- Don't forget `use client` when creating interactive components
- Server Components can't use hooks
When Claude Code runs in your project, it automatically loads this. Now Claude understands your tech stack, your standards, and your preferences without you explaining it every time.
2. Directory Memory (./api/CLAUDE.md)
Specific to a subdirectory. Useful for modules with distinct conventions.
# API Module Standards
## Structure
api/ routes/ middleware/ controllers/ services/ types/
## Patterns
- All routes should go through middleware chain
- Controllers handle request validation
- Services handle business logic
- Keep routes thin
## Error Handling
Always return consistent error format:
```json
{
"error": "error_code",
"message": "Human readable message",
"status": 400
}
**3. Personal Memory (`~/.claude/CLAUDE.md`)**
Your personal preferences, across all projects. This lives in your home directory.
```markdown
# My AI Assistant Configuration
## Writing Style
- Conversational, not robotic
- Use "we" when collaborating
- Concise—get to the point fast
- Use metaphors when explaining complex concepts
## Code Style Preferences
- I prefer functional programming patterns
- Favor readability over cleverness
- Comments should explain *why*, not *what*
## Common Patterns I Use
- Custom React hooks for logic extraction
- Repository pattern for data access
- Feature flags for releases
## Don't Do This
- Never suggest I use frameworks I haven't approved
- Don't generate boilerplate without asking
- Don't create files without confirmation
How Memory Gets Loaded
Claude Code automatically searches for memory files when you run it:
- Personal memory (
~/.claude/CLAUDE.md) - Project memory (
./CLAUDE.md) - Directory memory (current directory and parents)
All three get merged and provided as context to Claude. This happens silently—you just invoke the command and Claude has access to everything.
What Makes This Powerful
Imagine you’re pairing on a new project. Instead of spending 30 minutes explaining your architecture, you point Claude Code at your CLAUDE.md:
“Here’s our project memory. Now when I ask you to build a new API endpoint, you’ll understand where it goes, how it integrates, what patterns we use, and what we’re avoiding.”
Better yet: it works across sessions. You write memory once. Every future conversation has it automatically.
For indie developers especially, this is a game-changer. You can build increasingly sophisticated internal mental models—how your codebase is organized, your preferred patterns, your quality standards—and have them available instantly when you need to move fast.
The Memory + Slash Command Combo
Here’s where it gets really powerful. Your slash commands can reference your memory:
# Optimize Code Performance
Consider these architectural patterns from our project memory:
- We prefer functional patterns
- We avoid premature optimization
- Performance should be measurable, not theoretical
[rest of command...]
Now your /optimize command respects your philosophy. You’re not just automating the task—you’re automating the task your way.
Next: Skills & Subagents
We’ve covered slash commands and memory—the personalization layer of Claude Code. Next in Part 3, we’ll explore skills and subagents: how to build reusable workflows that operate autonomously and can collaborate with each other.
Subagents are where things get really exciting. Imagine spawning a code review agent, a test-writing agent, and a documentation agent, and having them work together on your PR. That’s what’s coming.
Have you built any slash commands? Drop by my email or ping me on Twitter if you’ve found patterns that work well. I’m always curious what workflows others have discovered.