githubSearchPullRequests
Search GitHub pull requests by keywords, state, or author to identify relevant PRs. Fetch head/base branch SHAs for detailed commit analysis or retrieve all PR commits with file changes for deeper insights.
Instructions
Search GitHub PRs by keywords, state, or author. Returns head/base SHAs for github_fetch_content (branch=SHA). Can fetch all PR commits with changes using getCommitData=true.
SEARCH STRATEGY FOR BEST RESULTS:
- Use minimal search terms for broader coverage (2-3 words max)
- Separate searches for different aspects vs complex queries
- Use filters to narrow scope after getting initial results
- Use getCommitData=true to get all commits in PR with file changes
- Use github_search_commits with head_sha/base_sha from results to get code changes
COMMIT DATA FETCHING (getCommitData=true):
- Fetches all commits in the PR using 'gh pr view --json commits'
- For each commit, fetches detailed changes using GitHub API
- Shows commit SHA, message, author, and file changes
- Includes up to 10 commits per PR with detailed diffs
- Each commit shows changed files with additions/deletions/patches
- Example: Shows individual commits like "Fix bug in component" with specific file changes
EXAMPLE OUTPUT WITH getCommitData=true: { "commits": { "total_count": 3, "commits": [ { "sha": "abc123", "message": "Fix bug in component", "author": "username", "diff": { "changed_files": 2, "additions": 15, "deletions": 3, "files": [...] } } ] } }
NOTE: The head_sha and base_sha fields in the PR results can be used as the 'hash' parameter in github_search_commits to look up the exact commit and get actual code changes.
TOKEN OPTIMIZATION:
- getCommitData=true is expensive in tokens. Use only when necessary.
- Consider using github_search_commits with head_sha/base_sha instead for specific commits
Input Schema
Name | Required | Description | Default |
---|---|---|---|
app | No | Filter by GitHub App author | |
archived | No | Filter by repository archived state | |
assignee | No | GitHub username of assignee | |
author | No | GitHub username of PR author | |
base | No | Filter on base branch name | |
checks | No | Filter by checks status | |
closed | No | Filter by closed date (e.g., >2020-01-01) | |
commenter | No | User who commented on PR | |
comments | No | Include comment content in search results. This is a very expensive operation in tokens and should be used with caution. | |
created | No | Filter by created date (e.g., >2020-01-01) | |
draft | No | Filter by draft state | |
getCommitData | No | Set to true to fetch all commits in the PR with their changes. Shows commit messages, authors, and file changes. WARNING: EXTREMELY expensive in tokens - fetches diff/patch content for each commit. | |
head | No | Filter on head branch name | |
interactions | No | Total interactions (reactions + comments) | |
involves | No | User involved in any way | |
label | No | Filter by label | |
language | No | Repository language | |
limit | No | Maximum number of results to fetch | |
locked | No | Filter by locked conversation status | |
match | No | Restrict search to specific fields | |
mentions | No | PRs mentioning this user | |
merged | No | Filter by merged state | |
merged-at | No | Filter by merged date (e.g., >2020-01-01) | |
milestone | No | Milestone title | |
no-assignee | No | Filter by missing assignee | |
no-label | No | Filter by missing label | |
no-milestone | No | Filter by missing milestone | |
no-project | No | Filter by missing project | |
order | No | Order of results (requires --sort) | desc |
owner | No | Repository owner (use with repo param) | |
project | No | Project board owner/number | |
query | Yes | Search query for PR content (keep minimal for broader results) | |
reactions | No | Filter by number of reactions | |
repo | No | Repository name (use with owner param) | |
review | No | Filter by review status | |
review-requested | No | User/team requested for review | |
reviewed-by | No | User who reviewed the PR | |
sort | No | Sort fetched results | |
state | No | Filter by state: open or closed | |
team-mentions | No | Filter by team mentions | |
updated | No | Filter by updated date (e.g., >2020-01-01) | |
visibility | No | Repository visibility |