Skip to content

Add Claude Code GitHub Workflow - #3

Merged
lwyBZss8924d merged 2 commits into
mainfrom
add-claude-github-actions-1757397860530
Sep 9, 2025
Merged

lwyBZss8924d merged 2 commits into
mainfrom
add-claude-github-actions-1757397860530

Conversation

@lwyBZss8924d

@lwyBZss8924d lwyBZss8924d commented Sep 9, 2025 •

Copy link
Copy Markdown
Owner

🤖 Installing Claude Code GitHub App

This PR adds a GitHub Actions workflow that enables Claude Code integration in our repository.

What is Claude Code?

Claude Code is an AI coding agent that can help with:

  • Bug fixes and improvements
  • Documentation updates
  • Implementing new features
  • Code reviews and suggestions
  • Writing tests
  • And more!

How it works

Once this PR is merged, we'll be able to interact with Claude by mentioning @claude in a pull request or issue comment.
Once the workflow is triggered, Claude will analyze the comment and surrounding context, and execute on the request in a GitHub action.

Important Notes

  • This workflow won't take effect until this PR is merged
  • @claude mentions won't work until after the merge is complete
  • The workflow runs automatically whenever Claude is mentioned in PR or issue comments
  • Claude gets access to the entire PR or issue context including files, diffs, and previous comments

Security

  • Our Anthropic API key is securely stored as a GitHub Actions secret
  • Only users with write access to the repository can trigger the workflow
  • All Claude runs are stored in the GitHub Actions run history
  • Claude's default tools are limited to reading/writing files and interacting with our repo by creating comments, branches, and commits.
  • We can add more allowed tools by adding them to the workflow file like:
allowed_tools: Bash(npm install),Bash(npm run build),Bash(npm run lint),Bash(npm run test)

There's more information in the Claude Code action repo.

After merging this PR, let's try mentioning @claude in a comment on any PR to get started!

Summary by CodeRabbit

  • 新功能

    • 引入自动化AI代码审查:在拉取请求打开或同步时自动运行,并以评论形式提供代码质量、潜在缺陷、性能、安全与测试覆盖建议。
    • 支持在 Issue/PR 讨论中通过“@claude”手动触发助手参与审查与解答。
  • Chores

    • 新增持续集成工作流以启用上述能力,包含最小必要权限与可选的触发条件、路径过滤与提示词自定义,便于按需调整与扩展。

@coderabbitai

coderabbitai Bot commented Sep 9, 2025 •

Copy link
Copy Markdown

Walkthrough

新增两个 GitHub Actions 工作流:一个在拉取请求开启/同步时自动运行 Claude 进行代码审查;另一个在议题/评论/评审中检测到“@claude”时按需触发。两者均检出仓库并调用 anthropics/claude-code-action@v1,使用 OAuth 令牌与最小必要权限进行评论回复。

Changes

Cohort / File(s) Change Summary
自动代码审查工作流(PR 触发)
.github/workflows/claude-code-review.yml
新增“Claude Code Review”工作流:在 pull_request opened/synchronize 时触发;检出代码后运行 anthropics/claude-code-action@v1;通过 CLAUDE_CODE_OAUTH_TOKEN 认证;内置详细审查提示词,使用 gh pr comment 留评;提供可选路径/作者过滤示例;设置 contents/pull-requests/issues 读权限与 id-token 写权限。
按需助手工作流(@claude 触发)
.github/workflows/claude.yml
新增“Claude Code”工作流:在 issue、issue_comment、pull_request_review、pull_request_review_comment 事件中检测包含“@claude”时运行;检出代码后执行 anthropics/claude-code-action@v1;使用 CLAUDE_CODE_OAUTH_TOKEN;附带可选自定义 prompt/claude_args 注释;权限包含 contents/pull-requests/issues/actions 读与 id-token 写。

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Dev as Developer
  participant GH as GitHub
  participant WF as Workflow: Claude Code Review
  participant Act as Claude Code Action
  participant PR as Pull Request

  Dev->>GH: Open/Synchronize PR
  GH-->>WF: Trigger workflow
  WF->>Act: Checkout repo and run action
  Act->>PR: Post review comments via gh pr comment
  Note over WF,Act: 最小权限与令牌配置
