Add a Claude Code hook to install the gh CLI in web sessions (#17429)

This commit is contained in:
Zanie Blue
2026-01-12 17:35:15 -06:00
committed by GitHub
parent 7fa30ab278
commit f1e5667d2f
3 changed files with 30 additions and 0 deletions

View File

@@ -0,0 +1,12 @@
#!/bin/bash
set -euo pipefail
# Install `gh`
if ! command -v gh &> /dev/null; then
GH_VERSION="2.83.2"
mkdir -p ~/.local/bin
curl -sL "https://github.com/cli/cli/releases/download/v${GH_VERSION}/gh_${GH_VERSION}_linux_amd64.tar.gz" -o /tmp/gh.tar.gz
tar -xzf /tmp/gh.tar.gz -C /tmp
mv /tmp/gh_${GH_VERSION}_linux_amd64/bin/gh ~/.local/bin/
rm -rf /tmp/gh.tar.gz /tmp/gh_${GH_VERSION}_linux_amd64
fi

7
.claude/hooks/session-start.sh Executable file
View File

@@ -0,0 +1,7 @@
#!/bin/bash
set -euo pipefail
# Dispatch to web hook if running remotely
if [ "${CLAUDE_CODE_REMOTE:-}" = "true" ]; then
exec "$(dirname "$0")/session-start-web.sh"
fi

View File

@@ -1,5 +1,16 @@
{
"hooks": {
"SessionStart": [
{
"matcher": "",
"hooks": [
{
"type": "command",
"command": ".claude/hooks/session-start.sh"
}
]
}
],
"PostToolUse": [
{
"matcher": "Edit|Write|MultiEdit",