# PR Snapshot Release

Guide a Mastra maintainer through publishing an npm snapshot from a pull request or a...

- Repository: https://github.com/mastra-ai/mastra (29259 stars)
- Category: Git and review
- License: see repository
- Last updated: 2026-11-01
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add mastra-ai/mastra --skill pr-snapshot-release -g -a claude-code -y`
Codex: `npx skills add mastra-ai/mastra --skill pr-snapshot-release -g -a codex -y`
Cursor: `npx skills add mastra-ai/mastra --skill pr-snapshot-release -g -a cursor -y`
Gemini CLI: `npx skills add mastra-ai/mastra --skill pr-snapshot-release -g -a gemini-cli -y`

## Description

Guide a Mastra maintainer through publishing an npm snapshot from a pull request or a specified repository branch. Use when asked to release, publish, or create a PR snapshot, branch snapshot, canary package build, or branch-specific npm tag. Performs source and branch preflight checks, requires confirmation before the irreversible publish, dispatches the existing Publish to npm workflow, monitors it, and reports installable package tags.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# PR Snapshot Release

Publish a snapshot from a PR or a specified branch using `.github/workflows/npm-publish.yml`. Snapshot publishing is manual, works only for branches in `mastra-ai/mastra`, and publishes real immutable package versions to npm.

## 1. Resolve the source

Accept a PR number or URL, an explicit branch, or both. If neither is supplied, try the PR for the current branch:

```bash
pr=${PR_NUMBER_OR_URL:-$(gh pr view --json number --jq .number)}
gh pr view "$pr" \
  --json number,title,url,state,isDraft,baseRefName,headRefName,headRefOid,headRepository,mergeable,reviewDecision \
  --jq '{number,title,url,state,isDraft,baseRefName,headRefName,headRefOid,headRepository: .headRepository.nameWithOwner,mergeable,reviewDecision}'
```

When the user specifies a branch, publish that branch instead of assuming the PR head branch. If both are supplied and differ, call out the override clearly. When a PR is the source, stop if it is not open and record its `headRefName`, `headRefOid`, and head repository.

A workflow dispatch can only target a ref in `mastra-ai/mastra`. If a PR head is in a fork, explain that it cannot be published directly, but allow the user to specify an existing branch in `mastra-ai/mastra` instead. Do not push contributor code to an upstream branch without explicit maintainer direction.

## 2. Verify the exact branch revision

Resolve the selected branch to an exact SHA. For a PR branch, compare it with the inspected PR head SHA. For an explicitly specified branch, record the remote SHA as `head_sha`:

```bash
branch=<specifiedBranch-or-headRefName>
remote_sha=$(git ls-remote origin "refs/heads/$branch" | awk '{print $1}')
test -n "$remote_sha"
head_sha=${head_sha:-$remote_sha}
test "$remote_sha" = "$head_sha"
```

If it differs, refresh the source metadata and repeat the checks. Re-run this comparison immediately before dispatch. Never publish a stale or ambiguous revision.

The rest: https://github.com/mastra-ai/mastra/blob/HEAD/.mastracode/skills/pr-snapshot-release/SKILL.md
