command-guide
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseClaude Code Command Selection Guide
Claude Code 命令选择指南
This skill helps you choose the most appropriate command, agent, or skill for different scenarios.
该Skill可帮助你针对不同场景选择最合适的命令、Agent或Skill。
Quick Decision Flowchart
快速决策流程图
mermaid
graph TD
A[User Request] --> B{Request Type?}
B -->|New Feature| C[/plan]
B -->|Bug Fix| D[/tdd or build-error-resolver]
B -->|Code Review| E[/code-review or code-reviewer agent]
B -->|Testing| F[/e2e or tdd-guide agent]
B -->|Context Too Long| G[/compact]
B -->|Documentation| H[/docs or docs-lookup agent]
B -->|Looping Task| I[/loop]
B -->|Security Review| J[security-reviewer agent]
C --> K[planner agent]
D --> L{Build Failed?}
L -->|Yes| M[build-error-resolver]
L -->|No| N[tdd-guide]
E --> O[code-reviewer]
F --> P[e2e-runner]mermaid
graph TD
A[User Request] --> B{Request Type?}
B -->|New Feature| C[/plan]
B -->|Bug Fix| D[/tdd or build-error-resolver]
B -->|Code Review| E[/code-review or code-reviewer agent]
B -->|Testing| F[/e2e or tdd-guide agent]
B -->|Context Too Long| G[/compact]
B -->|Documentation| H[/docs or docs-lookup agent]
B -->|Looping Task| I[/loop]
B -->|Security Review| J[security-reviewer agent]
C --> K[planner agent]
D --> L{Build Failed?}
L -->|Yes| M[build-error-resolver]
L -->|No| N[tdd-guide]
E --> O[code-reviewer]
F --> P[e2e-runner]1. Built-in Slash Commands
1. 内置斜杠命令
Session Management Commands
会话管理命令
| Command | Use Case | Example |
|---|---|---|
| Context too long (>150K tokens), slow response, task phase transition | |
| Start fresh conversation, clear history | |
| Periodic task execution, automated looping work | |
| View help, learn commands | |
| Need faster response (Opus 4.6 only) | |
| Switch model | |
| 命令 | 适用场景 | 示例 |
|---|---|---|
| 上下文过长(>150K tokens)、响应缓慢、任务阶段切换 | |
| 开启全新对话、清除历史记录 | |
| 周期性任务执行、自动化循环工作 | |
| 查看帮助、了解命令 | |
| 需要更快响应(仅Opus 4.6支持) | |
| 切换模型 | |
Development Workflow Commands
开发工作流命令
| Command | Use Case | Activation Timing |
|---|---|---|
| Start new feature, architecture refactor, complex tasks | Enter Plan Mode |
| Write tests, TDD development workflow | When test guidance needed |
| E2E testing, critical user flow verification | When browser testing needed |
| Code quality review | After writing code |
| Build failure, type errors | When build fails |
| Extract patterns from session, learning | Before session ends |
| Create new skill from git history | When repeating patterns found |
| 命令 | 适用场景 | 触发时机 |
|---|---|---|
| 启动新功能、架构重构、复杂任务 | 进入规划模式 |
| 编写测试、TDD开发工作流 | 需要测试指导时 |
| 端到端测试、关键用户流程验证 | 需要浏览器测试时 |
| 代码质量评审 | 编写代码完成后 |
| 构建失败、类型错误 | 构建失败时 |
| 从会话中提取模式、学习总结 | 会话结束前 |
| 从Git历史创建新Skill | 发现重复模式时 |
Documentation & Query Commands
文档与查询命令
| Command | Use Case | Example |
|---|---|---|
| Update project documentation | |
| Update code maps | |
| Save memory to memory system | |
| View task list | |
| 命令 | 适用场景 | 示例 |
|---|---|---|
| 更新项目文档 | |
| 更新代码映射 | |
| 将记忆保存到记忆系统 | |
| 查看任务列表 | |
2. Agents Selection
2. Agent选择
Development Workflow Agents
开发工作流Agent
| Agent | Trigger Condition | Purpose |
|---|---|---|
| Complex feature request, architectural decision | Create implementation plan |
| System design, tech stack selection | Architecture analysis and decisions |
| New feature, bug fix | TDD workflow guidance |
| Invoke immediately after writing code | Code quality review |
| Handling auth, API, sensitive data | Security vulnerability detection |
| Agent | 触发条件 | 用途 |
|---|---|---|
| 复杂功能需求、架构决策 | 创建实现方案 |
| 系统设计、技术栈选择 | 架构分析与决策 |
| 新功能开发、Bug修复 | TDD工作流指导 |
| 编写代码完成后立即调用 | 代码质量评审 |
| 处理认证、API、敏感数据 | 安全漏洞检测 |
Problem Solving Agents
问题解决Agent
| Agent | Trigger Condition | Purpose |
|---|---|---|
| Invoke immediately when build fails | Fix build/type errors |
| Critical user flows, before PR | E2E test execution |
| Code maintenance, dead code cleanup | Dead code detection and cleanup |
| Update docs, codemaps | Documentation sync |
| Agent | 触发条件 | 用途 |
|---|---|---|
| 构建失败时立即调用 | 修复构建/类型错误 |
| 关键用户流程、PR提交前 | 端到端测试执行 |
| 代码维护、死代码清理 | 死代码检测与清理 |
| 更新文档、代码映射 | 文档同步 |
Research & Exploration Agents
研究与探索Agent
| Agent | Trigger Condition | Purpose |
|---|---|---|
| Codebase exploration, file finding | Quick codebase exploration |
| Complex multi-step tasks | General task handling |
| Query library/framework docs | Get latest API documentation |
| Agent | 触发条件 | 用途 |
|---|---|---|
| 代码库探索、文件查找 | 快速代码库探索 |
| 复杂多步骤任务 | 通用任务处理 |
| 查询库/框架文档 | 获取最新API文档 |
3. Skills Selection
3. Skill选择
Workflow Skills
工作流Skill
| Skill | Trigger Timing | Purpose |
|---|---|---|
| Developing new feature/fixing bug | Complete TDD workflow guidance |
| After feature completion, before PR | Comprehensive verification (build/test/lint/security) |
| Long session, context pressure | Guide when to manually |
| Skill | 触发时机 | 用途 |
|---|---|---|
| 开发新功能/修复Bug | 完整TDD工作流指导 |
| 功能完成后、PR提交前 | 全面验证(构建/测试/代码检查/安全) |
| 长会话、上下文压力大 | 指导何时手动调用/compact |
Architecture & Pattern Skills
架构与模式Skill
| Skill | Trigger Timing | Purpose |
|---|---|---|
| Frontend development | React/Next.js/Vue best practices |
| Backend development | API/service architecture patterns |
| API design | RESTful/API design standards |
| MCP server development | MCP configuration and patterns |
| Skill | 触发时机 | 用途 |
|---|---|---|
| 前端开发 | React/Next.js/Vue最佳实践 |
| 后端开发 | API/服务架构模式 |
| API设计 | RESTful/API设计标准 |
| MCP服务器开发 | MCP配置与模式 |
Testing Skills
测试Skill
| Skill | Trigger Timing | Purpose |
|---|---|---|
| E2E testing needs | Playwright test generation |
| Security review needs | OWASP Top 10 detection |
| Skill | 触发时机 | 用途 |
|---|---|---|
| 端到端测试需求 | Playwright测试生成 |
| 安全评审需求 | OWASP Top 10检测 |
Research Skills
研究Skill
| Skill | Trigger Timing | Purpose |
|---|---|---|
| Need deep research | Multi-round search and research |
| Need web search | Web content search |
| Query library docs | Context7 documentation query |
| Skill | 触发时机 | 用途 |
|---|---|---|
| 需要深度研究 | 多轮搜索与研究 |
| 需要网页搜索 | 网页内容搜索 |
| 查询库文档 | Context7文档查询 |
4. Scenario Decision Matrix
4. 场景决策矩阵
By Task Phase
按任务阶段划分
| Phase | Recommended Tool Combination | Reason |
|---|---|---|
| Requirements Analysis | | Plan first, explore later |
| Architecture Design | | Professional architecture guidance |
| Pre-Development | | Test first |
| During Development | Direct edit + quick iteration | Stay in flow |
| Post-Development | | Quality gate |
| Testing Phase | | Complete test coverage |
| Before PR | | Final verification |
| Build Failure | | Focused fix |
| 阶段 | 推荐工具组合 | 原因 |
|---|---|---|
| 需求分析 | | 先规划,再探索 |
| 架构设计 | | 专业架构指导 |
| 开发前准备 | | 先测试 |
| 开发中 | 直接编辑 + 快速迭代 | 保持流畅开发状态 |
| 开发后 | | 质量把关 |
| 测试阶段 | | 完整测试覆盖 |
| PR提交前 | | 最终验证 |
| 构建失败 | | 专注修复 |
By Problem Type
按问题类型划分
| Problem | Invoke Immediately | Note |
|---|---|---|
| Build failure | | Minimal changes, quick fix |
| Type error | | TypeScript specialist |
| Bug fix | | Write test then fix |
| Security vulnerability | | OWASP detection |
| Poor code quality | | Immediate review |
| Missing documentation | | Auto update |
| Dead code | | Safe cleanup |
| 问题 | 立即调用 | 说明 |
|---|---|---|
| 构建失败 | | 最小改动,快速修复 |
| 类型错误 | | TypeScript专家 |
| Bug修复 | | 先写测试再修复 |
| 安全漏洞 | | OWASP检测 |
| 代码质量差 | | 立即评审 |
| 文档缺失 | | 自动更新 |
| 死代码 | | 安全清理 |
By Development Type
按开发类型划分
| Development Type | Skills Combination |
|---|---|
| Frontend feature | |
| Backend API | |
| MCP server | |
| Database | |
| Security feature | |
| 开发类型 | Skill组合 |
|---|---|
| 前端功能 | |
| 后端API | |
| MCP服务器 | |
| 数据库 | |
| 安全功能 | |
5. Parallel Execution Strategy
5. 并行执行策略
Parallelizable Scenarios
可并行场景
Recommended: Launch multiple independent tasks simultaneously
Scenario: Preparing PR after code completion
- Agent 1: code-reviewer (code quality)
- Agent 2: security-reviewer (security review)
- Agent 3: e2e-runner (E2E tests)
Scenario: Large refactor analysis
- Agent 1: architect (architecture analysis)
- Agent 2: Explore (code exploration)
- Agent 3: refactor-cleaner (dead code detection)
推荐:同时启动多个独立任务
场景:代码完成后准备PR
- Agent 1: code-reviewer(代码质量)
- Agent 2: security-reviewer(安全评审)
- Agent 3: e2e-runner(端到端测试)
场景:大型重构分析
- Agent 1: architect(架构分析)
- Agent 2: Explore(代码探索)
- Agent 3: refactor-cleaner(死代码检测)
Sequential Execution Required
需顺序执行场景
Cannot parallelize: Dependencies exist
Scenario: Fixing build error
- Sequence: build-error-resolver -> test verification -> code-reviewer
Scenario: New feature development
- Sequence: planner -> tdd-guide (write tests) -> implementation -> code-reviewer
不可并行:存在依赖关系
场景:修复构建错误
- 顺序:build-error-resolver -> 测试验证 -> code-reviewer
场景:新功能开发
- 顺序:planner -> tdd-guide(编写测试)-> 实现 -> code-reviewer
6. Auto-Trigger Rules
6. 自动触发规则
Invoke Without User Request
无需用户请求自动调用
| Situation | Auto Action |
|---|---|
| Code written/modified | Immediately invoke |
| Build fails | Immediately invoke |
| Complex feature request | Immediately invoke |
| Handling auth/sensitive data | Immediately invoke |
| New feature/bug fix | Immediately invoke |
| Architectural decision | Immediately invoke |
| 场景 | 自动操作 |
|---|---|
| 代码编写/修改 | 立即调用 |
| 构建失败 | 立即调用 |
| 复杂功能需求 | 立即调用 |
| 处理认证/敏感数据 | 立即调用 |
| 新功能/Bug修复 | 立即调用 |
| 架构决策 | 立即调用 |
7. Context Management Timing
7. 上下文管理时机
| Indicator | Trigger |
|---|---|
| Token > 150K | Immediately compact |
| Slow response | Suggest compact |
| Task phase switch | Compact at boundary |
| Major milestone completed | Compact then continue |
| Debugging ends -> new task | Clear debug traces |
Best Practices:
- Compact after research, before implementation (preserve plan)
- Compact after milestone completion (clear intermediate state)
- Don't compact mid-implementation (lose variables/paths)
| 指标 | 触发/compact |
|---|---|
| Token数 > 150K | 立即压缩 |
| 响应缓慢 | 建议压缩 |
| 任务阶段切换 | 在阶段边界压缩 |
| 主要里程碑完成 | 压缩后继续 |
| 调试结束 -> 新任务 | 清除调试痕迹 |
最佳实践:
- 研究完成后、实现前压缩(保留规划内容)
- 里程碑完成后压缩(清除中间状态)
- 实现过程中不要压缩(丢失变量/路径)
8. Command Cheat Sheet
8. 命令速查表
Development Workflow:
/plan -> Enter planning mode (complex tasks)
/tdd -> TDD workflow
/e2e -> E2E testing
/code-review -> Code review
/build-fix -> Fix build
Session Management:
/compact -> Compact context
/clear -> Clear session
/loop -> Looping task
/fast -> Fast mode
Documentation & Memory:
/docs -> Update docs
/remember -> Save memory
/tasks -> View tasks
Help:
/help -> View all commandsDevelopment Workflow:
/plan -> Enter planning mode (complex tasks)
/tdd -> TDD workflow
/e2e -> E2E testing
/code-review -> Code review
/build-fix -> Fix build
Session Management:
/compact -> Compact context
/clear -> Clear session
/loop -> Looping task
/fast -> Fast mode
Documentation & Memory:
/docs -> Update docs
/remember -> Save memory
/tasks -> View tasks
Help:
/help -> View all commands9. Usage Examples
9. 使用示例
Example 1: New Feature Development
示例1:新功能开发
User: Add user authentication feature
Workflow:
- /plan -> planner agent creates plan
- tdd-guide -> write tests
- Implementation -> edit code
- code-reviewer -> code review
- security-reviewer -> security review (auth sensitive)
- e2e-runner -> E2E tests
- /compact -> compact after milestone completion
用户:添加用户认证功能
工作流:
- /plan -> planner Agent创建方案
- tdd-guide -> 编写测试
- 实现 -> 编辑代码
- code-reviewer -> 代码评审
- security-reviewer -> 安全评审(认证属于敏感内容)
- e2e-runner -> 端到端测试
- /compact -> 里程碑完成后压缩上下文
Example 2: Build Failure
示例2:构建失败
User: npm run build failed
Workflow:
- build-error-resolver -> analyze error, minimal fix
- Verify build success
- code-reviewer -> check fix quality
用户:npm run build失败
工作流:
- build-error-resolver -> 分析错误,最小化修复
- 验证构建成功
- code-reviewer -> 检查修复质量
Example 3: Code Refactoring
示例3:代码重构
User: Refactor authentication module
Workflow:
- architect -> architecture analysis
- planner -> implementation plan
- refactor-cleaner -> dead code detection
- tdd-guide -> ensure test coverage
- Implementation -> refactor code
- verification-loop -> comprehensive verification
Core Principles:
- Plan first, implement later - Use for complex tasks
/plan - Test first - Use for new features
tdd-guide - Review immediately after coding - Use when code complete
code-reviewer - Fix build immediately when failed - Use
build-error-resolver - Review sensitive code - Use for auth/API
security-reviewer - Verify comprehensively before PR - Use
verification-loop
用户:重构认证模块
工作流:
- architect -> 架构分析
- planner -> 实现方案
- refactor-cleaner -> 死代码检测
- tdd-guide -> 确保测试覆盖
- 实现 -> 重构代码
- verification-loop -> 全面验证
核心原则:
- 先规划,后实现 - 复杂任务使用/plan
- 先测试 - 新功能使用tdd-guide
- 编码完成后立即评审 - 代码完成时使用code-reviewer
- 构建失败立即修复 - 使用build-error-resolver
- 敏感代码评审 - 认证/API相关使用security-reviewer
- PR提交前全面验证 - 使用verification-loop