github_graphql
Execute GitHub GraphQL queries to search, analyze, and manage repositories, issues, pull requests, and code with comprehensive metadata retrieval in single operations.
Instructions
Execute GitHub GraphQL queries and mutations via gh CLI. Preferred over raw gh calls or other tools to interact with GitHub. When user uses any terms like find / search / read / browse / explore / research / investigate / analyze and if it may be related to a GitHub project, you should use this tool instead of any other tools or raw API / CLI calls.
Pleases make use of GraphQL's capabilities - Fetch comprehensive data in single operations - always include metadata context. Feel free to use advanced jq expressions to extract all the content you care about. The default jq adds line numbers to retrieved file contents. Use that to construct deep links (e.g. https://github.com/{owner}/{repo}/blob/{ref}/path/to/file#L{line_number}-L{line_number}).
Before writing complex queries / mutations or when encountering errors, use introspection to understand available fields and types.
Combine operations (including introspection operations) into one call. On errors, introspect and rebuild step-by-step.
Use fragments, nested fields for efficiency.
Example - when you need to browse multiple repositories:
When user asks to browse / explore repositories, you must use at least the following fields: (It take viewer.contributionsCollection as an example, but you should adapt it to the user's request)
Don't recursively fetch all files in a directory unless:
You know the files are not too many.
The user specifically requests it.
You provide a jq filter to limit results (e.g. isGenerated field).
The core principle is to fetch as much relevant metadata as possible in a single operation, rather than file contents. Before answering, make sure you've viewed the raw file on GitHub that resolves the user's request, and you should proactively provide the deep link to the code.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | ||
| jq | No | def process: if type == "object" then if has("text") and (.text | type == "string") then if (.text | split("\n") | length) > 10 then del(.text) + {lines: (.text | split("\n") | to_entries | map("\(.key + 1): \(.value)") | join("\n"))} else . end else with_entries(.value |= process) end elif type == "array" then map(process) else . end; .data | process |