Skip to content

Commit 5dd1976

Browse files
authored
docs(skills): prefer && chains in github-cli, add worktree-to-PR workflow (#150)
## Summary - Reduce agent tool calls by chaining sequential gh/git commands with && across all three github-cli skill files - Add push+PR-create combo, CI from-URL shortcut, and new anti-patterns to SKILL.md - Add worktree-to-draft-PR workflow to git-worktrees skill; cross-reference from github-cli Issue-to-PR lifecycle - Fix pre-existing missing --signoff in several workflow recipes ## Test plan - [ ] Spot-check bash snippets for quoting and variable expansion correctness - [ ] Verify unquoted heredoc used where ISSUE needs expansion; quoted elsewhere Made with [Cursor](https://cursor.com) Signed-off-by: aagonzales <aagonzales@nvidia.com>
1 parent aae129d commit 5dd1976

4 files changed

Lines changed: 67 additions & 76 deletions

File tree

.agent/skills/git-worktrees/SKILL.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,27 @@ Lessons from real sessions working in this repo:
229229

230230
- Dependency safety: worktrees default to sharing the main repo's `.venv` via `UV_PROJECT_ENVIRONMENT`. If the worktree changes `pyproject.toml`, unset it and run `uv sync --frozen` to create a local venv. Never run bare `uv sync` in a worktree -- it can silently modify the tracked `uv.lock` file.
231231

232+
## Worktree to Draft PR
233+
234+
Common pattern: make changes in a worktree and open a draft PR in one chain.
235+
236+
```bash
237+
cd "$SS_WORKTREE_DIR/ss-wt-<name>" \
238+
&& git add -A && git commit -s -m "feat: description" \
239+
&& git push -u origin HEAD \
240+
&& gh pr create --draft --title "feat: description" --body "$(cat <<'EOF'
241+
## Summary
242+
- ...
243+
EOF
244+
)"
245+
```
246+
247+
When dispatching this workflow, ask the user whether they want a worktree or a local branch. Worktrees are preferred when:
248+
249+
- The main checkout has uncommitted work or is on a different branch
250+
- Multiple branches need to be active simultaneously
251+
- The user explicitly requested a worktree
252+
232253
## Quick Reference
233254

234255
| Situation | Command |

.agent/skills/github-cli/SKILL.md

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,16 @@ Note: The commands below are quick references. For comprehensive detail and mult
1818

1919
Always use `required_permissions: ["all"]` when running `gh` commands. Sandboxed environments fail with TLS certificate errors (`x509: OSStatus -26276`).
2020

21+
## Prefer && Chains
22+
23+
When running multiple sequential commands (pre-flight, commit, push, PR create), chain them with `&&` in a single shell call. Only use separate calls when you need to read intermediate output before deciding the next step.
24+
2125
## Pre-flight
2226

2327
Before any `gh` operation, verify the binary is available and authenticated:
2428

2529
```bash
26-
# Verify gh is available (check PATH, then common install location)
27-
which gh 2>/dev/null || ls ~/.local/bin/gh 2>/dev/null
28-
# If found at ~/.local/bin/gh but not on PATH:
29-
export PATH="$HOME/.local/bin:$PATH"
30-
# Verify authentication
31-
gh auth status
30+
export PATH="$HOME/.local/bin:$PATH" && gh auth status
3231
```
3332

3433
## Pull Requests
@@ -59,22 +58,26 @@ gh pr view --json number,url 2>/dev/null && echo "PR exists" || echo "No PR yet"
5958

6059
# Edit an existing PR's title/body
6160
gh pr edit <number> --title "New title" --body "New body"
61+
62+
# Push and create PR in one call (most common multi-step pattern)
63+
git push -u origin HEAD && gh pr create --draft --title "feat: short title" --body "$(cat <<'EOF'
64+
## Summary
65+
- ...
66+
EOF
67+
)"
6268
```
6369

6470
## CI / Actions
6571

6672
```bash
67-
# Check CI status for current branch
68-
gh pr checks
69-
70-
# List workflow runs
71-
gh run list --limit 10
73+
# Check CI status + recent runs in one call
74+
gh pr checks && gh run list --limit 5
7275

