gh auth

Data Community

Skill notes

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 gh commands if auth status is uncertain User explicitly requests GitHub authentication

2. Verify success

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: Invalid token format: Already authenticated: If gh auth status shows active authentication, skip to the original task.

Example

User: "List pull requests" Action: Run gh pr list → authentication error Detect error → activate skill Run: REPO_ROOT=$(git rev-parse --show-toplevel) && gh auth login --with-token < "$REPO_ROOT/.gh-token.txt"

Fluxly profile Runtime and permissions are inferred by Fluxly static checks, not author declarations or runtime test results.
Domain
Data
Author-declared agents
No explicit declaration found; this is not inferred or tested compatibility
Static check
94 / 100 · heuristic scan, not runtime safety proof
Runtime evidence
Not run; no isolated runtime test evidence is currently recorded
Author / version / license
@majiayu000 · MIT
Token usage
Lean
Setup complexity
Guided setup
External API key
Required · GitHub
Operating systems
Unspecified (assume cross-platform)
Runtime requirements
No explicit requirements detected
Detected file/system behavior
  • Read-only
  • Write / modify
  • Env read
Network behavior
External requests
Install commands
None (reference only)

Heads up: Tool permissions are not declared; actual access depends on the runtime.

Author source file SKILL.md

# 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 `gh` commands if auth status is uncertain
- User explicitly requests GitHub authentication

## Authentication Steps

### 1. Get repo root and authenticate

```bash
REPO_ROOT=$(git rev-parse --show-toplevel)
gh auth login --with-token < "$REPO_ROOT/.gh-token.txt"
```

### 2. Verify success

```bash
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**:
1. Run `gh pr list` → authentication error
2. Detect error → activate skill
3. Run: `REPO_ROOT=$(git rev-parse --show-toplevel) && gh auth login --with-token < "$REPO_ROOT/.gh-token.txt"`
4. Verify: `gh auth status` → success
5. Retry: `gh pr list` → returns PR list

## Security

- Token read via stdin (never in command args or history)
- `.gh-token.txt` should be in `.gitignore`
- Tokens masked in `gh auth status` output

Discussion

Powered by GitHub Discussions. Sign in with GitHub to comment, react, or subscribe.