Take inventory of an existing Issue tree and update the root issue body to the latest state (only the management block. Handwritten body text is preserved). Reassign open issues left under closed parents, relocate orphans, and synchronize phase labels, maintaining a structure that implement-issue-tree can consume via post-order DFS.
Usage
Pass the root tracking issue number as an argument.
--granularity Optionally, you can specify a granularity criterion (the upper limit of implementation time to fit into one issue).
2h・4h・1h Specify it as a positive integer plus a time unit (h). The priority order is
--granularity explicit > the root issue body's <!-- granularity: Nh --> marker > default 2h
(same granularity criterion and same marker format as create-issue-tree). The value is finalized as GRANULARITY
in Step 1 and used for the judgments in Step 2 and Step 7. When Step 8 updates the management block after the inventory,
GRANULARITY keep exactly one marker line at the top using the finalized value of
update-issue-tree 42
update-issue-tree 42 --granularity 4h
Prerequisites
ghThe CLI is installed and authenticated (check withgh auth status)- You have Issue write permission for the target repository
- The target tree iswithin a single repositoryand is self-contained. GitHub sub-issues can be linked across repositories, but this skill treats cross-repository sub-issues asout of scope.
Writing to the parent repository is outside this skill's prerequisites (write permission for the target repository);
this structurally prevents accidents where an issue with the same number in the wrong repository is operated on. The implementation of this contract is
scripts/reassign-sub-issue.shの fail-closed by exit 2(see the exit code table in Step 3 below). Because exit 2 is also shared with gh/jq being absent, being unauthenticated, or issue fetch failure (a resolvable prerequisite deficiency), only in this case isreason=cross-repository-parentadditionally output to stderr as a stable marker line (see the exit code table) - When the parent of the target issue isin another repository,
scripts/reassign-sub-issue.shcan only process that issue after the parent link is removed on the parent repository side andparent_issue_urlbecomes null (not linked to any parent). Removing a cross-repository parent link is an operation on the parent repository side, performed by someone with write permission for that repository. It is outside the scope of this skill - Reassigning a parent within the same repository is a core function of this skill and is not subject to the above null requirement.
Step 3 handles the approved old parent
--old-parentto execute DELETE→POST, there is no need to setparent_issue_urlto null beforehand (relocation of orphans is handled by Step 4 with--old-parentomitted)
Flow
Step 1: Recursively fetch the entire tree
Recursively call the sub_issues API from the root issue to fetch the tree structure of all hierarchies.
Taking pagination into account, fetch all items withper_page=100 .
ROOT_NUMBER="<ルート issue 番号>"
# --granularity の値は代入前に Claude 側でも同じ正規表現(^[1-9][0-9]*h$)で検証し、
# 不一致なら**このフェンスを実行せず**ユーザーに再指定を求める(未信頼値を生成済みシェルへ
# 埋め込まない)。優先順位は --granularity > ルートのマーカー > 既定 2h の順。
# --granularity で渡された時間を実際の値で代入する(実行時に Claude が置き換える)
# 例: --granularity 4h が指定された場合 → GRANULARITY_ARG="4h" / 未指定の場合は空文字
GRANULARITY_ARG="<--granularity で渡された時間(未指定なら空文字)>"
if [[ -n "${GRANULARITY_ARG}" ]]; then
GRANULARITY="${GRANULARITY_ARG}"
GRANULARITY_SOURCE="--granularity 引数"
else
# ルート本文の取得失敗とマーカー不在は分離する。取得失敗は「粒度を既定へ倒さず中止」する
# (gh issue view 自体の失敗を || true で握り潰すと、権限エラー・issue 不在等を
# 「マーカーなし」と誤読して既定 2h へサイレントに倒れてしまうため)
ROOT_BODY=$(gh issue view "${ROOT_NUMBER}" --json body --jq '.body') \
|| { echo "エラー: ルート issue #${ROOT_NUMBER} の本文を取得できません。粒度を既定へ倒さず中止します。"; exit 1; }
# 既存ルート本文の <!-- granularity: Nh --> マーカーから継承する。マーカーが無ければ既定 2h
# (|| true は grep のマーカー不在にのみ掛かる。gh issue view 自体の失敗は上で既に処理済み)
ROOT_GRANULARITY=$(printf '%s\n' "${ROOT_BODY}" \
| grep -oE '<!-- granularity: [1-9][0-9]*h -->' | head -1 | grep -oE '[1-9][0-9]*h' || true)
if [[ -n "${ROOT_GRANULARITY}" ]]; then
GRANULARITY="${ROOT_GRANULARITY}"
GRANULARITY_SOURCE="ルート issue #${ROOT_NUMBER} のマーカー"
else
GRANULARITY="2h"
GRANULARITY_SOURCE="既定値"
fi
fi
# 許可する構文は正整数 + h のみ(例: 1h / 2h / 4h)。引用符・空白・コマンド置換・0h・単位なしは
# ここで拒否する(ROOT_GRANULARITY はマーカー抽出時点で同じ正規表現を通しているが、
# GRANULARITY_ARG はユーザー入力の生値のため、代入元によらずこの検証を必ず通す)
if ! printf '%s' "${GRANULARITY}" | grep -qE '^[1-9][0-9]*h$'; then
echo "エラー: --granularity の値 '${GRANULARITY}' は不正です(許可: 正整数+h、例 2h)。中止します。"
exit 1
fi
# 確定値と由来を必ず出力する(既定 2h と読み替えないことをここで可視化する)
echo "粒度基準: ${GRANULARITY}(由来: ${GRANULARITY_SOURCE})"
# ルート直下の sub-issues を取得(ページネーション対応)
fetch_sub_issues() {
local PARENT="${1}"
local PAGE=1
while true; do
RESULT=$(gh api \
"repos/{owner}/{repo}/issues/${PARENT}/sub_issues?per_page=100&page=${PAGE}")
echo "${RESULT}"
COUNT=$(echo "${RESULT}" | jq 'length')
if [ "${COUNT}" -lt 100 ]; then break; fi
PAGE=$((PAGE + 1))
done
}
# ルートから再帰的にツリーを構築
fetch_sub_issues "${ROOT_NUMBER}"
The subsequent Steps use the value of GRANULARITY output in Step 1 (do not reinterpret it as the default 2h).
For each issue, record state(open / closed), labels, and title to create a tree map.
Step 2: Identify inventory targets
Analyze the fetched tree map and identify the following cases.
| Case | Handling policy |
|---|---|
| An open issue remains under a closed parent | Reattach to an appropriate open Phase parent |
| There is an orphan issue not linked to any parent | Link to the corresponding Phase parent (if the Phase is unknown, confirm with the user) |
| There is an issue whose phase label does not match its parent | Sync the label |
| There is a new task that does not fit into an existing Phase | Consider creating a new Phase parent |
Implementation time is ${GRANULARITY}(determined in Step 1; default 2h) An issue exceeding this is not broken down |
Break down into sub-issues (same granularity criteria as create-issue-tree) |
| The parent of the target issue is in another repository (cross-repository sub-issue) | Out of scope for this skill. Exclude from inventory targets and note in the items requiring confirmation in Step 9 |
Present the list of inventory targets to the user, obtain confirmation of the policy, and then execute the changes.
Reduce the approved targets into the two plan arrays read by Step 3 / Step 4. The array must always be declared
(declare it as an empty array even if there are 0 targets). If you proceed to Step 3 / Step 4 without declaring it,
"${REASSIGN_PLAN[@]}" will expand to empty, and even if there are approved targets, it will complete with 0 items without error and proceed to the completion report, so at the beginning of both steps check whether it is declared and stop fail-closed.
# 承認された「closed 親下の付け替え」対象。要素は "<issue> <old-parent> <new-parent>"。
# 空白区切りの 1 行 1 件にするのは、Step 3 のループが read で分割して受け取るため。
# issue 番号は全て 10 進の正整数であり、空白・改行を含まないことを Step 1 の取得時に保証する。
REASSIGN_PLAN=(
# "123 456 789"
)
# 承認された「孤児の再配置」対象。要素は "<orphan-issue> <phase-parent>"。
ORPHAN_PLAN=(
# "234 789"
)
Even when there are 0 targets, as described above, declare it as anempty array. "No targets (empty array)" and "plan unset (undeclared)" have different meanings, and the latter is a failure to execute Step 2 and is not a normal case.
Step 3: Reattach remaining open issues under closed parents
Move open issues remaining under a closed parent to the corresponding open Phase parent.
The two-stage operation of "DELETE from the old parent → POST to the new parent", along with the idempotency check before and after it and the post-verification, are
scripts/reassign-sub-issue.sh consolidated (raw in the SKILL.md body gh api , this produces defects such as proceeding to POST without detecting a DELETE failure).
The shared processing required by the caller (existence and type validation of the plan array, interpretation of the exit status of a single-item call) is
scripts/reassign-lib.sh and is used by Step 3 / Step 4 each sourcing it.
Each code fence may be executed in an independent shell(reassign-sub-issue.sh .
Therefore, we do not adopt a configuration in which shared processing is defined within one fence and reused by the other. At the time Step 4
is executed, the function definition is not inherited, resulting in command not found , and no orphan relocation is executed at all. The fences of both Steps are self-contained with the same preamble,
resolving and sourcing
reassign-lib.sh .
The deployment root of this skill differs depending on the installation form (source of this repository /npx skills add by
vendoring/.claude/skills/ via symlink). Before sourcing, check the 3 layouts in order and
adopt the one that exists (the same idea as implement-issue-tree's scriptPath 3 Layout and contribute-skill's
LOCAL_SKILL_DIR resolution).reassign-sub-issue.sh is not specified here——
because the library resolves it as a sibling from its own actual location, so the paired actual files always combine under any installation form.
# reassign-lib.sh を 3 レイアウトから解決して source する。
# **この前置きは Step 3 / Step 4 の両フェンスが同一の内容で持つ。** 手順書のコードフェンスは
# ブロックごとに独立シェルで実行され得るため、片方のフェンスで定義した関数・変数がもう一方へ
# 継承される保証がない(Issue #372 / PR #374 codex-review P1)。
REASSIGN_LIB=""
for CANDIDATE in \
"skills/update-issue-tree/scripts/reassign-lib.sh" \
".agents/skills/update-issue-tree/scripts/reassign-lib.sh" \
".claude/skills/update-issue-tree/scripts/reassign-lib.sh"; do
# 存在確認は -f のみで行う(-x にすると、npx skills add 等の vendoring で
# 実行ビットが落ちたファイルを「存在しない」と誤検知し、3 レイアウトいずれにも
# 見つからないという誤ったエラーメッセージになる)
if [[ -f "${CANDIDATE}" ]]; then
REASSIGN_LIB="${CANDIDATE}"
break
fi
done
if [[ -z "${REASSIGN_LIB}" ]]; then
echo "エラー: reassign-lib.sh が見つからない(3 レイアウトいずれにも存在しない)" >&2
exit 1
fi
# ライブラリは対の reassign-sub-issue.sh の存在まで確認したうえで、reassign_one /
# require_plan_array と REASSIGN_SCRIPT を定義する。欠落していれば非ゼロを返すので中断する。
# このフェンスで set -euo pipefail を使ってはならない(理由は reassign-lib.sh 冒頭のコメント参照。
# set -e があると reassign_one 内の `status=$?` 退避に到達せず、Issue #335 の欠陥が再発する)
source "${REASSIGN_LIB}" || exit 1
# 計画配列の存在・型ガード(fail-closed)。詳細は reassign-lib.sh の require_plan_array を参照
require_plan_array REASSIGN_PLAN || exit 1
# 呼び出し側ループ。契約の主体はここにある——「(b) 恒久的な対象外は次の 1 件へ進み、
# (a) 解消可能な前提不備は原因解消まで中断する」を実際に実現するのはこのループである。
# ISSUE_NUMBER / OLD_PARENT / NEW_PARENT は Step 2 で構築した REASSIGN_PLAN から供給する。
SKIPPED=()
NEEDS_REVIEW=()
for ENTRY in "${REASSIGN_PLAN[@]}"; do
# ENTRY は "<issue> <old-parent> <new-parent>" 形式。
# zsh は未クォートの展開を単語分割しないため、read で明示的に分割する
IFS=' ' read -r ISSUE_NUMBER OLD_PARENT NEW_PARENT <<< "${ENTRY}"
# `if reassign_one ...; then ... fi` の形にしてはならない。条件が偽で else が無い場合、
# `fi` の直後の $? は 0 になり(実測済み)、失敗が「成功」として読まれて
# (a)/(b)/(c) の判定も中断もすべて素通りする。`|| status=$?` で明示的に退避する。
status=0
reassign_one --issue "${ISSUE_NUMBER}" \
--old-parent "${OLD_PARENT}" \
--new-parent "${NEW_PARENT}" || status=$?
if (( status == 0 )); then
continue
fi
if (( status == 9 )); then
# (b) cross-repository 親。棚卸し対象から除外して次へ(Step 9 の要確認事項へ記載)
SKIPPED+=("${ISSUE_NUMBER}")
continue
fi
if (( status == 10 )); then
# (c) 補償復旧が成功し旧親へ復帰済み(本来の付け替えは未達)。fatal にせず要確認事項へ
# 記録して次の 1 件へ進む。exit 10 を中断扱いにすると残りの REASSIGN_PLAN が未処理のまま
# 中断し、Step 4 の孤児処理・Step 9 の報告経路自体がスキップされてしまう
NEEDS_REVIEW+=("#${ISSUE_NUMBER}: exit=10 restored — 旧親 #${OLD_PARENT} へ復帰済み。新親 #${NEW_PARENT} への付け替えは未達")
continue
fi
if (( status == 11 )); then
# (c) DELETE 後、第三者が別親を設定済みのため補償せず見送り。同一コマンドでの再実行禁止を
# 記録に残したうえで、fatal にせず次の 1 件へ進む
NEEDS_REVIEW+=("#${ISSUE_NUMBER}: exit=11 third-party-parent — 旧親 #${OLD_PARENT} から DELETE 済み、第三者が別親を設定済み。同じコマンドで再実行禁止。stderr の実測親を確認しユーザー承認のうえ再実行すること")
continue
fi
# (a) それ以外(exit 1-8。9・10・11 を除く)は握り潰さず中断する。原因を解消してから再実行する
echo "エラー: #${ISSUE_NUMBER} の付け替えが exit ${status} で失敗した。中断する" >&2
exit "${status}"
done
if (( ${#SKIPPED[@]} > 0 )); then
echo "対象外(cross-repository 親): ${SKIPPED[*]}" >&2
fi
if (( ${#NEEDS_REVIEW[@]} > 0 )); then
echo "要確認事項(Step 9 のレポートへ転記すること):" >&2
printf ' %s\n' "${NEEDS_REVIEW[@]}" >&2
fi
reassign_one はA call for a single item, and a non-zero exit isthe failure of that single itemand is propagated to
the function's return value. Since stderr required for the determination is captured within the function and then always re-output,
diagnostic information is not lost. The caller loop records it in the Step 9 items requiring confirmation, and then
routes it into the following 3 cases.(a) Resolvable prerequisite deficiencies(of exit 2, gh/jq such as absence, unauthenticated, issue retrieval failure, etc.
In general, exit 1–8 excluding 9, 10, and 11) suspends until the cause is resolved.(b) Permanently out of scope
(cross-repository parent. exit 9) is recorded in the items requiring confirmation and excluded from the inventory target, then proceeds to the next
single-item call.(c) Partially changed but processing may continue(exit 10 = compensation recovery after DELETE succeeded and returned to the old parent / exit 11 = after DELETE a third party has already set another parent so compensation is omitted)
are recorded in the items requiring confirmation, and then proceed to the next single item without making it fatal. If exit 10 / 11 were immediately
suspended with exit ,
the remaining REASSIGN_PLAN would stop unprocessed, and Step 4's orphan processing and Step 9's reporting path themselves
would be skipped, which is a defect; therefore, these 2 codes do not stop the loop (see the exit code table).
The determination of (a)/(b) is performed mechanically based on whether reason=cross-repository-parent appears in stderr
(if not, (a)). For (c), since the return value is directly 10 / 11, no stderr marker is needed for the determination.
Reason only (c) is made a continuation target (exit 3/4/5/7/8 are not continued): Looking at the exit code table,
exit 3, 4, 5, 7, and 8 also have "record in items requiring confirmation" in the "caller handling" column, which at first glance
looks the same as (c). However, the branching point of whether to stop or not stop is not "whether to record in items requiring confirmation" but
whether the terminal state of that one item is confirmed by actual measurement. exit 10 / 11 occur when the compensation recovery routine re-fetches the actual state and then lands on theconfirmed terminal statesof "under the old parent" or "under a third-party parent", and proceeding to the next item will not cause new destruction. In contrast, exit 3 (DELETE failure), 4 (POST failure), 5 (post-verification mismatch), 7 (race at POST time), and 8 (compensation also failed, state unknown/orphaned) are either unchanged, orphaned, or state unknown, and the cause (gh auth expiry, API failure, race condition) is likely to affect all subsequent items in common
so stop after one item and prioritize investigating the cause. This boundary is limited to exit 10 / 11, and must not be easily extended to 3/4/5/7/8.
Arguments
| Argument | Required | Meaning |
|---|---|---|
--issue |
Required | Issue number to be reparented |
--new-parent |
Required | Issue number of the reparent destination. Before DELETE, GET the new parent and verify that it exists,--issue that it is not itself (self-reference), and that it is in the same repository as the target issue. If any of these is not satisfied,without issuing a single DELETE, exit 1 (self-reference) / exit 2 (does not exist / different repository) and terminate unchanged |
--old-parent |
Optional | Current parent. Pass the old parent approved by the user in Step 2. If it differs from the actually measured current parent,without changing anything, stop with exit 6(to avoid destroying a parent-child relationship that was not approved). If omitted, it means that "it is an orphan" was approved, and if a parent is found by actual measurement, similarly stop with exit 6 |
--repo |
Optional | owner/name。Location of the target issue (--issue), not the location of the parent (--old-parent / --new-parent). If omitted, resolve from the cwd's git remote.--repo switches all API paths, not only the GET of the target issue but also DELETE / POST, so do not put the value of the parent repository just because the parent is in a different repository (doing so will erroneously operate on the issue with the same number in the parent repository) |
Exit codes and result= lines
The last line of stdout returns a machine-readable breakdown in the format result=<state> issue=<n> new_parent=<n> old_parent=<n|-> .Non-zero exits must not be ignored even once, and must always be recorded in the "Items requiring confirmation" section of the completion report in Step 9.
| Exit code | state |
Meaning | Caller handling | Whether changed |
|---|---|---|---|---|
| 0 | reassigned |
Performed DELETE→POST | Count toward the "reparented" count | Changed (success) |
| 0 | already-attached |
Already under the new parent (no-op) | Do not count toward the count | Unchanged (no-op) |
| 0 | posted-only |
Not under the old parent, POST only | Counted toward the "orphan relocation" count (same script as Step 4) | Changed (POST only) |
| 1 | — | Argument/usage error (--new-parent contains a self-reference) |
Executor error. Fix and re-run | No change(API not executed) |
| 2 | — | Precondition not met. Two types are mixed; determine mechanically via the marker line instderr: reason=cross-repository-parent If present, (b); if absent, (a). (a) Resolvable and re-runnable (gh/jq not present, unauthenticated, issue retrieval failed,new parent does not exist・new parent is a Pull Request・new parent is in a different repository)と、(b) permanently out of scopecross-repository parent (not resolved by re-running the same command; this skill cannot process it until the parent link is removed on the parent repository side) |
(a) Resolve the cause and re-run. (b) Note it in the items requiring confirmation and exclude it from the inventory scope (see Step 2) | No change(DELETE / POST not executed) |
| 3 | — | DELETE failed (gh exited non-zero).POST was not executed. Do not trust only the DELETE response; re-fetch and verify the actual state's stability, and confirm by actual measurement that it remains under the old parent before finalizing (if only the response retrieval failed and it succeeded server-side, it proceeds to the POST stage as an orphan, so this exit is not reached) | Note in items requiring confirmation. Remains under the old parent | No change(confirmed by actual measurement. DELETE failed, remains under the old parent) |
| 4 | — | POST failed (orphan path only. Since DELETE is not involved, there is no orphanization risk itself). Do not trust only the POST response; re-fetch and verify the actual state's stability, and confirm by actual measurement that it remains an orphan before finalizing (if only the response retrieval failed and it succeeded server-side, it becomes posted-only with exit 0, so this exit is not reached) |
Note in items requiring confirmation | No change(confirmed by actual measurement. DELETE not executed) |
| 5 | — | Not found under the new parent in post-verification (including cases where it is under a parent in a different repository) | Note in items requiring confirmation. Manually verify the actual state | Changed (DELETE / POST executed; manual verification of the actual state required) |
| 6 | — | The approved old parent and the actual measurement disagree. Nothing was changed | Note in items requiring confirmation.Do not re-run with the same command. Present the actual parent indicated by stderr to the user, obtain approval, then--old-parent put that value into and re-run |
No change |
| 7 | — | A race that had a different parent at the time of POST.No change because DELETE was not executed | Record in the items requiring confirmation. Re-measure and obtain approval again, then re-execute. | No change(DELETE not executed) |
| 8 | — | Re-acquisition of the actual state and stability confirmation for any of the following three casesended as an orphan / with unknown state / under a third party's parent: (1) Compensatory recovery for a POST failure after DELETE (either the compensatory POST itself failing, the re-acquisition for recovery failing, a verification mismatch after compensation, or a re-confirmation mismatch due to reflection delay.reason=compensation-post-failed(also an orphan when actually measured) / reason=compensation-post-failed-third-party-parent(actually measured that a third party had already set a different parent while the compensatory POST was failing) to determine the breakdown), (2) Re-acquisition of the actual state when DELETE fails (because the DELETE returned an error response but may have succeeded on the server side, re-acquisition was performed without concluding exit 3 from the response alone, and as a result the re-acquisition itself failed, mismatched, or was unstable), (3) Re-acquisition of the actual state when the orphan-path POST fails (because the POST returned an error response but may have succeeded on the server side, re-acquisition was performed without concluding exit 4 from the response alone, and as a result the re-acquisition itself failed, mismatched, or was unstable). Both (2) and (3) produce reason=recovery-state-unknown . The re-acquisition-related failure in (1) also produces the same reason=recovery-state-unknown . |
Record in the items requiring confirmation.None of these is no change (unknown state that could not be determined by actual measurement). Confirm the actual state and, if necessary, relink manually. Re-executing the same command will not recover it. | (1) Partial change(removed from the old parent and not attached to the new parent either. Excluding the case of being under a third party). (2)(3) Unknown state(because it is undetermined whether DELETE / POST succeeded on the server side, do not conclude either no change or partial change) |
| 10 | restored |
Compensatory recovery for a POST failure after DELETEsucceeded, and actual measurement confirmed restoration under the old parent (the original objective of reassigning to the new parent was not achieved) | Record in the items requiring confirmation (because the original reassignment was not achieved). Do not count it in the totals. | Changed(restored to the old parent. Reassignment to the new parent did not succeed) |
| 11 | — | When the actual state was re-acquired,a third party had already set a different parent, so compensation was not performed and it was left as is (reason=third-party-parent). It is reached from either of the following: (a) re-acquisition in response to a POST failure after DELETE, (b) re-acquisition in response to the DELETE failure itself (when re-acquisition was performed without concluding exit 3 from the DELETE response alone, and as a result it was found to be under a third party's parent).If under the new parent, it is directed to the success path (exit 0 / result=reassigned) before this determination, so this exit 11 is reached only when the actual measurement shows a different parent that is neither the old parent nor the new parent. |
State in the items to confirm.Do not re-execute with the same command. Present the actual measured parent indicated by stderr to the user, obtain approval, and then re-execute | Changed(Already DELETE'd from the old parent."Stop fail-closed without firing a compensating POST" is about the POST side toward the new parent, and the DELETE has already succeeded by the time it reaches exit 11 (as long as it appears under a third party's parent, in the server-side data model it has already been detached from the old parent). In actual measurement, it is under a different parent set by a third party) |
The script itself returns 0–8, 10, 11 (9 is not used). reassign-lib.sh の
reassign_one In addition to this, the wrapper returns 9 = permanently out of scope (cross-repository parent) . 9 is not the script's exit code but a value the wrapper synthesizes by judging a stderr
reason=cross-repository-parent marker, and is used by the caller loop
as a signal to "exclude from inventory targets and proceed to the next item." Since judging the marker
requires the script's stderr, the wrapper captures stderr to a file andalways re-outputs it
(do not suppress diagnostic information). 10 and 11 pass through unmodified under the wrapper's contract that "otherwise return the script's exit code as is," soreassign-lib.sh requires no change.
Contract for compensating recovery when POST fails after DELETE: The new parent's pre-validation eliminates "rejection conditions that can be determined in advance" before DELETE, but races between DELETE and POST and temporary 5xx remain as a residue that cannot be determined in advance. Terminating immediately on POST failure leaves the target issue stranded as an orphan, so upon detecting a POST failure,re-fetch the actual state of the target issueand then branch (determine the actual measurement first, then act):
- If the measured parent is the new parent → the POST was a false negative. Treated the same as a normal successful termination (
exit 0/result=reassigned). However, if the new parent is observed for the first time during a re-check that expected the old parent or an orphan, fetch once more with the new parent as the expected value, and only when the new parent is observed under it twice consecutively, finalizereassigned. If it does not match or re-fetching fails, do not lean toward success but terminate withexit 8(state unknown) - If actually measured as an orphan → a single read alone cannot rule out the possibility of observing a
transitional state due to propagation delay of DELETE/POST, so before performing a write such as a compensating POST, re-fetch after a short interval,
and only when no parent is observed twice consecutively is it finalized as a stable orphan. If stability is confirmed, the reverse operation of the approved operation
(returning to the old parent) is within the approved scope, so fire the compensating POST. If successful, re-take the post-confirmation
exit 10/result=restored. Multiple failures where the compensating POST itself fails, or state-unknown cases where re-fetching, post-confirmation, or stability confirmation fails, terminate withexit 8without writing - Measured: a third party has already set a different parent (including a different repository) → without firing a compensating POST
exit 11and fail-closed stop. Do not overwrite a parent-child relationship finalized by a third party
Re-confirmation of actual state for DELETE failure / orphan-path POST failure: The above is compensating recovery for POST failure after DELETE success (partial change), but DELETE failure itself (reason gh non-zero exits without family markers) and POST failures on the orphan path (without DELETE) are handled similarly.
gh api may return exit code 0 while only response retrieval fails, whereas a non-zero exit does not guarantee that "the operation did not succeed on the server side" (response-retrieval-side failures can also result in non-zero).
Therefore, if you immediately conclude exit 3 / exit 4 (no change) based solely on a non-zero exit of DELETE / POST, it becomes a false report when it actually succeeded on the server side.
Symmetrically re-acquire the actual state before branching:
- DELETE failure → re-acquire the actual state; if it can be stably confirmed to still be under the old parent,
exit 3(no change). If it can be stably confirmed to be an orphan, consider the DELETE to have already succeeded on the server side, and proceed as-is to the POST step (reattaching to the new parent).If it can be stably confirmed to be under the new parent, judge that before the third-party parent determination, regard DELETE→POST as already succeeded (or as already reattached to the new parent whose concurrent execution was approved), and set the sameresult=reassignedでexit 0as the existing success path (if the new parent is observed directly on the first read, align it with the same success terminal as when the new parent is observed during the stability confirmation, so that it does not fall to an unapproved third-party parent (exit 11) merely due to observation timing). Otherwise, if a third party has already set a different parent,exit 11reason=third-party-parent(same handling as the existing compensating recovery path). Failure, mismatch, or instability of re-acquisition isexit 8reason=recovery-state-unknown - POST failure on the orphan path (no DELETE) → re-acquire the actual state; if it can be stably confirmed to remain an orphan,
exit 4(no change). If it can be stably confirmed to be under the new parent, regard the POST as a false negative andresult=posted-onlyでexit 0. Since this path has no DELETE and thus no risk of orphaning itself, no compensating write (POST) occurs (it completes with determination only). Error-message-based race detection (exit 7. "only have one parent") is judged before re-acquisition. Otherwise (failure, mismatch, instability of re-acquisition, or a third-party parent not matching the message),exit 8reason=recovery-state-unknownterminate with
Contract of pre-validation and post-reporting: Rejection conditions that can be determined in advance (nonexistence of the new parent, self-reference, different repository) terminate without change with exit 1 / 2 without firing DELETE. On the other hand,Rejection conditions that cannot be determined in advance (races in which a third party moves the state between the prior GET and DELETE / POST, circular references, states in which the new parent does not accept sub-issues, etc.) are reported after the fact as exit 4 / exit 7 / exit 8. This is a contract, and prior validation does not replace it. Only POST failure after DELETE (a partial change that can result in orphaning) does not get reported immediately via exit but instead, after going through the above compensating recovery routine, lands on one of exit 8 / 10 / 11.
GET count: The GET count per path is as follows (the reassignment / relocation path includes one prior validation of the new parent).
| Path | GET count |
|---|---|
| Normal reassignment (reassigned) | 3 |
| Relocation of orphan (posted-only) | 3 |
| already-attached(no-op) | 1 |
| Approval mismatch (exit 6) | 1 |
The prior validation GET is at most 1, andupdate-issue-tree has on the order of tens of calls per run.
Relative to the authenticated REST limit of 5,000 req/h, this is negligible. In contrast, what it prevents isirreversible orphaning, so it is
worth it. The reason validation is also performed for orphan paths (paths that do not involve DELETE and therefore have no orphaning risk in the first place) is a deliberate decision to unify the contract that "rejection conditions determinable in advance always terminate without changes" regardless of path, and if the new parent does not exist, even an orphan path results in exit 2.
Step 4: Relocate orphan issues
Attach orphan issues that are not linked to any parent to the appropriate Phase parent.
--old-parent is omitted and the same script is called (DELETE is skipped and only POST is executed).
For issues whose Phase is unknown, read the title and body to decide; if it cannot be determined, confirm with the user.
This fence can be executed standalone without depending on the execution result of Step 3. Because the fence may be executed in an independent shell, write it on the assumption that it does not inherit the functions and variables defined by Step 3. The preamble is the same as Step 3.
# reassign-lib.sh を 3 レイアウトから解決して source する。
# **この前置きは Step 3 / Step 4 の両フェンスが同一の内容で持つ。** 手順書のコードフェンスは
# ブロックごとに独立シェルで実行され得るため、片方のフェンスで定義した関数・変数がもう一方へ
# 継承される保証がない(Issue #372 / PR #374 codex-review P1)。
REASSIGN_LIB=""
for CANDIDATE in \
"skills/update-issue-tree/scripts/reassign-lib.sh" \
".agents/skills/update-issue-tree/scripts/reassign-lib.sh" \
".claude/skills/update-issue-tree/scripts/reassign-lib.sh"; do
# 存在確認は -f のみで行う(-x にすると、npx skills add 等の vendoring で
# 実行ビットが落ちたファイルを「存在しない」と誤検知し、3 レイアウトいずれにも
# 見つからないという誤ったエラーメッセージになる)
if [[ -f "${CANDIDATE}" ]]; then
REASSIGN_LIB="${CANDIDATE}"
break
fi
done
if [[ -z "${REASSIGN_LIB}" ]]; then
echo "エラー: reassign-lib.sh が見つからない(3 レイアウトいずれにも存在しない)" >&2
exit 1
fi
# ライブラリは対の reassign-sub-issue.sh の存在まで確認したうえで、reassign_one /
# require_plan_array と REASSIGN_SCRIPT を定義する。欠落していれば非ゼロを返すので中断する。
# このフェンスで set -euo pipefail を使ってはならない(理由は reassign-lib.sh 冒頭のコメント参照。
# set -e があると reassign_one 内の `status=$?` 退避に到達せず、Issue #335 の欠陥が再発する)
source "${REASSIGN_LIB}" || exit 1
# Step 3 と同じガードを同じ関数で行う(非対称を作らない)
require_plan_array ORPHAN_PLAN || exit 1
SKIPPED_ORPHANS=()
NEEDS_REVIEW_ORPHANS=()
for ENTRY in "${ORPHAN_PLAN[@]}"; do
# ENTRY は "<orphan-issue> <phase-parent>" 形式
IFS=' ' read -r ORPHAN_NUMBER PHASE_NUMBER <<< "${ENTRY}"
# Step 3 と同じ理由で `if ...; then ... fi` は使わない(`fi` 直後の $? は 0 になる)
status=0
reassign_one --issue "${ORPHAN_NUMBER}" --new-parent "${PHASE_NUMBER}" || status=$?
if (( status == 0 )); then
continue
fi
if (( status == 9 )); then
SKIPPED_ORPHANS+=("${ORPHAN_NUMBER}")
continue
fi
if (( status == 10 )); then
# Step 3 と同じ (c) 扱い。孤児経路は --old-parent を渡さないため通常は起こり得ないが、
# ループ構造を Step 3 と非対称にしないため同じ分岐を持つ
NEEDS_REVIEW_ORPHANS+=("#${ORPHAN_NUMBER}: exit=10 restored — 補償復旧が発生。Phase 親 #${PHASE_NUMBER} への紐付けは未達。実状態を確認すること")
continue
fi
if (( status == 11 )); then
NEEDS_REVIEW_ORPHANS+=("#${ORPHAN_NUMBER}: exit=11 third-party-parent — 第三者が別親を設定済み。同じコマンドで再実行禁止。stderr の実測親を確認しユーザー承認のうえ再実行すること")
continue
fi
echo "エラー: #${ORPHAN_NUMBER} の再配置が exit ${status} で失敗した。中断する" >&2
exit "${status}"
done
if (( ${#SKIPPED_ORPHANS[@]} > 0 )); then
echo "対象外(cross-repository 親): ${SKIPPED_ORPHANS[*]}" >&2
fi
if (( ${#NEEDS_REVIEW_ORPHANS[@]} > 0 )); then
echo "要確認事項(Step 9 のレポートへ転記すること):" >&2
printf ' %s\n' "${NEEDS_REVIEW_ORPHANS[@]}" >&2
fi
It is the same functions and same loop structure as Step 3, and the handling of exit codes is also the same
((a) only resolvable precondition deficiencies are suspended until the cause is resolved, (b) permanent out-of-scope cases (exit 9) are recorded in the items requiring confirmation and then proceed to the next item, (c) cases that have been partially changed but may continue (exit 10 / 11) are also recorded in the items requiring confirmation without becoming fatal, and then proceed to the next item. The determination for (b) is made mechanically by the stderr captured by the function
reason=cross-repository-parent marker, and is conveyed to the caller as return value 9.
See the exit code table).
Step 5: Create a new Phase parent as needed
If there are many new tasks that do not fit into existing Phases, create a new Phase parent issue and link it to the root.
(This POST does not use reassign-sub-issue.sh . It is a single POST to an issue just created that is self-evidently without a parent, and is outside the scope of the DELETE path and idempotency determination.)
# phase ラベルが存在しないリポジトリでは issue 作成が失敗するため、必ず事前作成する
# (作成済みの場合は失敗を無視して続行する)
gh label create "phase:N" --color "0075ca" 2>/dev/null || true
# gh issue create は URL を出力する(--json 非対応)。URL 末尾から番号を抽出する
NEW_PHASE_URL=$(gh issue create \
--title "feat(phase-N): Phase N タイトル" \
--label "phase:N" \
--body "$(cat <<'EOF'
## 概要
Phase N の実装タスクをまとめる親 issue。
## タスク一覧
| Issue | タイトル | 分解 |
|-------|---------|------|
EOF
)")
NEW_PHASE_NUMBER=$(printf '%s' "${NEW_PHASE_URL}" | grep -oE '[0-9]+$')
# ルートへ紐付け。sub_issue_id は issue 番号ではなく database id を渡す(GitHub sub-issues API 仕様)
NEW_PHASE_ID=$(gh api "repos/{owner}/{repo}/issues/${NEW_PHASE_NUMBER}" --jq '.id')
gh api \
--method POST \
"repos/{owner}/{repo}/issues/${ROOT_NUMBER}/sub_issues" \
-F "sub_issue_id=${NEW_PHASE_ID}"
Step 6: Synchronize the phase labels
Check whether each issue's phase label matches the parent Phase, and fix any mismatched labels.
# ラベルを追加
gh issue edit "${ISSUE_NUMBER}" --add-label "phase:1"
# 古いラベルを削除
gh issue edit "${ISSUE_NUMBER}" --remove-label "phase:0"
Step 7: Break down issues exceeding the granularity criterion into sub-issues
During the inventory, implementation time is ${GRANULARITY}(determined in Step 1. Default 2h) Issues judged to exceed this are broken down into sub-issues using the same granularity criterion as create-issue-tree.
(This POST also does not use reassign-sub-issue.sh . The reason is the same as Step 5: a single POST to a newly created
parentless issue)
# phase ラベルが存在しない場合に備えて事前作成する(作成済みなら no-op)
gh label create "phase:N" --color "0075ca" 2>/dev/null || true
# sub-issue を作成(URL 末尾から番号を抽出)
SUB_URL=$(gh issue create \
--title "feat: サブタスク名" \
--label "phase:N" \
--body "...")
SUB_NUMBER=$(printf '%s' "${SUB_URL}" | grep -oE '[0-9]+$')
# 親 issue へ紐付け(sub_issue_id は database id)
SUB_ID=$(gh api "repos/{owner}/{repo}/issues/${SUB_NUMBER}" --jq '.id')
gh api \
--method POST \
"repos/{owner}/{repo}/issues/${ISSUE_NUMBER}/sub_issues" \
-F "sub_issue_id=${SUB_ID}"
Step 8: Update the management block in the root issue body (preserve the existing body)
Of the root issue body,only the scope managed by this skillis regenerated from the actual tree and replaced.
No other part of the body (overview, operations, handwritten plans or rationale, additions) may lose even one line. The entire body must not
be written back using a fixed template (because human-written content would disappear on every inventory, and count/date
placeholders could reach the body. Issue #545). The processing is scripts/update-root-body.sh
consolidated into.
Management scope and invariants
| Area | Marker (matches the entire line; valid only outside code fences) | Update rule |
|---|---|---|
| Per-Phase table | <!-- update-issue-tree:phase-plan:begin --> / <!-- update-issue-tree:phase-plan:end --> |
Fully replace between markers each time (table of all sub-issues directly under the root, and detail table of nodes with open children directly under it) |
| Inventory history | <!-- update-issue-tree:inventory:begin --> / <!-- update-issue-tree:inventory:end --> |
Append-only. Preserve existing lines and add one line with today's date and the count of 5 to the end (do not add if identical to the previous line) |
| granularity | <!-- granularity: Nh --> |
Keep only one line at the beginning. The value is GRANULARITY 's determined value |
- The only things that may be removed from the existing body are "lines between the phase-plan markers" and "the granularity marker line"
## 概要・## 運用is not managed. Preserve it verbatim if present, and do not add it if absent (generate the skeleton only when the body is empty)- Tables, counts, and dates are generated only from the actual tree and verified arguments. The count-of-5 argument is required with no default, and if a placeholder remains, it stops with exit 1 before the API call
- Issue titles are untrusted data.
|, newlines, and<・-->are sanitized before writing, so a title cannot forge a management marker - Marker inconsistencies (only one side, duplicates, reversed order, nesting) and unclosed code fences stop with exit 4 without editing (because an unclosed fence would treat everything after it as code and double-append the management block)
Migration of existing bodies without markers(all currently existing roots are in this state): Do not discard existing lines.
## Phase 別実装計画If the section exists, insert a generated block with a marker immediately after the heading. Within the same section, the leading part from immediately after the heading up to the first H3 and### PhaseH3 starting with is a candidate for old generated content as do not delete、<details>(explicitly state the evacuation date and "delete after confirmation if unnecessary" in the summary) move it verbatim to. Other H3s (### 実装ラン (...)etc.) leave them in their original position and content- If the section does not exist, append to the end of the body
## Phase 別実装計画and the block with a marker - The inventory history is
## 棚卸しで実施した整理(update-issue-tree 実行履歴)Insert the section immediately before the Phase-specific implementation plan. Do not touch the existing handwritten inventory section - When evacuation occurs, the last line of stdout
migration=phase-plan-archivedtransfer to the items requiring confirmation in Step 9
Confirmation before writing and writing: If the retrieved body and the body re-retrieved immediately before editing differ, it is treated as concurrent editing and
stops with exit 5. If there are no changes, result=unchanged do not edit with.--dry-run If you add
, output the merged body to stdout and do not call any write-related gh (recommended before the first migration).
Procedure for finalizing the count variables(Each code fence may be executed in an independent shell, so variables inside the fences in Steps 3-7 are not carried over to Step 8. Aggregate the actual values in the conversation, and at the beginning of the fence belowappend as an assignment line with the numeric value written directlybefore executing. Do not execute with estimates, default values, or placeholders):
| Variable | Value to finalize | Source of aggregation |
|---|---|---|
ROOT_NUMBER |
Root issue number | Argument |
GRANULARITY |
Granularity (2h etc.Nh format) |
Final value of the argument (default 2h) |
REASSIGNED_COUNT |
Number of successful reassignments of remaining issues under the closed parent | Step 3 で reassign-sub-issue.sh が result=reassigned / posted-only Number of times returned |
ORPHAN_COUNT |
Number of successful orphan issue relocations | Number of times similarly succeeded in Step 4 |
LABEL_SYNC_COUNT |
Number of successful phase label synchronizations | Number of issues for which labels were actually added/changed in Step 6 |
NEW_PHASE_COUNT |
Number of newly created Phase parents | Number of successful creations and linkings in Step 5 |
SPLIT_COUNT |
Number of successful sub-issue decompositions | Number of issues successfully decomposed (created and linked) in Step 7 |
- If the relevant Step was not executed or there were no targets,
0assign (do not leave it unset) - Failures/skips (nonzero exit, including exit 10 / 11) are not counted in the totals (same as the aggregation rules in Step 9)
- Assignment example (replace values with actual results):
ROOT_NUMBER=254 GRANULARITY=2h REASSIGNED_COUNT=1 ORPHAN_COUNT=0 LABEL_SYNC_COUNT=3 NEW_PHASE_COUNT=0 SPLIT_COUNT=0をexportwith, place at the beginning of the fence
Each code fence may be executed in an independent shell, so this fence resolves the script self-containedly from the 3 layouts, in the same form as Step 3 / Step 4. If the count variable is unset, stop before startup.
# Step 1〜7 の確定値。未設定ならここで停止する(プレースホルダーを本文へ流さない)
: "${ROOT_NUMBER:?}" "${GRANULARITY:?}" "${REASSIGNED_COUNT:?}" "${ORPHAN_COUNT:?}" \
"${LABEL_SYNC_COUNT:?}" "${NEW_PHASE_COUNT:?}" "${SPLIT_COUNT:?}"
UPDATE_ROOT_BODY=""
for CANDIDATE in \
"skills/update-issue-tree/scripts/update-root-body.sh" \
".agents/skills/update-issue-tree/scripts/update-root-body.sh" \
".claude/skills/update-issue-tree/scripts/update-root-body.sh"; do
# 存在確認は -f のみ(vendoring で実行ビットが落ちても bash 経由で起動できる)
if [[ -f "${CANDIDATE}" ]]; then
UPDATE_ROOT_BODY="${CANDIDATE}"
break
fi
done
if [[ -z "${UPDATE_ROOT_BODY}" ]]; then
echo "エラー: update-root-body.sh が見つからない(3 レイアウトいずれにも存在しない)" >&2
exit 1
fi
# echo を最終コマンドにしない。非ゼロ終了はそのままフェンスの終了ステータスにする
status=0
bash "${UPDATE_ROOT_BODY}" \
--root "${ROOT_NUMBER}" --granularity "${GRANULARITY}" \
--reassigned "${REASSIGNED_COUNT}" --orphans "${ORPHAN_COUNT}" \
--labels "${LABEL_SYNC_COUNT}" --new-phases "${NEW_PHASE_COUNT}" \
--split "${SPLIT_COUNT}" || status=$?
if (( status != 0 )); then
echo "exit=${status}" >&2
exit "${status}"
fi
Exit code(last line of stdout is result=<updated|unchanged|dry-run> root=<n> migration=<none|phase-plan-archived|inserted> phases=<k>)
| exit | Meaning | Body changes |
|---|---|---|
| 0 | Success (only updated changed) | updated only |
| 1 | Argument error (including remaining count placeholders) | None |
| 2 | Prerequisites not met (gh / jq absent, unauthenticated, root retrieval failed, root is a PR) | None |
| 3 | Tree retrieval failed, depth exceeded (8 levels), table row count mismatch, over 65,536 characters | None |
| 4 | Management marker inconsistency, or a code fence in the body is not closed | None |
| 5 | Concurrent edit detected | None |
| 6 | gh issue edit gh issue edit failed |
Unknown (check the actual state) |
| 7 | Post-check mismatch (the re-retrieved entire body does not match the sent body. Trailing newline and CR differences are ignored) | Yes (edited) |
Do not swallow non-zero exits; carry them over to the items requiring confirmation in Step 9. For exit 6 / 7, check the actual state of the body. If updated by mistake, it can be restored from GitHub's body edit history.
Step 9: Report the inventory results
## update-issue-tree 完了レポート
### 対象ルート issue
- #N: タイトル
### 棚卸し実施内容
| 操作 | 件数 |
|------|------|
| closed 親下の残置 issue 付け替え | N 件 |
| 孤児 issue の再配置 | N 件 |
| phase ラベル同期 | N 件 |
| 新 Phase 親の新設 | N 件 |
| 粒度基準超 issue の sub-issue 分解 | N 件 |
### 現在の Phase 別サマリー
| Phase | 親 issue | open 件数 |
|-------|----------|----------|
| Phase 1 | #N | N 件 |
### ルート本文の更新結果
- result: updated / unchanged、migration: none / phase-plan-archived / inserted
### 要確認事項(自動配置できなかった issue)
- #N: タイトル — 確認理由
- 退避ブロック(`<details>`)の確認 / Step 8 の exit 5・6・7(該当時)
The counts for "reassigning leftover issues under a closed parent" and "relocating orphan issues" are aggregated from the
reassign-sub-issue.sh lines for the number of times result= was called in Step 3 / Step 4 (reassigned / posted-only).
All non-zero exits(exit 1–8, 10, 11. Including cases where codes increase in the future) are not included in the counts at all,
and must always be listed in "Items requiring confirmation" with reasons. In particular, exit 8 ispartial changes remain, so
failing to report it leaves a broken tree unattended. exit 10 (compensatory recovery succeeded) and exit 11 (a third party has already set a different parent)
also did not achieve the intended reassignment, so they are not counted in the tally and are listed in items requiring confirmation.exit 9, 10, 11 are not treated as fatal by the Step 3 /
Step 4 loop itself and it continues, so (see the exit code table and the above loop),
these reach Step 9 after processing all remaining items in the plan array. Copy the contents of the SKIPPED / NEEDS_REVIEW(and SKIPPED_ORPHANS / NEEDS_REVIEW_ORPHANS) that Step 3 / Step 4
output to stderr into this section as-is.
Verification
- Confirm that the Phase-by-phase table in the root issue body has been updated. Also confirmthat sections outside the markers (overview, operations, handwritten sections) have not changed before and after the update, and
YYYY-MM-DD・N 件that placeholders such as are not present in the body (for the first time,update-root-body.sh ... --dry-runcheck the output with before writing) - Confirm that no open issue remains under the closed Phase parent.However, issues recorded in the items requiring confirmation due to exit 10 (compensation recovery successful) are intentionally restored under the old parent (closed) as a reverse operation within the approved scope, so treat them as exceptions to this confirmation. If on its own it looks like "leftover", check it against the record in the items requiring confirmation in Step 9 to confirm it originates from exit 10
- For each invocation of
reassign-sub-issue.shcalled in Step 3 / Step 4,echo "exit=${status}"check the value ofresult=line. If there is a non-zero exit, confirm whether it is reflected in the items requiring confirmation in Step 9. In addition, for fatal-type **exits 1-8 (excluding 9, 10, and 11)**, confirm that the code block itself returns a non-zero exit status (echothat it does not swallow the exit status by making it the last command). exit 9・10・11is a contract for loop continuation, not fatal, so the code block should terminate normally (exit status 0) as-is and reach the finalSKIPPED*/NEEDS_REVIEW*echo, and confirm that all remainingREASSIGN_PLAN/ORPHAN_PLANhave been processed
# 全 sub-issues の state を確認
gh api "repos/{owner}/{repo}/issues/${ROOT_NUMBER}/sub_issues" \
--jq '.[] | {number: .number, state: .state, title: .title}'
# Phase 親の sub-issues も確認
gh api "repos/{owner}/{repo}/issues/${PHASE_NUMBER}/sub_issues" \
--jq '.[] | {number: .number, state: .state}'
# phase ラベルの同期確認(各 Phase 親直下で確認)
gh api "repos/{owner}/{repo}/issues/${PHASE_NUMBER}/sub_issues" \
--jq '.[] | {number: .number, labels: [.labels[].name]}'
Common failures
| Problem | Workaround |
|---|---|
| The reassignment DELETE returns 404, and the subsequent POST fails with 422 | The delete path should use only the singular form sub_issue. The plural form sub_issues returns 404, and because the POST is made without detaching from the old parent, it Sub issue may only have one parent always fails (reassign-sub-issue.sh does not proceed to POST when DELETE fails, so this chained failure itself does not occur. Note this as a caution for when manually calling gh api directly) |
| The block was edited by hand but was overwritten in the next inventory | The section between markers is regenerated every time. Write content you want to keep outside the markers |
| Deleting only one of the management markers causes Step 8 to exit 4 | Restore both or delete both (if the markers are deleted, the next run is treated as a migration, and the old block is <details> saved to) |
--granularity に 2 h・2・0h If you pass such as , it will be interrupted |
Specify in positive integer + h format (^[1-9][0-9]*h$. Example: 2h・4h) |
Notes
- Present the changes to the user and obtain confirmation before the inventory(see Step 2)
- Pagination: if there are more than 100 sub-issues,
per_page=100&page=Npaginate to retrieve all of them (applies to retrieving the entire tree in Step 1.reassign-sub-issue.shdirectly references the target issue'sparent_issue_url, so pagination is not required for the reassignment determination itself) - Always quote shell command variables with
"${var}"(to prevent command injection) gh issue createは--jsondoes not support. Because it outputs the issue URL to stdout,| grep -oE '[0-9]+$'Extract the trailing number with- sub_issues API(POST / DELETE)の
sub_issue_idis not an issue number but a database id(GitHub specification).gh api "repos/{owner}/{repo}/issues/<number>" --jq '.id'and then pass the id obtained. If you pass the number as-is, you will operate on the wrong issue / get a 404 (reassign-sub-issue.shresolves this internally, so there is no need to obtain it manually in Step 3/4) - If the Phase of an orphan issue cannot be determined, do not guess and confirm with the user
- Note that the sub_issues DELETE API (the operation to detach from the old parent when reattaching) has a singular path
sub_issueand be sure to confirm the issue number to operate on before executing - After updating the tree, check that the structure allows implement-issue-tree to correctly process it via post-order DFS
- For the reattachment processing in Step 3 / Step 4, use
scripts/reassign-sub-issue.sh. Do not write rawgh apiDELETE/POST back into the SKILL.md body (because this returns to the class of defects where passing state variables breaks at code fence boundaries. For details, seescripts/reassign-sub-issue.shthe comment at the beginning) - Step 8 は
scripts/update-root-body.sh.gh issue edit --bodyDo not write back the entire root body (because handwritten body text will be lost. For details, seescripts/update-root-body.shthe comment at the beginning). If updated by mistake, it can be restored from GitHub's body edit history