73-
# View a failed run
74-
gh run view <run-id>
75-
76-
# View failed job logs
76+
# When you already have the run ID (e.g. from a URL the user pasted):
7777
gh run view <run-id> --log-failed
78+
79+
# Summary + logs in one call
80+
gh run view <run-id> && gh run view <run-id> --log-failed
7881
```
7982

8083
## Issues
@@ -129,6 +132,8 @@ Keep bodies concise -- 2-4 bullet summary for PRs, problem + options for issues.
129132

130133
## Common Mistakes
131134

135+
- Don't run `gh run view <id>` and `gh run view <id> --log-failed` as separate calls -- go straight to `--log-failed` when you already have the run ID
132136
- Don't WebFetch GitHub Actions URLs for private repos -- use `gh run view` instead (auth required)
133137
- Don't propose `gh pr create` without checking if a PR already exists first
134138
- Don't generate long PR/issue bodies -- users consistently ask agents to cut them down
139+
- Don't use separate shell calls for `git push` then `gh pr create` -- chain them with `&&`

.agent/skills/github-cli/references/full-reference.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,13 @@ The project has 7 GitHub Actions workflows:
8585
### Investigating Failures
8686

8787
```bash
88-
# Failed runs for current branch
89-
gh run list --branch=$(git branch --show-current) --status=failure
90-
91-
# View failed job logs
88+
# When you have a run ID (e.g. from a URL the user pasted), go straight to logs:
9289
gh run view <run-id> --log-failed
9390

91+
# Find and show logs for the latest failure on this branch in one call:
92+
RUN_ID=$(gh run list --branch=$(git branch --show-current) --status=failure --limit=1 --json databaseId -q '.[0].databaseId') \
93+
&& [ "$RUN_ID" != "null" ] && gh run view "$RUN_ID" --log-failed
94+
9495
# Full log for a specific job
9596
gh run view <run-id> --log --job=<job-id>
9697

.agent/skills/github-cli/references/workflows.md

Lines changed: 21 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ Complete check before merging a PR:
1212
```bash
1313
PR_NUMBER=<number>
1414

15-
# Full status in one call (avoids Projects Classic GraphQL bug with plain `gh pr view`)
16-
echo "=== PR Summary ==="
1715
gh pr view $PR_NUMBER \
1816
--json number,title,state,isDraft,mergeable,reviewDecision,additions,deletions,changedFiles,labels,assignees,author,statusCheckRollup,reviews \
1917
--jq '{
@@ -23,10 +21,8 @@ gh pr view $PR_NUMBER \
2321
labels: [.labels[].name],
2422
checks: [.statusCheckRollup[] | {name: .name, conclusion: .conclusion}],
2523
reviews: [.reviews[] | {author: .author.login, state: .state}]
26-
}'
27-
28-
echo "=== CI Status ==="
29-
gh pr checks $PR_NUMBER
24+
}' \
25+
&& gh pr checks $PR_NUMBER
3026
```
3127

3228
Checklist:
@@ -90,8 +86,7 @@ make test-ci-container
9086
After fixing locally:
9187

