# Pr Check Replication

> Reproduces Snyk PR check behavior by creating a case workspace, capturing the target SCM context, creating a personal test repo, importing it into Snyk default org (unless overridden), opening a controlled PR that introduces or fixes a vulnerability, and collecting check evidence.

- Skill: `snyk-general-support/pr-check-replication` (Agent Skill, multi-file: 3 files)
- Install (CLI): `npx skillmds@latest add snyk-general-support/pr-check-replication`
- Raw SKILL.md: https://api.skillmd.com/api/skills/snyk-general-support/pr-check-replication/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: Snyk-General-Support (https://skillmd.com/u/snyk-general-support)
- Updated: 2026-09-22
- Page: https://skillmd.com/skills/snyk-general-support/pr-check-replication

---


# 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:

1. Create case folder using `set-new-case`.
2. Capture which SCM is being replicated (GitHub/GitLab/Bitbucket) and create a personal test repo.
3. Seed the repo with a minimal project:
   - Open Source PR check: include a package manager manifest.
   - Code PR check: include source code only.
4. Import repo into Snyk.
5. Ask user when ready to open PR.
6. Create a PR that either introduces or fixes a vulnerability.
7. Capture PR/check artifacts into the case directory.

## Required prerequisites

- `gh` is authenticated to the personal GitHub account (`gh auth status`) for GitHub-based repro runs.
- `SNYK_TOKEN` is present and valid (validate via Snyk API, not CLI auth flow):

  ```bash
  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: `200`
- Case environment already configured (`SNYK_CASES_DIR` preferred).

## Inputs to collect from user

- `CASE_NUMBER`
- SCM to replicate (required): `github`, `gitlab`, or `bitbucket`
- Repro type: `oss` or `code`
- 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

```bash
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"`:

```bash
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:

```bash
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 auth` or `snyk monitor` as 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:

```bash
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:

```bash
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`

