Skip to content

Commit f19c21b

Browse files
tahierhussainclaude
andcommitted
fix(claude): sanitize branch name when building PR body temp path
Branch names always contain a `/` (feat/<kebab> or fix/<kebab>), so `/tmp/pr-body-<branch>.md` resolved to a non-existent subdirectory and broke the write, --body-file, and cleanup steps. Sanitize via `tr '/' '-'` into `$BRANCH_SAFE` and thread it through all three. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 711bccc commit f19c21b

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

.claude/skills/ship/SKILL.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,20 +130,26 @@ Use `TODO` as a marker for any section that can't be filled confidently.
130130

131131
### Phase 6 — Raise the PR
132132

133-
1. Write the rendered body to `/tmp/pr-body-<branch>.md`
134-
2. Run:
133+
1. Sanitize the branch name (the `feat/`/`fix/` prefix contains a `/`, which
134+
would create a non-existent subdirectory under `/tmp`):
135+
```bash
136+
BRANCH_SAFE=$(echo "<branch-name>" | tr '/' '-')
137+
# e.g. feat/google-oauth-signin → feat-google-oauth-signin
138+
```
139+
2. Write the rendered body to `/tmp/pr-body-$BRANCH_SAFE.md`
140+
3. Run:
135141
```bash
136142
# Title prefix: "FEAT: <summary>" for features, "FIX: <summary>" otherwise
137143
BASE=$(gh repo view --json defaultBranchRef --jq '.defaultBranchRef.name')
138144
gh pr create --draft \
139145
--title "FEAT: <summary>" \
140-
--body-file /tmp/pr-body-<branch>.md \
146+
--body-file "/tmp/pr-body-$BRANCH_SAFE.md" \
141147
--base "$BASE"
142148
```
143-
3. If `gh` is not authenticated (`gh auth status` fails), instruct the user to run
149+
4. If `gh` is not authenticated (`gh auth status` fails), instruct the user to run
144150
`gh auth login` and stop. Do not retry silently
145-
4. Capture stdout, extract and print the PR URL
146-
5. Clean up the temp file (`rm /tmp/pr-body-<branch>.md`)
151+
5. Capture stdout, extract and print the PR URL
152+
6. Clean up the temp file (`rm "/tmp/pr-body-$BRANCH_SAFE.md"`)
147153

148154
---
149155

0 commit comments

Comments
 (0)