Claude-skill-registry gh-auth
Automatically authenticate GitHub CLI using .gh-token.txt when seeing errors about "gh auth login", "GH_TOKEN environment variable", or "not logged into any GitHub hosts"
install
source · Clone the upstream repo
git clone https://github.com/majiayu000/claude-skill-registry
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/majiayu000/claude-skill-registry "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/data/gh-auth" ~/.claude/skills/majiayu000-claude-skill-registry-gh-auth && rm -rf "$T"
manifest:
skills/data/gh-auth/SKILL.mdsource content
GitHub CLI Authentication
Automatically authenticate
gh CLI using the token from .gh-token.txt in the repository root.
When to Use
Use this skill when:
- Seeing authentication errors: "gh auth login", "GH_TOKEN environment variable", "not logged into any GitHub hosts"
- Before running
commands if auth status is uncertaingh - User explicitly requests GitHub authentication
Authentication Steps
1. Get repo root and authenticate
REPO_ROOT=$(git rev-parse --show-toplevel) gh auth login --with-token < "$REPO_ROOT/.gh-token.txt"
2. Verify success
gh auth status
Should show:
✓ Logged in to github.com account <username>
3. Proceed with original task
If authentication was triggered by a failed command, retry that command.
Error Handling
Missing
:.gh-token.txt
ERROR: .gh-token.txt not found in repository root Create it: 1. Generate token: https://github.com/settings/tokens 2. Save to .gh-token.txt in repo root 3. File is git-ignored
Invalid token format:
ERROR: Invalid token format Tokens should start with github_pat_ or ghp_ Check .gh-token.txt for correct token
Already authenticated: If
gh auth status shows active authentication, skip to the original task.
Example
User: "List pull requests"
Action:
- Run
→ authentication errorgh pr list - Detect error → activate skill
- Run:
REPO_ROOT=$(git rev-parse --show-toplevel) && gh auth login --with-token < "$REPO_ROOT/.gh-token.txt" - Verify:
→ successgh auth status - Retry:
→ returns PR listgh pr list
Security
- Token read via stdin (never in command args or history)
should be in.gh-token.txt.gitignore- Tokens masked in
outputgh auth status