Sandbox
@oikon48/gh-setup-hooks

SessionStart hook for GitHub CLI in Claude Code

This package makes GitHub CLI available in Claude Code on the Web by running a SessionStart hook. When a session begins, it installs `gh` only in the remote Claude environment, updates PATH, and detects `GH_REPO` from the git remote.

48 stars3 forksJavaScriptUpdated 6mo ago
Who it's for

Builders who use Claude Code on the Web and need GitHub CLI commands in their sessions.

What it delivers

You can run `gh` commands in Claude Code on the Web without setting up GitHub CLI by hand.

What it does

SessionStart hook install

Runs `bun x gh-setup-hooks` or `npx -y gh-setup-hooks` when a Claude Code session starts.

Remote-only GitHub CLI setup

Installs `gh` only when `CLAUDE_CODE_REMOTE=true`, and skips local environments.

PATH persistence

Installs to `~/.local/bin` and keeps it on PATH for later commands in the session.

GitHub repo detection

Auto-detects `GH_REPO` from the git remote so `gh` works with the current repository.

Custom version control

Uses `GH_SETUP_VERSION` to choose which GitHub CLI version to install.

README

gh-setup-hooks

npm version License: MIT

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:

  1. Go to Claude Code on the Web
  2. Open SettingsCustom Environment
  3. Add environment variable:

Note: The token needs repo scope 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.

Cloud Environment Settings

How It Works

  1. Start a session on Claude Code on the Web
  2. SessionStart hook runs npx gh-setup-hooks
  3. Installs gh only in remote environment (CLAUDE_CODE_REMOTE=true)
  4. Installs to ~/.local/bin and persists PATH
  5. Auto-detects GH_REPO from git remote for gh CLI compatibility
  6. Does nothing in local environment

Configuration

Environment VariableDescriptionDefault
GH_SETUP_VERSIONgh version to install2.88.1

License

MIT

References

Files in the repo

Repository payload8 top-level entries
  • bin
  • images
  • src
  • test
  • .gitignore
  • LICENSE
  • package.json
  • README.md

Discussion (0)

Ask about usage, or say what you built with it

Sign in to join the discussion.

No comments yet. Be the first to say what this is good for.

More hooks

CLI proxy that reduces LLM token consumption by 60-90% on common dev commands. Single Rust binary, zero dependencies

80k

Warcraft III Peon voice notifications (+ more!) for Claude Code, Codex, IDEs, and any AI agent. Stop babysitting your terminal. Employ a Peon today.

5k
bahni-m/
code-with-quran

Read the Qur'an while Claude Code works. Start a session with 'claude --cwq' and a reader beside it walks forward through the Qur'an one ayah per prompt, resuming where you left off — in a terminal pane or a browser tab. Zero dependencies, fully offline.

48
zachahn/
vomit

Clean up Claude's token vomit with a separate LLM. Save your tokens, Opus is hopeless

193

A pre-execution guard for AI coding agents. It blocks destructive Git and file system commands, plus common attempts to access sensitive files, before a tool call runs. Supports Amp Code, Antigravity CLI, Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot CLI, Grok Build, Hermes Agent, Kimi Code, OpenClaw, OpenCode, and Pi.

1.5k