Creates GitHub fine-grained personal access tokens from a declarative JSON spec using browser automation. Handles the no-expiration modal, repo picker, and permission grids that break naive automation.
Ships in gh-tools. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
GitHub exposes no API to create fine-grained PATs (community #148626) — the web UI is the only way. This skill drives that UI over the Chrome DevTools Protocol from a declarative JSON spec, so token creation is repeatable, reviewable, and anti-fragile instead of a hand-clicked one-off.
Self-Evolving Skill: This skill improves through use. GitHub's settings UI drifts — if a selector misses, the modal/picker/permission flow changed, or a permission's detail-page noun is wrong, fix
scripts/,CLAUDE.md(selector map + noun map), or the spec immediately; don't defer. Only update for real, reproducible breakage.
vault.node (NOT bun — Bun's connectOverCDP times out) and playwright-core (already pinned at the repo root package.json).chrome-profiles. If GitHub is already signed in to a profile of your everyday Chrome, that plugin's setup <email> can drive it directly.A persistent Chrome profile holds the GitHub session cookie, so you log in once and every later run reuses it:
cd plugins/gh-tools/skills/gh-fine-grained-pat
node scripts/pat.mjs login # opens Chrome; sign in (incl. 2FA); it auto-detects success
node scripts/pat.mjs doctor # runtime + chrome + profile + auth health
The profile lives at ~/.local/share/gh-pat-automation/profile (override with GH_PAT_PROFILE_DIR). Treat it as sensitive — it can impersonate your GitHub session. It is outside the repo and never committed.
# write the value to a 0600 file (default) — the value is NEVER printed to the terminal
node scripts/pat.mjs create specs/release-bot.json --out /tmp/.tok
# …or pipe it straight into the SCS vault (value passed in-process, never to chat)
node scripts/pat.mjs create specs/release-bot.json --vault cc-skills:gh.token
# rotate: revoke the same-named token, create a replacement, store it (sink required)
node scripts/pat.mjs rotate specs/release-bot.json --vault cc-skills:gh.token
Other verbs: list, inspect <name>, delete <name>, quit (terminate the debug Chrome by its specific PID). rotate is the safe way to roll a token in place — it revokes the old value and stores the new one in one step.
A spec is JSON validated by schema/token-spec.schema.json (the machine-readable SSoT). Minimal shape:
{
"name": "release-bot",
"expiration": "none", // 7|30|60|90 | "YYYY-MM-DD" | "none"
"repositoryAccess": { "mode": "selected", "repos": ["owner/repo"] },
"permissions": { "repository": { "Contents": "write", "Issues": "write" } },
}
read → "Read-only", write → "Read and write". Permission keys are the exact UI labels (Contents, Pull requests, Commit statuses, Gists, …). Do not list Metadata — it is auto-required read-only.
specs/)| Spec | Purpose |
|---|---|
release-bot.json | semantic-release: Contents/Issues/PRs RW, one repo, no expiration |
read-only-auditor.json | Contents read-only, single repo |
ci-status-reporter.json | Commit statuses RW + Actions read |
account-scoped.json | Account permission (Gists) only, no repo write |
kitchen-sink.json | Superset: multiple repos, no expiration, many repo perms + account perms (exercises every UI branch) |
More illustrative shapes (all-repos admin, org-owned, secrets-management) live in specs/examples/ — not auto-run by the campaign. See that folder's README before relying on one.
--out <0600 file> or --vault <scope>:<dot.path>.lsof on the CDP port), never pkill -f (process-storm policy).node test/campaign.mjs # create→verify→delete every spec + a forced-failure case, in one session
The harness namespaces test tokens zz-pat-selftest-*, auto-deletes them, asserts none leak, and confirms a real token (cc-skills-release) is untouched. Re-running needs no login (proves session reuse).
GitHub's sudo mode ("Confirm access") normally needs a human gesture. The engine can clear it autonomously using a self-custodied credential — see the ADR. One-time per account:
node scripts/pat.mjs register --account <login> # capture a passkey (virtual authenticator) + password/TOTP → crown-strict vault scope github-web-<login>
node scripts/pat.mjs patch-password --account <login> # fix a missed password dialog (passkey kept; idempotent) [--force] [--totp]
node scripts/pat.mjs agent start # memory-only session agent: one Touch-ID unlock lasts the session
GH_PAT_AUTONOMOUS=1 node scripts/pat.mjs create specs/release-bot.json --account <login> --vault cc-skills:gh.token
Account is resolved from --account → the repo's origin host-alias → the spec owner → the logged-in profile. The credential is a Touch-ID-gated crown jewel stored as one blob (github-web-<login>): one tap when you go in to operate, then nothing for the session (the agent caches it in memory only). Headless/cron is intentionally unsupported (the gated tier needs that one live tap). Primary path = virtual-authenticator passkey; fallback = password + oathtool TOTP.
GitHub renames CSS classes but keeps names/roles/labels — the engine prefers role/name/label with DOM-text fallbacks and screenshots failures to /tmp/gh-pat-debug. When the UI drifts, the live selector map and the eight hard-won gotchas are documented in CLAUDE.md for fast repair.
After running this skill, reflect before closing the task:
scripts/form.mjs (or browser.mjs) and update the selector map in CLAUDE.md.test/campaign.mjs (NOUN) + the CLAUDE.md noun table.specs/ (or specs/examples/) template so it's reusable next time.CLAUDE.md (never renumber); the narrative goes in the commit body. Do NOT defer — the next invocation inherits whatever you leave behind.CLAUDE.md (opens in a new tab)schema/token-spec.schema.json (opens in a new tab)scripts/autosudo.mjs (opens in a new tab)scripts/browser.mjs (opens in a new tab)scripts/form.mjs (opens in a new tab)scripts/identity.mjs (opens in a new tab)scripts/pat.mjs (opens in a new tab)scripts/selectors.mjs (opens in a new tab)scripts/webauth-agent.mjs (opens in a new tab)scripts/webauthn.mjs (opens in a new tab)specs/account-scoped.json (opens in a new tab)specs/ci-status-reporter.json (opens in a new tab)specs/examples/README.md (opens in a new tab)specs/examples/all-repositories-admin.json (opens in a new tab)specs/examples/dependabot-secrets.json (opens in a new tab)specs/examples/org-owned.json (opens in a new tab)specs/kitchen-sink.json (opens in a new tab)specs/read-only-auditor.json (opens in a new tab)specs/relay-monitor-release-bot.json (opens in a new tab)specs/release-bot.json (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
Other plugins' skills for the same job
/gh-tools:gh-fine-grained-patfrom gh-tools
npx claudepluginhub terrylica/cc-skills --plugin gh-tools6 skills in this plugin
/fork-intelligenceDiscover valuable GitHub fork divergence beyond stars. TRIGGERS - fork analysis, fork intelligence, find forks/issue-createCreate well-formatted GitHub issues with AI label suggestions: bug reports, feature requests, questions, docs issues. TRIGGERS - file an issue, create an issue, gh issue create./issues-workflowPlan and track work using a GitHub Issues-first workflow with sub-issue hierarchies, issue-branch-PR lifecycle, and auto-close on merge./pr-gfm-validatorValidate and fix GFM links in PR descriptions. TRIGGERS - PR links, gh pr create, GFM validation, broken PR links./research-archivalScrape AI research URLs, archive with frontmatter, create GitHub Issues with identity verification.