How to merge branches from Claude Code Web
Contents
Claude Code on the Web is convenient, but there is one annoying limitation: even if it can git push, it cannot merge branches by default.
For this site, Vercel only deploys when changes land on main, so web-only work does not fully close the loop.
The tool that fixes this is gh-setup-hooks.
What Is gh-setup-hooks?
It is a tool that automatically installs the GitHub CLI (gh) when a Claude Code Web session starts.
- Repository: https://github.com/oikon48/gh-setup-hooks
- Runs automatically via a
SessionStarthook - Authenticates through the
GH_TOKENenvironment variable
That makes commands like gh pr merge available, which means you can merge from the web session.
Setup
1. Add the hook configuration to the project
Create .claude/settings.json:
{
"hooks": {
"SessionStart": [
{
"hooks": [
{
"type": "command",
"command": "npx -y gh-setup-hooks",
"timeout": 120
}
]
}
]
}
}
Commit and push this file in advance.
2. Create a GitHub Personal Access Token
- Go to https://github.com/settings/tokens
- Choose Generate new token -> Generate new token (classic)
- Set:
- Note: something easy to understand, such as
Claude Code web - Expiration: 90 days, or no expiration
- Scope: check
repo(required)
- Note: something easy to understand, such as
- Click Generate token
- Copy the token. Once you leave the page, GitHub will not show it again
3. Set the environment variable in Claude Code Web
- Open a Claude Code session at https://claude.ai
- Go to Settings -> Update cloud environment
- Add:
GH_TOKEN=ghp_xxxxxxxxxxxxx
- Save
4. Verify it works
Start a new web session and run:
gh --version
gh auth status
If gh auth status shows you as authenticated, the setup worked.
How to use it
Create a PR and merge it
# Create a branch and push changes
git checkout -b feature/new-article
git add .
git commit -m "Add article"
git push -u origin feature/new-article
# Create a PR
gh pr create --title "Add article" --body "Add a new article"
# Merge the PR and deploy to main
gh pr merge --merge
# Merge and delete the branch
gh pr merge --merge --delete-branch
Once it is merged to main, Vercel starts deployment automatically.
Bonus: local and web handoff features in Claude Code
Claude Code also has a teleport feature that lets you move sessions between local and web environments.
Local -> web with &
In the terminal version of Claude Code, prefixing a task with & sends it to the web:
& Review and fix this article
- A new web session is created
- The current conversation context is carried over
- The task keeps running even if you close your local machine
Web -> local with teleport
/teleport
# or
claude --teleport
That pulls the web session back into the local environment so you can continue there.
Caveats
&does not work in the VS Code extension, only the CLI- Teleport is one-way in practice, web to local
- Teleport only works within the same repository
Summary
With gh-setup-hooks, Claude Code Web can handle the full flow:
- Create an article
- Push a branch
- Create a PR
- Merge into
main - Let Vercel deploy automatically
That means you can publish articles from a phone or another machine without relying on a local development setup.
I tried it for real
I tested the local -> web -> merge flow using this article itself.
1. Move the session from local to web
In the terminal version of Claude Code, I ran:
& Run gh auth status and check whether gh CLI is set up
That created a web session and carried over the conversation context.
2. Then PR creation failed
When I tried gh pr create on the web, I got this error:
No commits between main and claude/check-gh-auth-RKZpu
It turned out that the VS Code version of Claude Code had already merged the same work into main locally, so the branch and main pointed at the same commit.
3. Retrying with this extra section
So I added this “I tried it for real” section and tried the PR -> merge flow again on a fresh branch.
# Create a new branch
git checkout -b claude/gh-merge-test-xxx
# Commit the change
git add .
git commit -m "Update article: add hands-on verification section"
# Push it
git push -u origin claude/gh-merge-test-xxx
# Create the PR
gh pr create --repo hide3tu/LiltingChannelWeb \
--title "Update article: add gh-setup-hooks verification section" \
--body "Add the actual test results" \
--base main
# Merge it
gh pr merge --repo hide3tu/LiltingChannelWeb --merge
Result: success. The merge to main completed from the web session, and Vercel started deploying automatically.