Claude Code Mastery
Complete skill for setting up, optimizing, and mastering Claude Code with a full development team of subagents.
Official Docs: https://code.claude.com/docs
⚡ Quick Check: Is Setup Complete?
Run this first:
CODEBLOCK0
If Claude Code is already installed, skip directly to the "Daily Use" section below.
🔧 FIRST-TIME SETUP (Skip if already installed)
Note to bot: Only follow this section if Claude Code is NOT installed. Check with the command above. Once setup is complete, this section can be ignored on future invocations.
Setup Scripts
Run these in order:
CODEBLOCK1
Configuration
Edit config.sh to customize:
- -
VALID_MODELS — Add models as Anthropic releases them - INLINECODE2 — Enable/disable in heartbeat (default: false)
- INLINECODE3 — Default to "starter" or "full"
Setup Gotchas
| Issue | Solution |
|---|
| "Command not found" | Add ~/.local/bin to PATH |
| Auth errors |
Run
./03-first-time-auth.sh |
| Slow startup | First run indexes codebase |
| Subagents not showing | Run
./04-install-subagents.sh |
Post-Setup: Add Heartbeat Task
After setup, add the maintenance task to your HEARTBEAT.md (see "Heartbeat Maintenance" in Daily Use section).
Setup complete! Continue to Daily Use section.
📘 DAILY USE (Always relevant)
This section covers ongoing usage - reference this for all coding tasks.
Dev Team Subagents
Subagents are installed to ~/.claude/agents/. Each has a "Learn More" section with curated links to deepen expertise.
Starter Pack (Default) — 3 Core Agents
Most users only need these:
| Agent | Model | Purpose |
|---|
| INLINECODE8 | Sonnet | Architecture, complex code, code review |
| INLINECODE9 |
Sonnet | Task breakdown, timelines, dependencies |
|
junior-dev |
Haiku | Quick fixes, simple tasks (fast & cheap) |
Install: ./04-install-subagents.sh (or --minimal)
Full Team (Optional) — All 10 Agents
For larger projects, install all 11 with --full-team:
| Agent | Model | Purpose |
|---|
| INLINECODE14 | Sonnet | Architecture, complex code, code review |
| INLINECODE15 |
Sonnet | Task breakdown, timelines, dependencies |
|
junior-dev |
Haiku | Quick fixes, simple tasks (fast & cheap) |
|
frontend-dev | Sonnet | React, UI, CSS, client-side |
|
backend-dev | Sonnet | APIs, databases, server-side |
|
ai-engineer | Sonnet | LLM apps, RAG, prompts, agents |
|
ml-engineer | Sonnet | ML models, training, MLOps |
|
data-scientist | Sonnet | SQL, analysis, statistics |
|
data-engineer | Sonnet | Pipelines, ETL, data infrastructure |
|
product-manager | Sonnet | Requirements, user stories, prioritization |
|
devops | Sonnet | CI/CD, Docker, K8s, infrastructure, automation |
Using Subagents
Interactive mode: Use the /agent slash command or natural language:
CODEBLOCK2
Non-interactive mode (-p): Use the --agent flag:
CODEBLOCK3
Note: Claude Code does NOT auto-delegate to subagents based on task type. You must explicitly specify which agent to use.
Multi-agent handoff: For tasks needing multiple specialists, use HANDOFF.md to pass context between agents. See docs/workflows.md for the full pattern.
Quick Reference
CLI Commands
CODEBLOCK4
Slash Commands
CODEBLOCK5
Keyboard Shortcuts
Shift+Tab - Toggle Plan mode (read-only exploration)
Ctrl+C - Cancel operation
Ctrl+B - Background task
Context Management (Critical!)
| Command | What it does | When to use |
|---|
| INLINECODE29 | Clear conversation, start fresh | Between unrelated tasks |
| INLINECODE30 |
Summarize and compress context | When context getting full |
|
Shift+Tab | Toggle Plan mode (read-only) | Exploration before implementing |
Best practices:
- 1.
/clear between unrelated tasks - Use Plan mode for exploration before implementing
- Subagents isolate verbose operations
- Create HANDOFF.md for session continuity
Project Configuration
settings.json
Create .claude/settings.json in your project:
CODEBLOCK7
CLAUDE.md
Create CLAUDE.md in your project root (Claude reads this automatically):
CODEBLOCK8
See examples/CLAUDE-template.md for a full template.
Claude-Mem (If Installed)
Check status:
CODEBLOCK9
Start if stopped:
CODEBLOCK10
Web UI: http://localhost:37777
Diagnostics & Troubleshooting
Quick diagnostics:
CODEBLOCK11
Full troubleshooting (if issues found):
CODEBLOCK12
Common issues guide: See docs/troubleshooting.md for solutions to:
- - Authentication problems (API key, OAuth, logout bugs)
- Installation issues (PATH, WSL, Node.js version)
- Network errors (firewalls, VPNs, proxies)
- Performance problems (high CPU, hangs, slow search)
Heartbeat Maintenance
Add to your HEARTBEAT.md for automatic maintenance:
CODEBLOCK13
Why this matters:
- - Skill improves over time through actual use
- Links stay current (broken ones get fixed)
- Best practices evolve with the ecosystem
- Each Clawdbot contributes back to the skill
Scripts Reference
| Script | Purpose | When to use |
|---|
| INLINECODE37 | Health check and status report | When issues occur |
| INLINECODE38 |
Generate improvement report | Weekly (Sunday) |
|
08-troubleshoot.sh | Comprehensive troubleshooting | When 06 finds issues |
Summary
For coding tasks:
- 1. Use appropriate subagent for the task
- Manage context with
/clear and Plan mode - Run diagnostics if something breaks
Heartbeat handles:
- - claude-mem health checks
- Daily quick diagnostics
- Weekly improvement research
The dev team subagents turn Claude Code into a full development organization.
Claude Code 精通技能
使用完整的子代理开发团队设置、优化和精通Claude Code的完整技能。
官方文档: https://code.claude.com/docs
⚡ 快速检查:设置是否完成?
首先运行:
bash
command -v claude >/dev/null && echo ✅ Claude Code 已安装 - 跳至日常使用部分 || echo ❌ 未安装 - 请按照下方首次设置操作
如果Claude Code已安装,直接跳至下方的日常使用部分。
🔧 首次设置(如已安装请跳过)
给机器人的提示: 仅在Claude Code未安装时执行此部分。使用上述命令检查。设置完成后,后续调用可忽略此部分。
设置脚本
按顺序运行:
bash
cd ~/clawd/skills/claude-code-mastery/scripts
1. 检查依赖
./01-check-dependencies.sh
2. 安装Claude Code
./02-install-claude-code.sh
3. 身份验证
./03-first-time-auth.sh
4. 安装开发团队子代理
./04-install-subagents.sh # 入门包(3个代理)- 推荐
./04-install-subagents.sh --full-team # 全部11个代理
5. (可选)持久化记忆 - 提示y/N,默认为否
./05-setup-claude-mem.sh # 交互式提示
./05-setup-claude-mem.sh --skip # 完全跳过
./05-setup-claude-mem.sh --yes # 直接安装,无需提示
配置
编辑 config.sh 以自定义:
- - VALIDMODELS — 随着Anthropic发布新模型进行添加
- HEARTBEATDIAGNOSTICS — 启用/禁用心跳诊断(默认:false)
- INSTALL_MODE — 默认为starter或full
设置常见问题
| 问题 | 解决方案 |
|---|
| 命令未找到 | 将 ~/.local/bin 添加到PATH |
| 认证错误 |
运行 ./03-first-time-auth.sh |
| 启动缓慢 | 首次运行会索引代码库 |
| 子代理未显示 | 运行 ./04-install-subagents.sh |
设置后:添加心跳任务
设置完成后,将维护任务添加到您的HEARTBEAT.md中(参见日常使用部分中的心跳维护)。
设置完成!继续查看日常使用部分。
📘 日常使用(始终相关)
此部分涵盖持续使用 - 所有编码任务请参考此部分。
开发团队子代理
子代理安装到 ~/.claude/agents/。每个代理都有了解更多部分,包含精选链接以深化专业知识。
入门包(默认)— 3个核心代理
大多数用户只需要这些:
| 代理 | 模型 | 用途 |
|---|
| senior-dev | Sonnet | 架构、复杂代码、代码审查 |
| project-manager |
Sonnet | 任务分解、时间线、依赖关系 |
| junior-dev |
Haiku | 快速修复、简单任务(快速且便宜) |
安装:./04-install-subagents.sh(或 --minimal)
完整团队(可选)— 全部10个代理
对于大型项目,使用 --full-team 安装全部11个:
| 代理 | 模型 | 用途 |
|---|
| senior-dev | Sonnet | 架构、复杂代码、代码审查 |
| project-manager |
Sonnet | 任务分解、时间线、依赖关系 |
| junior-dev |
Haiku | 快速修复、简单任务(快速且便宜) |
| frontend-dev | Sonnet | React、UI、CSS、客户端 |
| backend-dev | Sonnet | API、数据库、服务端 |
| ai-engineer | Sonnet | LLM应用、RAG、提示词、代理 |
| ml-engineer | Sonnet | 机器学习模型、训练、MLOps |
| data-scientist | Sonnet | SQL、分析、统计 |
| data-engineer | Sonnet | 管道、ETL、数据基础设施 |
| product-manager | Sonnet | 需求、用户故事、优先级排序 |
| devops | Sonnet | CI/CD、Docker、K8s、基础设施、自动化 |
使用子代理
交互模式: 使用 /agent 斜杠命令或自然语言:
/agent senior-dev
使用senior-dev代理审查这段代码
非交互模式(-p): 使用 --agent 标志:
bash
claude --agent senior-dev -p 审查这段代码是否存在安全问题
claude --agent project-manager -p 为认证功能创建任务分解
claude --agent junior-dev -p 修复README.md中的拼写错误
注意: Claude Code不会根据任务类型自动委派给子代理。您必须明确指定使用哪个代理。
多代理交接: 对于需要多个专家的任务,使用HANDOFF.md在代理之间传递上下文。完整模式请参见 docs/workflows.md。
快速参考
CLI命令
bash
claude # 启动交互模式
claude -c # 继续之前的会话
claude -p 提示词 # 非交互模式
斜杠命令
/agents - 管理子代理
/clear - 清除对话(在任务之间使用!)
/compact - 压缩上下文
/model - 更改模型
/help - 所有命令
键盘快捷键
Shift+Tab - 切换计划模式(只读探索)
Ctrl+C - 取消操作
Ctrl+B - 后台任务
上下文管理(关键!)
| 命令 | 作用 | 使用时机 |
|---|
| /clear | 清除对话,重新开始 | 在不同任务之间 |
| /compact |
总结并压缩上下文 | 上下文快满时 |
| Shift+Tab | 切换计划模式(只读) | 实施前进行探索 |
最佳实践:
- 1. 在不同任务之间使用 /clear
- 实施前使用计划模式进行探索
- 子代理隔离冗长操作
- 创建HANDOFF.md以保持会话连续性
项目配置
settings.json
在项目中创建 .claude/settings.json:
json
{
model: sonnet,
permissions: {
allow: [Bash(npm:), Bash(git:), Read, Write, Edit],
deny: [Bash(rm -rf:), Bash(sudo:)]
}
}
CLAUDE.md
在项目根目录创建 CLAUDE.md(Claude会自动读取):
markdown
项目:MyApp
技术栈
- - 前端:React, TypeScript, Tailwind
- 后端:Node.js, PostgreSQL
命令
- - npm run dev - 启动开发服务器
- npm test - 运行测试
完整模板请参见 examples/CLAUDE-template.md。
Claude-Mem(如已安装)
检查状态:
bash
pgrep -f worker-service >/dev/null && echo 运行中 || echo 已停止
如果已停止则启动:
bash
cd ~/.claude/plugins/marketplaces/thedotmack && bun plugin/scripts/worker-service.cjs start
Web界面:http://localhost:37777
诊断与故障排除
快速诊断:
bash
~/clawd/skills/claude-code-mastery/scripts/06-diagnostics.sh
完整故障排除(如发现问题):
bash
~/clawd/skills/claude-code-mastery/scripts/08-troubleshoot.sh
常见问题指南: 参见 docs/troubleshooting.md 获取以下问题的解决方案:
- - 认证问题(API密钥、OAuth、登出错误)
- 安装问题(PATH、WSL、Node.js版本)
- 网络错误(防火墙、VPN、代理)
- 性能问题(高CPU、卡顿、搜索缓慢)
心跳维护
添加到您的HEARTBEAT.md以实现自动维护:
markdown
Claude Code 维护
上次健康检查: [时间戳]
上次学习会话: [时间戳]
每次心跳(如果编码任务活跃):
- 1. 快速检查claude-mem(如已安装):
pgrep -f worker-service >/dev/null && echo 运行中 || echo 已停止