CLI: add `--from-pr` to `codex resume` and `codex exec resume`
What feature would you like to see?
Summary
Add a --from-pr flag that resumes a Codex CLI session associated with a GitHub Pull Request, selected by PR number, PR URL, or an interactive picker.
This is for the Codex CLI and should integrate with the existing codex resume and codex exec resume flows documented in the CLI reference.
Problem
Today, resuming requires a SESSION_ID or using the session picker (codex resume / codex exec resume --last), which makes it hard to jump back into "the session that produced PR X" without manually tracking session IDs.
Proposed UX
Support the flag on both commands:
codex resume --from-pr 123codex resume --from-pr https://github.com/ORG/REPO/pull/123codex exec resume --from-pr 123codex exec resume --from-pr https://github.com/ORG/REPO/pull/123
Interactive mode when no value is provided:
codex resume --from-pr- Show a list of PRs that have linked sessions (scoped to the current repo by default, consistent with how
--lastis CWD scoped unless--allis used). - After selecting a PR, if multiple sessions are linked, pick the most recent or show a second picker (implementation choice).
Accepted identifiers:
123#123- Full PR URL (
https://github.com/.../pull/123)
Additional information
Session auto-linking
Sessions should automatically store PR linkage metadata when a PR is created during the session (for example, when the workflow creates a PR via tooling like GitHub CLI). The --from-pr flag should use that stored metadata to resolve the target session(s).
Expected behavior
- If exactly 1 session matches the PR, resume it immediately.
- If multiple sessions match, prefer the most recent, or prompt to select one.
- If no session matches, exit non-zero with a clear message (include the parsed PR identifier and suggest
codex resumeas a fallback).
Acceptance criteria
codex resume --from-pr ...works for number,#number, and PR URL.codex exec resume --from-pr ...behaves the same.--from-printegrates cleanly with existing--allbehavior (global search when requested).- Help text and the CLI reference docs are updated to include
--from-pr.
4 Comments
I'm not sure we'd want to hard-code a command like this into the CLI. This should be easy to implement with a skill. Have you tried that approach?
@etraut-openai Thanks for the suggestion. I get the point about implementing this as a skill, but I would really prefer native CLI support for
--from-pr.Resuming the correct session from a PR feels like a core workflow, and having it built in makes it more discoverable (
--help), consistent, and reliable across machines and environments.Also,
claude-codealready ships this natively: their v2.1.27 release added--from-prto resume sessions linked to a specific GitHub PR number or URL.Just to add a datapoint to this, it seems like
codex resumealready is branch-aware as shows a column of the branch name when presenting the option of sessions.Rather than something that is pretty vendor-specific like
--from-pr(which is making assumptions re: Github and all), I imagine it would be just as useful to have a way to filter sessions for a branch name. Figuring that out from a Github PR feels like something easy to then package up as an alias/bash command withgh, but actually pruning down to the relevant sessions for a branch is something missing from codex.This feature request hasn't received enough upvotes, so I'm closing.