open-pr
Open a PR from the current branch to main. Commit if needed, push, then create the PR with a filled-in description and testing steps.
Important: Do NOT ask for confirmation at any step. Run the entire flow automatically from start to finish. Only stop and ask the user if something fails or if the branch is main and you need a branch name.
Step 0: Ensure we are on a feature branch
Run git branch --show-current to check the current branch.
Step 1: Ensure an Nx version plan exists
Run:
git diff main...HEAD --name-only -- .nx/version-plans/
- If the output is non-empty, a version plan already exists — skip to Step 2.
- Otherwise, create one. The rules — path→package mapping, always-
patch, one
file per affected package, filename convention — live in the release-plan
skill; follow them. In short: look at the changed paths
(git diff main...HEAD --name-only), and create one
.nx/version-plans/version-plan-<timestamp>-<pkg>.md per affected package with
single-package patch frontmatter, using a description line that matches the
PR title / commit message style.
Step 2: Create a commit if needed
If git status shows nothing to commit, skip to Step 3.
If git status shows uncommitted changes (staged or unstaged):
Step 3: Push the branch
Push the branch to the remote (or update it if already pushed):
git push -u origin HEAD
Step 4: Check for an existing PR
Run:
gh pr view --json url
- If a PR already exists, print the existing PR URL and stop.
- Otherwise, continue to Step 5.
Step 5: Prepare PR body
Generate the PR body using the following structure:
## Description
<!-- Focus on WHY the change is being made — the motivation, problem, or goal.
Briefly mention what was done only to give context for the why.
If the change is UI-related, remind to add screenshots. -->
## How to test
<!-- Add concrete testing steps derived from the changed code.
e.g. which screen to open, what to tap, what to expect.
Must be specific enough for a reviewer to follow. -->
## Screenshots
<!-- Before/after screenshots if UI change, otherwise N/A -->
Fill in the template:
- Description: Analyse the diff against
main (git diff main...HEAD). Write a description focused on why the change is being made. Briefly mention what was done to give context.
- How to test: Derive concrete, specific testing steps from the changed code (e.g. which screen to open, what to interact with, what to expect).
- Screenshots: If the change is UI-related, add "Add before/after screenshots here"; otherwise write "N/A".
Save the body to /tmp/pr-body.md.
Step 6: Create the PR with GitHub CLI
Generate a PR title using a conventional commit message. Format: <prefix>(<scope>): <summary>. Pick the most appropriate prefix:
feat — new feature or user-facing addition
fix — bug fix
refactor — code restructuring without behaviour change
chore — maintenance, dependency updates, CI changes
docs — documentation only
test — adding or updating tests
style — formatting, whitespace, etc.
Include an optional scope in parentheses when it helps clarify the area (e.g. feat(select): ..., fix(button): ...).
The title should be a concise, human-readable summary.
Run:
gh pr create --title "<generated title>" --base main --body-file /tmp/pr-body.md
If gh is not installed or not authenticated, tell the user to install the GitHub CLI and run gh auth login, then rerun the command.
Output the PR link. After the PR is created, print a clickable link to the PR URL.
Clean up by deleting /tmp/pr-body.md.
Summary
- Ensure we are on a feature branch (create one if on
main).
- Ensure an Nx version plan exists in
.nx/version-plans/ — create one if missing, based on affected packages and change type.
- If there are uncommitted changes, create a commit with a clear conventional message.
- Push the branch to the remote.
- Check if a PR already exists — if so, skip creation and print the URL.
- Build the PR body with Description (why), How to test (concrete steps), and Screenshots.
- Run
gh pr create --base main --body-file /tmp/pr-body.md and output a clickable link to the created PR.
- Delete the temporary body file.
1---2name: open-pr3description: Open a PR from the current branch to `main`: commit if needed, ensure an Nx version plan exists, push, and create the PR with a filled-in description and testing steps. Run only when the user explicitly asks to open/create a PR.4---56# open-pr78Open a PR from the current branch to `main`. Commit if needed, push, then create the PR with a filled-in description and testing steps.910**Important: Do NOT ask for confirmation at any step.** Run the entire flow automatically from start to finish. Only stop and ask the user if something fails or if the branch is `main` and you need a branch name.1112## Step 0: Ensure we are on a feature branch131415Run `git branch --show-current` to check the current branch.1617- If already on a feature branch: **skip to Step 1**18- If on `main`: Ask the user for a Jira ticket number, generate a descriptive branch name from uncommitted changes, then create and switch to `DLS-<number>-<branch-name>`:19 ```bash20 git checkout -b DLS-<number>-<branch-name>21 ```2223## Step 1: Ensure an Nx version plan exists2425Run:26```bash27git diff main...HEAD --name-only -- .nx/version-plans/28```29- If the output is non-empty, a version plan already exists — **skip to Step 2**.30- Otherwise, create one. The rules — path→package mapping, always-`patch`, one31 file per affected package, filename convention — live in the `release-plan`32 skill; follow them. In short: look at the changed paths33 (`git diff main...HEAD --name-only`), and create one34 `.nx/version-plans/version-plan-<timestamp>-<pkg>.md` per affected package with35 single-package `patch` frontmatter, using a description line that matches the36 PR title / commit message style.3738## Step 2: Create a commit if needed3940- If `git status` shows nothing to commit, **skip to Step 3**.4142- If `git status` shows **uncommitted changes** (staged or unstaged):43 - Summarise the diff in one short sentence.44 - Generate a conventional commit message (e.g. `feat(select): add custom trigger support`).45 - Run immediately without asking for confirmation:46 ```bash47 git add -A48 git commit -m "Your generated message"49 ```5051## Step 3: Push the branch5253Push the branch to the remote (or update it if already pushed):5455```bash56git push -u origin HEAD57```5859## Step 4: Check for an existing PR6061Run:62```bash63gh pr view --json url64```65- If a PR already exists, print the existing PR URL and **stop**.66- Otherwise, continue to Step 5.6768## Step 5: Prepare PR body69701. **Generate the PR body** using the following structure:7172 ```markdown73 ## Description7475 <!-- Focus on WHY the change is being made — the motivation, problem, or goal.76 Briefly mention what was done only to give context for the why.77 If the change is UI-related, remind to add screenshots. -->7879 ## How to test8081 <!-- Add concrete testing steps derived from the changed code.82 e.g. which screen to open, what to tap, what to expect.83 Must be specific enough for a reviewer to follow. -->8485 ## Screenshots8687 <!-- Before/after screenshots if UI change, otherwise N/A -->88 ```89902. **Fill in the template:**91 - **Description:** Analyse the diff against `main` (`git diff main...HEAD`). Write a description focused on *why* the change is being made. Briefly mention *what* was done to give context.92 - **How to test:** Derive concrete, specific testing steps from the changed code (e.g. which screen to open, what to interact with, what to expect).93 - **Screenshots:** If the change is UI-related, add "Add before/after screenshots here"; otherwise write "N/A".94953. **Save the body** to `/tmp/pr-body.md`.9697## Step 6: Create the PR with GitHub CLI98991. **Generate a PR title** using a conventional commit message. Format: `<prefix>(<scope>): <summary>`. Pick the most appropriate prefix:100 - `feat` — new feature or user-facing addition101 - `fix` — bug fix102 - `refactor` — code restructuring without behaviour change103 - `chore` — maintenance, dependency updates, CI changes104 - `docs` — documentation only105 - `test` — adding or updating tests106 - `style` — formatting, whitespace, etc.107108 Include an optional scope in parentheses when it helps clarify the area (e.g. `feat(select): ...`, `fix(button): ...`).109 The title should be a concise, human-readable summary.1101112. **Run:**112113 ```bash114 gh pr create --title "<generated title>" --base main --body-file /tmp/pr-body.md115 ```116117 If `gh` is not installed or not authenticated, tell the user to install the [GitHub CLI](https://cli.github.com/) and run `gh auth login`, then rerun the command.1181193. **Output the PR link.** After the PR is created, print a clickable link to the PR URL.1201214. **Clean up** by deleting `/tmp/pr-body.md`.122123## Summary1241251. Ensure we are on a feature branch (create one if on `main`).1262. Ensure an Nx version plan exists in `.nx/version-plans/` — create one if missing, based on affected packages and change type.1273. If there are uncommitted changes, create a commit with a clear conventional message.1284. Push the branch to the remote.1295. Check if a PR already exists — if so, skip creation and print the URL.1306. Build the PR body with Description (why), How to test (concrete steps), and Screenshots.1317. Run `gh pr create --base main --body-file /tmp/pr-body.md` and output a clickable link to the created PR.1328. Delete the temporary body file.