Skip to content

Commit b5a7d30

Browse files
authored
chore(ci): fix agent-fix issue targeting and PR token usage (#2200)
* chore(ci): strengthen AGENT_PR_TOKEN usage in raise-pr skill Add token verification step and fallback to prevent PRs being created with the wrong token (default GITHUB_TOKEN shows as app/github-actions and can't be merged). Adds post-creation author check. * chore(ci): pass explicit issue number to agent-fix prompt The prompt said "Fix this GitHub issue" without specifying which one, relying on claude-code-action to inject context. Over long runs the agent drifted to a different issue (#2175 instead of #1914). Now the issue number and title are passed explicitly in the prompt.
1 parent b878bf6 commit b5a7d30

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

.claude/skills/raise-pr/SKILL.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,17 @@ GH_TOKEN="$AGENT_PR_TOKEN" gh pr create \
125125
--body-file /tmp/pr-body.md
126126
```
127127

128-
**MANDATORY:** The `GH_TOKEN="$AGENT_PR_TOKEN"` prefix is required. PRs created without it cannot be merged. On CI, `AGENT_PR_TOKEN` is set automatically from `SHOPIFY_GH_ACCESS_TOKEN`. Locally, ensure it is exported or pass your token directly.
128+
> **CRITICAL — TOKEN VERIFICATION (read this before running `gh pr create`)**
129+
>
130+
> 1. First, verify the token is available: `[ -n "$AGENT_PR_TOKEN" ] && echo "token ok" || echo "TOKEN MISSING"` — do NOT echo the token value itself.
131+
> 2. You **MUST** use `GH_TOKEN="$AGENT_PR_TOKEN" gh pr create ...` — never bare `gh pr create`.
132+
> 3. PRs created with the default `GITHUB_TOKEN` show as `app/github-actions` and **cannot be merged**.
133+
> 4. After creating the PR, verify the author: `gh pr view --json author --jq '.author.login'` — it must NOT be `app/github-actions`.
134+
>
135+
> If `AGENT_PR_TOKEN` is empty, try `SHOPIFY_GH_ACCESS_TOKEN` as fallback: `GH_TOKEN="${AGENT_PR_TOKEN:-$SHOPIFY_GH_ACCESS_TOKEN}" gh pr create ...`
129136
130137
Before running `gh pr create`, double-check:
138+
- [ ] Token is verified (see above)
131139
- [ ] No mention of Claude, AI, Anthropic, or any AI tool anywhere
132140
- [ ] Description explains the "what" and "why" clearly
133141
- [ ] Test plan is specific to the change

.github/workflows/agent-fix.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,11 @@ jobs:
8080
prompt: |
8181
You are running on CI (GitHub Actions). There is no human to confirm with — act autonomously.
8282
Environment: macOS runner with Xcode and iOS simulator. No Android emulator.
83-
Fix this GitHub issue. Read and follow .claude/skills/fix-github-issue/SKILL.md for the full workflow.
83+
84+
YOUR ASSIGNED ISSUE: #${{ github.event.issue.number }}
85+
TITLE: ${{ github.event.issue.title }}
86+
87+
Fix ONLY this issue — do not fix other issues. Read and follow .claude/skills/fix-github-issue/SKILL.md for the full workflow.
8488
After fixing, read and follow .claude/skills/raise-pr/SKILL.md to raise a PR.
8589
CI notes: use default Metro port (8081).
8690

0 commit comments

Comments
 (0)