Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

Delete Claude bug fix workflow (#70993)

Nemanja Glumacacbf9bcc88c9
diff --git a/.github/workflows/claude-code-bug-fix.yml b/.github/workflows/claude-code-bug-fix.yml
deleted file mode 100644
index 39c413b12fa..00000000000
--- a/.github/workflows/claude-code-bug-fix.yml
+++ /dev/null
@@ -1,360 +0,0 @@
-name: "Claude Code Bug Fix"
-
-on:
- issues:
- types:
- - labeled
- pull_request_review:
- types:
- - submitted
- workflow_dispatch:
- inputs:
- issue_number:
- description: "Issue number to fix"
- required: true
- type: string
- override_employee_check:
- description: "Override employee check for issue creator"
- required: false
- default: false
- type: boolean
-
-jobs:
- auto-fix-bug:
- runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}
- timeout-minutes: 30
- permissions:
- contents: write
- issues: write
- pull-requests: write
- id-token: write
- if: |
- (github.event_name == 'issues' && github.event.label.name == 'Claude Bug Fix' && github.event.issue.state == 'open') ||
- (github.event_name == 'workflow_dispatch') ||
- (github.event_name == 'pull_request_review' && github.event.review.state == 'changes_requested' && startsWith(github.event.pull_request.head.ref, 'claude-fix/'))
- steps:
- - name: Checkout repository
- uses: actions/checkout@v4
- with:
- fetch-depth: 0
- token: ${{ secrets.GITHUB_TOKEN }}
-
- - name: Get issue data and check employee status
- id: get_issue
- uses: actions/github-script@v7
- with:
- github-token: ${{ secrets.GITHUB_TOKEN }}
- script: |
- const { getIssueData } = require('${{ github.workspace }}/.github/scripts/get-issue-data.js');
-
- try {
- const result = await getIssueData({
- context,
- github,
- manualIssueNumber: '${{ github.event.inputs.issue_number }}'
- });
-
- const { issueNumber, issueData, employeeComments, prReviews, triggerType, isIssueAuthorEmployee } = result;
-
- // Check employee status and fail if not authorized
- if (!result.isIssueAuthorEmployee && '${{ github.event.inputs.override_employee_check }}' !== 'true') {
- core.setFailed(`User ${result.issueData.user.login} is not a Metabase employee. Skipping bug fix automation.`);
- }
-
- core.setOutput('issue_number', issueNumber);
- core.setOutput('issue_data', JSON.stringify(issueData));
- core.setOutput('issue_comments', JSON.stringify(employeeComments));
- core.setOutput('pr_reviews', JSON.stringify(prReviews));
- core.setOutput('trigger_type', triggerType);
- } catch (error) {
- core.setFailed(error.message);
- }
-
- - name: Find linked Linear issue
- id: find_linear
- continue-on-error: true
- uses: actions/github-script@v7
- env:
- LINEAR_API_KEY: ${{ secrets.LINEAR_API_KEY }}
- ISSUE_NUMBER: ${{ steps.get_issue.outputs.issue_number }}
- with:
- script: |
- const { findLinearIssue } = require('${{ github.workspace }}/.github/scripts/find-linear-issue.js');
-
- const githubIssueUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}/issues/${process.env.ISSUE_NUMBER}`;
-
- const result = await findLinearIssue({
- githubIssueUrl,
- linearApiKey: process.env.LINEAR_API_KEY
- });
-
- if (result.success) {
- console.log(`Found Linear issue: ${result.issue}`);
- core.setOutput('linear_issue', result.issue);
- } else {
- console.log(`Could not find Linear issue: ${result.message}`);
- }
-
- - name: Set up git configuration
- run: |
- git config --global user.name "Claude Code[bot]"
- git config --global user.email "[email protected]"
-
- - name: Prepare issue context and bug fix prompt
- id: prepare_prompt
- uses: actions/github-script@v7
- env:
- ISSUE_DATA: ${{ steps.get_issue.outputs.issue_data }}
- ISSUE_COMMENTS: ${{ steps.get_issue.outputs.issue_comments }}
- PR_REVIEWS: ${{ steps.get_issue.outputs.pr_reviews }}
- TRIGGER_TYPE: ${{ steps.get_issue.outputs.trigger_type }}
- with:
- script: |
- const issueData = JSON.parse(process.env.ISSUE_DATA);
- const issueComments = JSON.parse(process.env.ISSUE_COMMENTS);
- const prReviews = JSON.parse(process.env.PR_REVIEWS);
- const triggerType = process.env.TRIGGER_TYPE;
- const issueNumber = '${{ steps.get_issue.outputs.issue_number }}';
-
- // Convert issue title to kebab case and create branch name
- const issueTitle = issueData.title || 'untitled';
- const kebabTitle = issueTitle
- .toLowerCase()
- .replace(/[^a-z0-9]+/g, '-')
- .replace(/^-+|-+$/g, '')
- .replace(/-+/g, '-')
- .substring(0, 50);
- const branchName = `claude-fix/issue-${issueNumber}-${kebabTitle}`;
-
- // Format data for bash environment
- const formattedComments = issueComments.length > 0
- ? issueComments.map(comment =>
- `**Comment by @${comment.user.login} on ${comment.created_at}:**\n${comment.body}`
- ).join('\n\n---\n\n')
- : '';
- const formattedReviews = prReviews.length > 0
- ? prReviews.map(review =>
- `**Review by @${review.user.login} on ${review.submitted_at} (Changes Requested):**\n${review.body || 'No review comment provided'}`
- ).join('\n\n---\n\n')
- : '';
-
- core.exportVariable('BRANCH_NAME', branchName);
- core.exportVariable('ISSUE_NUMBER', issueNumber);
- core.exportVariable('ISSUE_TITLE', issueData.title);
- core.exportVariable('ISSUE_AUTHOR', issueData.user.login);
- core.exportVariable('ISSUE_CREATED', issueData.created_at);
- core.exportVariable('ISSUE_BODY', issueData.body || 'No description provided');
- core.exportVariable('ISSUE_COMMENTS_FORMATTED', formattedComments);
- core.exportVariable('PR_REVIEWS_FORMATTED', formattedReviews);
- core.exportVariable('TRIGGER_TYPE', triggerType);
-
- - name: Generate bug fix prompt
- run: |
- cat << 'EOF' >> $GITHUB_ENV
- BUG_FIX_PROMPT<<PROMPT_END
- You are helping to fix a bug reported in GitHub issue #${{ env.ISSUE_NUMBER }}.
-
- ## Bug Report Details
- **Title:** ${{ env.ISSUE_TITLE }}
- **Reporter:** ${{ env.ISSUE_AUTHOR }}
- **Created:** ${{ env.ISSUE_CREATED }}
-
- **Description:**
- ${{ env.ISSUE_BODY }}
-
- **Comments:**
- ${{ env.ISSUE_COMMENTS_FORMATTED }}
- EOF
-
- # Add review feedback section only if this is a review trigger
- if [ "${{ env.TRIGGER_TYPE }}" = "pull_request_review" ]; then
- cat << 'EOF' >> $GITHUB_ENV
-
- ## Previous Fix Attempt - Review Feedback (MUST ADDRESS)
- Your previous automated fix attempt received the following feedback that needs to be addressed:
-
- ${{ env.PR_REVIEWS_FORMATTED }}
- EOF
- fi
-
- # Add the rest of the prompt (always the same)
- cat << 'EOF' >> $GITHUB_ENV
-
- ## Instructions
- 1. **Analyze the issue description and comments** - Understand what the issue is describing
- a. Pay particular attention to reproduction steps and if there's an agreed upon fix.
- 2. **Search the codebase** - Use Grep and Glob tools to find relevant files
- 3. **Implement a fix** - Use the appropriate write skill based on the file types:
- - Use clojure-write for Clojure/ClojureScript files
- - Use typescript-write for TypeScript/JavaScript files
- - Follow the coding standards and patterns in each skill
- 4. **Test the fix** - Run appropriate tests as specified in the skills
- 5. **Verify the fix** - Ensure tests pass and code follows conventions
-
- ## Important Guidelines
- - Use the appropriate write skill for the language you're working in
- - Write failing tests first, then fix them
- - Work in small, testable increments
- - Don't commit changes - leave that for the workflow
- - IMPORTANT: Focus only on fixing the reported bug, don't make unrelated changes
-
- ## Scratchpad Directory
- A `.claude-scratchpad/` directory has been created for your temporary files:
- - Use this directory for ALL temporary verification files. However, prefer using production test files rather than adhoc ones.
- - Only modify actual production code in the main repository directories
- - The scratchpad will be cleaned up automatically - nothing from it will be committed
-
- Start by understanding the bug and then systematically work toward a solution.
- PROMPT_END
- EOF
-
- - name: Determine branch strategy
- run: |
- BRANCH_NAME="${{ env.BRANCH_NAME }}"
- if git branch -r --list "origin/${BRANCH_NAME}" | grep -q .; then
- echo "Branch already exists: $BRANCH_NAME"
- echo "Will push to existing branch and skip PR creation"
- echo "BRANCH_EXISTS=true" >> $GITHUB_ENV
- else
- echo "Creating new branch: $BRANCH_NAME"
- echo "Will create new PR"
- echo "BRANCH_EXISTS=false" >> $GITHUB_ENV
- fi
-
- # Export the branch name
- echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
-
- - name: Create scratchpad directory for Claude
- run: |
- # Create a scratchpad directory for Claude to use for temporary files
- mkdir -p .claude-scratchpad
- echo "Scratchpad directory created for Claude's temporary verification files"
-
- - name: Prepare front-end environment
- uses: ./.github/actions/prepare-frontend
-
- - name: Prepare back-end environment
- uses: ./.github/actions/prepare-backend
-
- - name: Generate GitHub App Token for Claude
- uses: actions/create-github-app-token@v1
- id: claude-app-token
- with:
- app-id: ${{ secrets.METABASE_BOT_APP_ID }}
- private-key: ${{ secrets.METABASE_BOT_APP_PRIVATE_KEY }}
-
- - name: Generate Bug Fix with Claude Code
- uses: anthropics/claude-code-action@v1
- with:
- anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
- github_token: ${{ steps.claude-app-token.outputs.token }}
- prompt: ${{ env.BUG_FIX_PROMPT }}
- claude_args: |
- --allowedTools "Bash(bun run test-unit*),Bash(bun run lint-eslint-pure),Bash(./bin/mage*),Bash(clojure*),Bash(find*),Bash(ls*),Bash(grep*),Write,Read,Glob,Grep,Edit,MultiEdit"
- --disallowedTools "Bash(git commit*),Bash(git push*),Bash(gh*)"
-
- - name: Clean up scratchpad directory
- run: |
- # Remove the scratchpad directory so its contents don't get committed
- rm -rf .claude-scratchpad/
- # Remove output file generated by Claude Code action
- rm -f output.txt
- echo "Scratchpad directory and action output files cleaned up"
-
- - name: Check for changes and analysis
- id: check_changes
- run: |
- # Now check for actual code changes (excluding analysis file)
- if [ -n "$(git status --porcelain)" ]; then
- echo "has_changes=true" >> $GITHUB_OUTPUT
- echo "Changes detected:"
- git status --short
- else
- echo "has_changes=false" >> $GITHUB_OUTPUT
- echo "No changes made by Claude."
- fi
-
- - name: Get issue team labels and prepare reviewers
- if: steps.check_changes.outputs.has_changes == 'true'
- id: prepare_reviewers
- uses: actions/github-script@v7
- env:
- ISSUE_DATA: ${{ steps.get_issue.outputs.issue_data }}
- with:
- script: |
- const issueData = JSON.parse(process.env.ISSUE_DATA);
- const issueLabels = issueData.labels.map(label => label.name);
- const teamLabels = issueLabels.filter(label => label.startsWith('.Team/'));
- const issueCreator = issueData.user.login;
- core.setOutput('team_labels', teamLabels.join(','));
- core.setOutput('reviewers', issueCreator);
-
- - name: Create Pull Request
- id: create_pr
- if: steps.check_changes.outputs.has_changes == 'true'
- uses: peter-evans/create-pull-request@v6
- with:
- token: ${{ secrets.GITHUB_TOKEN }}
- branch: ${{ env.BRANCH_NAME }}
- base: master
- commit-message: |
- Fix: ${{ env.ISSUE_TITLE }}
-
- Fixes #${{ env.ISSUE_NUMBER }}
-
- πŸ€– Generated with [Claude Code](https://claude.ai/code)
-
- Co-Authored-By: Claude <[email protected]>
- committer: "Claude Code[bot] <[email protected]>"
- author: "Claude Code[bot] <[email protected]>"
- title: "Fix: ${{ env.ISSUE_TITLE }}"
- body: |
- This PR automatically fixes the bug reported in #${{ env.ISSUE_NUMBER }}.
-
- ${{ steps.find_linear.outputs.linear_issue && format('Closes {0}', steps.find_linear.outputs.linear_issue) || '' }}
-
- ## Bug Report
- **Original Issue:** #${{ env.ISSUE_NUMBER }}
- **Reporter:** @${{ env.ISSUE_AUTHOR }}
- **Issue Title:** ${{ env.ISSUE_TITLE }}
-
- ## Automated Fix
- πŸ€– This fix was generated automatically by Claude Code based on the issue description.
-
- **Please review carefully:**
- - [ ] The fix addresses the reported issue
- - [ ] Tests pass and code follows conventions
- - [ ] No unrelated changes were introduced
- - [ ] The solution is appropriate and maintainable
-
- ## Next Steps
- - Review the changes and test thoroughly
- - If the fix looks good, approve and merge
- - If issues are found, either fix them or close this PR
-
- ---
-
- πŸ€– Generated with [Claude Code](https://claude.ai/code)
-
- Co-Authored-By: Claude <[email protected]>
- labels: |
- ${{ steps.prepare_reviewers.outputs.team_labels }}
- automated-fix
- ci skip
- reviewers: ${{ steps.prepare_reviewers.outputs.reviewers }}
- assignees: ${{ github.actor }}
-
- - name: Log existing branch update
- if: steps.check_changes.outputs.has_changes == 'true' && env.BRANCH_EXISTS == 'true'
- uses: actions/github-script@v7
- with:
- script: |
- console.log('πŸ”„ Updated existing branch: ${{ env.BRANCH_NAME }}');
- console.log('The changes have been pushed to the existing PR for this issue.');
-
- - name: Log analysis for no changes
- if: steps.check_changes.outputs.has_changes == 'false'
- uses: actions/github-script@v7
- with:
- script: |
- console.log('πŸ€– No code changes were made by Claude.');