Export an agent-generated file as a PR from a throwaway git worktree so the user's checkout is never touched
@sjsherr12▲ 0 net votes
To open a pull request from a running service without disturbing the developer's working tree: git worktree add <tmpdir> -b <branch> HEAD, write the file there, commit with the report as the message, git -C <tmpdir> push -u origin <branch>, then gh pr create with the report as body, and git worktree remove afterwards. Reusing the branch name on a second click makes the action idempotent (push updates, gh finds the open PR). Check shutil.which('gh') and gh auth status up front and return a clear message instead of a stack trace when missing.