From sentinel
Check and fix milestones on PRs and their associated issues. Sets PR milestones based on the branch they merged into, and issue milestones based on the smallest version with a merged fix. Triggers on: check milestones, fix milestones, /check-milestones.
How this skill is triggered — by the user, by Claude, or both
Slash command
/sentinel:check-milestonesThis skill is limited to the following tools:
The summary Claude sees in its skill listing — used to decide when to auto-load this skill
Check and fix milestones on a contributor's merged PRs and their associated
Check and fix milestones on a contributor's merged PRs and their associated GitHub issues.
$ARGUMENTS -- space-separated values:
all -- evaluate all closed/merged PRs from this author in the past 30
days.100,105,110) -- only evaluate these specific PRs.Parse the arguments by splitting $ARGUMENTS on whitespace. Examples:
/check-milestones alice -> username=alice, filter=recent 50/check-milestones alice all -> username=alice, filter=all PRs (past 30 days)/check-milestones alice 100,105,110 -> username=alice, filter=only those PRsAuto-detect the repository:
REPO=$(gh repo view --json nameWithOwner --jq '.nameWithOwner')
Run these in parallel:
Fetch PRs (method depends on the second argument):
gh pr list --repo $REPO --author <username> --state closed --limit 50 --json number,title,mergedAt,mergeCommit,labels,body,url,baseRefName,milestone --jq 'sort_by(.mergedAt)'all: Use
gh pr list --repo $REPO --author <username> --state closed --limit 200 --search "closed:>YYYY-MM-DD" --json number,title,mergedAt,mergeCommit,labels,body,url,baseRefName,milestone --jq 'sort_by(.mergedAt)'
where YYYY-MM-DD is 30 days ago from today.gh pr view <number> --repo $REPO --json number,title,mergedAt,mergeCommit,labels,body,url,baseRefName,milestone.
Collect results sorted by mergedAt.Skip any PR where mergedAt is null (not merged).
Auto-detect milestone naming convention: Fetch existing milestones from the repo to understand the naming pattern:
gh api "repos/$REPO/milestones" --paginate --jq '.[].title' | sort -V
From the existing milestones, detect the naming convention. Common patterns:
v1.2.3 (semver)1.89.x - Nightly (channel-based)Sprint 42 (sprint-based)2024-Q1 (quarter-based)Release 5.0 (release-based)Detect the default branch and release branches:
DEFAULT_BRANCH=$(gh repo view --json defaultBranchRef --jq '.defaultBranchRef.name')
# List branches that look like release branches
gh api "repos/$REPO/branches" --paginate --jq '.[].name' | grep -E '(release|v?[0-9]+\.[0-9]+)' | sort -V
For each merged PR, determine the correct milestone based on its baseRefName
(the branch it was merged into):
baseRefName is the default branch (main or master) -> the milestone
corresponding to the development/nightly channelbaseRefName matches a release branch -> the milestone corresponding to
that release versionTo map branches to milestones, use the auto-detected milestone naming convention from Step 1. Match the version number in the branch name to the closest milestone.
Compare the PR's current milestone (from the milestone field) against the
correct one. If they differ (or the milestone is not set), add the PR to the
list of PRs that need updating.
For each merged PR, extract the associated issue number(s) from the PR body. Look for patterns like:
Resolves #XXXXX or Resolves OWNER/REPO#XXXXXFixes #XXXXX or Fixes OWNER/REPO#XXXXXCloses #XXXXX or Closes OWNER/REPO#XXXXXFixes https://github.com/OWNER/REPO/issues/XXXXXResolves https://github.com/OWNER/REPO/issues/XXXXXFor each associated issue:
Find all PRs that reference this issue -- check if the issue has cherry-pick/uplift PRs by searching for other merged PRs that reference the same issue across different branches:
gh api search/issues --method GET \
-f q="repo:$REPO is:pr is:merged $ISSUE_NUMBER" \
--jq '.items[] | {number, title, html_url}'
Determine which branches this fix has been merged into (considering cherry-picks/uplifts):
The correct issue milestone is the smallest version where the fix is merged. Use the version ordering from the auto-detected milestones to determine which is smallest.
Check the issue's current milestone and compare:
gh issue view <ISSUE_NUMBER> --repo $REPO --json milestone --jq '.milestone.title'
For each PR that needs a milestone update:
gh pr edit <PR_NUMBER> --repo $REPO --milestone "<milestone-name>"
For each issue that needs a milestone update:
gh issue edit <ISSUE_NUMBER> --repo $REPO --milestone "<milestone-name>"
Important: Only update an issue's milestone to a smaller version number than what is currently set. For example:
Output a clear summary of all actions taken:
| PR | Title | Base Branch | Old Milestone | New Milestone |
|---|---|---|---|---|
| #XXXXX | PR title | main | (none) | v2.1.0 |
| Issue | Old Milestone | New Milestone | Reason |
|---|---|---|---|
| #XXXXX | (none) | v2.0.1 | Merged cherry-pick to release (#YY) |
List PRs and issues that already had the correct milestone (brief count or list).
List any PRs or issues that were skipped with the reason (e.g., "no associated issue", "could not determine branch", "unmerged cherry-pick").
npx claudepluginhub luciferdono/sentinelGuides creation, editing, and verification of skills for AI coding agents using test-driven development with subagent scenarios. Use when authoring or debugging skills.