授权

数据 社区

技能解读

当前原文的自动摘译,尚未人工审校。

何时使用

在以下情况下使用此技能: 看到身份验证错误:“gh auth login”、“GH_TOKEN 环境变量”、“未登录到任何 GitHub 主机” 如果身份验证状态不确定,则在运行 gh 命令之前 用户明确请求 GitHub 身份验证

2.验证成功

应显示:✓ Logged in to github.com account <username>

3. 继续原来的任务

如果身份验证是由失败的命令触发的,请重试该命令。

错误处理

缺少 .gh-token.txt:令牌格式无效:已通过身份验证:如果 gh auth status 显示活动身份验证,请跳至原始任务。

示例

用户:“列出拉取请求”操作:运行gh pr list→身份验证错误检测错误→激活技能运行:REPO_ROOT=$(git rev-parse --show-toplevel) && gh auth login --with-token < "$REPO_ROOT/.gh-token.txt"

流狐档案 运行与权限由流狐静态检查推断,不代表作者声明或实际测试结果。
领域
数据
作者声明的智能体
未找到明确声明;不据此推断已兼容或已测试
静态检查
94 / 100 · 启发式扫描,不代表运行安全
运行环境证据
未执行;当前没有隔离运行测试证据
作者 / 版本 / 许可证
@majiayu000 · MIT
上下文用量评级
低消耗
接入复杂程度
需简单配置
是否需要外部接口密钥
需要 · GitHub
兼容的系统
未声明(默认跨平台)
运行环境要求
未检出明确要求
检测到的文件与系统行为
  • 只读
  • 允许写入 / 修改
  • 读取环境变量
网络行为
允许外网请求
安装命令数
无(仅作为资料)

需要注意: 未声明工具权限范围;实际权限由运行环境决定。

作者说明文件(原文) 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

讨论

基于 GitHub Discussions。登录 GitHub 即可参与讨论、点赞、订阅更新。