pr-link-issue — Claude Code skill: link an issue to a PR
Adds a GitHub issue and its linked Linear ticket to the current PR description. Use it when a pull request needs references to the work it addresses.
npx skills add getsentry/skills --skill pr-link-issue -a claude-codeWhat pr-link-issue does
The skill finds the open PR for the current branch unless you provide a PR number, then adds an #### Issues section with the GitHub issue and its Linear ticket. Give it an issue URL, or just an issue number when the PR belongs to the same repository.
It looks for the Linear key in an issue comment by linear-code. Before editing, it reads the existing PR description and preserves its contents; an existing #### Issues section is replaced rather than duplicated. If the comment has no matching ticket, the skill can ask you for the key or proceed with only the GitHub reference. It stops when there is no open PR on the branch, so supply a PR number if the target is elsewhere.
What it helps with
- add a GitHub issue reference to a PR description
- find the Linear ticket linked from an issue comment
- replace an existing
#### Issuessection without overwriting other PR text - connect an issue to a PR using its URL or number
Example prompts for the agent
- Add the issue from this GitHub URL and its linked Linear ticket to the current PR.
- Link issue
#1234to the open PR on this branch. - Update the
#### Issuessection on PR42using this GitHub issue.
How to install pr-link-issue
1Skills CLI (Vercel)
npx skills add getsentry/skills --skill pr-link-issue -a claude-code2Manually: put the files in place
~/.claude/skills/pr-link-issue/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/pr-link-issue/
1Skills CLI (Vercel)
npx skills add getsentry/skills --skill pr-link-issue -a codex2Manually: put the files in place
.agents/skills/pr-link-issue/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add getsentry/skills --skill pr-link-issue -a cursor2Manually: put the files in place
.cursor/skills/pr-link-issue/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install getsentry/skills pr-link-issue2Manually: put the files in place
.github/skills/pr-link-issue/SKILL.md1Skills CLI (Vercel)
npx skills add getsentry/skills --skill pr-link-issue -a gemini-cli2Platform CLI
gemini skills install https://github.com/getsentry/skills --path skills/pr-link-issueManually: put the files in place
.devin/skills/pr-link-issue/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add getsentry/skills --skill pr-link-issue -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about pr-link-issue
How do I install pr-link-issue in Claude Code?
Run npx skills add getsentry/skills --skill pr-link-issue -a claude-code. The skill file is installed at ~/.claude/skills/pr-link-issue/SKILL.md.
What does pr-link-issue do?
It adds a GitHub issue and its associated Linear ticket to a PR description. The skill reads the existing description first and keeps its other content intact.
What if the issue has no Linear ticket comment?
The skill can ask you for the Linear key or continue with the GitHub issue reference alone.
Source text
SKILL.md · Apache-2.0
---
name: pr-link-issue
description: Append a GitHub issue link and its Linear ticket to the current PR's description. Use when asked to "link issue to pr", "fill in issue and linear in pr", "add issue refs to pr", or when given a GitHub issue URL and asked to attach it to the current PR. Resolves the Linear ticket automatically from the issue's linear-linkback comment.
---
# Link a GitHub Issue + Linear Ticket on a PR
Appends a Sentry-style `#### Issues` block to a PR description, referencing both the GitHub issue and the Linear ticket pulled from the issue's `linear-linkback` comment.
## Inputs
- `<issue-url>` — GitHub issue URL like `https://github.com/<owner>/<repo>/issues/<n>`. Issue number alone is fine if the PR is in the same repo.
- (optional) `<pr-number>` — defaults to the open PR for the current branch.
## Steps
1. **Resolve the PR number** — skip if user supplied one:
```bash
gh pr view --json number,body -q '.number'
```
If no PR exists on the branch, stop and tell the user.
2. Extract issue number + repo from the input URL, or accept a bare `#1234` for current repo.
3. Fetch the Linear ticket from the issue's linear-linkback comment:
```bash
gh issue view <n> --repo <owner>/<repo> --json comments \
-q '.comments[] | select(.author.login=="linear-code") | .body' \
| grep -Eioe '[a-z]+-[0-9]+' | head -1
```
If no match, fall back to asking the user for the Linear key, or omit it.
4. Read the existing PR body so you can append rather than overwrite:
```bash
gh pr view <pr-number> --json body -q '.body'
```
5. Construct the new body. If the body is empty, use just the `#### Issues` block. Otherwise, append it after a blank line. Don't duplicate — if `#### Issues` is already present, replace that section instead of adding a second one.
Format:
```markdown
#### Issues
* Resolves: #<n>
* Resolves: <linear-key>
```
6. Update the PR with a heredoc to preserve newlines:
```bash
gh pr edit <pr-number> --body "$(cat <<'EOF'
<new body>
EOF
)"
```
7. Confirm by echoing the resulting PR URL:
```bash
gh pr view <pr-number> --json url -q '.url'
```
## Notes
- Linear linkback comments are posted by the GitHub user `linear-code`. The body contains a markdown link whose text is the Linear key, e.g. `PY-2357`.
- Project keys vary per repo (`PY-…` for sentry-python, `JS-…` for sentry-javascript, etc.) — the regex `[a-z]+-[0-9]+` covers them.
- Don't strip existing PR content. Always read first, append/replace second.
- If the issue doesn't have a Linear linkback yet (newly filed), proceed with just the GitHub issue reference and tell the user the Linear key is missing.
© getsentry · Apache-2.0 · getsentry/skills