PR Check Replication
Use this skill to replicate a Snyk PR check in a controlled repository.
Goal
Create an isolated repro case end-to-end:
- Create case folder using
set-new-case. - Capture which SCM is being replicated (GitHub/GitLab/Bitbucket) and create a personal test repo.
- Seed the repo with a minimal project:
- Open Source PR check: include a package manager manifest.
- Code PR check: include source code only.
- Import repo into Snyk.
- Ask user when ready to open PR.
- Create a PR that either introduces or fixes a vulnerability.
- Capture PR/check artifacts into the case directory.
Required prerequisites
ghis authenticated to the personal GitHub account (gh auth status) for GitHub-based repro runs.SNYK_TOKENis present and valid (validate via Snyk API, not CLI auth flow):curl -sS -o /dev/null -w "%{http_code}\n" \ -H "Authorization: token ${SNYK_TOKEN}" \ -H "Content-Type: application/json" \ "https://api.snyk.io/v1/user"Expected result:
200Case environment already configured (
SNYK_CASES_DIRpreferred).
Inputs to collect from user
CASE_NUMBER- SCM to replicate (required):
github,gitlab, orbitbucket - Repro type:
ossorcode - Language/package manager (if
oss) - Whether PR should introduce or fix a vulnerability
- Preferred repo name (optional; otherwise use autogenerated name)
- Snyk org override for import (optional). If not provided, use the default Snyk organization from the authenticated CLI context.
Workflow
1) Create case folder
chmod +x "set-new-case /scripts/set_new_case.sh"
export CASE_DIR="$(./set-new-case\ /scripts/set_new_case.sh "$CASE_NUMBER")"
Store all outputs in "$CASE_DIR".
2) Capture SCM and create personal test repo
From inside "$CASE_DIR":
REPO_NAME="${REPO_NAME:-snyk-pr-check-repro-${CASE_NUMBER}}"
# Require user to specify SCM first (github/gitlab/bitbucket).
# Current automated repo creation flow is implemented for GitHub.
gh repo create "$REPO_NAME" --public --clone
cd "$REPO_NAME"
Record SCM choice in "$CASE_DIR/pr-check-context.json" so check expectations are interpreted correctly.
3) Seed the repro project
- OSS mode: create a minimal manifest (
package.json,requirements.txt, etc.) and initial commit. - Code mode: create minimal source files and initial commit.
Then push:
git add .
git commit -m "chore: seed PR check repro project"
git push -u origin HEAD
4) Import into Snyk
Trigger Snyk import for this repository.
- By default, use the authenticated CLI's default org.
- Only use an explicit org flag/override if the user provided one.
- Do not run
snyk authorsnyk monitoras part of token validation for this skill; use Snyk API token checks instead.
Record imported project references in "$CASE_DIR/pr-check-context.json".
5) Create PR scenario
Ask user: "Ready to open PR?"
If yes:
- Create branch (for example
repro/pr-check). - Modify project to match the requested scenario:
- introduce vulnerability, or
- fix vulnerability.
- Commit, push, and open PR:
git checkout -b repro/pr-check
# apply requested vuln change
git add .
git commit -m "test: replicate PR check scenario"
git push -u origin repro/pr-check
gh pr create --title "PR check replication" --body "Repro for Snyk PR check behavior."
6) Collect check evidence
Run:
chmod +x pr-check-replication/scripts/collect_pr_check_context.sh
pr-check-replication/scripts/collect_pr_check_context.sh \
--repo "$REPO_NAME" \
--case-dir "$CASE_DIR"
This stores PR/check metadata to support troubleshooting.
Deliverables
At completion, return:
- GitHub repo URL
- PR URL
- Snyk project URL(s)
- Whether the PR check matched expected behavior
- Case artifact paths under
"$CASE_DIR"
References
- Checklist template:
references/checklist.md