wshobson--agents
1385ee046d
* "Claude PR Assistant workflow"
* "Claude Code Review workflow"
* ci: tune Claude Code workflows for marketplace review
- Auto-review (claude-code-review.yml): replace generic
/code-review:code-review slash command with a multi-line prompt that
carries the repo's invariants (source-of-truth under plugins/, no __
in plugin names, Codex 8 KB skill cap, AGENTS.md/CLAUDE.md/GEMINI.md
sync, quality gates). Bump model to claude-opus-4-7. Grant
pull-requests: write so inline comments and PR summaries can post.
Add track_progress: true. Skip drafts and dependabot.
- @claude responder (claude.yml): bump model to claude-opus-4-7. Grant
write scopes for contents/pull-requests/issues so @claude can
actually fix things. Gate on author_association so only OWNER /
MEMBER / COLLABORATOR can trigger writes (closes a real auth gap
flagged by coderabbit, critical now that scopes are write). Curate
--allowedTools for this repo's uv + ruff + ty + pytest + make + gh +
git toolchain.
- Both: pin actions/checkout to SHA with persist-credentials: false to
match .github/workflows/validate.yml convention.
Inspired by major7apps/pensyve and major7apps/maverick-bot review
workflows.
* ci: address coderabbit review on claude workflows
- Pin anthropics/claude-code-action to v1 commit SHA
(4481e6d3c7bbb88db2a928ca3444c536f589c7c1) — satisfies zizmor's
blanket-pin policy.
- Drop the implicit "approve with a one-line summary" instruction from
the review prompt; the workflow's allowedTools only expose inline
comments and gh pr comment, not a review-submission API. Replace
with an explicit "post a one-line ✅ summary via gh pr comment and
stop" so the success path is actually executable.
- Swap issues.types from [opened, assigned] to [opened, edited] on
claude.yml. The if:-condition only checks issue.body/title for
@claude, so reassignment-firing produces false triggers while edits
to existing issues currently fire nothing.
Skipped (with reason): "checkout PR head ref" finding. Anthropic's
canonical claude.yml template (anthropics/claude-code-action examples)
does not set with.ref — the action resolves the PR head internally
via the GitHub API. Forcing a specific ref would diverge from the
upstream contract.
* ci: enumerate git subcommands in @claude allowedTools
Replace the `Bash(git:*)` wildcard with an explicit list of safe
subcommands (status/diff/log/show/rev-parse/branch/tag/ls-files for
inspection; add/commit/checkout/switch/fetch/pull/push/stash for
workflow). Destructive ops like `reset`, `clean`, `rebase`,
`filter-branch`, and `branch -D` are no longer callable — they are
absent from the enumeration.
Addresses coderabbit finding: the wildcard conflicted with the repo's
own security checklist ("no destructive git in scripts") embedded in
claude-code-review.yml.
* ci: further tighten @claude allowedTools to read-only git + scoped gh
Drop `Bash(gh:*)` wildcard and the write-side `git` subcommands.
- `gh` is now enumerated: pr view/diff/list/comment/edit/checks,
issue view/list/comment/edit, api, run view, workflow view, search.
- `git` is now read-only: status, diff, log, show, rev-parse, ls-files.
Removed `branch`, `tag`, `add`, `commit`, `checkout`, `switch`,
`fetch`, `pull`, `push`, `stash` — `git branch -D`, `git tag -d`,
`git checkout -- .`, `git push --force`, etc. are no longer reachable.
Commits and branch creation are handled by anthropics/claude-code-action
internally via the GitHub API (`branch_prefix` / `branch_name_template`
action inputs), so local write-side git is not required for @claude to
fix things — `Edit`/`Write` produce the changes; the action commits.
Addresses coderabbit follow-up: --allowedTools doesn't understand
destructive flags, so safety comes from precise command patterns.
* ci: scope @claude gh api allowlist to specific endpoints
Drop `Bash(gh api:*)` (which exposed the entire GitHub REST API
surface, including DELETE/PATCH endpoints) in favor of three scoped
patterns sufficient for reading discussion context:
- repos/*/pulls/*/comments — PR review-thread reads
- repos/*/issues/*/comments — issue-thread reads
- repos/*/issues/*/timeline — issue history
Mirrors the same scoping style used in claude-code-review.yml. The
enumerated `gh pr` / `gh issue` / `gh run` / `gh workflow` / `gh search`
subcommands cover the rest of the responder's typical needs.
Addresses coderabbit finding.
80 行
3.7 KiB
YAML
80 行
3.7 KiB
YAML
name: Claude Code
|
|
|
|
on:
|
|
issue_comment:
|
|
types: [created]
|
|
pull_request_review_comment:
|
|
types: [created]
|
|
issues:
|
|
# `edited` (not `assigned`) is the actionable event here: the `if:`
|
|
# block below checks `github.event.issue.body` / `.title` for
|
|
# `@claude`, which only changes on edit. Reassignment would fire
|
|
# the workflow without any matching body/title change.
|
|
types: [opened, edited]
|
|
pull_request_review:
|
|
types: [submitted]
|
|
|
|
jobs:
|
|
claude:
|
|
# Gate on author_association so only repo owners / members /
|
|
# collaborators (who already have write access) can trigger this
|
|
# workflow — required because the job is granted write scopes below.
|
|
if: |
|
|
(
|
|
github.event_name == 'issue_comment' &&
|
|
contains(github.event.comment.body, '@claude') &&
|
|
contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.comment.author_association)
|
|
) ||
|
|
(
|
|
github.event_name == 'pull_request_review_comment' &&
|
|
contains(github.event.comment.body, '@claude') &&
|
|
contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.comment.author_association)
|
|
) ||
|
|
(
|
|
github.event_name == 'pull_request_review' &&
|
|
contains(github.event.review.body, '@claude') &&
|
|
contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.review.author_association)
|
|
) ||
|
|
(
|
|
github.event_name == 'issues' &&
|
|
(contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')) &&
|
|
contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.issue.author_association)
|
|
)
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: write
|
|
pull-requests: write
|
|
issues: write
|
|
id-token: write
|
|
actions: read # Required for Claude to read CI results on PRs
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
|
|
with:
|
|
fetch-depth: 1
|
|
persist-credentials: false
|
|
|
|
- name: Run Claude Code
|
|
id: claude
|
|
uses: anthropics/claude-code-action@4481e6d3c7bbb88db2a928ca3444c536f589c7c1 # v1
|
|
with:
|
|
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
|
|
|
|
# This is an optional setting that allows Claude to read CI results on PRs
|
|
additional_permissions: |
|
|
actions: read
|
|
|
|
# Tools tailored to this repo's uv-native Python toolchain.
|
|
# See AGENTS.md for the canonical command reference.
|
|
#
|
|
# Both `gh` and `git` are enumerated to safe subcommands only.
|
|
# Writes that need a commit/branch are handled by the action
|
|
# itself via the GitHub API (see action.yml `branch_prefix` /
|
|
# `branch_name_template` inputs) — local `git add/commit/push`
|
|
# is not in the allowlist, so destructive variants
|
|
# (`push --force`, `reset --hard`, `branch -D`, `tag -d`,
|
|
# `checkout -- .`, `clean -fd`) are unreachable.
|
|
claude_args: |
|
|
--model claude-opus-4-7
|
|
--allowedTools "Edit,Write,Read,Bash(uv:*),Bash(make:*),Bash(python:*),Bash(python3:*),Bash(ruff:*),Bash(ty:*),Bash(pytest:*),Bash(gh pr view:*),Bash(gh pr diff:*),Bash(gh pr list:*),Bash(gh pr comment:*),Bash(gh pr edit:*),Bash(gh pr checks:*),Bash(gh issue view:*),Bash(gh issue list:*),Bash(gh issue comment:*),Bash(gh issue edit:*),Bash(gh api repos/*/pulls/*/comments:*),Bash(gh api repos/*/issues/*/comments:*),Bash(gh api repos/*/issues/*/timeline:*),Bash(gh run view:*),Bash(gh workflow view:*),Bash(gh search:*),Bash(git status:*),Bash(git diff:*),Bash(git log:*),Bash(git show:*),Bash(git rev-parse:*),Bash(git ls-files:*),mcp__github_inline_comment__create_inline_comment"
|