Loading
sequenceDiagram
  autonumber
  actor User as User
  participant GH as GitHub
  participant WF as Workflow: Claude Code
  participant Act as Claude Code Action
  participant Thread as Issue/PR Thread

  User->>GH: Post comment with "@claude"
  GH-->>WF: Trigger (conditional on text match)
  WF->>Act: Checkout repo and run action
  Act->>Thread: Reply/comment with results
  Note over WF,Act: 支持可选 prompt/args 配置
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Pre-merge checks (3 passed)

✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed 此标题简洁明了地概括了主要变更——添加 Claude Code GitHub 工作流,直接反映了 PR 的核心意图,且不包含多余信息,便于团队快速理解。
Description Check ✅ Passed 此描述详细说明了添加 Claude Code 工作流的背景、触发方式、使用方式以及安全注意事项,与实际更改内容高度相关且清晰易懂。
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.

Poem

小兔挥爪敲键轻,
两道工作流入云行。
PR 开合评语至,
良言按需“@claude”鸣。
夜色如墨灯微明,
自动审阅护代码,跳跃踏星程。

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch add-claude-github-actions-1757397860530

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@lwyBZss8924d
lwyBZss8924d merged commit ae39a1f into main Sep 9, 2025

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🧹 Nitpick comments (4)
.github/workflows/claude-code-review.yml (3)

6-11: 可选:开启 paths 过滤以节省运行成本

若目标仅为代码变更,可启用 paths 过滤,避免文档/配置变更触发。


47-47: 确认 CLAUDE.md 的路径与存在性

提示引用“仓库的 CLAUDE.md”。请确认文件是否存在以及路径是否为预期(例如 dev-docs/sdd/CLAUDE.md)。若路径固定,建议在 prompt 中明确指向。

遵循长期记忆要求:对 .github/workflows 变更需获得维护者确认。


20-20: 修复 YAML 格式:移除行尾空格与多余空行

  • 移除行尾空格:行 20、27、46、50
  • 移除文件末尾多余空行
-# (这些行仅删除了不可见的行尾空格)

Also applies to: 27-27, 46-46, 50-50, 55-55

.github/workflows/claude.yml (1)

38-38: 修复 YAML 小问题:行尾空格与空行

  • 行 38 存在行尾空格
  • 文件末尾有多余空行
-          claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}␠
+          claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}

Also applies to: 50-50

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 22f7b74 and 80514c8.

