Skip to content

Commit 9770665

Browse files
authored
ref(docs): Avoid shell redirects in PR workflow docs (#5180)
Replace shell redirect examples (>, >>, |, &&) with Write/Edit tool instructions in pr.mdc and create-java-pr skill. This prevents permission prompt spam when agents update PR descriptions, since compound shell commands don't match simple permission patterns.
1 parent d6f6aaa commit 9770665

File tree

2 files changed

+14
-16
lines changed

2 files changed

+14
-16
lines changed

.claude/skills/create-java-pr/SKILL.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,12 @@ Skip this step for standalone PRs.
123123

124124
After creating the PR, update the PR description on **every other PR in the stack — including the collection branch PR** — so all PRs have the same up-to-date stack list. Follow the format and commands in `.cursor/rules/pr.mdc` § "Stack List in PR Description".
125125

126+
**Important:** When updating PR bodies, never use shell redirects (`>`, `>>`) or pipes (`|`) or compound commands (`&&`). These create compound shell expressions that won't match permission patterns. Instead:
127+
- Use `gh pr view <NUMBER> --json body --jq '.body'` to get the body (output returned directly)
128+
- Use the `Write` tool to save it to a temp file
129+
- Use the `Edit` tool to modify the temp file
130+
- Use `gh pr edit <NUMBER> --body-file /tmp/pr-body.md` to update
131+
126132
## Step 6: Update Changelog
127133

128134
First, determine whether a changelog entry is needed. **Skip this step** (and go straight to "No changelog needed" below) if the changes are not user-facing, for example:
@@ -173,8 +179,6 @@ git push
173179

174180
If no changelog entry is needed, add `#skip-changelog` to the PR description to disable the changelog CI check:
175181

176-
```bash
177-
gh pr view <PR_NUMBER> --json body --jq '.body' > /tmp/pr-body.md
178-
printf '\n#skip-changelog\n' >> /tmp/pr-body.md
179-
gh pr edit <PR_NUMBER> --body-file /tmp/pr-body.md
180-
```
182+
1. Get the current body: `gh pr view <PR_NUMBER> --json body --jq '.body'`
183+
2. Use the `Write` tool to save the output to `/tmp/pr-body.md`, appending `\n#skip-changelog\n` at the end
184+
3. Update: `gh pr edit <PR_NUMBER> --body-file /tmp/pr-body.md`

.cursor/rules/pr.mdc

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -223,19 +223,13 @@ No status column — GitHub already shows that. The `---` separates the stack li
223223

224224
This does not apply to standalone PRs or the collection branch PR.
225225

226-
To update the PR description, use `--body-file` to avoid shell quoting issues with special characters in the body:
226+
To update the PR description, use `--body-file` to avoid shell quoting issues with special characters in the body.
227227

228-
```bash
229-
# Get current PR description into a temp file
230-
gh pr view <PR_NUMBER> --json body --jq '.body' > /tmp/pr-body.md
231-
232-
# Edit /tmp/pr-body.md to prepend or replace the stack list section
233-
# (replace everything from "## PR Stack" up to and including the "---" separator,
234-
# or prepend before the existing description if no stack list exists yet)
228+
**Important:** Do not use shell redirects (`>`, `>>`, `|`) or compound commands (`&&`, `||`). These create compound shell expressions that won't match permission patterns. Instead, use the `Write` and `Edit` tools for file manipulation:
235229

236-
# Update the description
237-
gh pr edit <PR_NUMBER> --body-file /tmp/pr-body.md
238-
```
230+
1. Read the current body with `gh pr view <PR_NUMBER> --json body --jq '.body'` (the output is returned directly — use the `Write` tool to save it to `/tmp/pr-body.md`)
231+
2. Use the `Edit` tool to prepend or replace the stack list section in `/tmp/pr-body.md`
232+
3. Update the description: `gh pr edit <PR_NUMBER> --body-file /tmp/pr-body.md`
239233

240234
### Merging Stacked PRs (done by the user, not the agent)
241235

0 commit comments

Comments
 (0)