feat(skills): add pr-fixup, pr-ready, and pr-draft skills (#463)
This commit is contained in:
@@ -46,9 +46,11 @@ ci: add PR title linting workflow
|
||||
|
||||
## Steps
|
||||
|
||||
**Create a todo/task for each step below and mark them as completed as you go.**
|
||||
|
||||
1. Run `git status` and `git diff` to understand all changes
|
||||
2. Review recent commits with `git log --oneline -10` to match project style
|
||||
3. Stage relevant files (prefer specific files over `git add -A`)
|
||||
4. Write a commit message following the format above
|
||||
5. If changes span multiple concerns, consider separate commits
|
||||
6. After committing, run `make fmt` then `make lint` to verify
|
||||
3. Run `/verify` as a **sub-agent** to ensure formatters, linters, typechecks, and tests all pass. Fix any issues before committing.
|
||||
4. Stage relevant files (prefer specific files over `git add -A`)
|
||||
5. Write a commit message following the format above
|
||||
6. If changes span multiple concerns, consider separate commits
|
||||
|
||||
@@ -1,73 +0,0 @@
|
||||
---
|
||||
name: pr-comments
|
||||
description: Address PR review comments — fix valid ones, react with thumbs up, resolve threads, and push.
|
||||
---
|
||||
|
||||
# PR Comments
|
||||
|
||||
Read and address review comments on a pull request, then push fixes.
|
||||
|
||||
## Context
|
||||
|
||||
- Current branch: !`git branch --show-current`
|
||||
- Current PR (if any): !`gh pr view --json number,url,title`
|
||||
|
||||
## Steps
|
||||
|
||||
### 1. Fetch comments
|
||||
|
||||
Get the PR number from context or the user. Fetch all review comments:
|
||||
|
||||
```bash
|
||||
gh pr view <number> --json reviews,comments
|
||||
gh api repos/{owner}/{repo}/pulls/<number>/comments
|
||||
```
|
||||
|
||||
Also check for top-level PR comments and review threads.
|
||||
|
||||
### 2. Triage each comment
|
||||
|
||||
For each comment, decide:
|
||||
- **Valid and actionable** — the comment points to a real issue (bug, missing edge case, naming, architecture concern, code quality). Proceed to fix it.
|
||||
- **Already addressed** — the code already handles what the comment suggests. Skip it.
|
||||
- **Nitpick or preference** — subjective style preference not covered by linters. Skip unless the reviewer is insistent.
|
||||
- **Wrong or outdated** — the comment misunderstands the code or refers to old state. Skip it.
|
||||
|
||||
### 3. Fix valid comments
|
||||
|
||||
For each valid comment:
|
||||
1. Read the file at the referenced line
|
||||
2. Implement the fix
|
||||
3. React with a thumbs up on the comment:
|
||||
```bash
|
||||
gh api repos/{owner}/{repo}/pulls/comments/<comment_id>/reactions -f content="+1"
|
||||
```
|
||||
4. Resolve the review thread:
|
||||
```bash
|
||||
gh api graphql -f query='mutation { resolveReviewThread(input: {threadId: "<thread_node_id>"}) { thread { isResolved } } }'
|
||||
```
|
||||
Get the `thread_node_id` from the review threads query (use `node_id` field from the thread, not the comment ID).
|
||||
|
||||
### 4. Verify
|
||||
|
||||
Run `/verify` to ensure formatters, linters, typechecks, and tests all pass. Do NOT push until verify passes clean.
|
||||
|
||||
### 5. Commit and push
|
||||
|
||||
Run `/commit` to stage and commit the fixes. Use a message like:
|
||||
```
|
||||
fix: address PR review feedback
|
||||
```
|
||||
or be more specific if fixes are scoped (e.g., `fix: add nil check per review feedback`).
|
||||
|
||||
Then push:
|
||||
```bash
|
||||
git push
|
||||
```
|
||||
|
||||
### 6. Summary
|
||||
|
||||
Report what was done:
|
||||
- Which comments were addressed (with thumbs up)
|
||||
- Which comments were skipped and why
|
||||
- Link to the pushed commit
|
||||
@@ -0,0 +1,151 @@
|
||||
---
|
||||
name: pr-fixup
|
||||
description: Wait for CI checks and CodeRabbit review on a PR, fix failures and address comments, then push.
|
||||
---
|
||||
|
||||
# PR Fixup
|
||||
|
||||
Wait for CI and code review to complete on a pull request, fix any failures or valid comments, then push.
|
||||
|
||||
## Context
|
||||
|
||||
- Current branch: !`git branch --show-current`
|
||||
- Current PR: !`gh pr view --json number,url,title`
|
||||
|
||||
## Steps
|
||||
|
||||
**Create a todo/task for each step below and mark them as completed as you go.**
|
||||
|
||||
### 1. Gather PR state
|
||||
|
||||
Get the PR number from context or the user. Fetch the current state:
|
||||
|
||||
```bash
|
||||
gh pr checks <number>
|
||||
gh pr view <number> --json comments
|
||||
gh api repos/:owner/:repo/pulls/<number>/comments
|
||||
```
|
||||
|
||||
### 2. Wait for CI checks
|
||||
|
||||
If any checks are still running (`pending` / `queued` / `in_progress`), poll until they all resolve:
|
||||
|
||||
```bash
|
||||
gh pr checks <number>
|
||||
```
|
||||
|
||||
- Poll every **30 seconds**
|
||||
- Cap at **10 minutes** (20 polls). If still running after 10 min, report which checks are stuck and proceed.
|
||||
- Once done, note which checks passed and which failed.
|
||||
|
||||
### 3. Wait for CodeRabbit review
|
||||
|
||||
Check if CodeRabbit has posted or is generating a review. Look at comments from `coderabbitai`:
|
||||
|
||||
**Stop waiting immediately if:**
|
||||
- A comment contains `<!-- rate limited by coderabbit.ai -->` — CodeRabbit is rate-limited and won't review this PR.
|
||||
- A comment contains `<!-- walkthrough_start -->` — the review is already complete.
|
||||
|
||||
**Keep polling if:**
|
||||
- No `coderabbitai` comment exists AND `gh pr checks` shows a `CodeRabbit` check that is still `pending` — the review is being generated.
|
||||
|
||||
Poll every **30 seconds**, cap at **10 minutes**. Fetch comments each poll:
|
||||
```bash
|
||||
gh pr view <number> --json comments --jq '.comments[] | select(.author.login == "coderabbitai") | .body'
|
||||
```
|
||||
|
||||
### 4. Fix failing CI checks
|
||||
|
||||
If any CI checks failed:
|
||||
|
||||
1. Identify the failed runs from the `gh pr checks` output (the URL column contains the run URL)
|
||||
2. Fetch the failed logs:
|
||||
```bash
|
||||
gh run view <run-id> --log-failed
|
||||
```
|
||||
3. Read the relevant source files at the failing lines
|
||||
4. Fix the issues (lint errors, test failures, type errors, etc.)
|
||||
|
||||
### 5. Triage review comments
|
||||
|
||||
Fetch all review comments — both human reviewers and CodeRabbit:
|
||||
|
||||
```bash
|
||||
gh pr view <number> --json reviews,comments
|
||||
gh api repos/:owner/:repo/pulls/<number>/comments
|
||||
```
|
||||
|
||||
For each comment, decide:
|
||||
- **Valid and actionable** — real issue (bug, missing edge case, naming, architecture, code quality). Fix it.
|
||||
- **Already addressed** — the code already handles what the comment suggests. Skip.
|
||||
- **Nitpick or preference** — subjective style not covered by linters. Skip unless the reviewer insists.
|
||||
- **Wrong or outdated** — misunderstands the code or refers to old state. Skip.
|
||||
|
||||
### 6. Address each comment
|
||||
|
||||
Every comment must get a response — either a fix or a reply explaining why it was skipped.
|
||||
|
||||
**For valid comments:**
|
||||
1. Read the file at the referenced line
|
||||
2. Implement the fix
|
||||
3. React with thumbs up:
|
||||
```bash
|
||||
gh api repos/:owner/:repo/pulls/comments/<comment_id>/reactions -f content="+1"
|
||||
```
|
||||
4. Resolve the review thread (see below for thread ID retrieval)
|
||||
|
||||
**For skipped comments** (already addressed, nitpick, wrong, or outdated):
|
||||
1. Reply to the comment explaining why it was skipped:
|
||||
```bash
|
||||
gh api repos/:owner/:repo/pulls/<number>/comments/<comment_id>/replies -f body="<explanation>"
|
||||
```
|
||||
Examples:
|
||||
- "This is already handled by X on line Y."
|
||||
- "This is a style preference not enforced by our linters — keeping as-is."
|
||||
- "This refers to code that was changed in a later commit."
|
||||
2. Resolve the review thread
|
||||
|
||||
**Resolving threads:** First fetch thread node IDs to map comment IDs to threads:
|
||||
```bash
|
||||
gh api graphql -f query='
|
||||
query($owner: String!, $repo: String!, $number: Int!) {
|
||||
repository(owner: $owner, name: $repo) {
|
||||
pullRequest(number: $number) {
|
||||
reviewThreads(first: 100) {
|
||||
nodes {
|
||||
id
|
||||
comments(first: 1) {
|
||||
nodes { databaseId }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}' -f owner=":owner" -f repo=":repo" -F number=<number>
|
||||
```
|
||||
Then resolve using the thread `id`:
|
||||
```bash
|
||||
gh api graphql -f query='mutation { resolveReviewThread(input: {threadId: "<thread_node_id>"}) { thread { isResolved } } }'
|
||||
```
|
||||
|
||||
### 7. Commit and push
|
||||
|
||||
Run `/commit` to stage and commit fixes (it runs `/verify` internally). Use a descriptive message, e.g.:
|
||||
```
|
||||
fix: address PR review feedback
|
||||
fix: resolve CI lint failures
|
||||
fix: address review feedback and fix CI failures
|
||||
```
|
||||
|
||||
Then push:
|
||||
```bash
|
||||
git push
|
||||
```
|
||||
|
||||
### 8. Summary
|
||||
|
||||
Report what was done:
|
||||
- CI checks: which failed and how they were fixed
|
||||
- Comments addressed (with thumbs up)
|
||||
- Comments skipped and why
|
||||
- Link to the pushed commit
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
name: push-pr
|
||||
description: Push the current branch and open a draft PR. Use when the user wants to open a pull request or push their work for review.
|
||||
name: pr
|
||||
description: Commit, push, and create a PR. Default is ready-for-review with auto-fixup. Use --draft to skip review/fixup.
|
||||
---
|
||||
|
||||
## Context
|
||||
@@ -10,19 +10,28 @@ description: Push the current branch and open a draft PR. Use when the user want
|
||||
- Commits on this branch vs main: !`git log --oneline main..HEAD`
|
||||
- Recent commit messages for style reference: !`git log --oneline -5`
|
||||
|
||||
## Options
|
||||
|
||||
- `--draft` — create the PR as draft and skip the fixup step. Use when the work is not ready for review.
|
||||
- Default (no flag) — create as ready-for-review and run `/pr-fixup` to wait for CI/CodeRabbit and fix issues.
|
||||
|
||||
## Your task
|
||||
|
||||
Push the current branch and open a **draft** pull request.
|
||||
Commit, push, and create a pull request.
|
||||
|
||||
### Rules
|
||||
### Steps
|
||||
|
||||
1. **Uncommitted changes:** If there are dirty or staged changes, run the `/commit` skill first to commit them before proceeding.
|
||||
**Create a todo/task for each step below and mark them as completed as you go.**
|
||||
|
||||
2. **Branch:** If on `main`, create a new branch from the commits (use a descriptive name like `feat/short-description` or `fix/short-description`) and switch to it before pushing. If already on a feature branch, use it as-is.
|
||||
1. **Uncommitted changes:** If there are dirty or staged changes, run `/commit` first (it runs `/verify` internally).
|
||||
|
||||
3. **Push:** Push the branch to origin with `-u` to set upstream tracking.
|
||||
2. **Branch:** If on `main`, create a new branch from the commits (use a descriptive name like `feat/short-description` or `fix/short-description`) and switch to it. If already on a feature branch, use it as-is.
|
||||
|
||||
4. **PR title** must follow Conventional Commits format (CI validates this via `pr-title.yml`, and it becomes the squash-merge commit used for release notes):
|
||||
3. **Push** the branch to origin with `-u` to set upstream tracking.
|
||||
|
||||
4. **Create the PR.** Use `--draft` flag if the user requested draft mode, otherwise create as ready-for-review.
|
||||
|
||||
**PR title** must follow Conventional Commits format (CI validates this via `pr-title.yml`, and it becomes the squash-merge commit used for release notes):
|
||||
- Format: `type(scope): lowercase description` or `type: lowercase description`
|
||||
- Allowed types: `feat`, `fix`, `perf`, `refactor`, `docs`, `chore`, `ci`, `test`
|
||||
- Subject starts with a lowercase letter
|
||||
@@ -30,7 +39,7 @@ Push the current branch and open a **draft** pull request.
|
||||
- Add `!` after type for breaking changes: `feat!: remove legacy API`
|
||||
- Examples: `feat(ui): add task filter dialog`, `fix: prevent duplicate session on reconnect`
|
||||
|
||||
5. **PR body** must follow the project's pull request template. Fill in each section using these rules:
|
||||
**PR body** must follow the project's pull request template:
|
||||
- **Summary** (required): 1–2 sentences of prose, no heading. Lead with the problem/goal, end with the outcome. Say WHY, not what.
|
||||
- **Important Changes** (optional): short bullet list of significant architectural changes. Remove section if not needed.
|
||||
- **Validation** (required): list commands or checks run (e.g. `go test ./...`, `make lint`).
|
||||
@@ -41,17 +50,13 @@ Push the current branch and open a **draft** pull request.
|
||||
- Do NOT add tool attribution footers.
|
||||
- Do NOT leave placeholder text or unfilled sections.
|
||||
|
||||
6. **Always create as draft:** Use `gh pr create --draft`.
|
||||
```bash
|
||||
gh pr create [--draft] --title "type: description" --body "$(cat <<'EOF'
|
||||
<filled PR template>
|
||||
EOF
|
||||
)"
|
||||
```
|
||||
|
||||
7. **Execute in a single message.** Push and create the PR using parallel tool calls where possible. Do not read files or do anything else beyond what's listed here.
|
||||
5. **If ready (not draft):** Run `/pr-fixup` to wait for CI checks and CodeRabbit review, fix any failures or valid comments, and push.
|
||||
|
||||
### Command
|
||||
|
||||
```
|
||||
gh pr create --draft --title "type: description" --body "$(cat <<'EOF'
|
||||
<filled PR template>
|
||||
EOF
|
||||
)"
|
||||
```
|
||||
|
||||
8. **Return the PR URL** when done.
|
||||
6. **Return the PR URL** when done.
|
||||
@@ -0,0 +1,33 @@
|
||||
---
|
||||
name: push
|
||||
description: Commit and push to the current branch. Use --fixup to also wait for CI/CodeRabbit and fix issues.
|
||||
---
|
||||
|
||||
## Context
|
||||
|
||||
- Current branch: !`git branch --show-current`
|
||||
- Current git status: !`git status`
|
||||
|
||||
## Options
|
||||
|
||||
- `--fixup` — after pushing, run `/pr-fixup` to wait for CI and CodeRabbit review, fix issues, and push again.
|
||||
|
||||
## Your task
|
||||
|
||||
Commit any pending changes and push to the remote branch.
|
||||
|
||||
### Steps
|
||||
|
||||
**Create a todo/task for each step below and mark them as completed as you go.**
|
||||
|
||||
1. **Uncommitted changes:** If there are dirty or staged changes, run `/commit` first (it runs `/verify` internally).
|
||||
|
||||
2. **Push** the current branch:
|
||||
```bash
|
||||
git push
|
||||
```
|
||||
If the branch has no upstream, use `git push -u origin <branch>`.
|
||||
|
||||
3. **Report** the pushed commit hash and branch.
|
||||
|
||||
4. **If `--fixup`:** Run `/pr-fixup` to wait for CI checks and CodeRabbit review, fix any failures or valid comments, and push.
|
||||
Reference in New Issue
Block a user