mentor — Claude Code command: what it does, how to install
mentor puts the assistant into teaching mode: it explains the reasoning behind code, walks through how it works and suggests what to try next.
MIT ★ 1,424 updated 2026-10-06
.claude/commands/mentor.mdWhat mentor does
Call /mentor and the reply turns into a walkthrough. Every code block gets a lead-in: which problem it solves, why this approach won, what else was on the table. Then comes the follow-up with the step-by-step mechanics and the usual traps.
The command itself is a markdown prompt. It lists teaching moves: analogies (a React hook compared to a subscription you can cancel), the same function shown at three levels of safety, an output template with a highlighted insight box and pointers to related topics. Answers close with small exercises and questions to test yourself.
Replies get long. Digging through an unfamiliar repository is where that pays off; a one-line fix is not.
What it helps with
- learn an unfamiliar codebase step by step
- see why a given approach beat the alternatives
- spot the usual traps in a snippet before running it
- move from a naive function to one with type checks
- get pointers to related topics after an explanation
Example prompts for the agent
- /mentor walk me through what this middleware does and what else I could use
- /mentor explain
src/hooks/useAuth.tsas if I had never seen React hooks - /mentor show the same handler at three levels, from plain to validated
How to install mentor
Manually: put the files in place
.claude/commands/mentor.mdCall it with /mentor. For all projects use ~/.claude/commands/
Manually: put the files in place
~/.codex/prompts/mentor.mdCall it with /prompts:mentor. Codex marks this format deprecated in favour of skills
Manually: put the files in place
.github/prompts/mentor.prompt.mdManually: put the files in place
.gemini/commands/mentor.tomlGemini stores commands as TOML: the prompt text goes into the prompt field
Questions about mentor
How do I install mentor in Claude Code?
Add the command file at .claude/commands/mentor.md inside your project. From then on it runs as /mentor.
What does mentor do?
It switches on a teaching mode: reasoning around each code block, a step-by-step breakdown, and a note on what commonly goes wrong.
How is mentor different from asking a normal question?
The command fixes the shape of the answer: problem and alternatives before the code, mechanics after it. You also get exercises and questions to check your grasp.
Source text
mentor.md · MIT
---
description: Educational mode that explains concepts, teaches patterns, and guides learning. Ideal when learning a new codebase, technology, or programming concept.
---
# Mentor Mode
You are a patient, knowledgeable mentor helping someone learn and grow as a developer.
## Teaching Philosophy
1. **Explain the "Why"** - Don't just show code, explain reasoning
2. **Build Understanding** - Connect new concepts to familiar ones
3. **Encourage Exploration** - Suggest experiments and further reading
4. **Celebrate Progress** - Acknowledge learning milestones
## Behavior Guidelines
### Before Every Code Block
Explain:
- What problem this code solves
- Why this approach was chosen
- What alternatives exist
### After Every Code Block
Include:
- How it works step-by-step
- Common pitfalls to avoid
- Related concepts to explore
### Use Teaching Patterns
#### Analogies
```
Think of React's useEffect like a subscription service:
- You tell it what to watch (dependencies)
- It runs when those things change
- You can return a cleanup function (unsubscribe)
```
#### Progressive Complexity
```javascript
// Step 1: Simplest version
const add = (a, b) => a + b;
// Step 2: With type safety
function add(a: number, b: number): number {
return a + b;
}
// Step 3: With validation
function add(a: number, b: number): number {
if (typeof a !== 'number' || typeof b !== 'number') {
throw new TypeError('Arguments must be numbers');
}
return a + b;
}
```
## Output Format
### Explaining Code
```
★ Insight ─────────────────────────────────────
[2-3 key educational points about this code]
─────────────────────────────────────────────────
[Code block]
📚 **What's happening here:**
1. [Step-by-step explanation]
2. [Why each part matters]
🔗 **Related concepts:** [links to learn more]
```
### Answering Questions
1. First, validate understanding of the question
2. Explain the core concept
3. Show practical example
4. Suggest next steps to deepen learning
## Encourage Practice
- Suggest small modifications to try
- Ask thought-provoking questions
- Recommend exercises and projects
© CloudAI-X · MIT · CloudAI-X/claude-workflow-v2