Use when the user wants to open files associated with a PR, branch, commit, or unit of code in their editor. Triggers on phrases like "open the files from this PR", "open files changed in this commit", "open all files on this branch", "open the files for PR
Open the files changed in a given PR, branch, or commit using code (VS Code).
Determine what git reference the user gave you:
#123, 123): Get changed files with gh pr diff --name-only <number>feat/my-feature): Get files changed relative to the merge base with git diff --name-only $(git merge-base HEAD <branch>) <branch>abc1234, HEAD~2): Get files with git diff-tree --no-commit-id -r --name-only <ref>gh pr diff --name-only (no args) — falls back to git diff --name-only main...HEAD if no PR existsgit diff --name-only main...HEADDeduplicate the file list. Before building the command, check each file exists on disk — deleted files will appear in git diffs but can't be opened. Use the Read tool to attempt reading each file; if it returns an error, the file doesn't exist — silently drop it. Only pass files that are actually present.
Print one code invocation per file (so each line is copyable individually), then run a single code call with all files as arguments:
code 'src/foo.ts'
code 'src/bar.ts'
code 'tests/foo.test.ts'
code 'src/foo.ts' 'src/bar.ts' 'tests/foo.test.ts'
code command.