From 3b6c63aa7743f9683411644079cfe08a44f98912 Mon Sep 17 00:00:00 2001 From: ejc3 Date: Mon, 5 Jan 2026 19:45:22 +0000 Subject: [PATCH 1/2] Increase MAX_TURNS from 50 to 75 The Claude review agent was running out of turns when reviewing large PRs with many files. Increased from 50 to 75 to allow more thorough reviews. --- scripts/claude-assistant/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/claude-assistant/index.ts b/scripts/claude-assistant/index.ts index 3e1d7898..b65e7e5d 100644 --- a/scripts/claude-assistant/index.ts +++ b/scripts/claude-assistant/index.ts @@ -23,7 +23,7 @@ import { tmpdir } from "os"; // Configurable limits with sensible defaults const MAX_LOG_SIZE = parseInt(process.env.CLAUDE_MAX_LOG_SIZE ?? "100000", 10); -const MAX_TURNS = parseInt(process.env.CLAUDE_MAX_TURNS ?? "50", 10); +const MAX_TURNS = parseInt(process.env.CLAUDE_MAX_TURNS ?? "75", 10); // Branch naming convention for Claude-generated fix branches const FIX_BRANCH_PREFIX = "claude/fix-"; From 5f0d592f8a58fa0b60ec096327bb279b4165b510 Mon Sep 17 00:00:00 2001 From: ejc3 Date: Mon, 5 Jan 2026 19:50:16 +0000 Subject: [PATCH 2/2] Improve Claude review: wait for CI, run lint locally, verify fix PRs - Add STEP 0 to prompt: Wait for CI to pass before reviewing - Add instructions to run lint locally (cargo fmt, clippy) before committing - Add instructions to verify fix PRs pass CI before finishing - Add warning about editing files directly, no temp files - Add Rust toolchain (rustfmt, clippy) to all workflow jobs - Add fuse-backend-rs and fuser checkouts for workspace dependencies - Add build dependencies (libfuse3-dev, libclang-dev, clang) - Set FUSE_BACKEND_RS and FUSER env vars for cargo Tested: cargo fmt --check && cargo clippy --all-targets passes with new env vars --- .github/workflows/claude.yml | 104 ++++++++++++++++++++++++++++-- scripts/claude-assistant/index.ts | 58 +++++++++++++++++ 2 files changed, 158 insertions(+), 4 deletions(-) diff --git a/.github/workflows/claude.yml b/.github/workflows/claude.yml index 0cf164cf..c848eb92 100644 --- a/.github/workflows/claude.yml +++ b/.github/workflows/claude.yml @@ -159,6 +159,27 @@ jobs: with: fetch-depth: 0 token: ${{ steps.claude-token.outputs.token }} + path: fcvm + + - uses: actions/checkout@v4 + with: + repository: ejc3/fuse-backend-rs + ref: master + path: fuse-backend-rs + + - uses: actions/checkout@v4 + with: + repository: ejc3/fuser + ref: master + path: fuser + + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + with: + components: rustfmt, clippy + + - name: Install build dependencies + run: sudo apt-get update && sudo apt-get install -y libfuse3-dev libclang-dev clang - uses: actions/setup-node@v4 with: @@ -169,9 +190,10 @@ jobs: version: 9 - name: Install dependencies - run: cd scripts/claude-assistant && pnpm install + run: cd fcvm/scripts/claude-assistant && pnpm install - name: Run Claude review + working-directory: fcvm env: GH_TOKEN: ${{ steps.claude-token.outputs.token }} CLAUDE_CODE_OAUTH_TOKEN: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} @@ -183,6 +205,8 @@ jobs: BASE_BRANCH: ${{ github.event.pull_request.base.ref }} RUN_ID: ${{ github.run_id }} RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + FUSE_BACKEND_RS: ${{ github.workspace }}/fuse-backend-rs + FUSER: ${{ github.workspace }}/fuser run: | cd scripts/claude-assistant && pnpm exec tsx index.ts 2>&1 | tee /tmp/claude-output.log # Verify completion marker exists (detects if process was killed mid-execution) @@ -219,6 +243,27 @@ jobs: fetch-depth: 0 ref: refs/pull/${{ github.event.issue.number }}/head token: ${{ steps.claude-token.outputs.token }} + path: fcvm + + - uses: actions/checkout@v4 + with: + repository: ejc3/fuse-backend-rs + ref: master + path: fuse-backend-rs + + - uses: actions/checkout@v4 + with: + repository: ejc3/fuser + ref: master + path: fuser + + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + with: + components: rustfmt, clippy + + - name: Install build dependencies + run: sudo apt-get update && sudo apt-get install -y libfuse3-dev libclang-dev clang - uses: actions/setup-node@v4 with: @@ -229,7 +274,7 @@ jobs: version: 9 - name: Install dependencies - run: cd scripts/claude-assistant && pnpm install + run: cd fcvm/scripts/claude-assistant && pnpm install - name: Get PR info id: pr @@ -242,6 +287,7 @@ jobs: GH_TOKEN: ${{ steps.claude-token.outputs.token }} - name: Run Claude review + working-directory: fcvm env: GH_TOKEN: ${{ steps.claude-token.outputs.token }} CLAUDE_CODE_OAUTH_TOKEN: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} @@ -253,6 +299,8 @@ jobs: BASE_BRANCH: ${{ steps.pr.outputs.base_branch }} RUN_ID: ${{ github.run_id }} RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + FUSE_BACKEND_RS: ${{ github.workspace }}/fuse-backend-rs + FUSER: ${{ github.workspace }}/fuser run: | cd scripts/claude-assistant && pnpm exec tsx index.ts 2>&1 | tee /tmp/claude-output.log if ! grep -q "CLAUDE_ASSISTANT_COMPLETE" /tmp/claude-output.log; then @@ -287,6 +335,27 @@ jobs: with: fetch-depth: 0 token: ${{ steps.claude-token.outputs.token }} + path: fcvm + + - uses: actions/checkout@v4 + with: + repository: ejc3/fuse-backend-rs + ref: master + path: fuse-backend-rs + + - uses: actions/checkout@v4 + with: + repository: ejc3/fuser + ref: master + path: fuser + + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + with: + components: rustfmt, clippy + + - name: Install build dependencies + run: sudo apt-get update && sudo apt-get install -y libfuse3-dev libclang-dev clang - uses: actions/setup-node@v4 with: @@ -297,7 +366,7 @@ jobs: version: 9 - name: Install dependencies - run: cd scripts/claude-assistant && pnpm install + run: cd fcvm/scripts/claude-assistant && pnpm install - name: Get PR info id: pr @@ -317,6 +386,7 @@ jobs: fi - name: Run Claude respond + working-directory: fcvm env: GH_TOKEN: ${{ steps.claude-token.outputs.token }} CLAUDE_CODE_OAUTH_TOKEN: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} @@ -329,6 +399,8 @@ jobs: RUN_ID: ${{ github.run_id }} RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} COMMENT_BODY: ${{ github.event.comment.body }} + FUSE_BACKEND_RS: ${{ github.workspace }}/fuse-backend-rs + FUSER: ${{ github.workspace }}/fuser run: | cd scripts/claude-assistant && pnpm exec tsx index.ts 2>&1 | tee /tmp/claude-output.log if ! grep -q "CLAUDE_ASSISTANT_COMPLETE" /tmp/claude-output.log; then @@ -365,6 +437,27 @@ jobs: ref: ${{ github.event.workflow_run.head_sha }} fetch-depth: 0 token: ${{ steps.claude-token.outputs.token }} + path: fcvm + + - uses: actions/checkout@v4 + with: + repository: ejc3/fuse-backend-rs + ref: master + path: fuse-backend-rs + + - uses: actions/checkout@v4 + with: + repository: ejc3/fuser + ref: master + path: fuser + + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + with: + components: rustfmt, clippy + + - name: Install build dependencies + run: sudo apt-get update && sudo apt-get install -y libfuse3-dev libclang-dev clang - uses: actions/setup-node@v4 with: @@ -375,9 +468,10 @@ jobs: version: 9 - name: Install dependencies - run: cd scripts/claude-assistant && pnpm install + run: cd fcvm/scripts/claude-assistant && pnpm install - name: Run Claude CI fix + working-directory: fcvm env: GH_TOKEN: ${{ steps.claude-token.outputs.token }} CLAUDE_CODE_OAUTH_TOKEN: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} @@ -392,6 +486,8 @@ jobs: FAILED_RUN_ID: ${{ github.event.workflow_run.id }} FAILED_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.event.workflow_run.id }} WORKFLOW_NAME: ${{ github.event.workflow_run.name }} + FUSE_BACKEND_RS: ${{ github.workspace }}/fuse-backend-rs + FUSER: ${{ github.workspace }}/fuser run: | cd scripts/claude-assistant && pnpm exec tsx index.ts 2>&1 | tee /tmp/claude-output.log if ! grep -q "CLAUDE_ASSISTANT_COMPLETE" /tmp/claude-output.log; then diff --git a/scripts/claude-assistant/index.ts b/scripts/claude-assistant/index.ts index b65e7e5d..04b87240 100644 --- a/scripts/claude-assistant/index.ts +++ b/scripts/claude-assistant/index.ts @@ -229,6 +229,57 @@ All GitHub operations target **PR #${ctx.prNumber}** in **${ctx.repository}**. --- +## STEP 0: WAIT FOR CI TO PASS + +**Before doing anything else**, wait for CI checks to pass. + +### 0a. Check Lint status first (fast check) +\`\`\`bash +gh api repos/${ctx.repository}/commits/${ctx.headSha}/check-runs --jq '.check_runs[] | select(.name == "Lint") | {name: .name, status: .status, conclusion: .conclusion}' +\`\`\` + +### 0b. If Lint passes, check overall PR status +\`\`\`bash +gh pr checks ${ctx.prNumber} --repo ${ctx.repository} +\`\`\` + +**Rules:** +- If **Lint failed**: Stop immediately. Post comment: "Lint failed - please fix before I can review." +- If **any check failed**: Stop. Post comment noting which check failed. +- If **checks are still running**: Wait 30 seconds, then check again. Repeat until all pass/fail or 15 minutes elapsed. +- If **all checks pass**: Proceed to Step 1. + +**Do NOT proceed with the review until CI passes.** Reviewing code that doesn't pass CI is a waste of time. + +--- + +## CRITICAL: IF YOU MAKE CHANGES + +When you edit files and create a fix PR: + +### 1. Run lint locally BEFORE committing +\`\`\`bash +cargo fmt --check +cargo clippy --all-targets -- -D warnings +\`\`\` + +If lint fails, fix the issues before committing. **NEVER push code that doesn't pass lint.** + +### 2. After pushing, verify your PR passes CI +\`\`\`bash +gh pr checks --repo ${ctx.repository} --watch +\`\`\` + +If CI fails on your PR: +- Read the failure logs +- Fix the issue +- Commit and push again +- Repeat until CI passes + +**Your fix PR must pass CI before you're done.** Do not leave broken PRs. + +--- + ## STEP 1: UNDERSTAND THE FULL SCOPE ### 1a. Get PR context (title, description, comments) @@ -303,6 +354,13 @@ _Review by Claude | [Run](${ctx.runUrl})_" ### 5a. Edit files Make the minimum changes needed to fix the issues. +**IMPORTANT: Edit files directly in the repo. NEVER:** +- Copy files to /tmp and edit there +- Create temp files and copy back +- Use intermediate files + +Just use the Edit tool directly on the source files. + ### 5b. Commit \`\`\`bash git add -A