DEV Community

sampo shen
sampo shen

Posted on

PatchPilot: Run Copilot diff apply verify (Copilot CLI Challenge)

This is my submission for the GitHub Copilot CLI Challenge.

What I built

I built PatchPilot, a small command-line tool that closes the loop:

  • run a failing build/test command
  • ask GitHub Copilot CLI to make the smallest fix inside the repo
  • capture a real git diff
  • re-run the same command to verify it’s green
  • write a short report you can share/review

Repo: https://github.com/aisamposhen/patchpilot

Why it’s useful

A lot of “AI in terminal” demos stop at suggestions. PatchPilot is opinionated: no celebration until the command actually passes again.

This makes it great for:

  • quickly unblocking on small test/build failures
  • creating minimal, reviewable patches
  • teaching the habit of verifying fixes

Demo (90 seconds)

# install (dev)
python3 -m venv .venv
source .venv/bin/activate
pip install -e .

# run the intentionally broken sample project
cd sample_projects/python_pytest_broken
pip install -r requirements.txt
patchpilot run --show-prompts --branch patchpilot/demo -- pytest -q

# view the generated report
sed -n '1,140p' PATCHPILOT_REPORT.md
Enter fullscreen mode Exit fullscreen mode

How I used Copilot CLI (explicit)

PatchPilot calls Copilot CLI non-interactively via gh copilot.

The key design choice is that Copilot edits the repo in-place (with permission restricted to the repo directory), and PatchPilot then captures the patch using git diff. That keeps the result audit-friendly.

Example (simplified):

gh copilot -- --add-dir <repo> --allow-all-tools -p "...make pytest -q pass..."
Enter fullscreen mode Exit fullscreen mode

UX / safety

  • Requires a clean worktree before running (so diffs are trustworthy)
  • Creates a new branch (defaults to patchpilot/fix)
  • Never pushes automatically
  • Stops after one attempt (keeps it predictable)

What’s next

If I had more time:

  • add one retry loop (bounded)
  • optional gh pr create to open a PR with the report
  • support multiple languages/framework templates

Thanks for reading!

Top comments (0)