From 2412dd752516087b9778629d468f86338178de6c Mon Sep 17 00:00:00 2001 From: Daniel Demmel Date: Sat, 16 Aug 2025 01:46:12 +0200 Subject: [PATCH 1/5] "Claude PR Assistant workflow" --- .github/workflows/claude.yml | 64 ++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 .github/workflows/claude.yml diff --git a/.github/workflows/claude.yml b/.github/workflows/claude.yml new file mode 100644 index 00000000..bc773072 --- /dev/null +++ b/.github/workflows/claude.yml @@ -0,0 +1,64 @@ +name: Claude Code + +on: + issue_comment: + types: [created] + pull_request_review_comment: + types: [created] + issues: + types: [opened, assigned] + pull_request_review: + types: [submitted] + +jobs: + 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'))) + runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: read + issues: read + id-token: write + actions: read # Required for Claude to read CI results on PRs + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 1 + + - name: Run Claude Code + id: claude + uses: anthropics/claude-code-action@beta + 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 + + # Optional: Specify model (defaults to Claude Sonnet 4, uncomment for Claude Opus 4.1) + # model: "claude-opus-4-1-20250805" + + # Optional: Customize the trigger phrase (default: @claude) + # trigger_phrase: "/claude" + + # Optional: Trigger when specific user is assigned to an issue + # assignee_trigger: "claude-bot" + + # Optional: Allow Claude to run specific commands + # allowed_tools: "Bash(npm install),Bash(npm run build),Bash(npm run test:*),Bash(npm run lint:*)" + + # Optional: Add custom instructions for Claude to customize its behavior for your project + # custom_instructions: | + # Follow our coding standards + # Ensure all new code has tests + # Use TypeScript for new files + + # Optional: Custom environment variables for Claude + # claude_env: | + # NODE_ENV: test + From 53618496aa6aa7d52a90d3ca423a8bfca704b596 Mon Sep 17 00:00:00 2001 From: Daniel Demmel Date: Sat, 16 Aug 2025 01:46:13 +0200 Subject: [PATCH 2/5] "Claude Code Review workflow" --- .github/workflows/claude-code-review.yml | 78 ++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 .github/workflows/claude-code-review.yml diff --git a/.github/workflows/claude-code-review.yml b/.github/workflows/claude-code-review.yml new file mode 100644 index 00000000..a12225aa --- /dev/null +++ b/.github/workflows/claude-code-review.yml @@ -0,0 +1,78 @@ +name: Claude Code Review + +on: + pull_request: + types: [opened, synchronize] + # Optional: Only run on specific file changes + # paths: + # - "src/**/*.ts" + # - "src/**/*.tsx" + # - "src/**/*.js" + # - "src/**/*.jsx" + +jobs: + claude-review: + # Optional: Filter by PR author + # if: | + # github.event.pull_request.user.login == 'external-contributor' || + # github.event.pull_request.user.login == 'new-developer' || + # github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR' + + runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: read + issues: read + id-token: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 1 + + - name: Run Claude Code Review + id: claude-review + uses: anthropics/claude-code-action@beta + with: + claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} + + # Optional: Specify model (defaults to Claude Sonnet 4, uncomment for Claude Opus 4.1) + # model: "claude-opus-4-1-20250805" + + # Direct prompt for automated review (no @claude mention needed) + direct_prompt: | + Please review this pull request and provide feedback on: + - Code quality and best practices + - Potential bugs or issues + - Performance considerations + - Security concerns + - Test coverage + + Be constructive and helpful in your feedback. + + # Optional: Use sticky comments to make Claude reuse the same comment on subsequent pushes to the same PR + # use_sticky_comment: true + + # Optional: Customize review based on file types + # direct_prompt: | + # Review this PR focusing on: + # - For TypeScript files: Type safety and proper interface usage + # - For API endpoints: Security, input validation, and error handling + # - For React components: Performance, accessibility, and best practices + # - For tests: Coverage, edge cases, and test quality + + # Optional: Different prompts for different authors + # direct_prompt: | + # ${{ github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR' && + # 'Welcome! Please review this PR from a first-time contributor. Be encouraging and provide detailed explanations for any suggestions.' || + # 'Please provide a thorough code review focusing on our coding standards and best practices.' }} + + # Optional: Add specific tools for running tests or linting + # allowed_tools: "Bash(npm run test),Bash(npm run lint),Bash(npm run typecheck)" + + # Optional: Skip review for certain conditions + # if: | + # !contains(github.event.pull_request.title, '[skip-review]') && + # !contains(github.event.pull_request.title, '[WIP]') + From d9a438a236cc9a95ded8207ab95598a4f4991071 Mon Sep 17 00:00:00 2001 From: Daniel Demmel Date: Sat, 16 Aug 2025 01:52:00 +0200 Subject: [PATCH 3/5] Clean up old Claude Action --- .github/workflows/claude.yml | 7 ++-- .github/workflows/claude_code.yml | 47 ------------------------- .github/workflows/claude_code_login.yml | 21 ----------- 3 files changed, 5 insertions(+), 70 deletions(-) delete mode 100644 .github/workflows/claude_code.yml delete mode 100644 .github/workflows/claude_code_login.yml diff --git a/.github/workflows/claude.yml b/.github/workflows/claude.yml index bc773072..e624750b 100644 --- a/.github/workflows/claude.yml +++ b/.github/workflows/claude.yml @@ -33,6 +33,8 @@ jobs: - name: Run Claude Code id: claude uses: anthropics/claude-code-action@beta + env: + ALLOWED_TOOLS: "Bash,Edit,MultiEdit,View,GlobTool,Glob,GrepTool,Grep,BatchTool,Batch,LS,Read,Write,Replace,NotebookEditCell,mcp__github_file_ops__commit_files,mcp__github_file_ops__delete_files,mcp__github_file_ops__update_claude_comment,WebSearch,WebFetch" with: claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} @@ -49,8 +51,9 @@ jobs: # Optional: Trigger when specific user is assigned to an issue # assignee_trigger: "claude-bot" - # Optional: Allow Claude to run specific commands - # allowed_tools: "Bash(npm install),Bash(npm run build),Bash(npm run test:*),Bash(npm run lint:*)" + timeout_minutes: "120" + allowed_tools: "Bash,Edit,MultiEdit,View,GlobTool,Glob,GrepTool,Grep,BatchTool,Batch,LS,Read,Write,Replace,NotebookEditCell,mcp__github_file_ops__commit_files,mcp__github_file_ops__delete_files,mcp__github_file_ops__update_claude_comment,WebSearch,WebFetch" + max_turns: "500" # Optional: Add custom instructions for Claude to customize its behavior for your project # custom_instructions: | diff --git a/.github/workflows/claude_code.yml b/.github/workflows/claude_code.yml deleted file mode 100644 index 41d5f68c..00000000 --- a/.github/workflows/claude_code.yml +++ /dev/null @@ -1,47 +0,0 @@ -name: Claude PR Assistant - Authorized Users Only - -on: - issue_comment: - types: [created] - pull_request_review_comment: - types: [created] - issues: - types: [opened, assigned] - pull_request_review: - types: [submitted] - -jobs: - claude-code-action: - # Only respond to @claude mentions from daaain - 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')) - ) && github.actor == 'daaain' - runs-on: ubuntu-latest - permissions: - contents: read - pull-requests: read - issues: read - id-token: write - actions: write - steps: - - name: Checkout repository - uses: actions/checkout@v4 - with: - fetch-depth: 1 - - - name: Run Claude PR Action - uses: grll/claude-code-action@beta - with: - use_oauth: true - claude_access_token: ${{ secrets.CLAUDE_ACCESS_TOKEN }} - claude_refresh_token: ${{ secrets.CLAUDE_REFRESH_TOKEN }} - claude_expires_at: ${{ secrets.CLAUDE_EXPIRES_AT }} - secrets_admin_pat: ${{ secrets.SECRETS_ADMIN_PAT }} - timeout_minutes: "120" - allowed_tools: "Bash,Edit,MultiEdit,View,GlobTool,Glob,GrepTool,Grep,BatchTool,Batch,LS,Read,Write,Replace,NotebookEditCell,mcp__github_file_ops__commit_files,mcp__github_file_ops__delete_files,mcp__github_file_ops__update_claude_comment,WebSearch,WebFetch" - max_turns: "500" - custom_instructions: "Ignore diffs in JSON and HTML files (when doing a PR review) as they are very large. If you have to read their contents in a feature or bugfix branch, use seletive tools like jq or sed" diff --git a/.github/workflows/claude_code_login.yml b/.github/workflows/claude_code_login.yml deleted file mode 100644 index 750676c9..00000000 --- a/.github/workflows/claude_code_login.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: Claude OAuth - -on: - workflow_dispatch: - inputs: - code: - description: 'Authorization code (leave empty for step 1)' - required: false - -permissions: - actions: write # Required for cache management - contents: read # Required for basic repository access - -jobs: - auth: - runs-on: ubuntu-latest - steps: - - uses: grll/claude-code-login@v1 - with: - code: ${{ inputs.code }} - secrets_admin_pat: ${{ secrets.SECRETS_ADMIN_PAT }} From 0f7fad387d76981e330d18ffeab0cc439243d2b2 Mon Sep 17 00:00:00 2001 From: Daniel Demmel Date: Sat, 16 Aug 2025 01:53:29 +0200 Subject: [PATCH 4/5] Make PR review skippable --- .github/workflows/claude-code-review.yml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/claude-code-review.yml b/.github/workflows/claude-code-review.yml index a12225aa..cb6febb8 100644 --- a/.github/workflows/claude-code-review.yml +++ b/.github/workflows/claude-code-review.yml @@ -34,6 +34,9 @@ jobs: - name: Run Claude Code Review id: claude-review uses: anthropics/claude-code-action@beta + if: | + !contains(github.event.pull_request.title, '[skip-review]') && + !contains(github.event.pull_request.title, '[WIP]') with: claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} @@ -70,9 +73,4 @@ jobs: # Optional: Add specific tools for running tests or linting # allowed_tools: "Bash(npm run test),Bash(npm run lint),Bash(npm run typecheck)" - - # Optional: Skip review for certain conditions - # if: | - # !contains(github.event.pull_request.title, '[skip-review]') && - # !contains(github.event.pull_request.title, '[WIP]') From 44968ee9f645a43250ed79b7f4d9f01d310bbda2 Mon Sep 17 00:00:00 2001 From: Daniel Demmel Date: Sat, 16 Aug 2025 01:58:06 +0200 Subject: [PATCH 5/5] Fix lint --- claude_code_log/cli.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/claude_code_log/cli.py b/claude_code_log/cli.py index 80a0da86..97d2dcf8 100644 --- a/claude_code_log/cli.py +++ b/claude_code_log/cli.py @@ -117,7 +117,7 @@ def find_projects_by_cwd( def _find_exact_matches(project_dirs: List[Path], current_cwd_path: Path) -> List[Path]: """Find projects with exact working directory matches using path-based matching.""" expected_project_dir = convert_project_path_to_claude_dir(current_cwd_path) - + for project_dir in project_dirs: if project_dir == expected_project_dir: return [project_dir]