---
name: create-pr-gh
description: Creates a Pull Request on GitHub from the current branch. Runs the same logic as compose-pr, then executes gh pr create. Use when the user wants to open the PR directly from the CLI.
---

# /create-pr-gh

You are a PR creation assistant. All info for the PR comes from [`compose-pr.md`](./compose-pr.md). Never modify any part of the PR, just create it.

---

## Step 0 — Check GitHub CLI login

```bash
gh auth status
```

If the command fails or reports that you are not logged in, **stop and inform the user**. Tell them to run `gh auth login` and then run this command again. Do not proceed to Step 1 until `gh auth status` succeeds.

---

## Step 1 — Compose the PR

Use the [compose-pr.md](./compose-pr.md) command to get the PR details.

---

## Step 2 — Create the PR with GitHub CLI

1. Write the **body** (the full markdown from Step 1) to a temporary file, e.g. `.cursor/.pr-body.md` or `/tmp/pr-body.md`, so that newlines and special characters are preserved.
2. Run:

```bash
gh pr create --base <BASE_BRANCH> --title "<TITLE>" --body-file <PATH_TO_BODY_FILE> --label "<TRIBE_LABEL>" [--label "<FLOW_LABEL>" if applicable]
```

- Use the same `<BASE_BRANCH>` as in Step 1 (e.g. `develop` or `main`).
- Use the exact title and body file path from Step 1.
- Pass the **tribe label** from Step 1. If the step provided a **flow label**, add a second `--label` for it.

Example (tribe `data`, no flow label):

```bash
gh pr create --base develop --title "fix(EmployeeLifecycle): [SQGZ-642] disable dependency toggle when no previous actions" --body-file .cursor/.pr-body.md --label "data"
```

Example (tribe `talent`, bugfix flow):

```bash
gh pr create --base develop --title "fix(goals): [SQ-123] handle validation error" --body-file .cursor/.pr-body.md --label "talent" --label "stg fix"
```

3. If `gh pr create` fails (e.g. not authenticated, or no upstream), report the error to the user and optionally output the title and body so they can create the PR manually.
4. If the PR is created successfully, output the PR URL.

---

## Rules

- Always run the git commands (Steps 0) before generating title/body or creating the PR.
- **Step 1 must yield a tribe label** before running `gh pr create`. If the tribe is unknown, **stop** and ask the user — do not invent or infer from the diff. Do not create the PR without at least one label.
- The body file must contain valid markdown; avoid breaking the body with unescaped characters when writing the file.
