Catalog
getsentry/pr-link-issue

getsentry

pr-link-issue

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.

global
New~670
v1.0Saved Jul 11, 2026

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:

    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:

    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:

    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:

    #### Issues
    
    * Resolves: #<n>
    * Resolves: <linear-key>
    
  6. Update the PR with a heredoc to preserve newlines:

    gh pr edit <pr-number> --body "$(cat <<'EOF'
    <new body>
    EOF
    )"
    
  7. Confirm by echoing the resulting PR URL:

    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.
Files1
1 files · 10.5 KB

Select a file to preview

Overall Score

82/100

Grade

B

Good

Safety

80

Quality

88

Clarity

85

Completeness

78

Summary

This skill appends GitHub issue and Linear ticket references to a PR description using the GitHub CLI. It resolves the Linear ticket from a comment on the issue, reads the PR body, constructs a formatted "Issues" block, and updates the PR while preserving existing content.

Detected Capabilities

github cli usageissue metadata fetchingpr description updatingregex pattern matchingcomment body parsing

Trigger Keywords

Phrases that MCP clients use to match this skill to user intent.

link issue to pradd issue referenceconnect linear ticketfill pr descriptionreference github issue

Risk Signals

INFO

Modifies PR description via gh pr edit with user-supplied content

Step 6: Update the PR with heredoc
INFO

Reads PR and issue metadata from GitHub API via gh CLI

Steps 1, 3, 4, 7
INFO

Constructs markdown by concatenating issue number and optional Linear key

Step 5: Construct new body

Referenced Domains

External domains referenced in skill content, detected by static analysis.

github.comwww.apache.org

Use Cases

  • Link a GitHub issue to a pull request
  • Add Linear ticket reference to PR
  • Populate PR description with issue and ticket metadata
  • Automatically resolve Linear keys from GitHub comments
  • Update PR with issue references without overwriting existing content

Quality Notes

  • Well-scoped to a single, specific task with clear inputs and outputs
  • Excellent error handling guidance: handles missing PR, missing Linear linkback, and duplicate sections
  • Clear step-by-step instructions with exact gh CLI commands provided
  • Good documentation of edge cases (newly filed issues without Linear linkback, repo context)
  • Explains the format of Linear linkback comments and project key patterns
  • Includes deduplication logic to avoid duplicate '#### Issues' blocks
  • Clear examples of the expected markdown format
  • Notes preserve existing PR content (always read first, append/replace second)
Model: claude-haiku-4-5-20251001Analyzed: Jul 11, 2026

Reviews

Add this skill to your library to leave a review.

No reviews yet

Be the first to share your experience.

Add getsentry/pr-link-issue to your library

Command Palette

Search for a command to run...