gh 认证
- 作者仓库星标 330
- 许可证 MIT
- 作者仓库 claude-skill-registry
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
ghcommands if auth status is uncertain - 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
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" - Verify:
gh auth status→ success - Retry:
gh pr list→ returns PR list
Security
- Token read via stdin (never in command args or history)
.gh-token.txtshould be in.gitignore- Tokens masked in
gh auth statusoutput
- 流狐分类
- 数据
- 作者声明 Agent
- 未找到明确声明;不据此推断已兼容或已测试
- 静态检查
- 94 / 100 · 启发式扫描,不代表运行安全
- 作者 / 版本 / 许可
- @majiayu000 · MIT
- 流狐 Token 估算
- 低消耗
- 流狐接入估算
- 需简单配置
- 是否需要外部 API Key
- 需要 · GitHub
- 检测到的系统要求
- 未声明
- 底层运行要求
- 未声明
- 检测到的文件与系统行为
-
- 只读
- 允许写入 / 修改
- 读取环境变量
- 检测到的网络行为
- 允许外网请求
- 安装命令数
- 无(仅作为资料)
档案由构建时根据 SKILL.md 与安装命令自动衍生,可能与作者实际意图存在差异。
需要注意: 未限定 allowed-tools,默认拥有全部工具权限。
作者没有在当前 SKILL.md 中定义固定输出样例。 Use this skill when: Seeing authentication errors: "gh auth login", "GHTOKEN environment variable", "not logged into any GitHub hosts" Before running gh commands if auth status is uncertain
Authentication Steps
1. Get repo root and authenticate
Should show: ✓ Logged in to github.com account <username>
If authentication was triggered by a failed command, retry that command.
Missing .gh-token.txt: Invalid token format: Already authenticated:
# 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 作者原文负责流程事实;流狐只索引当前章节、要点、文件与命令。
章节 -> When to Use → Authentication Steps → 1. Get repo root and authenticate → 2. Verify success → 3. Proceed with original task → Error Handling
要点 -> Missing .gh-token.txt · Invalid token format · Already authenticated · User · Action
文件/命令 -> .gh-token.txt · ✓ Logged in to github.com account <username> · gh auth status · gh pr list · .gitignore
内容 SHA-256 -> 43fd689b7990
方法与流程
适用与边界
原文中的明确线索
.gh-token.txt、✓ Logged in to github.com account <username>、gh auth status、gh pr list、.gitignore