kata-research-phase

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese
<objective> Research how to implement a phase. Spawns kata-phase-researcher agent with phase context.
Note: This is a standalone research command. For most workflows, use
/kata-plan-phase
which integrates research automatically.
Use this command when:
  • You want to research without planning yet
  • You want to re-research after planning is complete
  • You need to investigate before deciding if a phase is feasible
Orchestrator role: Parse phase, validate against roadmap, check existing research, gather context, spawn researcher agent, present results.
Why subagent: Research burns context fast (WebSearch, Context7 queries, source verification). Fresh 200k context for investigation. Main context stays lean for user interaction. </objective>
<context> Phase number: $ARGUMENTS (required)
Normalize phase input in step 1 before any directory lookups. </context>
<process>
<objective> 研究如何实现某个阶段。基于阶段上下文生成kata-phase-researcher Agent。
注意: 这是一个独立的研究命令。对于大多数工作流,请使用
/kata-plan-phase
命令,它会自动集成研究环节。
在以下场景使用此命令:
  • 你希望先开展研究,暂不进行规划
  • 你希望在规划完成后重新开展研究
  • 你需要先调研,再判断某个阶段是否可行
编排器角色: 解析阶段信息,对照路线图验证,检查已有研究,收集上下文,生成研究Agent,呈现结果。
为何使用子Agent: 研究过程会快速消耗上下文(WebSearch、Context7查询、来源验证)。新生成的Agent拥有200k的独立上下文用于调研,主上下文则保持精简,专注于与用户交互。 </objective>
<context> 阶段编号:$ARGUMENTS(必填)
在进行任何目录查找前,第一步先标准化阶段输入。 </context>
<process>

0. Resolve Model Profile

0. 解析模型配置文件

Read model profile for agent spawning:
bash
MODEL_PROFILE=$(cat .planning/config.json 2>/dev/null | grep -o '"model_profile"[[:space:]]*:[[:space:]]*"[^"]*"' | grep -o '"[^"]*"$' | tr -d '"' || echo "balanced")
Default to "balanced" if not set.
Model lookup table:
Agentqualitybalancedbudget
kata-phase-researcheropussonnethaiku
Store resolved model for use in Task calls below.
读取用于生成Agent的模型配置文件:
bash
MODEL_PROFILE=$(cat .planning/config.json 2>/dev/null | grep -o '"model_profile"[[:space:]]*:[[:space:]]*"[^"]*"' | grep -o '"[^"]*"$' | tr -d '"' || echo "balanced")
如果未设置,则默认使用“balanced”。
模型查找表:
Agentqualitybalancedbudget
kata-phase-researcheropussonnethaiku
存储解析后的模型,供后续Task调用使用。

1. Normalize and Validate Phase

1. 标准化并验证阶段信息

bash
undefined
bash
undefined

Normalize phase number (8 → 08, but preserve decimals like 2.1 → 02.1)

标准化阶段编号(8 → 08,但保留小数格式如2.1 → 02.1)

if [[ "$ARGUMENTS" =~ ^[0-9]+$ ]]; then PHASE=$(printf "%02d" "$ARGUMENTS") elif [[ "$ARGUMENTS" =~ ^([0-9]+).([0-9]+)$ ]]; then PHASE=$(printf "%02d.%s" "${BASH_REMATCH[1]}" "${BASH_REMATCH[2]}") else PHASE="$ARGUMENTS" fi
grep -A5 "Phase ${PHASE}:" .planning/ROADMAP.md 2>/dev/null

**If not found:** Error and exit. **If found:** Extract phase number, name, description.
if [[ "$ARGUMENTS" =~ ^[0-9]+$ ]]; then PHASE=$(printf "%02d" "$ARGUMENTS") elif [[ "$ARGUMENTS" =~ ^([0-9]+).([0-9]+)$ ]]; then PHASE=$(printf "%02d.%s" "${BASH_REMATCH[1]}" "${BASH_REMATCH[2]}") else PHASE="$ARGUMENTS" fi
grep -A5 "Phase ${PHASE}:" .planning/ROADMAP.md 2>/dev/null

**如果未找到:** 报错并退出。**如果找到:** 提取阶段编号、名称和描述。

2. Find Phase Directory and Check Existing Research

2. 查找阶段目录并检查已有研究

bash
undefined
bash
undefined

Universal phase discovery

通用阶段发现逻辑

