create-command

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Create New Slash Command

创建新的Slash命令

Create a new slash command in both
.cursor/commands/
(with
trellis-
prefix) and
.claude/commands/trellis/
directories based on user requirements.
根据用户需求,在
.cursor/commands/
(带有
trellis-
前缀)和
.claude/commands/trellis/
两个目录中创建新的slash命令。

Usage

使用方法

/trellis:create-command <command-name> <description>
Example:
/trellis:create-command review-pr Check PR code changes against project guidelines
/trellis:create-command <command-name> <description>
示例:
/trellis:create-command review-pr Check PR code changes against project guidelines

Execution Steps

执行步骤

1. Parse Input

1. 解析输入

Extract from user input:
  • Command name: Use kebab-case (e.g.,
    review-pr
    )
  • Description: What the command should accomplish
从用户输入中提取:
  • 命令名称:使用kebab-case格式(例如:
    review-pr
  • 描述:该命令需要完成的操作

2. Analyze Requirements

2. 分析需求

Determine command type based on description:
  • Initialization: Read docs, establish context
  • Pre-development: Read guidelines, check dependencies
  • Code check: Validate code quality and guideline compliance
  • Recording: Record progress, questions, structure changes
  • Generation: Generate docs, code templates
根据描述确定命令类型:
  • 初始化类:读取文档,建立上下文
  • 预开发类:读取规范,检查依赖
  • 代码检查类:验证代码质量和规范合规性
  • 记录类:记录进度、问题、结构变更
  • 生成类:生成文档、代码模板

3. Generate Command Content

3. 生成命令内容

Based on command type, generate appropriate content:
Simple command (1-3 lines):
markdown
Concise instruction describing what to do
Complex command (with steps):
markdown
undefined
根据命令类型生成对应的内容:
简单命令(1-3行):
markdown
描述操作内容的简洁指令
复杂命令(包含步骤):
markdown
undefined

Command Title

命令标题

Command description
命令描述

Steps

步骤

1. First Step

1. 第一步

Specific action
具体操作

2. Second Step

2. 第二步

Specific action
具体操作

Output Format (if needed)

输出格式(如有需要)

Template
undefined
模板
undefined

4. Create Files

4. 创建文件

Create in both directories:
  • .cursor/commands/trellis-<command-name>.md
  • .claude/commands/trellis/<command-name>.md
在两个目录中创建文件:
  • .cursor/commands/trellis-<command-name>.md
  • .claude/commands/trellis/<command-name>.md

5. Confirm Creation

5. 确认创建

Output result:
[OK] Created Slash Command: /<command-name>

File paths:
- .cursor/commands/trellis-<command-name>.md
- .claude/commands/trellis/<command-name>.md

Usage:
/trellis:<command-name>

Description:
<description>
输出结果:
[OK] 已创建Slash命令: /<command-name>

文件路径:
- .cursor/commands/trellis-<command-name>.md
- .claude/commands/trellis/<command-name>.md

使用方法:
/trellis:<command-name>

描述:
<description>

Command Content Guidelines

命令内容规范

[OK] Good command content

[√] 优质命令内容

  1. Clear and concise: Immediately understandable
  2. Executable: AI can follow steps directly
  3. Well-scoped: Clear boundaries of what to do and not do
  4. Has output: Specifies expected output format (if needed)
  1. 清晰简洁:一目了然
  2. 可执行:AI可直接遵循步骤操作
  3. 范围明确:清晰界定操作边界
  4. 有输出:指定预期输出格式(如有需要)

[X] Avoid

[×] 需避免的情况

  1. Too vague: e.g., "optimize code"
  2. Too complex: Single command should not exceed 100 lines
  3. Duplicate functionality: Check if similar command exists first
  1. 过于模糊:例如:"优化代码"
  2. 过于复杂:单个命令内容不应超过100行
  3. 功能重复:先检查是否存在类似命令

Naming Conventions

命名规范

Command TypePrefixExample
Session Start
start
start
Pre-development
before-
before-frontend-dev
Check
check-
check-frontend
Record
record-
record-session
Generate
generate-
generate-api-doc
Update
update-
update-changelog
OtherVerb-first
review-code
,
sync-data
命令类型前缀示例
会话启动
start
start
预开发
before-
before-frontend-dev
检查类
check-
check-frontend
记录类
record-
record-session
生成类
generate-
generate-api-doc
更新类
update-
update-changelog
其他动词开头
review-code
,
sync-data

Example

示例

Input

输入

/trellis:create-command review-pr Check PR code changes against project guidelines
/trellis:create-command review-pr Check PR code changes against project guidelines

Generated Command Content

生成的命令内容

markdown
undefined
markdown
undefined

PR Code Review

PR Code Review

Check current PR code changes against project guidelines.
Check current PR code changes against project guidelines.

Steps

Steps

1. Get Changed Files

1. Get Changed Files

bash
git diff main...HEAD --name-only
bash
git diff main...HEAD --name-only

2. Categorized Review

2. Categorized Review

Frontend files (
apps/web/
):
  • Reference
    .trellis/spec/frontend/index.md
Backend files (
packages/api/
):
  • Reference
    .trellis/spec/backend/index.md
Frontend files (
apps/web/
):
  • Reference
    .trellis/spec/frontend/index.md
Backend files (
packages/api/
):
  • Reference
    .trellis/spec/backend/index.md

3. Output Review Report

3. Output Review Report

Format:
Format:

PR Review Report

PR Review Report

Changed Files

Changed Files

  • [file list]
  • [file list]

Check Results

Check Results

  • [OK] Passed items
  • Issues found
  • [OK] Passed items
  • Issues found

Suggestions

Suggestions

  • [improvement suggestions]
undefined
  • [improvement suggestions]
undefined