Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 46 additions & 14 deletions .github/workflows/claude.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Claude Code

on:
workflow_dispatch:
pull_request:
types: [opened, synchronize, ready_for_review, reopened]
issue_comment:
Expand All @@ -16,10 +17,16 @@ jobs:
# Automatic PR review (can fix linting issues and push)
# Blocked for fork PRs to prevent malicious code execution
pr-review:
concurrency:
group: pr-review-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
if: |
github.event_name == 'pull_request' &&
github.actor != 'claude[bot]' &&
github.event.pull_request.head.repo.full_name == github.repository
(
github.event_name == 'pull_request' &&
github.actor != 'claude[bot]' &&
github.event.pull_request.head.repo.full_name == github.repository
) ||
github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
permissions:
contents: write
Expand All @@ -32,7 +39,7 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref }}
ref: ${{ github.event.pull_request.head.ref || github.ref }}

- name: Install uv
uses: astral-sh/setup-uv@v6
Expand All @@ -54,7 +61,9 @@ jobs:
with:
use_bedrock: "true"
use_sticky_comment: true
track_progress: true
allowed_bots: "claude[bot],codeflash-ai[bot]"
exclude_comments_by_actor: "*[bot]"
prompt: |
<context>
repo: ${{ github.repository }}
Expand Down Expand Up @@ -109,6 +118,33 @@ jobs:
Record findings for the summary comment. Refer to CLAUDE.md for project conventions.
</step>

<step name="duplicate_detection">
Check whether this PR introduces code that duplicates logic already present elsewhere in the repository — including across languages. Focus on finding true duplicates, not just similar-looking code.

1. Get changed source files (excluding tests and config):
`git diff --name-only origin/main...HEAD -- '*.py' '*.js' '*.ts' '*.java' | grep -v -E '(test_|_test\.(py|js|ts)|\.test\.(js|ts)|\.spec\.(js|ts)|conftest\.py|/tests/|/test/|/__tests__/)' | grep -v -E '^(\.github/|code_to_optimize/|\.tessl/|node_modules/)'`

2. For each changed file, read it and identify functions/methods added or substantially modified (longer than 5 lines).

3. Search for duplicates using Grep:
- Same function name defined elsewhere
- 2-3 distinctive operations from the body (specific API calls, algorithm patterns, string literals)

4. Cross-module check: this codebase has parallel modules under `languages/python/`, `languages/javascript/`, and `languages/java/` plus runtimes under `packages/codeflash/runtime/` and `codeflash-java-runtime/`. When a changed file is under one of these areas, search the others for equivalent logic. Only flag cases where the logic is genuinely shared or one module could import from the other.

5. When a Grep hit looks promising, read the full function and compare semantics. Flag only:
- Same function with same/very similar body in another module
- Same helper logic repeated in sibling files
- Same logic implemented inline across multiple classes
- Same algorithm reimplemented across language modules (Python code, not target-language differences)

Report at most 5 findings with confidence (HIGH/MEDIUM), locations, what's duplicated, and suggestion.

DO NOT report: boilerplate, functions under 5 lines, config/setup, intentional polymorphism, test files, imports, code that must differ due to target-language semantics.

If no duplicates found, include "No duplicates detected" in the summary.
</step>

<step name="coverage">
Analyze test coverage for changed files:

Expand All @@ -120,19 +156,12 @@ jobs:
</step>

<step name="summary_comment">
Post exactly one summary comment containing all results from previous steps.

To ensure one comment: find an existing claude[bot] comment and update it, or create one if none exists.
Delete any duplicate claude[bot] comments.

```
gh api repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments --jq '.[] | select(.user.login == "claude[bot]") | .id' | head -1
```
Post exactly one summary comment containing all results from previous steps using this format:

Format:
## PR Review Summary
### Prek Checks
### Code Review
### Duplicate Detection
### Test Coverage
---
*Last updated: <timestamp>*
Expand Down Expand Up @@ -165,12 +194,15 @@ jobs:
- All findings are in a single summary comment (no inline review comments were created)
- If fixes were made, they were verified with prek
</verification>
claude_args: '--model us.anthropic.claude-opus-4-6-v1 --allowedTools "Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*),Bash(gh pr list:*),Bash(gh pr checks:*),Bash(gh pr merge:*),Bash(gh issue view:*),Bash(gh issue list:*),Bash(gh api:*),Bash(uv run prek *),Bash(uv run mypy *),Bash(uv run coverage *),Bash(uv run pytest *),Bash(git status*),Bash(git add *),Bash(git commit *),Bash(git push*),Bash(git diff *),Bash(git checkout *),Read,Glob,Grep,Edit,Skill"'
claude_args: '--model us.anthropic.claude-opus-4-6-v1 --max-turns 25 --allowedTools "Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*),Bash(gh pr list:*),Bash(gh pr checks:*),Bash(gh pr merge:*),Bash(gh issue view:*),Bash(gh issue list:*),Bash(gh api:*),Bash(uv run prek *),Bash(uv run mypy *),Bash(uv run coverage *),Bash(uv run pytest *),Bash(git status*),Bash(git add *),Bash(git commit *),Bash(git push*),Bash(git diff *),Bash(git checkout *),Read,Glob,Grep,Edit,Skill"'
additional_permissions: |
actions: read

# @claude mentions (can edit and push) - restricted to maintainers only
claude-mention:
concurrency:
group: claude-mention-${{ github.event.issue.number || github.event.pull_request.number || github.run_id }}
cancel-in-progress: false
if: |
(
github.event_name == 'issue_comment' &&
Expand Down
119 changes: 0 additions & 119 deletions .github/workflows/duplicate-code-detector.yml

This file was deleted.

Loading