Skip to content

feat: auto fix common review issues#2355

Open
paul-nechifor wants to merge 1 commit into
mainfrom
paul/feat/auto-fixes
Open

feat: auto fix common review issues#2355
paul-nechifor wants to merge 1 commit into
mainfrom
paul/feat/auto-fixes

Conversation

@paul-nechifor
Copy link
Copy Markdown
Contributor

@paul-nechifor paul-nechifor commented Jun 4, 2026

Problem

Reviewing takes a long time. Some issues come up multiple times, so we can automate them.

Closes DIM-978

Solution

  • Add a script to automatically fix common review issues.
  • Instead of just saying what the issues are, make fixes for them and allow the author to drop commits he doesn't agree with.

Contributor License Agreement

  • I have read and approved the CLA.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Jun 4, 2026

Greptile Summary

This PR introduces a misc/auto-fixes/ toolchain consisting of an orchestration shell script and two Claude-agent prompt templates that automate scanning a contributor branch for code-quality issues and opening a follow-up PR of fixes.

  • auto-fix.sh: Creates an isolated git worktree, runs a scan agent to write issues.ignore.md, then (if issues exist) runs a fix agent on a fresh branch, strips AI attribution from commit messages via git filter-branch, verifies authorship, pushes, and opens a PR with gh.
  • scan_template.md / fix_template.md: LLM prompt templates encoding the repo's style rules for the scan and fix passes; the fix template enforces per-fix commits, test/mypy verification, and pre-commit gating.

Confidence Score: 3/5

Safe to merge as a non-production utility, but the error-coloring bug means failures look identical to success in terminal output.

The err() function emits text in the same green color as log(), making every failure path visually indistinguishable from a successful step. The deprecated git filter-branch and the broken backtick span in the scan template are lower-priority but also worth addressing.

misc/auto-fixes/auto-fix.sh — the error-color and filter-branch issues are both here.

Important Files Changed

Filename Overview
misc/auto-fixes/auto-fix.sh New bash orchestration script that runs Claude scan+fix agents in a git worktree and opens a PR; error messages incorrectly use green color (same as progress), and git filter-branch is deprecated.
misc/auto-fixes/fix_template.md Prompt template for the fix agent; clear instructions for committing, testing, and scoping — no issues found.
misc/auto-fixes/scan_template.md Prompt template listing code-quality rules for the scan agent; the git diff command example has a broken markdown code span (opening backtick on one line, closing on the next).

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A([auto-fix.sh branch]) --> B[fetch origin main + branch]
    B --> C[create git worktree detached at origin/branch]
    C --> D[uv sync]
    D --> E[run scan agent]
    E --> F{issues.ignore.md non-empty?}
    F -- No --> G([exit 0: nothing to do])
    F -- Yes --> H[pick fresh AUTOFIX_BRANCH name]
    H --> I[checkout -b AUTOFIX_BRANCH]
    I --> J[run fix agent]
    J --> K{any new commits?}
    K -- No --> L([exit 0: no fixes committed])
    K -- Yes --> M[git filter-branch: strip attribution]
    M --> N{attribution still present?}
    N -- Yes --> O([exit 1: abort])
    N -- No --> P{all commits use default git user?}
    P -- No --> Q([exit 1: abort])
    P -- Yes --> R[git push AUTOFIX_BRANCH]
    R --> S[gh pr create]
    S --> T([cleanup worktree + local branch])
Loading

Reviews (1): Last reviewed commit: "auto-fixes" | Re-trigger Greptile

Comment on lines +9 to +12
GREEN=$'\033[0;32m'
RESET=$'\033[0m'
log() { echo "${GREEN}$*${RESET}"; } # stdout (progress)
err() { echo "${GREEN}$*${RESET}" >&2; } # stderr (errors)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Error messages printed in green (same as progress)

Both log and err emit text in GREEN, so error output is visually identical to normal progress output. When the script calls err "scan agent failed" or err "refusing to push: non-default author detected." and exits non-zero, the operator has no visual cue that something went wrong. Error messages should use a distinct color (e.g. red) so they stand out, especially in CI/terminal logs where the exit code may not be immediately visible.

Suggested change
GREEN=$'\033[0;32m'
RESET=$'\033[0m'
log() { echo "${GREEN}$*${RESET}"; } # stdout (progress)
err() { echo "${GREEN}$*${RESET}" >&2; } # stderr (errors)
GREEN=$'\033[0;32m'
RED=$'\033[0;31m'
RESET=$'\033[0m'
log() { echo "${GREEN}$*${RESET}"; } # stdout (progress)
err() { echo "${RED}$*${RESET}" >&2; } # stderr (errors)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Comment on lines +125 to +127
FILTER_BRANCH_SQUELCH_WARNING=1 git -C "$WORKTREE" filter-branch -f --msg-filter \
'grep -viE "^(Co-authored-by:|Generated with \[Claude Code\])|🤖"' \
-- "$BASE_SHA"..HEAD
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 filter-branch has been deprecated since Git 2.24. While FILTER_BRANCH_SQUELCH_WARNING=1 suppresses the warning, some hardened environments disable the command entirely. Consider migrating to git-filter-repo, the officially recommended successor.

Comment on lines +2 to +3

The branch is $$BRANCH$$. You can perform a diff with `git diff main...$$BRANCH$$ -- . ':(exclude)*.lock' ':(exclude)uv.lock' ':(exclude)package-lock.json' ':(exclude)yarn.lock' ':(exclude)pnpm-lock.yaml' ':(exclude)Cargo.lock' ':(exclude)*.pdf' ':(exclude)*.png' ':(exclude)*.jpg'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Broken inline-code span across newline

The backtick opening the code span for the git diff command is on line 2, but the closing backtick is on line 3 (its own line). In CommonMark, a single-backtick code span cannot contain a newline, so the command renders as plain text followed by a stray backtick.

@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 4, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@paul-nechifor paul-nechifor changed the title auto-fixes feat: auto fix common review issues Jun 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant