.claude/skills/vercel-preview/SKILL.md
Resolve Vercel preview deployment URL for the current git branch. Invoked by browser-verification when deployment.enabled is true, or directly to check deployment status. Use to check deployment status or when browser verification needs a URL.
npx skillsauth add benjaminshoemaker/ai_coding_project_base vercel-previewInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Resolve the Vercel preview deployment URL for the current git branch. Used by browser-verification and phase-checkpoint to run E2E tests against production-like environments instead of localhost.
browser-verification skill when deployment.enabled is truephase-checkpoint for browser-based acceptance criteria.vercel/project.json exists)vercel command available)From .claude/verification-config.json:
{
"deployment": {
"enabled": true,
"service": "vercel",
"waitForDeployment": true,
"deploymentTimeout": 300,
"tokenVar": "VERCEL_TOKEN"
}
}
Copy this checklist and track progress:
Vercel Preview Progress:
- [ ] Step 1: Get git context (branch, commit)
- [ ] Step 2: Check Vercel project linking
- [ ] Step 3: Query deployments for branch
- [ ] Step 4: Wait for deployment (if configured)
- [ ] Step 5: Return URL or error guidance
# Get current branch name
BRANCH=$(git rev-parse --abbrev-ref HEAD)
# Get current commit SHA (short)
COMMIT=$(git rev-parse --short HEAD)
# Get full commit SHA for exact matching
COMMIT_FULL=$(git rev-parse HEAD)
Branch name sanitization: Vercel sanitizes branch names for URLs (replaces / with -,
removes special characters). The vercel ls command handles this automatically via metadata
matching.
Verify the project is linked to Vercel:
# Check for Vercel project config
if [ -f ".vercel/project.json" ]; then
PROJECT_ID=$(jq -r '.projectId' .vercel/project.json)
ORG_ID=$(jq -r '.orgId' .vercel/project.json)
echo "Vercel project: $PROJECT_ID (org: $ORG_ID)"
else
echo "ERROR: Project not linked to Vercel"
echo "Run 'vercel link' to connect this project"
exit 1
fi
Use vercel ls with metadata filtering to find deployments for the current branch:
# List deployments for this branch (most reliable method)
vercel ls --json -m gitBranch="$BRANCH" --status READY 2>/dev/null | head -1
Why this approach:
gitBranch metadata is set automatically by Vercel's GitHub integration--status READY filters to only completed deploymentsRESPONSE=$(vercel ls --json -m gitBranch="$BRANCH" --status READY 2>/dev/null)
if ! echo "$RESPONSE" | jq empty 2>/dev/null; then
echo "ERROR: vercel ls returned invalid JSON"
# Return error status, don't attempt to parse
fi
# Extract URL from JSON response
DEPLOYMENT_URL=$(vercel ls --json -m gitBranch="$BRANCH" --status READY 2>/dev/null | \
jq -r '.[0].url // empty')
if [ -z "$DEPLOYMENT_URL" ]; then
echo "No ready deployment found for branch: $BRANCH"
# Check if deployment exists but is still building
BUILDING=$(vercel ls --json -m gitBranch="$BRANCH" --status BUILDING 2>/dev/null | \
jq -r '.[0].url // empty')
if [ -n "$BUILDING" ]; then
echo "Deployment in progress: $BUILDING"
fi
fi
If waitForDeployment is enabled and no ready deployment exists:
# Get the latest deployment (any status) for the branch
LATEST=$(vercel ls --json -m gitBranch="$BRANCH" 2>/dev/null | jq -r '.[0].url // empty')
if [ -z "$LATEST" ]; then
echo "No deployments found for branch: $BRANCH"
echo "Possible causes:"
echo " - Branch has not been pushed to remote"
echo " - Vercel project is not linked (run: vercel link)"
echo " - Branch name doesn't match Vercel's git integration"
# Return empty result, let caller decide how to handle
fi
if [ -n "$LATEST" ]; then
echo "Waiting for deployment to be ready: $LATEST"
# Use vercel inspect --wait with timeout
TIMEOUT=${DEPLOYMENT_TIMEOUT:-300}
vercel inspect "$LATEST" --wait --timeout "${TIMEOUT}s"
if [ $? -eq 0 ]; then
DEPLOYMENT_URL="https://$LATEST"
echo "Deployment ready: $DEPLOYMENT_URL"
else
echo "Deployment did not become ready within ${TIMEOUT}s"
fi
fi
If vercel inspect --wait is unavailable, poll using the same deployment query
from Step 3 (vercel ls --json -m gitBranch="$BRANCH") with a 10-second interval:
MAX_ATTEMPTS = DEPLOYMENT_TIMEOUT / 10readyState from the Step 3 responseREADY: extract URL as https://<url> and breakVERCEL PREVIEW URL RESOLVED
===========================
Branch: feature/user-auth
Commit: a1b2c3d
URL: https://my-app-abc123-team.vercel.app
Status: READY
Age: 5 minutes ago
Ready for browser verification.
VERCEL PREVIEW URL NOT FOUND
============================
Branch: feature/user-auth
Commit: a1b2c3d
No ready deployment found. Possible causes:
1. Push has not triggered a deployment yet
2. Deployment is still building
3. Branch name doesn't match Vercel's git integration
Checked:
- Ready deployments: 0
- Building deployments: 1 (https://my-app-xyz-team.vercel.app)
Options:
1. Wait for deployment (run with waitForDeployment: true)
2. Fall back to local dev server
3. Trigger deployment manually: vercel --prod
VERCEL PREVIEW URL ERROR
========================
Error: {error message}
Troubleshooting:
- Verify Vercel CLI is installed: npm i -g vercel
- Verify project is linked: vercel link
- Check authentication: vercel whoami
- Check VERCEL_TOKEN environment variable (if using CI)
Vercel CLI uses stored credentials from vercel login. No additional configuration
needed for local use.
Set VERCEL_TOKEN environment variable:
# In CI, use token auth
export VERCEL_TOKEN="${VERCEL_TOKEN}"
vercel ls --token "$VERCEL_TOKEN" --json -m gitBranch="$BRANCH"
The skill reads deployment.tokenVar from config to determine which env var to use.
When browser-verification invokes this skill:
# Example integration output
PREVIEW_RESOLUTION
==================
Deployment: Vercel
Branch: main
URL: https://my-app.vercel.app (or null)
Fallback: http://localhost:3000 (if enabled)
Action: USE_PREVIEW | USE_FALLBACK | BLOCK
git log origin/$BRANCHvercel login to re-authenticateVERCEL_TOKEN is set correctlyvercel link in project directory.vercel/project.json was createdvercel logs <deployment-url>deploymentTimeout in verification-config.json| Situation | Action |
|-----------|--------|
| Vercel CLI not installed (vercel command not found) | Report "Vercel CLI unavailable", suggest npm i -g vercel, fall back to local dev server if enabled |
| .vercel/project.json missing (project not linked) | Stop and instruct user to run vercel link; do not attempt deployment queries |
| vercel ls returns invalid JSON or empty response | Report parse error, skip deployment matching, return error response with troubleshooting steps |
| Authentication failure (expired token or missing credentials) | Report auth error, suggest vercel login (local) or check VERCEL_TOKEN (CI); do not retry |
| Deployment wait timeout exceeded | Stop waiting, report current deployment state, ask user whether to use local fallback or abort |
If Vercel CLI is not installed and cannot be installed:
devServer.urlfallbackToLocal is disabled: BLOCK with clear messageIf all deployments are failing:
If branch has never been deployed:
If timeout reached while waiting:
testing
Audit project alignment with VISION.md, identify SDLC gaps, and generate feature proposals. Use when reviewing strategic direction or planning new features.
development
Run code-verification on a specific task. Use to verify a single task's acceptance criteria after implementation.
tools
Discover and sync all toolkit-using projects with the latest skills. Use when skills are modified, after the post-commit hook reminds you, or to batch-sync multiple projects.
development
Update documentation after commits. Syncs README, AGENTS.md, CHANGELOG, and docs/ with code changes. Use after commits or to analyze working tree changes.