generate_command
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCreate a Custom Claude Code Command
创建自定义Claude Code命令
Create a new slash command in for the requested task.
.claude/commands/在目录下为需求任务创建新的斜杠命令。
.claude/commands/Goal
目标
#$ARGUMENTS
#$ARGUMENTS
Key Capabilities to Leverage
可利用的核心能力
File Operations:
- Read, Edit, Write - modify files precisely
- Glob, Grep - search codebase
- MultiEdit - atomic multi-part changes
Development:
- Bash - run commands (git, tests, linters)
- Task - launch specialized agents for complex tasks
- TodoWrite - track progress with todo lists
Web & APIs:
- WebFetch, WebSearch - research documentation
- GitHub (gh cli) - PRs, issues, reviews
- Playwright - browser automation, screenshots
Integrations:
- AppSignal - logs and monitoring
- Context7 - framework docs
- Stripe, Todoist, Featurebase (if relevant)
文件操作:
- 读取、编辑、写入 - 精准修改文件
- Glob、Grep - 搜索代码库
- MultiEdit - 原子化多部分变更
开发:
- Bash - 运行命令(git、测试、lint检查工具)
- Task - 为复杂任务启动专用Agent
- TodoWrite - 用待办列表跟踪进度
Web与API:
- WebFetch、WebSearch - 查阅文档
- GitHub (gh cli) - 处理PR、issue、评审
- Playwright - 浏览器自动化、截图
集成能力:
- AppSignal - 日志与监控
- Context7 - 框架文档
- Stripe、Todoist、Featurebase(如适用)
Best Practices
最佳实践
- Be specific and clear - detailed instructions yield better results
- Break down complex tasks - use step-by-step plans
- Use examples - reference existing code patterns
- Include success criteria - tests pass, linting clean, etc.
- Think first - use "think hard" or "plan" keywords for complex problems
- Iterate - guide the process step by step
- 明确具体 - 详细的指令能得到更好的结果
- 拆解复杂任务 - 使用分步执行计划
- 使用示例 - 参考现有代码模式
- 包含成功标准 - 测试通过、lint检查无问题等
- 先思考 - 复杂问题使用"think hard"或"plan"关键词
- 迭代推进 - 逐步引导流程
Required: YAML Frontmatter
必填项:YAML 前置元数据
EVERY command MUST start with YAML frontmatter:
yaml
---
name: command-name
description: Brief description of what this command does (max 100 chars)
argument-hint: "[what arguments the command accepts]"
---Fields:
- : Lowercase command identifier (used internally)
name - : Clear, concise summary of command purpose
description - : Shows user what arguments are expected (e.g.,
argument-hint,[file path],[PR number])[optional: format]
所有命令必须以YAML前置元数据开头:
yaml
---
name: command-name
description: Brief description of what this command does (max 100 chars)
argument-hint: "[what arguments the command accepts]"
---字段说明:
- :小写命令标识符(内部使用)
name - :清晰简洁的命令用途概述
description - :向用户展示预期接收的参数(例如
argument-hint、[文件路径]、[PR编号])[可选:格式]
Structure Your Command
命令结构
markdown
undefinedmarkdown
undefined[Command Name]
[Command Name]
[Brief description of what this command does]
[Brief description of what this command does]
Steps
Steps
-
[First step with specific details]
- Include file paths, patterns, or constraints
- Reference existing code if applicable
-
[Second step]
- Use parallel tool calls when possible
- Check/verify results
-
[Final steps]
- Run tests
- Lint code
- Commit changes (if appropriate)
-
[First step with specific details]
- Include file paths, patterns, or constraints
- Reference existing code if applicable
-
[Second step]
- Use parallel tool calls when possible
- Check/verify results
-
[Final steps]
- Run tests
- Lint code
- Commit changes (if appropriate)
Success Criteria
Success Criteria
- Tests pass
- Code follows style guide
- Documentation updated (if needed)
undefined- Tests pass
- Code follows style guide
- Documentation updated (if needed)
undefinedTips for Effective Commands
高效命令编写技巧
- Use $ARGUMENTS placeholder for dynamic inputs
- Reference CLAUDE.md patterns and conventions
- Include verification steps - tests, linting, visual checks
- Be explicit about constraints - don't modify X, use pattern Y
- Use XML tags for structured prompts: ,
<task>,<requirements><constraints>
- 动态输入使用占位符
$ARGUMENTS - 参考CLAUDE.md的模式和规范
- 包含验证步骤 - 测试、lint检查、可视化校验
- 明确约束条件 - 不修改X内容、使用Y模式等
- 结构化提示词使用XML标签:、
<task>、<requirements><constraints>
Example Pattern
示例模式
markdown
Implement #$ARGUMENTS following these steps:
1. Research existing patterns
- Search for similar code using Grep
- Read relevant files to understand approach
2. Plan the implementation
- Think through edge cases and requirements
- Consider test cases needed
3. Implement
- Follow existing code patterns (reference specific files)
- Write tests first if doing TDD
- Ensure code follows CLAUDE.md conventions
4. Verify
- Run tests: `bin/rails test`
- Run linter: `bundle exec standardrb`
- Check changes with git diff
5. Commit (optional)
- Stage changes
- Write clear commit messagemarkdown
Implement #$ARGUMENTS following these steps:
1. Research existing patterns
- Search for similar code using Grep
- Read relevant files to understand approach
2. Plan the implementation
- Think through edge cases and requirements
- Consider test cases needed
3. Implement
- Follow existing code patterns (reference specific files)
- Write tests first if doing TDD
- Ensure code follows CLAUDE.md conventions
4. Verify
- Run tests: `bin/rails test`
- Run linter: `bundle exec standardrb`
- Check changes with git diff
5. Commit (optional)
- Stage changes
- Write clear commit messageCreating the Command File
创建命令文件
- Create the file at (subdirectories like
.claude/commands/[name].mdsupported)workflows/ - Start with YAML frontmatter (see section above)
- Structure the command using the template above
- Test the command by using it with appropriate arguments
- 在路径下创建文件(支持
.claude/commands/[名称].md等子目录)workflows/ - 以YAML前置元数据开头(参考上文章节)
- 使用上述模板组织命令结构
- 传入合适的参数测试命令
Command File Template
命令文件模板
markdown
---
name: command-name
description: What this command does
argument-hint: "[expected arguments]"
---markdown
---
name: command-name
description: What this command does
argument-hint: "[expected arguments]"
---Command Title
Command Title
Brief introduction of what the command does and when to use it.
Brief introduction of what the command does and when to use it.
Workflow
Workflow
Step 1: [First Major Step]
Step 1: [First Major Step]
Details about what to do.
Details about what to do.
Step 2: [Second Major Step]
Step 2: [Second Major Step]
Details about what to do.
Details about what to do.
Success Criteria
Success Criteria
- Expected outcome 1
- Expected outcome 2
undefined- Expected outcome 1
- Expected outcome 2
undefined