DEV Community

Cover image for Automate Bug Fixes From GitHub Issues With Claude Code
Zira
Zira

Posted on

Automate Bug Fixes From GitHub Issues With Claude Code

Small bug fixes often follow the same workflow:

GitHub issue → investigate → edit code → run tests → open pull request
Enter fullscreen mode Exit fullscreen mode

Claude Code can automate most of this while keeping review and merging under human control.

1. Install Claude Code

npm install -g @anthropic-ai/claude-code
cd your-project
claude
Enter fullscreen mode Exit fullscreen mode

Then connect it to GitHub:

/install-github-app
Enter fullscreen mode Exit fullscreen mode

Follow the setup steps to install the GitHub app and add the required API key secret.

2. Add Repository Instructions

Create a CLAUDE.md file:

# Project Rules

- Run `npm test` before completing changes.
- Run `npm run lint`.
- Add a regression test for every bug fix.
- Do not modify unrelated files.
- Do not add dependencies without approval.
- Keep changes small and focused.
Enter fullscreen mode Exit fullscreen mode

This prevents the agent from improvising its own development philosophy, which is rarely a gift.

3. Add CI Checks

Create .github/workflows/ci.yml:

name: CI

on:
  pull_request:

jobs:
  test:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4

      - uses: actions/setup-node@v4
        with:
          node-version: 22
          cache: npm

      - run: npm ci
      - run: npm run lint
      - run: npm test
Enter fullscreen mode Exit fullscreen mode

Now every generated pull request is checked independently.

4. Trigger the Workflow

Create a detailed GitHub issue, then comment:

@claude investigate this bug and create a fix.

Requirements:
- Find the root cause
- Make the smallest safe change
- Add a regression test
- Run lint and tests
- Create a draft pull request
- Do not modify unrelated files
Enter fullscreen mode Exit fullscreen mode

Claude Code can inspect the repository, implement the fix, and prepare the pull request.

5. Keep Humans in Control

Do not let the agent merge directly into main.

Require:

  • Passing CI checks
  • Human review
  • Branch protection
  • Draft pull requests
  • Manual approval for security, payments, or authentication changes

The useful goal is not fully autonomous development.

It is reducing repetitive work while humans still make the final decision.

Top comments (0)