simplify

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Code Simplifier

Code Simplifier

Run the code-simplifier agent to clean up and refine code on this branch.
运行code-simplifier agent来清理和优化当前分支上的代码。

Instructions

操作说明

  1. First, determine the scope of changes to simplify:
bash
undefined
  1. 首先,确定需要简化的变更范围:
bash
undefined

Check if we're on a PR branch

检查是否处于PR分支

gh pr view --json number,headRefName 2>/dev/null || echo "Not on a PR branch"
gh pr view --json number,headRefName 2>/dev/null || echo "Not on a PR branch"

Get the current branch

获取当前分支

git branch --show-current
git branch --show-current

Show files changed vs main

显示与main分支相比有变更的文件

git diff --name-only main...HEAD 2>/dev/null || git diff --name-only origin/main...HEAD

2. Use the Task tool to run the code-simplifier agent:
Task tool with subagent_type: code-simplifier:code-simplifier

**Prompt for the agent based on scope:**

- If `$ARGUMENTS.scope` is empty or "branch":
  "Simplify and refine all code changes on this branch compared to main. Focus on recently modified files. Show me a cleaned-up version with explanations of what was simplified."

- If `$ARGUMENTS.scope` is "staged":
  "Simplify and refine only the staged changes. Show me a cleaned-up version."

- If `$ARGUMENTS.scope` starts with "file:":
  "Simplify and refine the specified file: [extract path]. Show me a cleaned-up version."

- If `$ARGUMENTS.scope` is "all":
  "Do a comprehensive simplification pass on recently modified code in this codebase. Show me a cleaned-up version with explanations."

3. After the agent completes, summarize:
   - What files were simplified
   - Key changes made (removed duplication, improved naming, etc.)
   - Any suggestions the agent couldn't auto-apply
git diff --name-only main...HEAD 2>/dev/null || git diff --name-only origin/main...HEAD

2. 使用Task工具运行code-simplifier agent:
Task tool with subagent_type: code-simplifier:code-simplifier

**基于范围的Agent提示词:**

- 如果`$ARGUMENTS.scope`为空或为"branch":
  "简化并优化此分支与main分支相比的所有代码变更。重点关注最近修改的文件。为我展示清理后的版本以及简化内容的说明。"

- 如果`$ARGUMENTS.scope`为"staged":
  "仅简化并优化已暂存的变更。为我展示清理后的版本。"

- 如果`$ARGUMENTS.scope`以"file:"开头:
  "简化并优化指定文件:[提取路径]。为我展示清理后的版本。"

- 如果`$ARGUMENTS.scope`为"all":
  "对代码库中最近修改的代码进行全面简化处理。为我展示清理后的版本以及简化内容的说明。"

3. Agent完成后,总结以下内容:
   - 哪些文件被简化
   - 主要变更内容(移除重复代码、改进命名等)
   - Agent无法自动应用的任何建议

Usage Examples

使用示例

/simplify              # Simplify branch changes vs main
/simplify staged       # Only staged changes
/simplify file:src/lib/utils.ts  # Specific file
/simplify all          # Broader pass on recent changes
/simplify              # 简化与main分支相比的分支变更
/simplify staged       # 仅简化已暂存的变更
/simplify file:src/lib/utils.ts  # 简化指定文件
/simplify all          # 对最近的变更进行更全面的处理