kata-remove-phase
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese<objective>
Remove an unstarted future phase from the roadmap and renumber all subsequent phases to maintain a clean, linear sequence.
Purpose: Clean removal of work you've decided not to do, without polluting context with cancelled/deferred markers.
Output: Phase deleted, all subsequent phases renumbered, git commit as historical record.
</objective>
<execution_context>
@.planning/ROADMAP.md
@.planning/STATE.md
</execution_context>
<process>
<step name="parse_arguments">
Parse the command arguments:
- Argument is the phase number to remove (integer or decimal)
- Example: `/kata-remove-phase 17` → phase = 17
- Example: `/kata-remove-phase 16.1` → phase = 16.1
If no argument provided:
ERROR: Phase number required
Usage: /kata-remove-phase <phase-number>
Example: /kata-remove-phase 17Exit.
</step>
<step name="load_state">
Load project state:
bash
cat .planning/STATE.md 2>/dev/null
cat .planning/ROADMAP.md 2>/dev/nullParse current phase number from STATE.md "Current Position" section.
</step>
<step name="validate_phase_exists">
Verify the target phase exists in ROADMAP.md:
-
Search forheading
### Phase {target}: -
If not found:
ERROR: Phase {target} not found in roadmap Available phases: [list phase numbers]Exit.</step>
- Compare target phase to current phase from STATE.md
- Target must be > current phase number
If target <= current phase:
ERROR: Cannot remove Phase {target}
Only future phases can be removed:
- Current phase: {current}
- Phase {target} is current or completed
To abandon current work, use /kata-pause-work instead.Exit.
- Find and check for SUMMARY.md files in phase directory:
bash
undefined<objective>
从路线图中移除尚未启动的未来阶段,并重新编号所有后续阶段,以保持清晰的线性序列。
目的:彻底移除已决定不执行的工作,避免用已取消/延期标记污染上下文。
输出:阶段已删除,所有后续阶段重新编号,git提交作为历史记录。
</objective>
<execution_context>
@.planning/ROADMAP.md
@.planning/STATE.md
</execution_context>
<process>
<step name="parse_arguments">
解析命令参数:
- 参数为要移除的阶段编号(整数或小数)
- 示例:`/kata-remove-phase 17` → 阶段 = 17
- 示例:`/kata-remove-phase 16.1` → 阶段 = 16.1
如果未提供参数:
ERROR: Phase number required
Usage: /kata-remove-phase <phase-number>
Example: /kata-remove-phase 17退出。
</step>
<step name="load_state">
加载项目状态:
bash
cat .planning/STATE.md 2>/dev/null
cat .planning/ROADMAP.md 2>/dev/null从STATE.md的"Current Position"部分解析当前阶段编号。
</step>
<step name="validate_phase_exists">
验证目标阶段在ROADMAP.md中存在:
-
搜索标题
### Phase {target}: -
如果未找到:
ERROR: Phase {target} not found in roadmap Available phases: [list phase numbers]退出。</step>
- 比较目标阶段与STATE.md中的当前阶段
- 目标阶段编号必须大于当前阶段编号
如果目标阶段编号 <= 当前阶段编号:
ERROR: Cannot remove Phase {target}
Only future phases can be removed:
- Current phase: {current}
- Phase {target} is current or completed
To abandon current work, use /kata-pause-work instead.退出。
- 在阶段目录中查找并检查SUMMARY.md文件:
bash
undefinedUniversal phase discovery for target phase
Universal phase discovery for target phase
PADDED_TARGET=$(printf "%02d" "$TARGET" 2>/dev/null || echo "$TARGET")
PHASE_DIR=""
for state in active pending completed; do
PHASE_DIR=$(find .planning/phases/${state} -maxdepth 1 -type d -name "${PADDED_TARGET}-" 2>/dev/null | head -1)
[ -z "$PHASE_DIR" ] && PHASE_DIR=$(find .planning/phases/${state} -maxdepth 1 -type d -name "${TARGET}-" 2>/dev/null | head -1)
[ -n "$PHASE_DIR" ] && break
done
PADDED_TARGET=$(printf "%02d" "$TARGET" 2>/dev/null || echo "$TARGET")
PHASE_DIR=""
for state in active pending completed; do
PHASE_DIR=$(find .planning/phases/${state} -maxdepth 1 -type d -name "${PADDED_TARGET}-" 2>/dev/null | head -1)
[ -z "$PHASE_DIR" ] && PHASE_DIR=$(find .planning/phases/${state} -maxdepth 1 -type d -name "${TARGET}-" 2>/dev/null | head -1)
[ -n "$PHASE_DIR" ] && break
done
Fallback: flat directory (backward compatibility)
Fallback: flat directory (backward compatibility)
if [ -z "$PHASE_DIR" ]; then
PHASE_DIR=$(find .planning/phases -maxdepth 1 -type d -name "${PADDED_TARGET}-" 2>/dev/null | head -1)
[ -z "$PHASE_DIR" ] && PHASE_DIR=$(find .planning/phases -maxdepth 1 -type d -name "${TARGET}-" 2>/dev/null | head -1)
fi
find "${PHASE_DIR}" -maxdepth 1 -name "*-SUMMARY.md" 2>/dev/null
If any SUMMARY.md files exist:
ERROR: Phase {target} has completed work
Found executed plans:
- {list of SUMMARY.md files}
Cannot remove phases with completed work.
Exit.
</step>
<step name="gather_phase_info">
Collect information about the phase being removed:
1. Extract phase name from ROADMAP.md heading: `### Phase {target}: {Name}`
2. Phase directory already found via universal discovery: `${PHASE_DIR}`
3. Find all subsequent phases (searching across active/pending/completed subdirectories) (integer and decimal) that need renumbering
**Subsequent phase detection:**
For integer phase removal (e.g., 17):
- Find all phases > 17 (integers: 18, 19, 20...)
- Find all decimal phases >= 17.0 and < 18.0 (17.1, 17.2...) → these become 16.x
- Find all decimal phases for subsequent integers (18.1, 19.1...) → renumber with their parent
For decimal phase removal (e.g., 17.1):
- Find all decimal phases > 17.1 and < 18 (17.2, 17.3...) → renumber down
- Integer phases unchanged
List all phases that will be renumbered.
</step>
<step name="confirm_removal">
Present removal summary and confirm:
Removing Phase {target}: {Name}
This will:
- Delete: ${PHASE_DIR}
- Renumber {N} subsequent phases:
- Phase 18 → Phase 17
- Phase 18.1 → Phase 17.1
- Phase 19 → Phase 18 [etc.]
Proceed? (y/n)
Wait for confirmation.
</step>
<step name="delete_phase_directory">
Delete the target phase directory if it exists:
```bash
if [ -d "${PHASE_DIR}" ]; then
rm -rf "${PHASE_DIR}"
echo "Deleted: ${PHASE_DIR}"
fiIf directory doesn't exist, note: "No directory to delete (phase not yet created)"
</step>
<step name="renumber_directories">
Rename all subsequent phase directories:
For each phase directory that needs renumbering (in reverse order to avoid conflicts):
Find each subsequent phase using universal discovery, then rename within the same state subdirectory:
bash
undefinedif [ -z "$PHASE_DIR" ]; then
PHASE_DIR=$(find .planning/phases -maxdepth 1 -type d -name "${PADDED_TARGET}-" 2>/dev/null | head -1)
[ -z "$PHASE_DIR" ] && PHASE_DIR=$(find .planning/phases -maxdepth 1 -type d -name "${TARGET}-" 2>/dev/null | head -1)
fi
find "${PHASE_DIR}" -maxdepth 1 -name "*-SUMMARY.md" 2>/dev/null
如果存在任何SUMMARY.md文件:
ERROR: Phase {target} has completed work
Found executed plans:
- {list of SUMMARY.md files}
Cannot remove phases with completed work.
退出。
</step>
<step name="gather_phase_info">
收集要移除的阶段相关信息:
1. 从ROADMAP.md的标题`### Phase {target}: {Name}`中提取阶段名称
2. 已通过通用查找找到阶段目录:`${PHASE_DIR}`
3. 查找所有需要重新编号的后续阶段(遍历active/pending/completed子目录)(整数和小数阶段)
**后续阶段检测规则:**
移除整数阶段(如17)时:
- 查找所有编号大于17的整数阶段(18、19、20...)
- 查找所有编号 >=17.0且<18.0的小数阶段(17.1、17.2...)→ 这些阶段将变为16.x
- 查找后续整数阶段下的所有小数阶段(18.1、19.1...)→ 随父阶段一起重新编号
移除小数阶段(如17.1)时:
- 查找所有编号>17.1且<18的小数阶段(17.2、17.3...)→ 编号递减
- 整数阶段保持不变
列出所有需要重新编号的阶段。
</step>
<step name="confirm_removal">
展示移除摘要并确认:
Removing Phase {target}: {Name}
This will:
- Delete: ${PHASE_DIR}
- Renumber {N} subsequent phases:
- Phase 18 → Phase 17
- Phase 18.1 → Phase 17.1
- Phase 19 → Phase 18 [etc.]
Proceed? (y/n)
等待确认。
</step>
<step name="delete_phase_directory">
如果目标阶段目录存在则删除:
```bash
if [ -d "${PHASE_DIR}" ]; then
rm -rf "${PHASE_DIR}"
echo "Deleted: ${PHASE_DIR}"
fi如果目录不存在,提示:"No directory to delete (phase not yet created)"
</step>
<step name="renumber_directories">
重命名所有后续阶段目录:
对每个需要重新编号的阶段目录(按倒序处理以避免冲突):
通过通用查找找到每个后续阶段,然后在同一状态子目录内重命名:
bash
undefinedFor each subsequent phase, find it across state subdirectories
For each subsequent phase, find it across state subdirectories
for state in active pending completed; do
Example: renaming 18-dashboard to 17-dashboard within the same state dir
SRC=$(find .planning/phases/${state} -maxdepth 1 -type d -name "18-dashboard" 2>/dev/null | head -1)
[ -n "$SRC" ] && mv "$SRC" ".planning/phases/${state}/17-dashboard"
done
for state in active pending completed; do
Example: renaming 18-dashboard to 17-dashboard within the same state dir
SRC=$(find .planning/phases/${state} -maxdepth 1 -type d -name "18-dashboard" 2>/dev/null | head -1)
[ -n "$SRC" ] && mv "$SRC" ".planning/phases/${state}/17-dashboard"
done
Fallback: flat directory
Fallback: flat directory
SRC=$(find .planning/phases -maxdepth 1 -type d -name "18-dashboard" 2>/dev/null | head -1)
[ -n "$SRC" ] && mv "$SRC" ".planning/phases/17-dashboard"
Process in descending order (20→19, then 19→18, then 18→17) to avoid overwriting.
Also rename decimal phase directories:
- `17.1-fix-bug` → `16.1-fix-bug` (if removing integer 17)
- `17.2-hotfix` → `17.1-hotfix` (if removing decimal 17.1)
</step>
<step name="rename_files_in_directories">
Rename plan files inside renumbered directories:
For each renumbered directory, rename files that contain the phase number:
```bashSRC=$(find .planning/phases -maxdepth 1 -type d -name "18-dashboard" 2>/dev/null | head -1)
[ -n "$SRC" ] && mv "$SRC" ".planning/phases/17-dashboard"
按降序处理(20→19,然后19→18,再18→17)以避免覆盖。
同时重命名小数阶段目录:
- `17.1-fix-bug` → `16.1-fix-bug`(当移除整数阶段17时)
- `17.2-hotfix` → `17.1-hotfix`(当移除小数阶段17.1时)
</step>
<step name="rename_files_in_directories">
重命名已重新编号目录内的计划文件:
对每个已重新编号的目录,重命名包含阶段编号的文件:
```bashInside 17-dashboard (was 18-dashboard):
Inside 17-dashboard (was 18-dashboard):
mv "18-01-PLAN.md" "17-01-PLAN.md"
mv "18-02-PLAN.md" "17-02-PLAN.md"
mv "18-01-SUMMARY.md" "17-01-SUMMARY.md" # if exists
mv "18-01-PLAN.md" "17-01-PLAN.md"
mv "18-02-PLAN.md" "17-02-PLAN.md"
mv "18-01-SUMMARY.md" "17-01-SUMMARY.md" # if exists
etc.
etc.
Also handle CONTEXT.md and DISCOVERY.md (these don't have phase prefixes, so no rename needed).
</step>
<step name="update_roadmap">
Update ROADMAP.md:
1. **Remove the phase section entirely:**
- Delete from `### Phase {target}:` to the next phase heading (or section end)
2. **Remove from phase list:**
- Delete line `- [ ] **Phase {target}: {Name}**` or similar
3. **Remove from Progress table:**
- Delete the row for Phase {target}
4. **Renumber all subsequent phases:**
- `### Phase 18:` → `### Phase 17:`
- `- [ ] **Phase 18:` → `- [ ] **Phase 17:`
- Table rows: `| 18. Dashboard |` → `| 17. Dashboard |`
- Plan references: `18-01:` → `17-01:`
5. **Update dependency references:**
- `**Depends on:** Phase 18` → `**Depends on:** Phase 17`
- For the phase that depended on the removed phase:
- `**Depends on:** Phase 17` (removed) → `**Depends on:** Phase 16`
6. **Renumber decimal phases:**
- `### Phase 17.1:` → `### Phase 16.1:` (if integer 17 removed)
- Update all references consistently
Write updated ROADMAP.md.
</step>
<step name="update_state">
Update STATE.md:
1. **Update total phase count:**
- `Phase: 16 of 20` → `Phase: 16 of 19`
2. **Recalculate progress percentage:**
- New percentage based on completed plans / new total plans
Do NOT add a "Roadmap Evolution" note - the git commit is the record.
Write updated STATE.md.
</step>
<step name="update_file_contents">
Search for and update phase references inside plan files:
```bash
同时处理CONTEXT.md和DISCOVERY.md(这些文件没有阶段前缀,因此无需重命名)。
</step>
<step name="update_roadmap">
更新ROADMAP.md:
1. **完全移除该阶段章节:**
- 删除从`### Phase {target}:`到下一个阶段标题(或章节末尾)的所有内容
2. **从阶段列表中移除:**
- 删除`- [ ] **Phase {target}: {Name}**`或类似行
3. **从进度表中移除:**
- 删除Phase {target}对应的行
4. **重新编号所有后续阶段:**
- `### Phase 18:` → `### Phase 17:`
- `- [ ] **Phase 18:` → `- [ ] **Phase 17:`
- 表格行:`| 18. Dashboard |` → `| 17. Dashboard |`
- 计划引用:`18-01:` → `17-01:`
5. **更新依赖引用:**
- `**Depends on:** Phase 18` → `**Depends on:** Phase 17`
- 对于依赖已移除阶段的阶段:
- `**Depends on:** Phase 17`(已移除)→ `**Depends on:** Phase 16`
6. **重新编号小数阶段:**
- `### Phase 17.1:` → `### Phase 16.1:`(当移除整数阶段17时)
- 统一更新所有相关引用
写入更新后的ROADMAP.md。
</step>
<step name="update_state">
更新STATE.md:
1. **更新阶段总数:**
- `Phase: 16 of 20` → `Phase: 16 of 19`
2. **重新计算进度百分比:**
- 基于已完成计划数/新的总计划数计算新百分比
请勿添加“Roadmap Evolution”注释 - git提交即为记录。
写入更新后的STATE.md。
</step>
<step name="update_file_contents">
搜索并更新计划文件内的阶段引用:
```bashFind files that reference the old phase numbers (search across state subdirectories)
Find files that reference the old phase numbers (search across state subdirectories)
for state in active pending completed; do
grep -r "Phase 18" .planning/phases/${state}/17-/ 2>/dev/null
grep -r "Phase 19" .planning/phases/${state}/18-/ 2>/dev/null
done
for state in active pending completed; do
grep -r "Phase 18" .planning/phases/${state}/17-/ 2>/dev/null
grep -r "Phase 19" .planning/phases/${state}/18-/ 2>/dev/null
done
Fallback: flat directories
Fallback: flat directories
grep -r "Phase 18" .planning/phases/17-/ 2>/dev/null
grep -r "Phase 19" .planning/phases/18-/ 2>/dev/null
grep -r "Phase 18" .planning/phases/17-/ 2>/dev/null
grep -r "Phase 19" .planning/phases/18-/ 2>/dev/null
etc.
etc.
Update any internal references to reflect new numbering.
</step>
<step name="commit">
Stage and commit the removal:
**Check planning config:**
```bash
COMMIT_PLANNING_DOCS=$(cat .planning/config.json 2>/dev/null | grep -o '"commit_docs"[[:space:]]*:[[:space:]]*[^,}]*' | grep -o 'true\|false' || echo "true")
git check-ignore -q .planning 2>/dev/null && COMMIT_PLANNING_DOCS=falseIf : Skip git operations
COMMIT_PLANNING_DOCS=falseIf (default):
COMMIT_PLANNING_DOCS=truebash
git add .planning/
git commit -m "chore: remove phase {target} ({original-phase-name})"The commit message preserves the historical record of what was removed.
</step>
<step name="completion">
Present completion summary:
Phase {target} ({original-name}) removed.
Changes:
- Deleted: ${PHASE_DIR}
- Renumbered: Phases {first-renumbered}-{last-old} → {first-renumbered-1}-{last-new}
- Updated: ROADMAP.md, STATE.md
- Committed: chore: remove phase {target} ({original-name})
Current roadmap: {total-remaining} phases
Current position: Phase {current} of {new-total}
---
更新所有内部引用以匹配新编号。
</step>
<step name="commit">
暂存并提交移除操作:
**检查规划配置:**
```bash
COMMIT_PLANNING_DOCS=$(cat .planning/config.json 2>/dev/null | grep -o '"commit_docs"[[:space:]]*:[[:space:]]*[^,}]*' | grep -o 'true\|false' || echo "true")
git check-ignore -q .planning 2>/dev/null && COMMIT_PLANNING_DOCS=false如果: 跳过git操作
COMMIT_PLANNING_DOCS=false如果(默认值):
COMMIT_PLANNING_DOCS=truebash
git add .planning/
git commit -m "chore: remove phase {target} ({original-phase-name})"提交消息会保留已移除内容的历史记录。
</step>
<step name="completion">
展示完成摘要:
Phase {target} ({original-name}) removed.
Changes:
- Deleted: ${PHASE_DIR}
- Renumbered: Phases {first-renumbered}-{last-old} → {first-renumbered-1}-{last-new}
- Updated: ROADMAP.md, STATE.md
- Committed: chore: remove phase {target} ({original-name})
Current roadmap: {total-remaining} phases
Current position: Phase {current} of {new-total}
---What's Next
What's Next
Would you like to:
- — see updated roadmap status
/kata-track-progress - Continue with current phase
- Review roadmap
</step>
</process>
<anti_patterns>
- Don't remove completed phases (have SUMMARY.md files)
- Don't remove current or past phases
- Don't leave gaps in numbering - always renumber
- Don't add "removed phase" notes to STATE.md - git commit is the record
- Don't ask about each decimal phase - just renumber them
- Don't modify completed phase directories
</anti_patterns>
<edge_cases>
**Removing a decimal phase (e.g., 17.1):**
- Only affects other decimals in same series (17.2 → 17.1, 17.3 → 17.2)
- Integer phases unchanged
- Simpler operation
**No subsequent phases to renumber:**
- Removing the last phase (e.g., Phase 20 when that's the end)
- Just delete and update ROADMAP.md, no renumbering needed
**Phase directory doesn't exist:**
- Phase may be in ROADMAP.md but directory not created yet
- Skip directory deletion, proceed with ROADMAP.md updates
**Decimal phases under removed integer:**
- Removing Phase 17 when 17.1, 17.2 exist
- 17.1 → 16.1, 17.2 → 16.2
- They maintain their position in execution order (after current last integer)
</edge_cases>
<success_criteria>
Phase removal is complete when:
- [ ] Target phase validated as future/unstarted
- [ ] Phase directory deleted (if existed)
- [ ] All subsequent phase directories renumbered
- [ ] Files inside directories renamed ({old}-01-PLAN.md → {new}-01-PLAN.md)
- [ ] ROADMAP.md updated (section removed, all references renumbered)
- [ ] STATE.md updated (phase count, progress percentage)
- [ ] Dependency references updated in subsequent phases
- [ ] Changes committed with descriptive message
- [ ] No gaps in phase numbering
- [ ] User informed of changes
</success_criteria>Would you like to:
- — see updated roadmap status
/kata-track-progress - Continue with current phase
- Review roadmap
</step>
</process>
<anti_patterns>
- 请勿移除已完成阶段(包含SUMMARY.md文件)
- 请勿移除当前或过往阶段
- 请勿留下编号空缺 - 务必重新编号
- 请勿在STATE.md中添加“已移除阶段”注释 - git提交即为记录
- 请勿逐个询问小数阶段的处理方式 - 直接统一重新编号
- 请勿修改已完成阶段的目录
</anti_patterns>
<edge_cases>
**移除小数阶段(如17.1):**
- 仅影响同一系列的其他小数阶段(17.2 → 17.1,17.3 → 17.2)
- 整数阶段保持不变
- 操作更简单
**无后续阶段需要重新编号:**
- 移除最后一个阶段(例如,阶段20为最后一个阶段时)
- 只需删除并更新ROADMAP.md,无需重新编号
**阶段目录不存在:**
- 阶段可能已在ROADMAP.md中记录,但尚未创建目录
- 跳过目录删除步骤,继续执行ROADMAP.md更新操作
**已移除整数阶段下的小数阶段:**
- 当移除阶段17且存在17.1、17.2时
- 17.1 → 16.1,17.2 → 16.2
- 它们会保持在执行顺序中的位置(位于当前最后一个整数阶段之后)
</edge_cases>
<success_criteria>
阶段移除完成的判定标准:
- [ ] 目标阶段已验证为未来/未启动阶段
- [ ] 阶段目录已删除(如果存在)
- [ ] 所有后续阶段目录已重新编号
- [ ] 目录内文件已重命名({old}-01-PLAN.md → {new}-01-PLAN.md)
- [ ] ROADMAP.md已更新(章节已移除,所有引用已重新编号)
- [ ] STATE.md已更新(阶段总数、进度百分比)
- [ ] 后续阶段中的依赖引用已更新
- [ ] 变更已通过描述性提交消息提交
- [ ] 阶段编号无空缺
- [ ] 已向用户告知变更内容
</success_criteria>