|
| 1 | +--- |
| 2 | +name: graphite-pr-workflow |
| 3 | +description: Create branches, commits, and pull requests using Graphite CLI (gt) for the snowflake-jdbc repository. Use when the user asks to create a PR, submit a PR, commit changes, or push a branch. Covers Graphite commands, SNOW-ticket commit message conventions, PR description templates, and snowflake-jdbc-specific pre-commit formatting/checkstyle requirements. |
| 4 | +--- |
| 5 | + |
| 6 | +# Graphite PR Workflow (snowflake-jdbc) |
| 7 | + |
| 8 | +## CRITICAL: Do Not Commit or Submit Without Explicit Instruction |
| 9 | + |
| 10 | +**NEVER run `gt commit create`, `git commit`, `gt submit`, or open a PR unless the user has explicitly asked you to.** Completing a feature is NOT permission to commit. Passing tests is NOT permission to commit. Pre-commit checks succeeding is NOT permission to commit. |
| 11 | + |
| 12 | +When you have finished implementing a feature or change, you MAY ask the user whether they want you to proceed with creating a commit and PR. Phrase it as a question and wait for explicit confirmation before doing anything that mutates git history or the remote. |
| 13 | + |
| 14 | +Examples of acceptable prompts after finishing work: |
| 15 | +- "The change is implemented and tests pass. Would you like me to format, run checkstyle, and create a commit + PR?" |
| 16 | +- "Should I proceed with `gt commit create` and `gt submit`?" |
| 17 | + |
| 18 | +Do NOT interpret ambiguous responses ("looks good", "great", "thanks") as approval to commit. Wait for an explicit "yes, commit" / "create the PR" / "go ahead and submit". |
| 19 | + |
| 20 | +## Required Pre-Commit Checks (snowflake-jdbc) |
| 21 | + |
| 22 | +Before running ANY commit command (`gt commit create`, `git commit`, `gt commit amend`), you MUST run the following two Maven commands in order from the repo root and confirm they succeed: |
| 23 | + |
| 24 | +1. **Format the code** with the Spotify fmt plugin: |
| 25 | + |
| 26 | + ```bash |
| 27 | + mvn com.spotify.fmt:fmt-maven-plugin:format |
| 28 | + ``` |
| 29 | + |
| 30 | +2. **Validate checkstyle** passes cleanly: |
| 31 | + |
| 32 | + ```bash |
| 33 | + mvn clean validate --batch-mode --show-version -P check-style |
| 34 | + ``` |
| 35 | + |
| 36 | +If either command fails, fix the reported issues (re-running the formatter for any new files, or addressing checkstyle violations manually) and re-run both commands until both succeed. Only then may you proceed with committing — and only if the user has explicitly asked you to commit (see section above). |
| 37 | + |
| 38 | +## Commit Message Convention |
| 39 | + |
| 40 | +Prefix with Jira ticket: `SNOW-{ticket}: {description}` |
| 41 | + |
| 42 | +``` |
| 43 | +SNOW-3254915: Add QueryStatus enum and is_still_running/is_an_error static methods |
| 44 | +``` |
| 45 | + |
| 46 | +Use `NO-SNOW:` for changes without a ticket. |
| 47 | + |
| 48 | +## Creating a PR (only after explicit user approval) |
| 49 | + |
| 50 | +```bash |
| 51 | +# 1. Create a tracked branch |
| 52 | +gt branch create {user}/{branch-name} |
| 53 | + |
| 54 | +# 2. Format and validate (REQUIRED — see Pre-Commit Checks above) |
| 55 | +mvn com.spotify.fmt:fmt-maven-plugin:format |
| 56 | +mvn clean validate --batch-mode --show-version -P check-style |
| 57 | + |
| 58 | +# 3. Stage files |
| 59 | +git add <files> |
| 60 | + |
| 61 | +# 4. Commit (runs pre-commit hooks) |
| 62 | +gt commit create -m "SNOW-{ticket}: {description}" |
| 63 | + |
| 64 | +# 5. Push and create PR (draft mode in non-interactive) |
| 65 | +gt submit --no-edit |
| 66 | +``` |
| 67 | + |
| 68 | +Then update title/description via `gh pr edit` or the Graphite web UI. |
| 69 | + |
| 70 | +## PR Description Template |
| 71 | + |
| 72 | +```markdown |
| 73 | +## Summary |
| 74 | +- Bullet points describing what changed and why |
| 75 | + |
| 76 | +## Context |
| 77 | +Brief explanation of how this fits into the larger effort (e.g., "first of two PRs for...") |
| 78 | + |
| 79 | +## Test plan |
| 80 | +Explain how the change was tested: what commands were run, what was |
| 81 | +verified, and the results. Be specific to this PR. |
| 82 | +``` |
| 83 | + |
| 84 | +## Key Commands |
| 85 | + |
| 86 | +| Command | Purpose | |
| 87 | +|---------|---------| |
| 88 | +| `mvn com.spotify.fmt:fmt-maven-plugin:format` | Auto-format Java sources (REQUIRED before commit) | |
| 89 | +| `mvn clean validate --batch-mode --show-version -P check-style` | Run checkstyle validation (REQUIRED before commit) | |
| 90 | +| `gt branch create {name}` | Create branch tracked by Graphite | |
| 91 | +| `gt commit create -m "..."` | Commit with message | |
| 92 | +| `gt commit amend` | Amend current commit | |
| 93 | +| `gt submit --no-edit` | Push and create/update PR | |
| 94 | +| `gt submit --stack` | Submit entire stack of PRs | |
| 95 | +| `gt restack` | Rebase stack after upstream changes | |
| 96 | + |
| 97 | +## Before Creating a PR: Required Checks |
| 98 | + |
| 99 | +Before proceeding with branch creation or committing, you MUST: |
| 100 | + |
| 101 | +1. **Confirm the user has explicitly requested a commit/PR.** See the top of this file. Do not commit proactively. |
| 102 | + |
| 103 | +2. **Run the formatter and checkstyle commands** described in the Required Pre-Commit Checks section above and confirm both pass. |
| 104 | + |
| 105 | +3. **Ask for SNOW ticket number** if the user hasn't provided one. Use AskQuestion: |
| 106 | + - Prompt: "What is the SNOW Jira ticket number for this change?" |
| 107 | + - Options: a text-free response, or "NO-SNOW (no ticket)" |
| 108 | + Do NOT proceed with a commit until the ticket number is confirmed. |
| 109 | + |
| 110 | +4. **Detect stacked PR situation.** Run `git log --oneline main..HEAD` or check `git branch --show-current` and its parent. If the current branch is NOT based directly off `main` (i.e., there are intermediate branches), ask: |
| 111 | + - "This branch is based off `{parent_branch}`, not `main`. Should this be a stacked PR?" |
| 112 | + - If yes: use `gt submit --stack` to submit the full stack |
| 113 | + - If no: use `gt submit --no-edit` for just this branch |
| 114 | + |
| 115 | +## Notes |
| 116 | + |
| 117 | +- `gt submit --no-edit` creates PRs in **draft mode** when non-interactive |
| 118 | +- Pre-commit hooks run automatically on `gt commit create`, but they are NOT a substitute for running the formatter + checkstyle commands manually beforehand |
0 commit comments