kata-inserting-phases
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese<objective>
Insert a decimal phase for urgent work discovered mid-milestone that must be completed between existing integer phases.
Uses decimal numbering (72.1, 72.2, etc.) to preserve the logical sequence of planned phases while accommodating urgent insertions.
Purpose: Handle urgent work discovered during execution without renumbering entire roadmap.
</objective>
<execution_context>
@.planning/ROADMAP.md
@.planning/STATE.md
</execution_context>
<process>
<step name="parse_arguments">
Parse the command arguments:
- First argument: integer phase number to insert after
- Remaining arguments: phase description
Example:
→ after = 72
→ description = "Fix critical auth bug"
/kata-insert-phase 72 Fix critical auth bugValidation:
bash
if [ $# -lt 2 ]; then
echo "ERROR: Both phase number and description required"
echo "Usage: /kata-insert-phase <after> <description>"
echo "Example: /kata-insert-phase 72 Fix critical auth bug"
exit 1
fiParse first argument as integer:
bash
after_phase=$1
shift
description="$*"<objective>
在里程碑执行中途发现的紧急工作,需在现有整数阶段之间插入小数阶段来处理。
采用小数编号(如72.1、72.2等),在容纳紧急插入任务的同时,保留原计划阶段的逻辑顺序。
目的:在无需重新为整个路线图编号的情况下,处理执行过程中发现的紧急工作。
</objective>
<execution_context>
@.planning/ROADMAP.md
@.planning/STATE.md
</execution_context>
<process>
<step name="parse_arguments">
解析命令参数:
- 第一个参数:插入位置之后的整数阶段编号
- 剩余参数:阶段描述
示例:
→ after = 72
→ description = "修复严重认证漏洞"
/kata-insert-phase 72 Fix critical auth bug验证:
bash
if [ $# -lt 2 ]; then
echo "ERROR: Both phase number and description required"
echo "Usage: /kata-insert-phase <after> <description>"
echo "Example: /kata-insert-phase 72 Fix critical auth bug"
exit 1
fi将第一个参数解析为整数:
bash
after_phase=$1
shift
description="$*"Validate after_phase is an integer
Validate after_phase is an integer
if ! [[ "$after_phase" =~ ^[0-9]+$ ]]; then
echo "ERROR: Phase number must be an integer"
exit 1
fi
</step>
<step name="load_roadmap">
Load the roadmap file:
```bash
if [ -f .planning/ROADMAP.md ]; then
ROADMAP=".planning/ROADMAP.md"
else
echo "ERROR: No roadmap found (.planning/ROADMAP.md)"
exit 1
fiRead roadmap content for parsing.
</step>
<step name="verify_target_phase">
Verify that the target phase exists in the roadmap:
-
Search for "### Phase {after_phase}:" heading
-
If not found:
ERROR: Phase {after_phase} not found in roadmap Available phases: [list phase numbers]Exit. -
Verify phase is in current milestone (not completed/archived) </step>
- Search for all "### Phase {after_phase}.N:" headings
- Extract decimal suffixes (e.g., for Phase 72: find 72.1, 72.2, 72.3)
- Find the highest decimal suffix
- Calculate next decimal: max + 1
Examples:
- Phase 72 with no decimals → next is 72.1
- Phase 72 with 72.1 → next is 72.2
- Phase 72 with 72.1, 72.2 → next is 72.3
Store as:
</step>
<step name="generate_slug">
Convert the phase description to a kebab-case slug:
decimal_phase="$(printf "%02d" $after_phase).${next_decimal}"bash
slug=$(echo "$description" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9]/-/g' | sed 's/--*/-/g' | sed 's/^-//;s/-$//')Phase directory name:
Example: (phase 6 insertion)
</step>
<step name="create_phase_directory">
Create the phase directory structure:
{decimal-phase}-{slug}06.1-fix-critical-auth-bugbash
phase_dir=".planning/phases/pending/${decimal_phase}-${slug}"
mkdir -p "$phase_dir"Confirm: "Created directory: $phase_dir"
</step>
<step name="update_roadmap">
Insert the new phase entry into the roadmap:
-
Find insertion point: immediately after Phase {after_phase}'s content (before next phase heading or "---")
-
Insert new phase heading with (INSERTED) marker:
### Phase {decimal_phase}: {Description} (INSERTED) **Goal:** [Urgent work - to be planned] **Depends on:** Phase {after_phase} **Plans:** 0 plans Plans: - [ ] TBD (run /kata-plan-phase {decimal_phase} to break down) **Details:** [To be added during planning] -
Write updated roadmap back to file
The "(INSERTED)" marker helps identify decimal phases as urgent insertions.
Preserve all other content exactly (formatting, spacing, other phases).
</step>
<step name="update_project_state">
Update STATE.md to reflect the inserted phase:
- Read
.planning/STATE.md - Under "## Accumulated Context" → "### Roadmap Evolution" add entry:
- Phase {decimal_phase} inserted after Phase {after_phase}: {description} (URGENT)
If "Roadmap Evolution" section doesn't exist, create it.
Add note about insertion reason if appropriate.
</step>
<step name="completion">
Present completion summary:
Phase {decimal_phase} inserted after Phase {after_phase}:
- Description: {description}
- Directory: .planning/phases/{decimal-phase}-{slug}/
- Status: Not planned yet
- Marker: (INSERTED) - indicates urgent work
Roadmap updated: {roadmap-path}
Project state updated: .planning/STATE.md
---if! [[ "$after_phase" =~ ^[0-9]+$ ]]; then
echo "ERROR: Phase number must be an integer"
exit 1
fi
</step>
<step name="load_roadmap">
加载路线图文件:
```bash
if [ -f.planning/ROADMAP.md ]; then
ROADMAP=".planning/ROADMAP.md"
else
echo "ERROR: No roadmap found (.planning/ROADMAP.md)"
exit 1
fi读取路线图内容以进行解析。
</step>
<step name="verify_target_phase">
验证目标阶段是否存在于路线图中:
-
搜索"### Phase {after_phase}:"标题
-
如果未找到:
ERROR: Phase {after_phase} not found in roadmap Available phases: [list phase numbers]退出程序。 -
验证阶段处于当前里程碑(未完成/归档) </step>
- 搜索所有"### Phase {after_phase}.N:"标题
- 提取小数后缀(例如,对于Phase 72:查找72.1、72.2、72.3)
- 找到最大的小数后缀
- 计算下一个小数编号:最大值 + 1
示例:
- Phase 72无小数阶段 → 下一个编号为72.1
- Phase 72已有72.1 → 下一个编号为72.2
- Phase 72已有72.1、72.2 → 下一个编号为72.3
存储为:
</step>
<step name="generate_slug">
将阶段描述转换为短横线分隔的小写格式(kebab-case):
decimal_phase="$(printf "%02d" $after_phase).${next_decimal}bash
slug=$(echo "$description" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9]/-/g' | sed 's/--*/-/g' | sed 's/^-//;s/-$//')阶段目录名称:
示例:(插入到Phase 6之后)
</step>
<step name="create_phase_directory">
创建阶段目录结构:
{decimal-phase}-{slug}06.1-fix-critical-auth-bugbash
phase_dir=".planning/phases/pending/${decimal_phase}-${slug}"
mkdir -p "$phase_dir"确认提示:"Created directory: $phase_dir"
</step>
<step name="update_roadmap">
将新阶段条目插入到路线图中:
-
找到插入位置:紧跟在Phase {after_phase}的内容之后(在下一个阶段标题或"---"之前)
-
插入带有(INSERTED)标记的新阶段标题:
### Phase {decimal_phase}: {Description} (INSERTED) **Goal:** [Urgent work - to be planned] **Depends on:** Phase {after_phase} **Plans:** 0 plans Plans: - [ ] TBD (run /kata-plan-phase {decimal_phase} to break down) **Details:** [To be added during planning] -
将更新后的路线图写回文件
"(INSERTED)"标记用于标识小数阶段为紧急插入的任务。
完全保留所有其他内容(格式、空格、其他阶段)。
</step>
<step name="update_project_state">
更新STATE.md以反映插入的阶段:
- 读取
.planning/STATE.md - 在"## Accumulated Context" → "### Roadmap Evolution"下添加条目:
- Phase {decimal_phase} inserted after Phase {after_phase}: {description} (URGENT)
如果"Roadmap Evolution"部分不存在,则创建该部分。
如有需要,添加插入原因的说明。
</step>
<step name="completion">
展示完成总结:
Phase {decimal_phase} inserted after Phase {after_phase}:
- Description: {description}
- Directory:.planning/phases/{decimal-phase}-{slug}/
- Status: Not planned yet
- Marker: (INSERTED) - indicates urgent work
Roadmap updated: {roadmap-path}
Project state updated:.planning/STATE.md
---▶ Next Up
▶ Next Up
Phase {decimal_phase}: {description} — urgent insertion
/kata-plan-phase {decimal_phase}<sub> first → fresh context window</sub>
/clearAlso available:
- Review insertion impact: Check if Phase {next_integer} dependencies still make sense
- Review roadmap
</step>
</process>
<anti_patterns>
- Don't use this for planned work at end of milestone (use /kata-add-phase)
- Don't insert before Phase 1 (decimal 0.1 makes no sense)
- Don't renumber existing phases
- Don't modify the target phase content
- Don't create plans yet (that's /kata-plan-phase)
- Don't commit changes (user decides when to commit)
</anti_patterns>
<success_criteria>
Phase insertion is complete when:
- [ ] Phase directory created: `.planning/phases/pending/{N.M}-{slug}/`
- [ ] Roadmap updated with new phase entry (includes "(INSERTED)" marker)
- [ ] Phase inserted in correct position (after target phase, before next integer phase)
- [ ] STATE.md updated with roadmap evolution note
- [ ] Decimal number calculated correctly (based on existing decimals)
- [ ] User informed of next steps and dependency implications
</success_criteria>Phase {decimal_phase}: {description} — urgent insertion
/kata-plan-phase {decimal_phase}<sub> first → fresh context window</sub>
/clearAlso available:
- Review insertion impact: Check if Phase {next_integer} dependencies still make sense
- Review roadmap
</step>
</process>
<anti_patterns>
- 请勿将此用于里程碑末尾的计划工作(使用/kata-add-phase)
- 请勿在Phase 1之前插入(小数0.1无意义)
- 请勿重新编号现有阶段
- 请勿修改目标阶段的内容
- 请勿创建计划(该操作属于/kata-plan-phase)
- 请勿提交更改(由用户决定何时提交)
</anti_patterns>
<success_criteria>
阶段插入完成的判定标准:
- [ ] 阶段目录已创建:`.planning/phases/pending/{N.M}-{slug}/`
- [ ] 路线图已更新,添加新阶段条目(包含"(INSERTED)"标记)
- [ ] 阶段插入到正确位置(目标阶段之后,下一个整数阶段之前)
- [ ] STATE.md已更新路线图演进记录
- [ ] 小数编号计算正确(基于已存在的小数阶段)
- [ ] 已告知用户后续步骤和依赖影响
</success_criteria>