PADDED=$(printf "%02d" "$PHASE" 2>/dev/null || echo "$PHASE") PHASE_DIR="" for state in active pending completed; do PHASE_DIR=$(find .planning/phases/${state} -maxdepth 1 -type d -name "${PADDED}-" 2>/dev/null | head -1) [ -z "$PHASE_DIR" ] && PHASE_DIR=$(find .planning/phases/${state} -maxdepth 1 -type d -name "${PHASE}-" 2>/dev/null | head -1) [ -n "$PHASE_DIR" ] && break done
PADDED=$(printf "%02d" "$PHASE" 2>/dev/null || echo "$PHASE") PHASE_DIR="" for state in active pending completed; do PHASE_DIR=$(find .planning/phases/${state} -maxdepth 1 -type d -name "${PADDED}-" 2>/dev/null | head -1) [ -z "$PHASE_DIR" ] && PHASE_DIR=$(find .planning/phases/${state} -maxdepth 1 -type d -name "${PHASE}-" 2>/dev/null | head -1) [ -n "$PHASE_DIR" ] && break done

Fallback: flat directory (backward compatibility)

回退方案:扁平化目录(向后兼容)

if [ -z "$PHASE_DIR" ]; then PHASE_DIR=$(find .planning/phases -maxdepth 1 -type d -name "${PADDED}-" 2>/dev/null | head -1) [ -z "$PHASE_DIR" ] && PHASE_DIR=$(find .planning/phases -maxdepth 1 -type d -name "${PHASE}-" 2>/dev/null | head -1) fi
ls ${PHASE_DIR}/RESEARCH.md 2>/dev/null

**If exists:** Offer: 1) Update research, 2) View existing, 3) Skip. Wait for response.

**If doesn't exist:** Continue.
if [ -z "$PHASE_DIR" ]; then PHASE_DIR=$(find .planning/phases -maxdepth 1 -type d -name "${PADDED}-" 2>/dev/null | head -1) [ -z "$PHASE_DIR" ] && PHASE_DIR=$(find .planning/phases -maxdepth 1 -type d -name "${PHASE}-" 2>/dev/null | head -1) fi
ls ${PHASE_DIR}/RESEARCH.md 2>/dev/null

**如果已存在:** 提供选项:1) 更新研究内容,2) 查看已有研究,3) 跳过。等待用户响应。

**如果不存在:** 继续执行后续步骤。

3. Gather Phase Context

3. 收集阶段上下文

bash
grep -A20 "Phase ${PHASE}:" .planning/ROADMAP.md
cat .planning/REQUIREMENTS.md 2>/dev/null
cat ${PHASE_DIR}/${PHASE}-CONTEXT.md 2>/dev/null
grep -A30 "### Decisions Made" .planning/STATE.md 2>/dev/null
Present summary with phase description, requirements, prior decisions.
bash
grep -A20 "Phase ${PHASE}:" .planning/ROADMAP.md
cat .planning/REQUIREMENTS.md 2>/dev/null
cat ${PHASE_DIR}/${PHASE}-CONTEXT.md 2>/dev/null
grep -A30 "### Decisions Made" .planning/STATE.md 2>/dev/null
呈现阶段描述、需求、过往决策的汇总信息。

3.5. Load Phase-Researcher Instructions

3.5. 加载阶段研究Agent指令

Read the phase-researcher agent instructions for inlining into Task() calls:
bash
phase_researcher_instructions_content=$(cat references/phase-researcher-instructions.md)
读取phase-researcher Agent的指令,用于嵌入到Task()调用中:
bash
phase_researcher_instructions_content=$(cat references/phase-researcher-instructions.md)

4. Spawn kata-phase-researcher Agent

4. 生成kata-phase-researcher Agent

Research modes: ecosystem (default), feasibility, implementation, comparison.
markdown
<research_type>
Phase Research — investigating HOW to implement a specific phase well.
</research_type>

<key_insight>
The question is NOT "which library should I use?"

The question is: "What do I not know that I don't know?"

For this phase, discover:
- What's the established architecture pattern?
- What libraries form the standard stack?
- What problems do people commonly hit?
- What's SOTA vs what Claude's training thinks is SOTA?
- What should NOT be hand-rolled?
</key_insight>

<objective>
Research implementation approach for Phase {phase_number}: {phase_name}
Mode: ecosystem
</objective>

<context>
**Phase description:** {phase_description}
**Requirements:** {requirements_list}
**Prior decisions:** {decisions_if_any}
**Phase context:** {context_md_content}
</context>

<downstream_consumer>
Your RESEARCH.md will be loaded by `/kata-plan-phase` which uses specific sections:
- `## Standard Stack` → Plans use these libraries
- `## Architecture Patterns` → Task structure follows these
- `## Don't Hand-Roll` → Tasks NEVER build custom solutions for listed problems
- `## Common Pitfalls` → Verification steps check for these
- `## Code Examples` → Task actions reference these patterns

Be prescriptive, not exploratory. "Use X" not "Consider X or Y."
</downstream_consumer>

<quality_gate>
Before declaring complete, verify:
- [ ] All domains investigated (not just some)
- [ ] Negative claims verified with official docs
- [ ] Multiple sources for critical claims
- [ ] Confidence levels assigned honestly
- [ ] Section names match what phase-plan expects
</quality_gate>

