Add Claude dispatcher for cross-repo PRs#799
Conversation
|
All Contributors have signed the CLA. ✅ |
|
👋 Hello @JaviChulvi, thank you for submitting a
For more guidance, please refer to our Contributing Guide. Don't hesitate to leave a comment if you have any questions. Thank you for contributing to Ultralytics! 🚀 |
UltralyticsAssistant
left a comment
There was a problem hiding this comment.
🔍 PR Review
Made with ❤️ by Ultralytics Actions
Found two issues: the workflow gives Claude an org-wide write token in an untrusted prompt context, and PR creation can still fail when Claude leaves partial changes but invalid/missing JSON output. Otherwise the dispatcher flow is straightforward.
💬 Posted 2 inline comments
| - name: Run Claude | ||
| env: | ||
| CLAUDE_CODE_OAUTH_TOKEN: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} # subscription auth (see plan §2) | ||
| GH_TOKEN: ${{ secrets._GITHUB_TOKEN }} # gh CLI auth so Claude can read issues/PRs/comments during the run |
There was a problem hiding this comment.
GH_TOKEN and exfiltrate or use it across the org. Please avoid giving the agent an org-wide write token; use a fine-grained GitHub App/PAT scoped only to the selected target repo and required permissions, and keep any broader token out of the Claude execution environment.
| git add -A | ||
| git commit -m "Claude: $TITLE" | ||
| git push origin "$BRANCH" | ||
| BODY="$(jq -r '.result // "Automated change via the Claude dispatcher."' "$RUNNER_TEMP/result.json")" |
There was a problem hiding this comment.
💡 MEDIUM: If Claude exits after producing file changes but writes empty/malformed/no JSON, this jq command fails under set -e and prevents the PR from being opened, which defeats the earlier logic to preserve partial work after non-zero Claude exits. Add a fallback around jq so partial changes still get pushed and opened.
Suggested change:
| BODY="$(jq -r '.result // "Automated change via the Claude dispatcher."' "$RUNNER_TEMP/result.json")" | |
| BODY="$(jq -r '.result // "Automated change via the Claude dispatcher."' "$RUNNER_TEMP/result.json" 2>/dev/null || echo "Automated change via the Claude dispatcher.")" |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
I have read the CLA Document and I sign the CLA |
Generate claude code token for subscription billing: claude setup-token (expires in 1 year)
gh secret set CLAUDE_CODE_OAUTH_TOKEN --repo ultralytics/actions
create a separate PAT for Claude Code (?)
Initial version, future plan:
🛠️ PR Summary
Made with ❤️ by Ultralytics Actions
🌟 Summary
Adds a new GitHub Actions workflow that centrally dispatches Claude Code tasks to target repositories and automatically opens PRs with generated changes. 🤖
📊 Key Changes
.github/workflows/claude-dispatcher.ymlwith manualworkflow_dispatchinputs for target repo, prompt, Claude model, and max turns.ghCLI access for issue/PR context gathering.🎯 Purpose & Impact