9288
```bash
93-
git add -A && git commit -m "fix: resolve CI failure"
94-
git push
89+
git add -A && git commit -s -m "fix: resolve CI failure" && git push
9590

9691
# Or re-run failed jobs directly
9792
gh run rerun $RUN_ID --failed
@@ -113,14 +108,9 @@ The release process uses the `release.yml` manual workflow dispatch.
113108
### Step 1: Verify Readiness
114109

115110
```bash
116-
# Ensure main is clean and up to date
117-
git checkout main && git pull
118-
119-
# Check the version in package_info.py
120-
grep VERSION src/nemo_safe_synthesizer/package_info.py
121-
122-
# Confirm no open blockers
123-
gh issue list --label "priority:high" --state open
111+
git checkout main && git pull \
112+
&& grep VERSION src/nemo_safe_synthesizer/package_info.py \
113+
&& gh issue list --label "priority:high" --state open
124114
```
125115

126116
### Step 2: Trigger the Release
@@ -171,12 +161,7 @@ gh issue view <number>
171161
### Step 2: Label and Assign
172162

173163
```bash
174-
# Add appropriate labels
175-
gh issue edit <number> --add-label "bug" # or "enhancement", "documentation"
176-
gh issue edit <number> --add-label "priority:high"
177-
178-
# Assign to someone
179-
gh issue edit <number> --add-assignee username
164+
gh issue edit <number> --add-label "bug" --add-label "priority:high" --add-assignee username
180165
```
181166

182167
### Step 3: Link to Milestone (if applicable)
@@ -212,35 +197,19 @@ gh pr checkout <number>
212197
### Step 2: Understand the Changes
213198

214199
```bash
215-
# See the diff
216-
gh pr diff
217-
218-
# List changed files
219-
gh pr view --json files | jq -r '.files[].path'
220-
221-
# Read the PR description
222-
gh pr view <number>
200+
gh pr diff && gh pr view --json files -q '[.files[].path]'
223201
```
224202

225203
### Step 3: Run Local Checks
226204

227205
```bash
228-
# Format check
229-
make format
230-
231-
# Lint
232-
make lint
233-
234-
# Unit tests
235-
make test
206+
make format && make lint && make test
236207
```
237208

238209
### Step 4a: Push Fixes (if contributing to the PR)
239210

240211
```bash
241-
git add -A
242-
git commit -m "fix: address lint/format issues"
243-
git push
212+
git add -A && git commit -s -m "fix: address lint/format issues" && git push
244213
```
245214

246215
### Step 4b: Leave a Review (if just reviewing)
@@ -264,6 +233,8 @@ git stash pop
264233

265234
End-to-end workflow: create an issue, branch, implement, and open a draft PR.
266235

236+
Before branching, ask the user whether to use a local branch (`git checkout -b`) or a worktree for isolated development. Worktrees are preferred when the main checkout has uncommitted work or when multiple branches need to be active simultaneously. See the [git-worktrees skill](../../git-worktrees/SKILL.md) for the worktree-to-draft-PR workflow.
237+
267238
### Step 1: Create the Issue
268239

269240
```bash
@@ -277,24 +248,19 @@ EOF
277248
)"
278249
```
279250

280-
### Step 2: Create Branch and Implement
251+
### Step 2: Create Branch, Implement, and Open Draft PR
281252

282253
```bash
283254
ISSUE=<number-from-step-1>
284255
git checkout -b $USER/$ISSUE-short-name origin/main
285256
# ... make changes ...
286-
git add -A
287-
git commit -s -m "fix: description (closes #$ISSUE)"
288-
git push -u origin HEAD
289-
```
290-
291-
### Step 3: Open Draft PR
292-
293-
```bash
294-
gh pr create --draft \
295-
--title "fix: description" \
296-
--body "$(cat <<'EOF'
297-
Closes #<issue-number>
257+
git add -A \
258+
&& git commit -s -m "fix: description (closes #$ISSUE)" \
259+
&& git push -u origin HEAD \
260+
&& gh pr create --draft \
261+
--title "fix: description" \
262+
--body "$(cat <<EOF
263+
Closes #$ISSUE
298264
299265
- Change 1
300266
- Change 2
@@ -316,9 +282,7 @@ gh api repos/NVIDIA-NeMo/Safe-Synthesizer/pulls/<number>/comments
316282
Make fixes, commit with signoff:
317283

318284
```bash
319-
git add -A
320-
git commit -s -m "fix: address review feedback"
321-
git push
285+
git add -A && git commit -s -m "fix: address review feedback" && git push
322286
```
323287

324288
### Step 3: Update PR Body for Squash Merge

0 commit comments

Comments
 (0)