gh-token-rotate

gh-token-rotate is a skill for Claude Code from jamestexas/agents. It costs 101 tokens per session (947 once invoked), scanned A, original, Apache-2.0.

A procedure for rotating or restoring the GitHub personal access token used by GitHub CLI and Git over HTTPS on macOS. It stores the token in the macOS keychain instead of shell files or command history.

In plain words
What is it for?
Use it when a GitHub token expires, is regenerated, stops working, or when setting up a new Mac. It covers storing the token, checking its status and using it for GitHub access.
Why use it?
Expired or revoked tokens can make pushes and GitHub CLI commands fail with unclear authentication errors. This keeps the replacement token out of ordinary files, prompts and command history.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter.

Good fit Use it when a GitHub token expires, is regenerated, stops working, or when setting up a new Mac. It covers storing the token, checking its status and using it for GitHub access.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/jamestexas/agents/gh-token-rotate
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add jamestexas/agents --skill gh-token-rotate
Clone the repo
git clone --depth 1 https://github.com/jamestexas/agents

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for gh-token-rotate

README.md
[![agentmods](https://agentmods.dev/badge/skills/jamestexas/agents/gh-token-rotate/github.svg)](https://agentmods.dev/skills/jamestexas/agents/gh-token-rotate)
Your own site
<a href="https://agentmods.dev/skills/jamestexas/agents/gh-token-rotate"><img src="https://agentmods.dev/badge/skills/jamestexas/agents/gh-token-rotate/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for gh-token-rotate

Your own site · 80×15
<a href="https://agentmods.dev/skills/jamestexas/agents/gh-token-rotate"><img src="https://agentmods.dev/badge/skills/jamestexas/agents/gh-token-rotate.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 101 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 947 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00101 $0.00947
Opus 5.5 $0.00040 $0.00379
Sonnet 5.5 $0.00020 $0.00189
Haiku 4.5 $0.00010 $0.00095

Measured 24d ago against content hash e8a0c2a5d2e0, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

gh-token-rotate scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 24d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/gh-token-rotate/SKILL.md · 92 lines

How it starts

The opening of the file, as written. The whole thing — 92 lines — stays where its author put it; the contents beside it link to each section on GitHub.

gh-token-rotate — rotate the PAT without it ever touching disk or history

A GitHub PAT expires on a schedule, and the failure it produces names neither the token nor the fix:

remote: Invalid username or token. Password authentication is not supported for Git operations.
fatal: Authentication failed for 'https://github.com/<owner>/<repo>.git/'

gh auth status is the one that says it plainly — The token in keyring is invalid.

The token lives in the macOS keychain under the service name gh-pat, and is piped from there straight into gh. It is never echoed, never pasted into a prompt, and never written to a dotfile or an export line.

Procedure

  1. Regenerate at https://github.com/settings/tokens. Scopes that this setup actually uses: repo, read:org, workflow. gh auth status prints the granted scopes, so compare against that rather than guessing.

  2. Store it, pasting at the prompt rather than on the command line — -w with no value prompts twice and echoes nothing, so the token never enters shell history:

    security add-generic-password -U -a "$USER" -s gh-pat -w
    

    -U updates the existing item in place, so rotation reuses one keychain entry instead of accumulating one per rotation.

  3. Load it into gh — the pipe is the point: the secret goes keychain → gh without a stop in a variable, a file, or the scrollback:

    security find-generic-password -a "$USER" -s gh-pat -w \
      | gh auth login --hostname github.com --git-protocol https --with-token \
      && gh auth setup-git
    
  4. Verify: gh auth status should report the account logged in via (keyring) and list the scopes. Then the failing git push just works — no new remote, no re-clone.

Two things that silently defeat this

  • GH_TOKEN / GITHUB_TOKEN in the environment outrank the keyring. gh uses the variable and never consults the stored credential, so a stale one exported in a shell profile produces the same auth failure immediately after a successful rotation. Check before diagnosing anything else.

Read the full file on GitHub · 92 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 24d ago First seen · 92 lines · 101 tokens per session scan A e8a0c2a5d2e0

Subscribe to this mod's changes

gh-token-rotate is a skill published in the GitHub repository jamestexas/agents (2 stars, last pushed today), licensed Apache-2.0. It adds 101 tokens to every session and 947 once invoked, about $0.0004 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-11-07.

Related

gh-token-rotate compared with skills from other repositories

gh-token-rotate next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
gh-token-rotatejamestexas/agentsSkill2todayApache-2.0A101Claude Code
commit-messageskyegomez/swarmsSkill7.4ktodayApache-2.0A23Claude Code, Codex
git-guardrails-claude-codevinvcn/mattpocock-skills-zh-CNSkill6.2kyesterdayMITB68Claude Code, Codex
changelog-genlaolaoshiren/claude-code-skills-zhSkill928yesterdayMITA88Claude Code
setup-pre-commitdevcxl/mattpocock-skills-zhSkill568todayMITA70Claude Code, Codex
release-versionvnotex/vnoteSkill13kyesterdayLGPL-3.0A86Claude Code, Codex
artifact-metadatajmagly/aiwgSkill233todayMITA21Claude Code, Codex