Convert draft items in a project into GitHub Issues and set up parent-child relationships (sub-issues).
Prerequisites
- Draft items must exist in the target GitHub Project
ghCLI is installed and authenticated (with theprojectscope)
Flow
Step 1: Retrieve draft items
gh project item-list <number> \
--owner <owner> \
--format json \
--limit 999
From the JSON output, items whose type is DraftIssue Filter items of .
Step 2: Confirm the conversion targets with the user
Display the list of draft items and confirm the conversion targets:
- Convert all items
- Select only specific items
Step 3: Determine the parent Issue
Confirm the following with the user:
- Specify an existing parent Issue number
- Create a new parent Issue
- No parent Issue (create individual Issues only)
For new creation:
gh issue create \
--title "feat: プロジェクト名" \
--body "$(cat <<'EOF'
## 概要
プロジェクトのトラッキング Issue。
## サブタスク
(sub-issues として自動追加されます)
EOF
)"
Step 4: Save the draft field values
Before conversion, retrieve and save the field values of each draft item:
gh project item-list <number> \
--owner <owner> \
--format json \
--limit 999
Record the field values such as Status, Priority, and Size for each item.
Step 5: Create the Issues and add them to the project
For each draft item:
# 1. Issue を作成
gh issue create \
--title "<ドラフトのタイトル>" \
--body "<ドラフトの本文>" \
--repo <owner>/<repo>
# 2. 作成した Issue をプロジェクトに追加
gh project item-add <number> \
--owner <owner> \
--url <issue-url> \
--format json
# 3. 新しいアイテムにフィールド値をコピー
gh project item-edit \
--id <new-item-id> \
--field-id <field-id> \
--project-id <project-id> \
--single-select-option-id <option-id>
# 4. 元のドラフトアイテムを削除
gh project item-delete <number> \
--owner <owner> \
--id <draft-item-id>
Issue titles are recommended to use the Conventional Commits format: feat:, fix:, chore: , etc.
Step 6: Link as sub-issues
If a parent Issue is specified, link each child Issue as a sub-issue:
# 子 Issue の database id(ノード ID ではない数値 id)を取得する
child_id=$(gh api "repos/{owner}/{repo}/issues/{child_number}" --jq '.id')
gh api \
--method POST \
"repos/{owner}/{repo}/issues/{parent_number}/sub_issues" \
-F "sub_issue_id=${child_id}"
Note:
sub_issue_idPass the database id (the number ofgh api repos/{owner}/{repo}/issues/<number> --jq '.id'), not the issue number or node ID. Since it is sent as a number, use-F.
Step 7: Report the results
Display the list of created Issues:
| # | Issue | Title | Priority | Size | Sub-issue |
|---|---|---|---|---|---|
| 1 | #42 | feat: Social login | High | L | Child of #40 |
| 2 | #43 | feat: Password reset | Medium | M | Child of #40 |
Notes
- Issue titles are recommended to use the Conventional Commits format
- Field values are lost when converting drafts to Issues, so save them in advance in Step 4
- If labels, assignees, or milestones are needed, confirm with the user
- When converting many drafts, be mindful of GitHub API rate limits
- Requires network access (mainly via the API. See the "Running in a sandbox environment" section below)
Verification
After completing Step 7, verify the created Issues and their addition to the project with the following:
gh issue list --state open --limit 20
gh project item-list <number> --owner <owner> --format json --limit 999
It is complete if the pre-conversion drafts are gone and the real Issues have been added to the project. Check the parent Issue's sub-issues with gh api repos/{owner}/{repo}/issues/{parent_number}/sub_issues .
Running in a sandbox environment
This skill requires GitHub operations over the network (draft-to-Issue conversion and adding to projects). The relevant commands are executed with the sandbox disabled on a per-command basis. It cannot be executed in an environment where network blocking cannot be lifted.