I'm Oikon. I typically share Claude Code insights on X (Twitter).
Recently, Claude Code on the Web removed gh from the disallowed_tools list, making GitHub CLI available. In this article, I'll show you how to configure it. I've also published a setup package, so you can get started right away.
oikon48
/
gh-setup-hooks
Enable `gh` command in Claude Code on the Web environment, just adding SessionStartHooks
gh-setup-hooks
Auto-install GitHub CLI on Claude Code on the Web. Just add one line to settings.json.
Setup
1. Add hook to settings.json
Add to .claude/settings.json:
{
"hooks": {
"SessionStart": [
{
"hooks": [
{
"type": "command",
"command": "bun x gh-setup-hooks",
"timeout": 120
}
]
}
]
}
}
npx -y gh-setup-hooks is also ok.
2. Set up Claude Code on the Web
To use gh commands (e.g., gh pr create), you need to set GH_TOKEN or GITHUB_TOKEN:
- Go to Claude Code on the Web
- Open Settings → Custom Environment
- Add environment variable:
- Name:
GH_TOKENorGITHUB_TOKEN - Value: Your GitHub Personal Access Token
- Name:
Note: The token needs
reposcope for most operations.
Claude Code on the Web network should be Full or Custom. If using Custom, you need to allow release-assets.githubusercontent.com.
How
…TL;DR
- Around December 17, 2025,
ghwas removed fromdisallowed_tools - Configure
GITHUB_TOKENin a custom environment - Easy setup with
bun x gh-setup-hooks - Use
CLAUDE_CODE_REMOTEto detect the "on the Web" environment
Note:
The specifications in this article are based on Claude Code on the Web as of January 8, 2026. Some setup steps may become unnecessary ifghcommand becomes installed by default in the future.
Quick Start
Here's how to get gh working in the shortest time possible.
1. Custom Environment Configuration
Create a custom environment in Claude Code on the Web and configure the following:
-
Environment Variable:
GITHUB_TOKEN=ghp_xxxx...(Personal Access Token issued from GitHub) -
Network Access: "Full" or "Custom" with
release-assets.githubusercontent.comallowed
2. Hooks Configuration
Add the following to your repository's .claude/settings.json:
{
"hooks": {
"SessionStart": [
{
"hooks": [
{
"type": "command",
"command": "bun x gh-setup-hooks",
"timeout": 120
}
]
}
]
}
}
That's it! When you start a session in Claude Code on the Web, gh will be automatically installed, enabling PR creation and issue management.
⚠️ Warning:
Due to sandbox proxy configuration, you need to use the-R owner/repoflag when usingghcommands. Claude Code often adds this automatically, but adding a note in CLAUDE.md makes things smoother.
What is Claude Code on the Web?
Claude Code on the Web is an environment where you can run Claude Code directly in your browser.
The main appeal is that you can develop with just a browser, even without a PC at hand. It works by cloning GitHub repositories and running Claude Code in a sandboxed environment. For detailed specifications, please check out my previous article:
As a side note, by prefixing your Claude Code prompt with &, you can send tasks from local Claude Code to Claude Code on the Web.
The Removal of gh Command Restrictions
Previously, the gh command was explicitly blocked in Claude Code on the Web. The startup options included --disallowed-tools Bash(gh:*), and the system prompt contained this statement:
The GitHub CLI (
gh) is not available in this environment.
In other words, any GitHub CLI operations like creating PRs or managing issues were completely unavailable.
However, around December 17, 2025, gh had been removed from the disallowed_tools list.
The diff in data/startup.json shows that "disallowed_tools": ["Bash(gh:*)"] has been removed. This means the gh command itself is no longer blocked. However, since gh isn't installed by default, you still can't use it out of the box.
How the Setup Works
The gh-setup-hooks package uses sessionStartHooks to automatically install gh at session start.
How It Works
- Hook fires at session start
- Checks if it's a "on the Web" environment using
CLAUDE_CODE_REMOTEenvironment variable - Downloads and installs
ghonly in the "on the Web" environment - Writes PATH to
CLAUDE_ENV_FILEto enable it throughout the session
About the Environment Variables
CLAUDE_CODE_REMOTE: An environment variable set to true only in the Claude Code on the Web environment. This allows the script to skip execution in local environments and run only in the "on the Web" environment.
if [ "$CLAUDE_CODE_REMOTE" != "true" ]; then
log "Not a remote session, skipping gh setup"
exit 0
fi
CLAUDE_ENV_FILE: An environment variable file path provided by Claude Code. Writing to this file persists PATH settings throughout the session.
if [ -n "$CLAUDE_ENV_FILE" ]; then
echo "export PATH=\"$LOCAL_BIN:\$PATH\"" >> "$CLAUDE_ENV_FILE"
log "PATH persisted to CLAUDE_ENV_FILE"
fi
If you want to write your own script instead of using the package, here's a reference:Script Details (gh-setup.sh)
#!/bin/bash
# SessionStart hook: GitHub CLI auto-installation for remote environments
set -e
LOG_PREFIX="[gh-setup]"
log() { echo "$LOG_PREFIX $1" >&2; }
if [ "$CLAUDE_CODE_REMOTE" != "true" ]; then
log "Not a remote session, skipping gh setup"
exit 0
fi
log "Remote session detected, checking gh CLI..."
if command -v gh &>/dev/null; then
log "gh CLI already available: $(gh --version | head -1)"
exit 0
fi
LOCAL_BIN="$HOME/.local/bin"
mkdir -p "$LOCAL_BIN"
if [ -x "$LOCAL_BIN/gh" ]; then
log "gh found in $LOCAL_BIN"
export PATH="$LOCAL_BIN:$PATH"
[ -n "$CLAUDE_ENV_FILE" ] && echo "export PATH=\"$LOCAL_BIN:\$PATH\"" >> "$CLAUDE_ENV_FILE"
exit 0
fi
log "Installing gh CLI to $LOCAL_BIN..."
TEMP_DIR=$(mktemp -d)
trap "rm -rf $TEMP_DIR" EXIT
ARCH=$(uname -m)
case "$ARCH" in
x86_64) GH_ARCH="amd64" ;;
aarch64|arm64) GH_ARCH="arm64" ;;
*) log "Unsupported architecture: $ARCH"; exit 0 ;;
esac
GH_VERSION="2.62.0"
GH_URL="https://github.com/cli/cli/releases/download/v${GH_VERSION}/gh_${GH_VERSION}_linux_${GH_ARCH}.tar.gz"
curl -sL "$GH_URL" -o "$TEMP_DIR/gh.tar.gz" || { log "Failed to download"; exit 0; }
tar -xzf "$TEMP_DIR/gh.tar.gz" -C "$TEMP_DIR" || { log "Failed to extract"; exit 0; }
mv "$TEMP_DIR/gh_${GH_VERSION}_linux_${GH_ARCH}/bin/gh" "$LOCAL_BIN/gh" || { log "Failed to install"; exit 0; }
chmod +x "$LOCAL_BIN/gh"
export PATH="$LOCAL_BIN:$PATH"
[ -n "$CLAUDE_ENV_FILE" ] && echo "export PATH=\"$LOCAL_BIN:\$PATH\"" >> "$CLAUDE_ENV_FILE"
log "gh CLI installed successfully: $($LOCAL_BIN/gh --version | head -1)"
Conclusion
With gh now available, you can read issues and execute tasks, or create PRs directly in Claude Code on the Web. The CLAUDE_CODE_REMOTE variable can also be useful for other remote-only workflows.
If you found this article valuable, follow the author on X (@oikon48) for ongoing Claude Code insights and updates.
References
GitHub
oikon48
/
gh-setup-hooks
Enable `gh` command in Claude Code on the Web environment, just adding SessionStartHooks
gh-setup-hooks
Auto-install GitHub CLI on Claude Code on the Web. Just add one line to settings.json.
Setup
1. Add hook to settings.json
Add to .claude/settings.json:
{
"hooks": {
"SessionStart": [
{
"hooks": [
{
"type": "command",
"command": "bun x gh-setup-hooks",
"timeout": 120
}
]
}
]
}
}
npx -y gh-setup-hooks is also ok.
2. Set up Claude Code on the Web
To use gh commands (e.g., gh pr create), you need to set GH_TOKEN or GITHUB_TOKEN:
- Go to Claude Code on the Web
- Open Settings → Custom Environment
- Add environment variable:
- Name:
GH_TOKENorGITHUB_TOKEN - Value: Your GitHub Personal Access Token
- Name:
Note: The token needs
reposcope for most operations.
Claude Code on the Web network should be Full or Custom. If using Custom, you need to allow release-assets.githubusercontent.com.
How
…Documentation
Claude Code on the Web - Official Documentation
Claude Code Hooks - Official Documentation
Managing Personal Access Tokens - GitHub Docs

zenn.dev
Top comments (0)