DEV Community

Cover image for From Failing Tests to Fix PRs in One Command (GitHub Copilot CLI Challenge)
Keerthana
Keerthana

Posted on

From Failing Tests to Fix PRs in One Command (GitHub Copilot CLI Challenge)

GitHub Copilot CLI Challenge Submission

This is a submission for the GitHub Copilot CLI Challenge

What I Built

I built copilot-bugfix, a GitHub Copilot CLI–powered agent that takes you from a red test to a ready‑to‑review pull request in a single command.

Instead of manually reading stack traces, hunting through files, and hand‑crafting patches, you run:

bash
copilot-bugfix "npm test -- failing-test"

and the tool:

Runs your tests and captures the full failure output.

Builds a rich “debug bundle” (stack trace, recent diffs, and relevant file snippets).

Asks GitHub Copilot CLI to explain the root cause and propose a unified diff patch.

Shows you the patch, applies it on confirmation, and re‑runs the tests.

Optionally creates a branch, generates a Copilot‑written conventional commit message, and opens a PR via GitHub CLI.

My goal was to treat Copilot CLI not as a toy assistant, but as a serious terminal agent that you could imagine wired into a real team’s workflow.

Demo

Repo: copilot-bugfix - https://github.com/pulipatikeerthana9-wq/copilot-bugfix

Start with a real, intentionally broken test suite.

Show npm test failing in red with a stack trace.

Run copilot-bugfix "npm test -- failing-test":

Step‑by‑step terminal output (run tests → build context → Copilot analysis → patch).

The proposed diff for the failing file.

Applying the patch and watching tests turn green.



Open GitHub:

Show the CI badge and a green GitHub Actions run (unit + integration + e2e).

Optionally show the PR that copilot-bugfix prepared, including the Copilot‑generated commit message.

Screenshots that work well here:

Terminal screenshot of copilot-bugfix fixing a failing test.

GitHub Actions page showing the full matrix (Node 16/18/20, unit + integration + e2e).

The PR view with the generated commit message and diff.

My Experience with GitHub Copilot CLI

I used GitHub Copilot CLI as the brain of this workflow and built everything else around making that brain trustworthy:

Analysis & patch generation: I send a curated context bundle to gh copilot suggest so it can reason about failures with just enough signal: test output, recent git changes, and focused code snippets rather than the entire repo.

Commit messages: After a patch is applied, I use Copilot CLI again to generate a short, conventional commit message that actually reads like something a teammate would write.

Safety & diagnostics: Copilot’s output goes through a hardened parser that understands both fenced diffs and hunk‑only patches, and I can optionally save the raw Copilot output for debugging when something looks off.

To make this feel production‑ready (not just a weekend script), I invested in:

Full test coverage: unit tests for the parser (including edge cases and weird diff formats), an integration test that simulates Copilot’s output and applies a patch, and a cross‑platform e2e test that mocks gh to validate the entire CLI flow.

Multi‑version CI: GitHub Actions runs the test suite on Node 16, 18, and 20 so contributors (and judges) see green checks before they even clone the repo.

Repo hygiene: CODEOWNERS, CONTRIBUTING, CI badge, and clear npm scripts (test, test:unit, test:integration, test:e2e) so the project looks and behaves like something you could drop into a real team’s toolbox.
Working with Copilot CLI this way felt very close to pairing with another engineer sitting in my terminal: I focused on shaping the workflow, curating context, and enforcing safety rails, while Copilot focused on reading diffs, writing patches, and explaining failures in human language.

If you’ve ever stared at a failing test at 2 AM and wished an experienced teammate would just “take it from here,” copilot-bugfix is my attempt to turn that wish into a single command.

A Special Thank You

I am so grateful to have the opportunity to participate in the GitHub Copilot CLI Challenge. This hackathon pushed me to think deeply about how AI agents can solve real developer problems—turning a simple "failing test" into a complete "bug → fix → PR" workflow with minimal friction.

Thanks to the DEV Community and GitHub for creating this challenge. It's been an incredible learning experience!

Top comments (1)

Collapse
 
keerthana_696356 profile image
Keerthana

One thing about this platform before joining this ,i have little bit knowledge , but after participating in dev and it's challenges, i have learned so much , i strongly believe that this is the starting and very great phase for my journey😘