diff --git a/.claude/settings.json b/.claude/settings.json index 9cd91ce..a7c23a4 100644 --- a/.claude/settings.json +++ b/.claude/settings.json @@ -53,6 +53,7 @@ "Skill(sentry-skills:gh-review-requests)", "Skill(sentry-skills:gha-security-review)", "Skill(sentry-skills:iterate-pr)", + "Skill(sentry-skills:pr-link-issue)", "Skill(sentry-skills:pr-writer)", "Skill(sentry-skills:presentation-creator)", "Skill(sentry-skills:prompt-optimizer)", diff --git a/README.md b/README.md index 87f50ca..0ece624 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,7 @@ Works with Claude Code, Cursor, Cline, GitHub Copilot, and other compatible agen | [gha-security-review](skills/gha-security-review/SKILL.md) | GitHub Actions security review for workflow exploitation vulnerabilities. | | [iterate-pr](skills/iterate-pr/SKILL.md) | Iterate on a PR until CI passes and actionable review feedback is addressed. | | [presentation-creator](skills/presentation-creator/SKILL.md) | Create data-driven presentation slides using React, Vite, and Recharts with Sentry branding. | +| [pr-link-issue](skills/pr-link-issue/SKILL.md) | Append a GitHub issue link and its Linear ticket to the current PR's description. | | [pr-writer](skills/pr-writer/SKILL.md) | Canonical workflow to create and update pull requests following Sentry conventions. | | [prompt-optimizer](skills/prompt-optimizer/SKILL.md) | Optimize prompts with evals, model-family adapters, and exact external context references. | | [replay-ux-research](skills/replay-ux-research/SKILL.md) | Analyze Sentry session replays to surface UX patterns, pain points, and user journeys for a given product area. | diff --git a/skills/claude-settings-audit/SKILL.md b/skills/claude-settings-audit/SKILL.md index d1dbdca..782923d 100644 --- a/skills/claude-settings-audit/SKILL.md +++ b/skills/claude-settings-audit/SKILL.md @@ -157,6 +157,7 @@ If this is a Sentry project (or sentry-skills plugin is installed), include: "Skill(sentry-skills:gh-review-requests)", "Skill(sentry-skills:gha-security-review)", "Skill(sentry-skills:iterate-pr)", + "Skill(sentry-skills:pr-link-issue)", "Skill(sentry-skills:pr-writer)", "Skill(sentry-skills:presentation-creator)", "Skill(sentry-skills:prompt-optimizer)", diff --git a/skills/pr-link-issue/SKILL.md b/skills/pr-link-issue/SKILL.md new file mode 100644 index 0000000..0884103 --- /dev/null +++ b/skills/pr-link-issue/SKILL.md @@ -0,0 +1,74 @@ +--- +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 + +- `` — GitHub issue URL like `https://github.com///issues/`. Issue number alone is fine if the PR is in the same repo. +- (optional) `` — 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 --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 --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: # + * Resolves: + ``` + +6. Update the PR with a heredoc to preserve newlines: + + ```bash + gh pr edit --body "$(cat <<'EOF' + + EOF + )" + ``` + +7. Confirm by echoing the resulting PR URL: + + ```bash + gh pr view --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.