@jonchurch/claude-code-gh 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License Copyright (c) 2026 Jon Church
2
+
3
+ Permission is hereby granted, free of
4
+ charge, to any person obtaining a copy of this software and associated
5
+ documentation files (the "Software"), to deal in the Software without
6
+ restriction, including without limitation the rights to use, copy, modify, merge,
7
+ publish, distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to the
9
+ following conditions:
10
+
11
+ The above copyright notice and this permission notice
12
+ (including the next paragraph) shall be included in all copies or substantial
13
+ portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
16
+ ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
18
+ EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
19
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # claude-code-gh
2
+
3
+ Claude Code web sessions run on ephemeral VMs that don't have the GitHub CLI (`gh`) installed. This means that if you're used to having claude work with the `gh` cli locally for interacting with Github, you are not able to in Claude Code web sessions.
4
+
5
+ This package provides a [SessionStart hook](https://code.claude.com/docs/en/hooks#sessionstart) that installs the latest `gh` automatically when your session starts. Hooks are scripts that Claude Code runs at specific points - SessionStart hooks run once when a new session begins, making them perfect for environment setup.
6
+
7
+ ## Setup
8
+
9
+ Add to your repo's `.claude/settings.json` (not user level `~/.claude/settings.json` because remote sessions only see repo-level settings):
10
+
11
+ ```json
12
+ {
13
+ "hooks": {
14
+ "SessionStart": [
15
+ {
16
+ "matcher": "startup",
17
+ "hooks": [
18
+ {
19
+ "type": "command",
20
+ "command": "npx @jonchurch/claude-code-gh"
21
+ }
22
+ ]
23
+ }
24
+ ]
25
+ }
26
+ }
27
+ ```
28
+
29
+ Commit that file and `gh` will be available in your next web session.
30
+
31
+ ## Environment
32
+
33
+ Your Claude Code environment needs "Limited" (default) or "Full" network access. "No internet" mode will fail since we need to reach GitHub.
34
+
35
+ To authenticate `gh` for private repos or higher rate limits, add `GH_TOKEN` to your environment variables in the Claude web app settings.
36
+
37
+ ## License
38
+
39
+ MIT
package/bin/setup.sh ADDED
@@ -0,0 +1,67 @@
1
+ #!/bin/bash
2
+ set -eo pipefail
3
+
4
+ log() { echo "[claude-code-gh] $1" >&2; }
5
+ context() { echo "{\"hookSpecificOutput\":{\"hookEventName\":\"SessionStart\",\"additionalContext\":\"$1\"}}"; }
6
+
7
+ ### -------- check if we need to install the cli
8
+
9
+ [[ "$CLAUDE_CODE_REMOTE" == "true" ]] || { log "Not remote, skipping"; exit 0; }
10
+
11
+ LOCAL_BIN="$HOME/.local/bin"
12
+ mkdir -p "$LOCAL_BIN"
13
+ export PATH="$LOCAL_BIN:$PATH"
14
+
15
+ if command -v gh &>/dev/null; then
16
+ log "gh already available"
17
+ context "GitHub CLI available: $(gh --version | head -1)"
18
+ exit 0
19
+ fi
20
+
21
+ ### -------- check network access
22
+
23
+ if ! curl -sL --connect-timeout 5 -o /dev/null https://api.github.com 2>/dev/null; then
24
+ log "Failed to install gh CLI: cannot reach GitHub API. Network may be restricted - configure 'Limited' or 'Full' network access in your Claude Code environment settings."
25
+ exit 2
26
+ fi
27
+
28
+ ### -------- prepare to install CLI
29
+
30
+ log "Installing gh CLI..."
31
+
32
+ ARCH=$(uname -m)
33
+ case "$ARCH" in
34
+ x86_64) GH_ARCH="amd64" ;;
35
+ aarch64|arm64) GH_ARCH="arm64" ;;
36
+ *) log "Failed to install gh CLI: unsupported architecture '$ARCH'. Only x86_64 and arm64 are supported."; exit 2 ;;
37
+ esac
38
+
39
+ log "Detected arch $ARCH"
40
+
41
+ # Fetch latest version from GitHub API
42
+ RELEASE_JSON=$(curl -sL "https://api.github.com/repos/cli/cli/releases/latest") || { log "Failed to install gh CLI: could not fetch release info from GitHub API."; exit 2; }
43
+ if command -v jq &>/dev/null; then
44
+ VERSION=$(echo "$RELEASE_JSON" | jq -r '.tag_name | ltrimstr("v")')
45
+ else
46
+ VERSION=$(echo "$RELEASE_JSON" | sed -n 's/.*"tag_name": *"v\([^"]*\)".*/\1/p' | head -1)
47
+ fi
48
+ [[ -n "$VERSION" && "$VERSION" != "null" ]] || { log "Failed to install gh CLI: could not parse version from GitHub API response."; exit 2; }
49
+
50
+ log "Downloading v$VERSION..."
51
+ TEMP_DIR=$(mktemp -d)
52
+ trap 'rm -rf "$TEMP_DIR"' EXIT
53
+
54
+ ### -------- fetch and unpack the tarball
55
+
56
+ TAR_NAME="gh_${VERSION}_linux_${GH_ARCH}"
57
+ curl -sL "https://github.com/cli/cli/releases/download/v${VERSION}/${TAR_NAME}.tar.gz" \
58
+ | tar -xz -C "$TEMP_DIR" || { log "Failed to install gh CLI: could not download or extract release tarball."; exit 2; }
59
+
60
+
61
+ ### -------- mv the binary to local bin
62
+
63
+ mv "$TEMP_DIR/${TAR_NAME}/bin/gh" "$LOCAL_BIN/" && chmod +x "$LOCAL_BIN/gh"
64
+ [[ -n "$CLAUDE_ENV_FILE" ]] && echo "export PATH=\"$LOCAL_BIN:\$PATH\"" >> "$CLAUDE_ENV_FILE"
65
+
66
+ log "Installed $(gh --version | head -1)"
67
+ context "GitHub CLI installed: $(gh --version | head -1) use gh for github operations"
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "@jonchurch/claude-code-gh",
3
+ "version": "0.1.0",
4
+ "description": "Auto-install GitHub CLI (gh) for Claude Code web/remote sessions",
5
+ "author": "Jon Church",
6
+ "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/jonchurch/claude-code-gh.git"
10
+ },
11
+ "bugs": {
12
+ "url": "https://github.com/jonchurch/claude-code-gh/issues"
13
+ },
14
+ "homepage": "https://github.com/jonchurch/claude-code-gh#readme",
15
+ "keywords": [
16
+ "anthropic",
17
+ "claude",
18
+ "claude-code",
19
+ "gh",
20
+ "github-cli",
21
+ "remote",
22
+ "session-hook",
23
+ "web"
24
+ ],
25
+ "bin": {
26
+ "claude-code-gh": "bin/setup.sh"
27
+ },
28
+ "files": [
29
+ "bin"
30
+ ]
31
+ }