Published on April 22nd, 2025 by Braden Keith

Automate AI‑Powered Fixes with “codex‑autopilot”

— How one GitHub Action turns an Issue label into a pull request you can merge in minutes

Have you ever opened an issue, added a hint of what you wanted changed, and wished the code magically updated itself? That’s exactly what codex‑autopilot does.

https://gist.github.com/bradenkeith/e25914ba3150d7bb575f7ccc7eb24767


What the workflow does

  1. Listens for the codex label
    Tag any issue with codex and the workflow wakes up.

  2. Acknowledges the issue (👀)
    It immediately reacts with an eyes emoji so the reporter knows work has started.

  3. Checks out your repo & installs OpenAI Codex
    The workflow pulls the code, installs the Codex CLI, and passes the issue’s title + body as the prompt.

  4. Codex edits your code—completely non‑interactive
    Using auto-edit mode, Codex rewrites files or creates new ones in seconds.

  5. Commits to a new branch (codex/<issue#>), pushes, and opens a PR
    The branch is deleted automatically after you merge.

  6. Leaves a tidy, human‑readable commit & PR body
    You see exactly which issue it fixes and a link back to the automation.


One prerequisite that can trip you up

Settings → Actions → Workflow permissions → Allow GitHub Actions to create and approve pull requests

If that checkbox is off, the default GITHUB_TOKEN can’t open PRs and you’ll get
GitHub Actions is not permitted to create or approve pull requests.”

  • Can’t enable it? Swap secrets.GITHUB_TOKEN for a PAT with contents + pull‑requests write scopes.

Local dry‑runs with act

brew install act          # or use Homebrew/core
act -s GITHUB_TOKEN=$PAT  # run the job in Docker exactly as GH would

Supply a Personal Access Token (PAT) so the create-pull-request step can push back to GitHub.


Why this matters

  • Instant feedback loop – non‑developers can open issues, add the codex label, and watch a PR appear.
  • Reliable automation – Codex runs in a fresh container every time, so you get reproducible edits.
  • Human oversight – you still review the PR; Codex never commits directly to main.

Ready to try it?

  1. Copy the YAML from the gist into .github/workflows/codex‑autopilot.yml.
  2. Tick the pull‑request permission box (or add a PAT).
  3. Create an issue, describe your change, add the codex label, and enjoy the magic.

See the full code and inline comments here:
https://gist.github.com/bradenkeith/e25914ba3150d7bb575f7ccc7eb24767

Happy auto‑hacking!