gh-auth

Authenticates gh CLI using token from repository root's .gh-txt file.

Updated Dec 6, 2025
One-click install
npx skills add https://github.com/austinpray/feed-baby --skill gh-auth
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: gh-auth
Source: https://github.com/austinpray/feed-baby/tree/main/.claude/skills/gh-auth
Command: npx skills add https://github.com/austinpray/feed-baby --skill gh-auth

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill automatically authenticates the GitHub CLI using a token from the repository root (.gh-token.txt) when you encounter common login errors such as "gh auth login", "GH_TOKEN environment variable", or "not logged into any GitHub hosts". It streamlines command execution by ensuring you are authenticated before proceeding with GitHub operations.

Core Features & Use Cases

  • Auto-authentication: Detects authentication errors and logs in to gh using the token from .gh-token.txt.
  • Status Verification: Verifies success with gh auth status to confirm login.
  • Seamless Retries: Automatically retries the original task after successful authentication.
  • Security Best Practices: Reads the token from stdin and keeps the token file in .gitignore to protect credentials.

Quick Start

  • Trigger an authentication check or run a GitHub CLI command that requires login. REPO_ROOT=$(git rev-parse --show-toplevel) && gh auth login --with-token < "$REPO_ROOT/.gh-token.txt"
  • Verify success: gh auth status
  • Retry the original command if needed.

Frequently Asked Questions about gh-auth

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I automatically authenticate the GitHub CLI when I get login errors?

Auto-authenticate gh CLI by storing your token in .gh-token.txt at your repository root. This Skill detects authentication errors like "gh auth login" prompts or "not logged into any GitHub hosts" and automatically logs you in using that token, then retries your command.

Can I use a token file instead of the GH_TOKEN environment variable for gh authentication?

Yes. This Skill reads authentication tokens from .gh-token.txt instead of relying on GH_TOKEN environment variables, applying the token via gh auth login --with-token when auth fails, and keeps the file secure by reading via stdin and masking output.

How does automatic GitHub CLI authentication work in a CI/CD or automation workflow?

The Skill detects when gh commands fail due to missing authentication, locates your repository root, applies the stored token, and verifies success with gh auth status before retrying the original command—ideal for DevOps pipelines where manual login isn't possible.

What security practices does this authentication method follow?

Tokens are read via stdin rather than passed as arguments, and the .gh-token.txt file should be in .gitignore to prevent credential exposure. The Skill masks tokens in status output to protect sensitive data during execution.

What happens if the token file is missing or invalid?

The Skill handles missing or invalid tokens gracefully by checking token status and avoiding repeated authentication attempts. It distinguishes between genuine auth failures and already-authenticated states to prevent unnecessary retries.