📒 Files selected for processing (2)
  • .github/workflows/claude-code-review.yml (1 hunks)
  • .github/workflows/claude.yml (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-09-09T05:32:43.271Z
Learnt from: CR
PR: lwyBZss8924d/spec-kit-ai-sdd#0
File: dev-docs/sdd/CLAUDE.md:0-0
Timestamp: 2025-09-09T05:32:43.271Z
Learning: Applies to dev-docs/sdd/.github/workflows/** : Modifications to CI/CD under .github/workflows/ require confirmation

Applied to files:

  • .github/workflows/claude-code-review.yml
🪛 YAMLlint (1.37.1)
.github/workflows/claude-code-review.yml

[error] 20-20: trailing spaces

(trailing-spaces)


[error] 27-27: trailing spaces

(trailing-spaces)


[error] 46-46: trailing spaces

(trailing-spaces)


[error] 50-50: trailing spaces

(trailing-spaces)


[warning] 54-54: too many blank lines (1 > 0)

(empty-lines)

.github/workflows/claude.yml

[error] 38-38: trailing spaces

(trailing-spaces)


[warning] 50-50: too many blank lines (1 > 0)

(empty-lines)

🔇 Additional comments (2)
.github/workflows/claude.yml (2)

37-42: 确认密钥存在并避免日志泄漏

请在仓库 Settings → Secrets 中创建 CLAUDE_CODE_OAUTH_TOKEN,并确认 anthropics/claude-code-action 仅将其用于 GitHub 操作认证且不会输出到日志。


29-36: 进一步验证:请确认项目根目录下是否存在 Dependabot 配置(如 .github/dependabot.yml 或 .github/dependabot.yaml)来判断是否已启用 Dependabot 维护。若不存在,请添加对应配置并将第三方 Action(anthropics/claude-code-action)固定到具体 commit SHA。

Comment on lines +13 to +15
jobs:
claude-review:
# Optional: Filter by PR author

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

防止 fork PR 上的秘密缺失或误触发;为 secrets 与 fork 加保护条件

来自 fork 的 pull_request 运行环境无法访问仓库 secrets,当前作业会失败。建议在作业层添加条件,确保仅在非 fork 且已配置密钥时运行。

 jobs:
   claude-review:
+    if: ${{ !github.event.pull_request.head.repo.fork && secrets.CLAUDE_CODE_OAUTH_TOKEN != '' }}
     runs-on: ubuntu-latest

Also applies to: 21-22, 34-39


为了验证 .github/workflows/claude-code-review.yml 中 claude-review 作业当前是否已包含 if 条件,运行以下脚本查看文件前 100 行内容:


🏁 Script executed:

#!/bin/bash
sed -n '1,100p' .github/workflows/claude-code-review.yml

Length of output: 1892


为 fork PR 添加作业级保护
在 claude-review 作业最上层添加以下 if 判断,确保仅在非 fork 且已配置 secrets.CLAUDE_CODE_OAUTH_TOKEN 时运行,否则因 secrets 不可用导致失败。

 jobs:
   claude-review:
+    if: ${{ !github.event.pull_request.head.repo.fork && secrets.CLAUDE_CODE_OAUTH_TOKEN != '' }}
     runs-on: ubuntu-latest
     permissions:
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
jobs:
claude-review:
# Optional: Filter by PR author
jobs:
claude-review:
# Optional: Filter by PR author
if: ${{ !github.event.pull_request.head.repo.fork && secrets.CLAUDE_CODE_OAUTH_TOKEN != '' }}
runs-on: ubuntu-latest
permissions:
# …existing permissions…
🤖 Prompt for AI Agents
.github/workflows/claude-code-review.yml around lines 13 to 15: add a top-level
if condition on the claude-review job to skip running for forked PRs and when
the CLAUDE_CODE_OAUTH_TOKEN secret is not available; specifically require the PR
head repo to be the same as the base repo (non-fork) and that
secrets.CLAUDE_CODE_OAUTH_TOKEN is set (e.g., if:
github.event.pull_request.head.repo.full_name == github.repository &&
secrets.CLAUDE_CODE_OAUTH_TOKEN != '') so the job is only executed in non-forked
PRs with the secret configured.

Comment on lines +21 to +27
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
issues: read
id-token: write

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

权限与评论能力不匹配;精简到最小权限并去除不必要的 OIDC

当前仅授予 read 权限,但步骤要求用 gh pr comment 发表评论;若依赖 GITHUB_TOKEN 评论,需要 pull-requests: write / issues: write;若改由 claude_code_oauth_token 进行评论,则可保持 read,但无需 id-token: write。请二选一并移除多余权限。

[建议修订 - 选项A:使用 GITHUB_TOKEN 评论]

 permissions:
   contents: read
-  pull-requests: read
-  issues: read
-  id-token: write
+  pull-requests: write
+  issues: write

[建议修订 - 选项B:继续用 OAuth 令牌评论(推荐最小权限)]

 permissions:
   contents: read
   pull-requests: read
   issues: read
-  id-token: write

Also applies to: 49-54


🏁 Script executed:

#!/bin/bash
set -e

FILE=".github/workflows/claude-code-review.yml"
if [ ! -f "$FILE" ]; then
  echo "Error: 未找到工作流文件 $FILE"
  exit 1
fi

echo "## 查看文件前 100 行:"
sed -n '1,100p' "$FILE"
echo

echo "## 查找评论相关命令:"
grep -n "gh pr comment" "$FILE" || echo "未发现 gh pr comment 用法"
echo

echo "## 查找 OIDC 与 id-token 权限使用:"
grep -n "id-token" "$FILE" || echo "未发现 id-token 字样"
grep -n "uses:.*oidc" "$FILE" || echo "未发现 OIDC 用法"

Length of output: 2275


精简权限:移除 id-token 或调整 pull-requests 写权限

  • 选项 A(使用 GITHUB_TOKEN 留言):
 permissions:
   contents: read
-  pull-requests: read
+  pull-requests: write
   issues: read
-  id-token: write
  • 选项 B(继续使用 claude_code_oauth_token):
 permissions:
   contents: read
   pull-requests: read
   issues: read
-  id-token: write
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
issues: read
id-token: write
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
issues: read
Suggested change
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
issues: read
id-token: write
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
issues: read
🧰 Tools
🪛 YAMLlint (1.37.1)

[error] 27-27: trailing spaces

(trailing-spaces)

🤖 Prompt for AI Agents
.github/workflows/claude-code-review.yml lines 21-27: 当前 workflow 同时授予 id-token:
write 和 pull-requests: read,审查建议要求精简权限;如果改为使用 GITHUB_TOKEN 留言,删除 id-token: write
并保留或设置 pull-requests: write 为需要的最小权限以便留言;如果继续使用 claude_code_oauth_token 则移除
id-token: write 并将 pull-requests 权限改为 write(或者仅保留 read 并改用外部 token
完成写入),确保只授予执行所需的最小权限且在文档中注明为什么需要该权限。

Comment on lines +30 to +36
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Run Claude Code Review
id: claude-review
uses: anthropics/claude-code-action@v1

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

将第三方 Action 固定到 commit SHA,降低供应链风险

目前使用浮动标签 @v4 / @v1。请固定到具体 commit SHA,并由 Dependabot 定期更新。

示例(请替换为官网公布的最新 SHA):

-uses: actions/checkout@v4
+uses: actions/checkout@<commit-sha>
...
-uses: anthropics/claude-code-action@v1
+uses: anthropics/claude-code-action@<commit-sha>

[建议查证最新可用 SHA]


🌐 Web query:

请查询 actions/checkout@v4 与 anthropics/claude-code-action@v1 的当前推荐 pin 的 commit SHA。

💡 Result:

actions/checkout@v4 的推荐 pin(v4 对应的 commit SHA):
08eba0b27e820071cde6df949e0beb9ba4906955。[1]

anthropics/claude-code-action@v1 的推荐 pin(v1 当前指向的 commit SHA):
fd2c17f101639b10696381c1fd85fa735239090a。[2]

Sources:
[1] actions/checkout — tag v4 commit.
[2] anthropics/claude-code-action — tag v1 commit.


固定第三方 Action 到具体 commit SHA 降低供应链风险

-        uses: actions/checkout@v4
+        uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955

…

-        uses: anthropics/claude-code-action@v1
+        uses: anthropics/claude-code-action@fd2c17f101639b10696381c1fd85fa735239090a

请由 Dependabot 定期检查并更新以上 SHA。

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Run Claude Code Review
id: claude-review
uses: anthropics/claude-code-action@v1
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955
with:
fetch-depth: 1
- name: Run Claude Code Review
id: claude-review
uses: anthropics/claude-code-action@fd2c17f101639b10696381c1fd85fa735239090a
🤖 Prompt for AI Agents
.github/workflows/claude-code-review.yml lines 30-36: third-party Actions are
referenced by floating tags which is a supply-chain risk; replace the uses
entries (e.g., actions/checkout@v4 and anthropics/claude-code-action@v1) with
pinned refs that include the exact commit SHA (e.g.,
actions/checkout@<commit-sha> and anthropics/claude-code-action@<commit-sha>),
commit the updated workflow, and add/configure Dependabot to periodically check
and open PRs to update those pinned SHAs so they stay up-to-date.

Comment on lines +15 to +20
if: |
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) ||
(github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) ||
(github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')))
runs-on: ubuntu-latest

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

⚠️ Potential issue

与 PR 说明不一致:当前任何人@claude均可触发;需限制为具写权限成员

PR 说明称“仅具有写权限的用户可触发”,但 if 条件只检查包含“@claude”,未限制触发者。请加入 author_association 约束。

-  claude:
-    if: |
-      (github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||
-      (github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) ||
-      (github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) ||
-      (github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')))
+  claude:
+    if: |
+      (
+        github.event_name == 'issue_comment' &&
+        contains(github.event.comment.body, '@claude') &&
+        (github.event.comment.author_association == 'OWNER' || github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'COLLABORATOR')
+      ) || (
+        github.event_name == 'pull_request_review_comment' &&
+        contains(github.event.comment.body, '@claude') &&
+        (github.event.comment.author_association == 'OWNER' || github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'COLLABORATOR')
+      ) || (
+        github.event_name == 'pull_request_review' &&
+        contains(github.event.review.body, '@claude') &&
+        (github.event.review.author_association == 'OWNER' || github.event.review.author_association == 'MEMBER' || github.event.review.author_association == 'COLLABORATOR')
+      ) || (
+        github.event_name == 'issues' &&
+        (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')) &&
+        (github.event.issue.author_association == 'OWNER' || github.event.issue.author_association == 'MEMBER' || github.event.issue.author_association == 'COLLABORATOR')
+      )
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if: |
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) ||
(github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) ||
(github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')))
runs-on: ubuntu-latest
claude:
if: |
(
github.event_name == 'issue_comment' &&
contains(github.event.comment.body, '@claude') &&
(github.event.comment.author_association == 'OWNER' || github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'COLLABORATOR')
) || (
github.event_name == 'pull_request_review_comment' &&
contains(github.event.comment.body, '@claude') &&
(github.event.comment.author_association == 'OWNER' || github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'COLLABORATOR')
) || (
github.event_name == 'pull_request_review' &&
contains(github.event.review.body, '@claude') &&
(github.event.review.author_association == 'OWNER' || github.event.review.author_association == 'MEMBER' || github.event.review.author_association == 'COLLABORATOR')
) || (
github.event_name == 'issues' &&
(contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')) &&
(github.event.issue.author_association == 'OWNER' || github.event.issue.author_association == 'MEMBER' || github.event.issue.author_association == 'COLLABORATOR')
)
runs-on: ubuntu-latest
🤖 Prompt for AI Agents
.github/workflows/claude.yml lines 15-20: the if-condition currently triggers on
any "@claude" mention regardless of who posted it; update each branch to also
require the actor's author_association to indicate write-level access by adding
checks like github.event.comment.author_association,
github.event.review.user.author_association and
github.event.issue.author_association and require one of the write-level values
(e.g. 'COLLABORATOR' or 'MEMBER' or 'OWNER'); apply these additional
author_association checks alongside the existing contains('@claude') checks for
issue_comment, pull_request_review_comment, pull_request_review and issues
branches so only users with write permissions can trigger the workflow.

Comment on lines +21 to +27
permissions:
contents: read
pull-requests: read
issues: read
id-token: write
actions: read # Required for Claude to read CI results on PRs
steps:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

精简权限;评估是否需要 id-token: write

除非确有 OIDC 联邦需求,否则去掉 id-token: write。actions: read 仅在需要读 CI 结果时保留。

 permissions:
   contents: read
   pull-requests: read
   issues: read
-  id-token: write
   actions: read # Required for Claude to read CI results on PRs

🏁 Script executed:

#!/bin/bash
# 定位 claude.yml 文件
file=$(fd claude.yml .github/workflows)
if [ -z "$file" ]; then
  echo "未找到 .github/workflows/claude.yml"
  exit 1
fi
echo "文件路径:$file"
# 输出文件前 200 行,便于检查 OIDC、id-token 用法
sed -n '1,200p' "$file"

Length of output: 1980


删除不必要的 id-token: write 权限
除非使用 OIDC 联邦身份验证,否则可移除 id-token: write。 (awesome.ecosyste.ms)

 permissions:
   contents: read
   pull-requests: read
   issues: read
-  id-token: write
   actions: read # Required for Claude to read CI results on PRs
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
permissions:
contents: read
pull-requests: read
issues: read
id-token: write
actions: read # Required for Claude to read CI results on PRs
steps:
permissions:
contents: read
pull-requests: read
issues: read
actions: read # Required for Claude to read CI results on PRs
steps:
🤖 Prompt for AI Agents
.github/workflows/claude.yml around lines 21 to 27: the workflow currently
grants id-token: write which is unnecessary unless you use OIDC federated
authentication; remove the "id-token: write" permission line (or set it to
"none"/omit it) to follow least-privilege practices and keep other permissions
as-is.

@github-actions

github-actions Bot commented Sep 9, 2025 •

Copy link
Copy Markdown

🤖 AI Code Review - comprehensive

PR #3

Review Summary

⚠️ Issues Found

  • ⚠️ No specification files updated - verify if needed
  • ⚠️ No test files - ensure TDD compliance

💡 Suggestions

  • Security scan placeholder - implement with actual scanning

SDD Compliance Checklist

  • Specification updated (if feature change)
  • Tests written before implementation (TDD)
  • Task references in commit messages
  • Documentation updated
  • No [NEEDS CLARIFICATION] markers
  • Agent context files updated (if needed)

Next Steps

  1. Address any issues identified above
  2. Ensure all checklist items are complete
  3. Request human review when ready

This review was performed automatically. For detailed analysis, run a comprehensive Claude Code review.

@lwyBZss8924d

Copy link
Copy Markdown
Owner Author

🤖 AI Code Review - comprehensive

PR #3

Review Summary

⚠️ Issues Found

  • ⚠️ No specification files updated - verify if needed
  • ⚠️ No test files - ensure TDD compliance

💡 Suggestions

  • Security scan placeholder - implement with actual scanning

SDD Compliance Checklist

  • Specification updated (if feature change)
  • Tests written before implementation (TDD)
  • Task references in commit messages
  • Documentation updated
  • No [NEEDS CLARIFICATION] markers
  • Agent context files updated (if needed)

Next Steps

  1. Address any issues identified above
  2. Ensure all checklist items are complete
  3. Request human review when ready

This review was performed automatically. For detailed analysis, run a comprehensive Claude Code review.

@claude Claude, a member of the AI Engineer team, needs to add new issues to address any problems identified above.

@claude

claude Bot commented Sep 9, 2025 •

Copy link
Copy Markdown

Claude finished @lwyBZss8924d's task —— View job


Creating GitHub Issues for PR #3 Review Feedback

Based on the automated review feedback, I need to create GitHub issues to address the identified problems from the merged PR #3 that added Claude Code GitHub Actions workflows.

Issues to Create:

Issue 1: Add Specification for GitHub Actions Workflow Feature

Title: Missing specification for Claude Code GitHub Actions integration

Description:
Following our SDD methodology, PR #3 added GitHub Actions workflows for Claude Code integration without a corresponding specification. We need to create a proper spec following our template structure.

Acceptance Criteria:

  • Create specs/001-claude-github-integration/spec.md following the spec-template.md format
  • Document user stories for GitHub Actions integration
  • Include security requirements and constraints
  • Define success criteria for the feature
  • Reference existing workflows in .github/workflows/

Priority: Medium
Labels: sdd-compliance, documentation, post-merge


Issue 2: Add Tests for GitHub Actions Workflows

Title: Missing tests for Claude Code GitHub Actions workflows

Description:
PR #3 added GitHub Actions workflows without corresponding tests, violating our TDD approach. We need to add tests to ensure workflow reliability and prevent regressions.

Acceptance Criteria:

  • Add workflow validation tests to tests/ directory
  • Test workflow trigger conditions
  • Validate YAML syntax and structure
  • Mock GitHub API interactions for testing
  • Add CI integration tests for workflow behavior

Technical Notes:

  • Consider using act for local GitHub Actions testing
  • Test both claude.yml and claude-code-review.yml workflows
  • Validate security constraints (fork PR handling, permissions)

Priority: High
Labels: testing, tdd-compliance, github-actions


Issue 3: Implement Security Scanning for GitHub Actions

Title: Add actual security scanning implementation for GitHub Actions workflows

Description:
The automated review identified a security scan placeholder. We need to implement proper security scanning for our GitHub Actions workflows.

Acceptance Criteria:

  • Implement dependency vulnerability scanning
  • Add workflow security linting (e.g., with actionlint)
  • Scan for hardcoded secrets in workflow files
  • Validate third-party action pinning to commit SHAs
  • Add security policy documentation

Technical Implementation:

  • Use tools like actionlint, semgrep, or snyk
  • Integrate into existing CI pipeline
  • Document security guidelines in CLAUDE.md

Priority: High
Labels: security, github-actions, automation


Issue 4: Address CodeRabbit Technical Feedback

Title: Fix GitHub Actions workflow configuration issues identified by CodeRabbit

Description:
CodeRabbit identified several technical issues in the GitHub Actions workflows that need to be addressed:

Specific Issues:

  1. Permissions: Remove unnecessary id-token: write permissions
  2. Security: Add protection for fork PRs to prevent secret exposure
  3. Action Pinning: Pin third-party actions to commit SHAs instead of floating tags
  4. Access Control: Limit @claude triggers to users with write permissions
  5. YAML Format: Fix trailing spaces and extra blank lines

Acceptance Criteria:

  • Fix permissions in both workflow files (remove id-token: write where unused)
  • Add fork PR protection with conditional job execution
  • Pin actions/checkout@v4 and anthropics/claude-code-action@v1 to specific SHAs
  • Add author_association checks for @claude triggers
  • Clean up YAML formatting issues
  • Add Dependabot configuration for action updates

Priority: High
Labels: bug-fix, security, github-actions


Since I cannot directly create GitHub issues, you can create these issues manually in the repository. Each issue is structured with clear acceptance criteria and priorities based on the automated review feedback.

The key problems identified were:

  1. ⚠️ Missing specification files (violates SDD methodology)
  2. ⚠️ Missing tests (violates TDD compliance)
  3. 🔒 Security improvements needed
  4. 🛠️ Technical workflow configuration fixes

All issues reference PR #3 and provide actionable next steps for addressing the review feedback.

lwyBZss8924d added a commit that referenced this pull request Sep 10, 2025
Addresses CodeQL security warnings about missing workflow permissions.
Following the principle of least privilege, all jobs now explicitly
declare 'contents: read' permission only.

Security improvements:
- Added global default permissions at workflow level
- Each job explicitly declares minimal required permissions
- Prevents unintended write access via GITHUB_TOKEN
- Complies with GitHub Actions security best practices

Fixes 6 CodeQL alerts: #1, #2, #3, #4, #6, #7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant