The gh CLI — Claude Code's Best Integration
For most GitHub workflows, gh CLI outperforms the GitHub MCP server: no context overhead, battle-tested, zero setup if you're already authenticated. This article covers when to use gh vs GitHub MCP, core patterns, and building automation workflows around gh.
Quick Reference
- →gh is a first-class tool in Claude Code — no setup if already installed and authenticated
- →Claude knows gh from training — no docs or schema loading needed
- →Core commands: gh pr create, gh pr view, gh issue create, gh pr checks, gh pr merge
- →--from-pr flag in claude lets you start a PR-aware session directly
- →Build /fix-issue and /create-pr skills around gh for reusable team workflows
- →gh pr checks is the key command for CI monitoring loops
- →GitHub MCP: reach for it when gh can't do it (fine-grained API, webhook management)
- →gh is synchronous; GitHub MCP is better for event-driven or webhook-triggered workflows
Why gh Beats GitHub MCP for Most Use Cases
When engineers first add GitHub integration to Claude Code, the instinct is to reach for the GitHub MCP server — it's official, it sounds comprehensive, and it promises deep API access. But for the 90% of day-to-day GitHub workflows, gh CLI is a better choice.
| Dimension | gh CLI | GitHub MCP |
|---|---|---|
| Setup | Already installed for most engineers | Requires installing and configuring MCP server |
| Context overhead | Zero — Claude calls it as Bash | Adds MCP tool schemas to context window |
| Claude's knowledge | Deeply trained on gh syntax | Treats it as a new API to discover |
| Reliability | Battle-tested, widely used | Newer, fewer edge cases handled |
| API coverage | Complete for common operations | More comprehensive for obscure API calls |
| Event-driven use | Not native | Better for webhook and event-driven patterns |
The context overhead difference is real: every MCP server adds tool schemas to Claude's context window. For a simple pr create, you're spending tokens on schema discovery that could be used for code analysis. gh commands are two-token invocations that Claude already knows how to use.
Reach for GitHub MCP when you need fine-grained API calls that gh doesn't expose (repository settings, webhook management, GitHub Apps), when you want event-driven triggers (e.g., respond when a label is added), or when you need to interact with GitHub's GraphQL API for complex queries.