<output>
Write to: ${PHASE_DIR}/${PHASE}-RESEARCH.md
</output>
Task(
  prompt="<agent-instructions>\n{phase_researcher_instructions_content}\n</agent-instructions>\n\n" + filled_prompt,
  subagent_type="general-purpose",
  model="{researcher_model}",
  description="Research Phase {phase}"
)
研究模式:生态系统(默认)、可行性、实现方案、对比分析。
markdown
<research_type>
Phase Research — investigating HOW to implement a specific phase well.
</research_type>

<key_insight>
The question is NOT "which library should I use?"

The question is: "What do I not know that I don't know?"

For this phase, discover:
- What's the established architecture pattern?
- What libraries form the standard stack?
- What problems do people commonly hit?
- What's SOTA vs what Claude's training thinks is SOTA?
- What should NOT be hand-rolled?
</key_insight>

<objective>
Research implementation approach for Phase {phase_number}: {phase_name}
Mode: ecosystem
</objective>

<context>
**Phase description:** {phase_description}
**Requirements:** {requirements_list}
**Prior decisions:** {decisions_if_any}
**Phase context:** {context_md_content}
</context>

<downstream_consumer>
Your RESEARCH.md will be loaded by `/kata-plan-phase` which uses specific sections:
- `## Standard Stack` → Plans use these libraries
- `## Architecture Patterns` → Task structure follows these
- `## Don't Hand-Roll` → Tasks NEVER build custom solutions for listed problems
- `## Common Pitfalls` → Verification steps check for these
- `## Code Examples` → Task actions reference these patterns

Be prescriptive, not exploratory. "Use X" not "Consider X or Y."
</downstream_consumer>

<quality_gate>
Before declaring complete, verify:
- [ ] All domains investigated (not just some)
- [ ] Negative claims verified with official docs
- [ ] Multiple sources for critical claims
- [ ] Confidence levels assigned honestly
- [ ] Section names match what phase-plan expects
</quality_gate>

<output>
Write to: ${PHASE_DIR}/${PHASE}-RESEARCH.md
</output>
Task(
  prompt="<agent-instructions>\n{phase_researcher_instructions_content}\n</agent-instructions>\n\n" + filled_prompt,
  subagent_type="general-purpose",
  model="{researcher_model}",
  description="Research Phase {phase}"
)

5. Handle Agent Return

5. 处理Agent返回结果

## RESEARCH COMPLETE
:
Display summary, offer: Plan phase, Dig deeper, Review full, Done.
## CHECKPOINT REACHED
:
Present to user, get response, spawn continuation.
## RESEARCH INCONCLUSIVE
:
Show what was attempted, offer: Add context, Try different mode, Manual.
## RESEARCH COMPLETE
显示汇总信息,提供选项:规划阶段、深入调研、查看完整内容、结束。
## CHECKPOINT REACHED
将内容呈现给用户,获取响应后生成后续Agent。
## RESEARCH INCONCLUSIVE
展示已尝试的操作,提供选项:补充上下文、更换研究模式、手动处理。

6. Spawn Continuation Agent

6. 生成后续Agent

markdown
<objective>
Continue research for Phase {phase_number}: {phase_name}
</objective>

<prior_state>
Research file: @${PHASE_DIR}/${PHASE}-RESEARCH.md
</prior_state>

<checkpoint_response>
**Type:** {checkpoint_type}
**Response:** {user_response}
</checkpoint_response>
Task(
  prompt="<agent-instructions>\n{phase_researcher_instructions_content}\n</agent-instructions>\n\n" + continuation_prompt,
  subagent_type="general-purpose",
  model="{researcher_model}",
  description="Continue research Phase {phase}"
)
</process>
<success_criteria>
  • Phase validated against roadmap
  • Existing research checked
  • kata-phase-researcher spawned with context
  • Checkpoints handled correctly
  • User knows next steps </success_criteria>
markdown
<objective>
Continue research for Phase {phase_number}: {phase_name}
</objective>

<prior_state>
Research file: @${PHASE_DIR}/${PHASE}-RESEARCH.md
</prior_state>

<checkpoint_response>
**Type:** {checkpoint_type}
**Response:** {user_response}
</checkpoint_response>
Task(
  prompt="<agent-instructions>\n{phase_researcher_instructions_content}\n</agent-instructions>\n\n" + continuation_prompt,
  subagent_type="general-purpose",
  model="{researcher_model}",
  description="Continue research Phase {phase}"
)
</process>
<success_criteria>
  • 阶段信息已对照路线图验证
  • 已检查已有研究内容
  • 已基于上下文生成kata-phase-researcher Agent
  • 检查点已正确处理
  • 用户了解后续操作步骤 </success_criteria>