1---2name: pr-and-check3description: Use this skill when you are requested to create a PR for a feature branch to develop, or from develop to production.4---5
6# Instructions
7
8## 1. Validate branch and determine PR target
9- Check current branch: `git branch --show-current`
10- Determine the PR flow:
11 - If on `develop` → create PR to `production`
12 - If on `production` → report error and stop (cannot create PR from production)
13 - If on any other branch (feature branch) → create PR to `develop`
14- Store the target branch for later use
15
16## 2. Check for existing PR
17- Check if a PR already exists for this branch to the target:
18 - `gh pr list --head <branch-name> --base <target-branch> --json number,url`
19- If a PR exists, report the existing PR URL and skip to step 5 (code review)
20
21## 3. Run tests locally
22- Run linting first:
23 - run: `npm run lint`
24 - if linting fails, analyse the failure, report findings, and stop
25- Run unit tests:
26 - run: `npm test`
27 - if tests fail, analyse the failure, report findings, and stop
28- Run build to verify compilation:
29 - run: `npm run build`
30 - if build fails, analyse the failure, report findings, and stop
31
32## 4. Create PR
33- Get version number for the PR body:
34 - `jq -r .version package.json`
35- Get list of commits to include:
36 - `git log origin/<target-branch>..HEAD --oneline`
37- Create a well-formatted PR:
38 - use `gh pr create --base <target-branch> --title "<title>" --body "<body>"` with a HEREDOC for the body
39 - highlight the changes and the purpose of the branch
40 - include test results summary and version number
41- Capture the PR number from the output (needed for code review step)
42 - the `gh pr create` command outputs the PR URL, extract the number from it
43
44## 5. Monitor code review
45- A code review using the workflow claude-code-review.yml was automatically triggered by the PR
46- Verify the workflow started:
47 - wait 5 seconds, then check: `gh run list --workflow=claude-code-review.yml --limit 1 --json databaseId,status,headBranch`
48 - confirm the run is for the correct branch
49 - if workflow failed to start, report error and stop
50- Poll for completion (check once per minute, max 10 minutes total):
51 - Use separate bash commands with `sleep 60 && gh run list --workflow=claude-code-review.yml --limit 1 --json databaseId,status,conclusion`
52 - IMPORTANT: Do NOT use complex shell constructs like `for i in {1..10}` as they cause parse errors
53 - Make sequential individual bash calls, checking the status after each one
54 - If status is "completed", stop polling
55- Check the result:
56 - if the workflow did not finish within 10 minutes, report timeout and stop
57 - view the review: `gh pr view <pr-number> --comments` or check the PR review file artifact
58 - if the review includes recommendations to address before merging, summarize the recommendations and stop
59 - if the review ended without critical recommendations, summarize the overall comments and stop