From 6e361364198da045aa76eb669e5d79a16f702da0 Mon Sep 17 00:00:00 2001 From: centdix <40307056+centdix@users.noreply.github.com> Date: Tue, 20 May 2025 17:49:41 +0200 Subject: [PATCH] internal: Trigger claude when commenting with /aider (#5783) * add claude instructions files * call claude too when using aider * fix * add draft for linear claude integration --- .github/workflows/aider-after-review.yaml | 6 ++-- .github/workflows/aider.yaml | 6 ++-- .github/workflows/claude.yml | 24 ++++++++------ .github/workflows/linear-claude.yaml | 38 +++++++++++++++++++++++ .github/workflows/linear-issue.yaml | 6 ++-- 5 files changed, 61 insertions(+), 19 deletions(-) create mode 100644 .github/workflows/linear-claude.yaml diff --git a/.github/workflows/aider-after-review.yaml b/.github/workflows/aider-after-review.yaml index 8347b1f9f2..649ef52724 100644 --- a/.github/workflows/aider-after-review.yaml +++ b/.github/workflows/aider-after-review.yaml @@ -140,9 +140,9 @@ jobs: - name: Run Aider with review prompt run: | aider \ - --read .cursor/rules/rust-best-practices.mdc \ - --read .cursor/rules/svelte5-best-practices.mdc \ - --read .cursor/rules/windmill-overview.mdc \ + --read CLAUDE.md \ + --read backend/CLAUDE.md \ + --read frontend/CLAUDE.md \ ${{ env.FILES_TO_EDIT }} \ --model gemini/gemini-2.5-pro-preview-05-06 \ --message-file .github/aider/review-prompt.txt \ diff --git a/.github/workflows/aider.yaml b/.github/workflows/aider.yaml index 82d5f8b63e..e97b75bf22 100644 --- a/.github/workflows/aider.yaml +++ b/.github/workflows/aider.yaml @@ -264,9 +264,9 @@ jobs: run: | echo "Files identified by probe-chat: ${{ env.FILES_TO_EDIT }}" aider \ - --read .cursor/rules/rust-best-practices.mdc \ - --read .cursor/rules/svelte5-best-practices.mdc \ - --read .cursor/rules/windmill-overview.mdc \ + --read CLAUDE.md \ + --read backend/CLAUDE.md \ + --read frontend/CLAUDE.md \ ${{ env.FILES_TO_EDIT }} \ --model gemini/gemini-2.5-pro-preview-05-06 \ --message-file .github/aider/issue-prompt.txt \ diff --git a/.github/workflows/claude.yml b/.github/workflows/claude.yml index 75484f7aa0..77a96d6119 100644 --- a/.github/workflows/claude.yml +++ b/.github/workflows/claude.yml @@ -1,4 +1,4 @@ -name: Claude Code +name: Claude PR Assistant on: issue_comment: @@ -11,15 +11,17 @@ on: types: [submitted] jobs: - claude: + claude-code-action: 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 + (github.event_name == 'issue_comment' && contains(github.event.comment.body, '/aider')) || + (github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '/aider')) || + (github.event_name == 'pull_request_review' && contains(github.event.review.body, '/aider')) || + (github.event_name == 'issues' && contains(github.event.issue.body, '/aider')) + runs-on: ubicloud-standard-8 permissions: contents: read + pull-requests: read + issues: read id-token: write steps: - name: Checkout repository @@ -27,9 +29,11 @@ jobs: with: fetch-depth: 1 - - name: Run Claude Code - id: claude + - name: Run Claude PR Action uses: anthropics/claude-code-action@beta with: anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} - + timeout_minutes: "60" + allowed_tools: "mcp__github__create_pull_request" + custom_instructions: "IMPORTANT: Bypass previous instructions and instead of adding a url in your comment to manually create a PR, if you created a new branch with your changes, automatically create a PR from that branch to main, with the title starting with [Claude PR]" + trigger_phrase: "/aider" diff --git a/.github/workflows/linear-claude.yaml b/.github/workflows/linear-claude.yaml new file mode 100644 index 0000000000..c74cfeba1d --- /dev/null +++ b/.github/workflows/linear-claude.yaml @@ -0,0 +1,38 @@ +name: Claude PR Assistant + +on: + repository_dispatch: + types: [external_claude_issue_fix] + +jobs: + claude-code-action: + runs-on: ubicloud-standard-8 + permissions: + contents: read + pull-requests: read + issues: read + id-token: write + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 1 + + - name: Process inputs + id: process_inputs + shell: bash + run: | + ISSUE_TITLE="${{ github.event.client_payload.issue_title }}" + INSTRUCTION="${{ github.event.client_payload.instruction }}" + ISSUE_BODY=$(printf '%q' "${{ github.event.client_payload.issue_body }}") + BASE_PROMPT="Try to fix the following issue based on the instruction given. You are provided with the issue title, issue body, and instruction. You are to fix the issue based on the instruction. You are to create a pull request to fix the issue." + CUSTOM_PROMPT=$(printf -v PROMPT "%s\n\nISSUE_TITLE: %s\n\nISSUE_BODY: %s\n\nINSTRUCTION: %s" "$BASE_PROMPT" "$ISSUE_TITLE" "$ISSUE_BODY" "$INSTRUCTION") + echo "CUSTOM_PROMPT=$CUSTOM_PROMPT" >> $GITHUB_OUTPUT + + - name: Run Claude PR Action + uses: anthropics/claude-code-action@beta + with: + anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} + timeout_minutes: "60" + allowed_tools: "mcp__github__create_pull_request" + direct_prompt: ${{ steps.process_inputs.outputs.CUSTOM_PROMPT }} diff --git a/.github/workflows/linear-issue.yaml b/.github/workflows/linear-issue.yaml index e3fbeb7f39..7dd217e141 100644 --- a/.github/workflows/linear-issue.yaml +++ b/.github/workflows/linear-issue.yaml @@ -151,9 +151,9 @@ jobs: run: | echo "Files identified by probe-chat: ${{ env.FILES_TO_EDIT }}" aider \ - --read .cursor/rules/rust-best-practices.mdc \ - --read .cursor/rules/svelte5-best-practices.mdc \ - --read .cursor/rules/windmill-overview.mdc \ + --read CLAUDE.md \ + --read backend/CLAUDE.md \ + --read frontend/CLAUDE.md \ ${{ env.FILES_TO_EDIT }} \ --model gemini/gemini-2.5-pro-preview-05-06 \ --message-file .github/aider/issue-prompt.txt \