Skip to content

Document expiring tokens in the gh skill - #14782

Merged
babakks merged 2 commits into
trunkfrom
babakks/skill-gh-expiring-tokens
Oct 21, 2026
Merged

babakks merged 2 commits into
trunkfrom
babakks/skill-gh-expiring-tokens

Conversation

@babakks

@babakks babakks commented Oct 21, 2026

Copy link
Copy Markdown
Member

Part of #14449.

Description

gh can now store expiring OAuth tokens and refresh them automatically (gh auth login --expiring). The gh agent skill in skills/gh/SKILL.md doesn't mention this yet, so an agent following it may cache the output of gh auth token, keep retrying after a refresh token is rejected, or expect expiring tokens on hosts that don't issue them.

This adds a few bullets to the Authentication section of the skill:

  • Expiring tokens are reported in gh auth status --json with "refreshable": true and a tokenExpiresAt timestamp.
  • Only github.com and GHE.com (*.ghe.com) hosts support expiring tokens so far.
  • The output of gh auth token should not be cached, because gh rotates expiring tokens on refresh. Agents should run it again when they need a token, or prefer gh api so gh handles the refresh.
  • A refresh_expired state means the refresh token was rejected and needs an interactive gh auth login or gh auth refresh, so the agent should ask the user instead of retrying.
  • Tokens from GH_TOKEN or GITHUB_TOKEN are never refreshed.

How did you test this change?

Not tested with an agent, since this is a documentation-only change to the skill. I checked each statement against the code on trunk: the refreshable and tokenExpiresAt fields and the refresh_expired state in pkg/cmd/auth/status, and the warning gh auth login --expiring prints for GitHub Enterprise Server hosts in pkg/cmd/auth/shared/login_flow.go.

Key points

The new lines are hard-wrapped to match the rest of SKILL.md. The guidance stays short and focused on what an agent needs to do differently, and leaves the details of the login and refresh flows to gh help auth login and gh help auth refresh.

Notes for reviewers

The whole change is in the Authentication section of skills/gh/SKILL.md. #14449 tracks the expiring token work this documents.

Authorship and follow-up

Who wrote this:

  • A human wrote it.
  • An agent wrote it under close human direction.
  • An agent wrote it independently, and no human has guided the implementation beyond the initial prompt.

Who answers review comments:

  • @babakks will read and reply directly.
  • An agent will draft replies and @babakks will read them before they are posted.
  • Nobody has explicitly committed to replying.

Teach agents how gh reports and refreshes expiring tokens, which hosts
support them, why `gh auth token` output must not be cached, and how to
handle a rejected refresh token.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: ac178b5a-5b62-49bd-9e83-4796c7ddec46
@babakks
babakks requested a review from a team as a code owner October 21, 2026 14:46
@babakks
babakks requested review from niik and a balanced review from Copilot October 21, 2026 14:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The new authentication-status examples omit the required JSON field selector and return errors instead of authentication data.

1 open issue
What changed in this PR

Updates the gh agent skill to document expiring-token behavior introduced by the refreshable-token work.

Changes:

  • Documents expiry metadata and supported hosts.
  • Explains token caching, refresh-failure recovery, and environment-token limitations.
File Description
skills/​gh/​SKILL.md Adds expiring-token guidance to Authentication.

Review effort: Balanced

Comment thread skills/gh/SKILL.md Resolved
Clarify behavior of `gh auth status --json` regarding token refresh and expiration.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants