CLI: add `--from-pr` to `codex resume` and `codex exec resume`

Resolved 💬 4 comments Opened Jan 31, 2026 by pygarap Closed Mar 14, 2026
💡 Likely answer: A maintainer (etraut-openai, contributor) responded on this thread — see the highlighted reply below.

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 123
  • codex resume --from-pr https://github.com/ORG/REPO/pull/123
  • codex exec resume --from-pr 123
  • codex 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 --last is CWD scoped unless --all is 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 resume as a fallback).

Acceptance criteria

  • codex resume --from-pr ... works for number, # number, and PR URL.
  • codex exec resume --from-pr ... behaves the same.
  • --from-pr integrates cleanly with existing --all behavior (global search when requested).
  • Help text and the CLI reference docs are updated to include --from-pr.

View original on GitHub ↗

4 Comments

etraut-openai contributor · 6 months ago

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?

pygarap contributor · 6 months ago

@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-code already ships this natively: their v2.1.27 release added --from-pr to resume sessions linked to a specific GitHub PR number or URL.

lgo · 6 months ago

Just to add a datapoint to this, it seems like codex resume already 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 with gh, but actually pruning down to the relevant sessions for a branch is something missing from codex.

etraut-openai contributor · 5 months ago

This feature request hasn't received enough upvotes, so I'm closing.