Skip to content

Home / Integrations / GitHub

VCS

GitHub

Learn how Claude Code integrates with GitHub to automate commits, pull requests, code reviews, and issue triage directly from your terminal.

Setup

  1. 1.
    Install and authenticate the GitHub CLI
    Claude Code uses the gh CLI under the hood for pull requests, issues, and reviews. Install it and log in so Claude Code can act on your behalf.
    brew install gh && gh auth login
  2. 2.
    Initialize a git repository
    Make sure your project is a git repo with a remote pointing to GitHub. Claude Code reads your git config to understand branches, remotes, and history.
    git init && git remote add origin https://github.com/you/repo.git
  3. 3.
    Add a CLAUDE.md with branch conventions
    Tell Claude Code how your team names branches, formats commit messages, and which branch to target for PRs. This keeps automated git operations consistent with your workflow.
    echo "# Git Conventions\n- Branch format: feat/<ticket>-<description>\n- Commit style: conventional commits\n- PR target: main" > CLAUDE.md
  4. 4.
    Start using Claude Code for git tasks
    Ask Claude Code to create branches, commit changes, open PRs, or review diffs. It runs real git and gh commands in your terminal, so everything appears in your normal git history.
    claude "create a PR for the changes in this branch with a detailed description"

Features

  • +Creates branches, commits, and pull requests with proper messages and descriptions
  • +Reads and responds to PR review comments using gh CLI
  • +Triages GitHub Issues by reading labels, descriptions, and linked PRs
  • +Runs in headless mode inside GitHub Actions for CI-driven code changes
  • +Understands git history and diffs to provide context-aware suggestions
  • +Manages merge conflicts by reading both sides and applying intelligent resolutions

Use Cases

End-to-end feature development

Describe a feature and let Claude Code create the branch, write the code, run tests, commit, and open a pull request — all in one session.

Automated PR reviews

Point Claude Code at an open PR and ask it to review the diff. It reads every changed file, identifies bugs, suggests improvements, and can post review comments via gh.

Issue-driven development

Give Claude Code a GitHub Issue URL. It reads the issue, creates a feature branch, implements the requested changes, and opens a PR that references and closes the issue.

CI pipeline agent

Run Claude Code in headless mode inside GitHub Actions to automatically fix failing tests, update dependencies, or apply code review feedback without human intervention.

How Claude Code works with GitHub

Claude Code treats git as a first-class tool. It runs real git commands (git checkout, git commit, git push) and real GitHub CLI commands (gh pr create, gh issue view) in your terminal. There is no plugin, extension, or OAuth app to install — if git and gh work on your machine, Claude Code can use them.

This means every action Claude Code takes shows up in your normal git log and GitHub activity. Commits have real SHAs, PRs appear in your repository, and branch protections still apply. Claude Code works within your existing permissions, not around them.

Typical workflow: from issue to merged PR

Headless mode in GitHub Actions

Claude Code supports a headless (non-interactive) mode that makes it ideal for CI/CD. You can trigger it from a GitHub Actions workflow to automatically fix lint errors, apply review feedback, or update generated files. The agent reads the CI context, makes changes, commits, and pushes — no human in the loop.

Does Claude Code need a GitHub token?+
Claude Code uses the GitHub CLI (gh), which manages authentication. Run gh auth login once and Claude Code inherits your credentials. No separate token configuration is needed.
Can Claude Code push to protected branches?+
No. Claude Code respects your repository's branch protection rules. It will create feature branches and open PRs, but merging still requires the approvals and checks you have configured.
Will Claude Code force-push or rewrite history?+
By default, Claude Code creates new commits rather than amending or rebasing. It avoids destructive git operations unless you explicitly instruct it to do so.
Can I use Claude Code with GitHub Enterprise?+
Yes. As long as the gh CLI is authenticated against your GitHub Enterprise instance, Claude Code will use it seamlessly.

Related tools

Claude CodeGitHub Copilot

Related terms

エージェンティック・コーディングModel Context Protocol(MCP)AIコードレビュー

Master Claude Code in days, not months

37 hands-on lessons from beginner to CI/CD automation. Module 1 is free.

START FREE →
← ALL INTEGRATIONS