home / skills / seika139 / dotfiles / gh-unlink-subissue

This skill unlinks a GitHub sub-issue from its parent by resolving the IDs via gh and performing the removeSubIssue mutation.

npx playbooks add skill seika139/dotfiles --skill gh-unlink-subissue

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
1.8 KB
---
name: "gh-unlink-subissue"
description: "GitHub Issue から Sub-issue の紐付けを解除します。親 Issue の URL/番号と、解除する子 Issue の URL/番号を指定してください。"
---

# GitHub Sub-issue 紐付け解除スキル

親 Issue から子 Issue の Sub-issue 紐付けを解除します。

## 前提条件

- `gh` CLI がインストール・認証済みであること
- 対象リポジトリへのアクセス権があること

## 入力

ユーザーから以下の情報を収集してください:

- **親 Issue**: `owner/repo#number` 形式または GitHub URL
- **子 Issue**: `owner/repo#number` 形式または GitHub URL

## 手順

### Step 1: Issue の Node ID を取得

```bash
# 親 Issue
PARENT_ID=$(gh api graphql -f query='
query($owner: String!, $repo: String!, $number: Int!) {
  repository(owner: $owner, name: $repo) {
    issue(number: $number) { id }
  }
}' -f owner="OWNER" -f repo="REPO" -F number=NUMBER \
  -q '.data.repository.issue.id')

# 子 Issue
CHILD_ID=$(gh api graphql -f query='
query($owner: String!, $repo: String!, $number: Int!) {
  repository(owner: $owner, name: $repo) {
    issue(number: $number) { id }
  }
}' -f owner="OWNER" -f repo="REPO" -F number=NUMBER \
  -q '.data.repository.issue.id')
```

### Step 2: removeSubIssue mutation で紐付け解除

```bash
gh api graphql -f query='
mutation($parent: ID!, $child: ID!) {
  removeSubIssue(input: {issueId: $parent, subIssueId: $child}) {
    issue { id title }
    subIssue { id title }
  }
}' -f parent="$PARENT_ID" -f child="$CHILD_ID"
```

### Step 3: 結果の確認

解除が成功したら、親 Issue と子 Issue のタイトルを表示して結果を報告してください。

## 注意事項

- 紐付けが存在しない場合はエラーが返る
- 解除しても Issue 自体は削除されない(紐付け関係のみ解除)

Overview

This skill unlinks a sub-issue from a parent GitHub Issue using the GitHub CLI and GraphQL API. Provide the parent issue and the child (sub-issue) by URL or owner/repo#number and the skill performs the removeSubIssue mutation. It reports the titles of both issues after the unlink operation.

How this skill works

The skill uses gh api graphql to fetch the GraphQL Node IDs for the parent and child issues. It then calls the removeSubIssue mutation with those IDs to remove the sub-issue relation. Finally, it reads the mutation response and returns the parent and sub-issue titles to confirm success.

When to use it

  • You need to remove a sub-issue relation without deleting either issue.
  • Cleaning up incorrect or outdated sub-issue links in a repository.
  • When reorganizing issue hierarchy or moving work out of a parent issue.
  • Automating maintenance tasks that manage issue relationships via scripts.

Best practices

  • Ensure gh CLI is installed and authenticated with access to the target repository.
  • Supply issues in owner/repo#number or full GitHub URL format to avoid ambiguity.
  • Check that the parent-child link exists before running the unlink to reduce errors.
  • Run the Node ID fetch steps manually if you need to inspect outputs for debugging.
  • Handle API errors and permission issues in automation to surface clear messages.

Example use cases

  • Remove a mistakenly linked sub-issue after splitting a task into separate work items.
  • Clean up project board relationships when reclassifying a child issue as independent work.
  • Automate unlinking as part of a larger script that migrates tasks between milestones.
  • Undo a bulk operation that unintentionally created sub-issue links.

FAQ

Will unlinking delete either issue?

No. removeSubIssue only removes the relationship; both issues remain in the repository.

What permissions are required?

You need gh authentication with at least write access to the repository to call the GraphQL mutation.

What happens if the link does not exist?

The API returns an error. Check the parent and child Node IDs and verify the relationship exists before retrying.