For large-scale implementations split into multiple phases, the root session does not implement; it decides with the user how to divide the next phase to start and the seams between phases. Implementation is handed off to a separate session (child) via a handoff prompt, but regardless of launch method the root receives questions, progress, and completion reports, and holds the window for user review through to the end. Agreement is reached in chat; no design document file is created. Since the child reads only the handoff prompt, what was decided and the contact point to the root are written there.
Phases are not all decided upfront. What is created first is only the list of what to do in this session. Each time the previous phase is merged, only the portion for the next round is cut out from that list.
The root starts on the default branch of the repo's main checkout (not a linked worktree). The root does not write code or commit, so it needs no branch of its own. The child's worktree is created with the wt CLI. In Herdr, the child is launched in a child workspace under the root's workspace; in Tern, in a floating panel tied to the root panel where the main omp runs. Tern's child is placed in the same session and tab as the root; no separate session is created. When proceeding with multiple features in parallel, add roots in the repo's main checkout (Herdr adds them to the root's workspace; Tern adds tabs to the root's session) and share the same checkout (the root does not switch branches). The terminal CLI reads the installed kstack-handoff の SKILL.md and follows the reference files it points to.
Procedure
-
Solidify requirements — Confirm that the root is on the default branch of the repo's main checkout (the path on line 1 of
git rev-parse --show-toplevelがgit worktree list, wheregit branch --show-currentis the default branch); if not, tell the user to restart there and stop. Read the request and existing code, and grasp what to build (screens, endpoints, data, settings, etc.), what existing things can be used, and the file placement conventions. If the investigation is broad, delegate only fact gathering to a subagent, keeping the root's context for design. Comparison of options, phase division, and seam design are decided by the root; do not have subagents consider them. Ask the user about requirements where the design diverges. Then, list in one line per item what must be done in this session to satisfy the completion conditions, and write it in the todo (it persists after compaction). Write down small decisions in the items with provisional values, and include them in "things to decide" in the proposal for the phase where they matter. Do not decide the phase division or the design of each item here. Completion conditions: what to build and what is out of scope are decided, and there is a list of what to do -
Create the next phase proposal — If the previous phase is already merged,
git fetchthe root's checkout and advance it to the latest default branch withmerge --ff-only(kstack-handoffIf delegated, it would have been handled by "integration"), and revise the list to match the code and results. From the list, extract only the current phase using the "Phase division" below, and assemble it in the form of the "Phase draft" below. Completion criteria: satisfy all of the following- Every phase in this round has all its prerequisites already merged
- Every file in this round is handled by exactly one phase
- At each seam, the phase that creates it (within this round) and the work it uses (list items) are written
- It fits within 50 lines
-
Conform to the conventions and the current implementation — Only once, before showing the phase draft to the user for the first time,
kstack-skill-reviewhave the subagent usingkstack-drift-reviewreview the phase draft in parallel, and root reflects the findings in the draft (do not let the subagents rewrite it). If a draft with placements or seams that deviate from the conventions, or that conflicts with the current code or documents, is handed off as is, the contract children conforming to the draft cannot fix it, and parallel children will copy the same discrepancy. Give the subagents the full text of the phase draft (to be treated as a design document), the absolute path of the repo, and the following way to read it. Completion criteria: all findings are classified as either "fixed" or "not fixed (with reason)", and the draft satisfies the completion criteria of step 2- skill-review: Treat the files in charge as code with seam types/APIs and screens, and select the SKILLs to apply
- skill-review: Since the internal construction of a phase is left to the children and is not in the draft, the conventions for how to write function bodies (hooks used, state holding, validators, query writing, test assembly) are out of scope. Findings of that kind will be caught when the children run their assigned files through skill-review, so do not write them in the draft
- skill-review: Type and field names are the contract with the children written in Japanese, so do not treat them as violations of naming conventions. Identifiers are decided by the children according to the repo's naming conventions (apply naming conventions to file paths)
- drift-review: Cross-check what the draft lists as existing and the assigned files to be changed against the current code. For documents that will become outdated if implemented as drafted, flag only those that are not included in the charge of any phase in this round (if included, the phase in charge will fix them. Those decided to be fixed in a later phase are added to the list)
-
Agree — Show the phase draft in chat. At the same time, briefly show the findings fixed in step 3, and the findings not fixed, items needing confirmation, and discrepancies between SKILLs (with reasons). For "things you want decided", after showing the draft, ask in chat according to the following rules, and proceed only after receiving answers. Reflect the user's findings and answers in the draft and show it again. Do not rerun the review in step 3; root confirms that the completion criteria of step 2 are met. Completion criteria: the user approves, and all conclusions on the things you want decided are given
- Do not use omp's ask tool (the multiple-choice question UI). Write questions in the chat
- Ask only one question per reply. Wait for the answer before asking the next one
- Include background and decision material (actual code, diffs, comparison tables) with the question
- You may present options and a recommendation (tentative). However, accept answers outside the options as well
- When asking again, rewrite the background, premises, and decision material. Do not ask by merely referring to a previous message, such as "How about the question I asked earlier?"
- If the user answers only part of the question, proceed with only what was answered. Ask the rest as the next single question, rewriting it from the background
- Anything decided through exchanges with the adviser, child sessions, or subagents must be written in a form visible to the user before proceeding. Do not assume conversations the user has not read
Bad: 決めてほしいことを ask tool に選択肢だけで渡す。または、複数の問いをチャットに並べて turn を終える。答えの無かった問いを「先ほどの質問はいかがでしょうか」とだけ催促する Good: 1 項目について、背景と関係するコードを添え、選択肢とおすすめを示して聞く。答えを案に反映してから次の項目を聞く。聞き直すときも背景から書き直すWhy: the ask tool has little room to write background, so the user ends up choosing without seeing the decision material, and it is hard to think of answers outside the prepared options. Questions placed in the chat let the turn proceed even if only part is answered, and missed answers and reminders increase back-and-forth. The user does not remember questions from several turns ago or exchanges with children or subagents, so a reminder that only refers back cannot be answered.
-
Take over and supervise — Replace the extracted items with per-phase todos. Confirm that it is the root's
intercom({ action: "status" })がConnected: Yes, and note down theSession ID. If you cannot connect, tell the user at root what settings are needed and stop; do not move the point of contact to the child. Start only the current phase with a handoff prompt filled in with the work location and the root's contact information, and note that if there are multiple phases, they should be started in parallel. Read the installedkstack-handoffのSKILL.md, and determine the terminal using "Select a terminal" in the reference file it points to. If it is Herdr or Tern, launch the child withkstack-handoff, and the root manages questions, user review, commit after approval, and any push, PR, or merge explicitly specified by the user. If operating the terminal or reading the reference file fails, do not switch to manual handoff; report to the user what failed and stop. Only when running in a terminal that is neither Herdr nor Tern, follow "Hand off manually", and even after the user launches the child, the root receives reports and questions, and requests user review withskill://kstack-review-request. The root checks the child's status, and does not ask the user to patrol the child's terminal screen or forward reports. If the child asks for approval of an implementation that deviates from existing patterns, the root does not decide on its own but asks the user, and returns the conclusion to the child. When all phases of this round have been merged, return to step 2 if any remain in the list, and finish if none remain. Completion condition: approval for this round's phases and the explicitly permitted integrations are confirmed. If there are phases awaiting permission or unmerged, leave a waiting state at rootFor phases where the UI (appearance and operation) changes, the user review is
skill://kstack-review-requestFirst run the live review (the dev server URL reported by the child), have the child fix the issues it points out, and then move on to the code review (the diff). Phases where there is nothing to verify live, such as wording-only fixes, may be skipped, but write the reason for skipping in the gate's未解決事項.Bad: 画面を変えたフェーズを差分だけで review に出し、動作や崩れを user が merge 後に見つける Good: 子の dev server で live review → 指摘を子が直す → 差分のコード reviewWhy: The diff does not reveal the behavior when run or the visual breakage. Since visual feedback changes the code, doing the live review first saves you from having to redo the code review.
Phase plan
Write the following 5 things in the chat. Write only the current phase and keep it to an amount the user can read in one screen (within 50 lines).
- Purpose and out of scope — 1–2 lines each. Also give the feature a short name in lowercase English letters and
-(kstack-handoffの<feature>). Use the same name from the second time onward - To do — Write the remaining work needed to meet the completion criteria, one item per line; mark merged items as "done" and add the N of the phase that item enters this time. Do not split later work into phases; just add the conditions under which it can start
- Phase table and order — The current phase's name, goal, owner, prerequisites, and completion criteria. The name is a short word in lowercase English letters and
-, and becomeskstack-handoffのp<N>-<名前>. Continue N from the previous round. Add the reason for splitting the phases in one line on the order row. Write in one line below the table what happens if the screen-building phase succeeds and if it fails - Interface — The shapes this phase creates and later work uses. Shared types, API requests and responses per status, values passed to another phase's component, and for CI, job names and config keys, etc. At the end, add "N creates, <list items> use"
- Decisions needed — Things that require the user's judgment. New tables, external services, permissions, placeholder values, and implementations that deviate from existing patterns identifiable at the proposal stage (those listed in the handoff prompt), etc.
# メンバー招待(invite)
project の owner が、メールで member を招待できるようにする。対象外: 招待の取り消しと期限切れ。
やること
- 招待の型を作る(1 済)
- 招待 API を作る(2)
- 招待フォームを作る(3)
- メンバー画面から招待できるようにする(2 と 3 の後)
2 と 3 を並列に始める。どちらも 1 が作った型だけが前提なので、並列にできる。
| N | 名前 | ゴール | 担当 | 前提 | 完了条件 |
| - | ---- | -------------------- | ----------------------------- | ---- | ----------------------- |
| 2 | api | 招待 API が動く | api/ の招待 API 一式 | 1 | use case のテストが通る |
| 3 | form | 招待フォームが描ける | web/components/InviteForm.tsx | 1 | 描画テストが通る |
3 のフォーム: 送信中は送信を押せず、エラーの文言を受け取って出す。
つなぎ目
- POST /api/projects/:projectId/invitations(2 が作り、メンバー画面が呼ぶ)
- 認証: project の owner だけ。request: `{ メール, 役割 }`
- response: 201 `{ 招待 }` / 403 owner ではない / 409 既に member か、招待済み
- フォームに渡す値 = `{ 送信中, エラー, 送信する }`(3 が作り、メンバー画面が渡す)
決めてほしいこと
- 招待の table を新しく作る — 仮置き: unique は (プロジェクト ID, メール)
- 招待メールの文面 — 仮置き: 固定文
Bad: フェーズの中で閉じる関数まで並べる。子が決められることを user が読み、決めてほしいことが埋もれる
招待を作る(プロジェクト ID, メール, 役割) → 招待。失敗: 既に member, DB, メール送信
├── メンバーをメールで探す(プロジェクト ID, メール) → メンバー?
├── 招待を保存する(招待) → 招待
└── メールを送る(宛先, 件名, 本文)
Good: フェーズをまたぐ形だけ書く。上の「つなぎ目」の 2 項目で足りる
Why: Children disagree only at phase boundaries. How to split functions and files within a phase can be decided by the child by looking at the repo. Children in later phases use the code names created by earlier phases as they are. The more you write, the more the decisions the user wants to verify get buried. The reason for not creating a separate design document is that the child reads only the handoff prompt, and keeping the same content in two places means one becomes stale when the other is fixed.
How to write
- State one thing per sentence. Put supplementary notes in a separate sentence
- Write only the reasons that affect decisions in one sentence. If it gets long, make it a "decision needed" and ask the user
- Write using standard tables, bullet lists, and code formats. Do not use symbols that require a legend
- Keep table cells to one line (about 30 characters). Make goals short declarative phrases like "the invitation API works", and write longer explanations in one line below the table
- Things you want decided should be one item per line (within 60 characters), written in the form "what — tentative: short value". Do not attach reasons to items; answer when the user asks.
- Write the names of functions, components, types, and items in Japanese. Write endpoints and file paths as they are.
- Do not write things that can be understood by reading the repo's code or configuration; have the child read them.
Why: a proposal the user cannot read through will be approved without being verified, and the discrepancy remains through to the child's implementation.
How to divide phases
Make only work that can be started now (work whose prerequisites have all been merged) into phases. Later work is cut out after the preceding phase is merged, by looking at that code. If there are multiple pieces of work that can be started now, they may be made into parallel phases in the same round. A single file is handled by only one phase. Write ownership by directory, and decide only files that two phases could touch (registration index, package.json, lock file, etc.) by file name. Decide prerequisites at the seams, and the using side is cut out after the phase that creates it is merged. Parallel phases do not use each other. For UI, separate into display components that draw only from received values and connections that call the API and pass values. Display components are built in parallel with the API based only on the types they use (props match the shape of the API response so the connection can pass them as is), and connections are cut out after both are merged. Make one phase the size that finishes in one session, and attach verifiable completion conditions. If the whole job fits in one session, do not divide it and make it one phase. However, when there is an order in which you want to merge and verify first, divide at that boundary.
Bad: UI 全体を API の後の回に回し、表示まで API を待って直列になる
回 1: 1 API — api/routes/invitations.ts, api/routes/index.ts
回 2: 2 UI — web/routes/members.tsx(前提 1)
Good: 表示は型だけを前提に API と同じ回で並列にし、接続だけを後の回に回す。index は API のフェーズだけが持つ(上の表)
Why: if work whose prerequisites are not finished is made into a phase first, the proposal becomes stale when the situation changes due to the preceding phase's implementation. If parallel children touch the same file, one change is overwritten or conflicts in the merge. A phase whose consumer does not yet exist cannot pass type checking, and completion cannot be verified. A phase that is too large uses up the child's context and drops prerequisites midway. Dividing small work makes the overhead of starting sessions and PRs larger than the work itself.
Handoff prompt
Output in the following form for each phase. The child has no conversation history and reads only this prompt. Fill in the work location, branch, and the root's full Session ID before starting, and paste in full from the proposal the seams and decisions that concern the owner. If there are no other phases in the same round, remove the one sentence that says so.
フェーズ N(<名前>)を実装してください。目的: <機能の 1 行>。同じ回のほかのフェーズ(<N 名前: ゴール>, …)は別の session が担当します。
- 作業場所: `<worktree の path>`(branch `<branch>`)。repo の変更はこの worktree の中だけにする
- root の連絡先: `<root の full Session ID>`。この session は子で、user との会話と user review の窓口は root が持つ
- 開始: `intercom({ action: "status" })` が `Connected: Yes` であることを確かめ、自分の full Session ID とフェーズ N・cwd・branch を `intercom({ action: "send", to: "<root の full Session ID>", message })` で root に報告する。連絡先が未指定、接続できない、送信できない場合は実装を始めず、子が user review の窓口になる代替には切り替えない
- 質問: 依頼文だけでは決められないことは `intercom({ action: "ask", to: "<root の full Session ID>", message })` で root に聞く。user に聞きたいことも root に聞く。ask が timeout したら turn を終えて root からの message を待つ
- 担当: <ファイル・ディレクトリ>。触るのはここだけ
- つなぎ目(user と合意済み。この形に合わせる): <フェーズ N が作るつなぎ目>
- 決めたこと: <フェーズ N にかかる「決めてほしいこと」の結論。仮置きは「仮置き」と書く>
- 名前は日本語で書いてある。識別子と型の書き方は repo の規約で決める(つなぎ目は形が一致すればよい)。前提フェーズで作られたものと既存のものは、コードにある名前をそのまま使う。フェーズの中の関数やファイルの分け方は、既存パターンに倣う範囲で自由に決めてよい
- つなぎ目のとおりでは実装できない、または担当外のファイルを変える必要が出たら、そこで止め、理由と変更案を intercom の `ask` で root に報告する
- 既存の実装の拡張と言えない実装は、書く前に止め、外れる案と既存に倣う案を代償付きで intercom の `ask` で root に聞き、承認されたものだけ書く。該当するのは、この prompt で決まっていない次のもの: 新しいディレクトリの作成(既存のディレクトリの下に足すものも含む)、新しい package・レイヤー、テストの無い package・app へのテストの追加、repo に前例の無い書き方(ライブラリの内部構造への依存、新しい依存など)、規約に抵触しうる切り方(1 ファイルに複数の責務など)、既存の関数・モジュールが持つ責務の移動(採番や計算をする場所を変えるなど)。前例に倣う形の拡張(項目の追加、型の generic 化など)は含めない。完了報告で事後に知らせて済ませない
- 完了条件: <フェーズの完了条件>
- 完了条件を満たしたら、最初の報告の前に 1 回だけ、`kstack-skill-review` を使う subagent、`kstack-drift-review` を使う subagent、`ponytail-review` を使う subagent に、並行して担当ファイルだけをレビューさせる。drift-review にはつなぎ目の全文も渡す(ほかのフェーズの担当ファイルはまだ無くてよい)。`ponytail-review` が環境に入っていなければ、代わりに review せず、入っていないことを報告に書く。subagent には直させず、指摘はあなたが直し、直した後も完了条件を満たすことを確かめる。つなぎ目か担当外のファイルを変えないと直せない指摘と、ponytail-review の指摘のうち決めたことを削る・既存パターンから外れる修正になるものは、直さずに報告する。報告の後に届く review の指摘を直すときは、この 3 つのレビューを回し直さず、完了条件だけ確かめて報告する
- 最後に、フェーズ N・cwd・branch・変更したファイル・完了条件ごとの確認コマンドと結果・skill-review と drift-review と ponytail-review で直した指摘と直さなかった指摘(理由付き)・つなぎ目との差分を、intercom の `send` で root に報告して turn を終える
- UI(見た目・操作)を変えたら、完了報告に dev server の URL(`localhost:<port>`)を書き、root から review 終了が届くまで dev server を止めない(root がその URL で live review を開く)
- user review の依頼・指摘への返信・再依頼と、review の開始・終了は root に任せ、user に直接 review を頼まない。user がこの端末の画面で review を頼んだ場合も root に連絡して窓口をそろえる。root から届いた指摘を直して再検証し、指摘ごとの対応結果と返信文を intercom の `send` で root に返して待つ
- commit: user review の承認が root から届くまでは commit しない。承認が届いたら、担当の変更だけを `skill://kstack-git` の「commit の書き方」で自分の worktree の branch に commit し、commit hash を intercom の `send` で root に報告する(承認を commit の許可とみなす)
- push・PR・merge は、user が明示した許可と範囲を root から受け取ったときだけ行う。PR は `skill://kstack-git` の「PR の作り方」で作り、PR を作っただけでは merge しない。merge を許可されたら `skill://kstack-git` の「PR を merge する」に従い、CI と approve がそろっていなければ merge せずに root に報告する。PR の URL・merge commit などの結果は intercom の `send` で root に報告する。review の承認から push・PR・merge の許可を推測しない
The reason to have the child stop and report to root is that the seams have already been agreed with the user and serve as the premise for later phases, and files outside its responsibility may be touched by another child in the same run. For the same reason, the child is not made to fix convention issues that come from the seams; root decides whether to fix them. The reason to make it stop before writing an implementation that deviates from existing patterns is that, once the code is written, a report afterward makes the user more likely to bend their judgment out of concern for the rework cost, and a deviation merged without approval gets copied as precedent by children in later phases. The reason to write the contact and review channel into the prompt is that the child does not read this SKILL. Reports reach root directly via intercom regardless of the launch method. Root fixes the seams, re-agrees with the user in step 4, and reissues the handoff prompts for the affected phases.