local-chatgpt-token-heal

local-chatgpt-token-heal is a skill for Claude Code from tonydzi/second-brain-starter-kit. It costs 76 tokens per session (1,498 once invoked), scanned A, original, MIT.

A local recovery tool for refreshing an expired ChatGPT access token used by a nightly synchronisation job. It obtains a fresh token from the longer-lived login session and can fall back to Chrome if that session has expired.

In plain words
What is it for?
Use it when the nightly ChatGPT sync reports an expired token, or to verify whether the current token is still valid.
Why use it?
It restores the sync when short-lived access tokens expire, without manually logging in each time or using a browser for routine refreshes.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the second-brain-skills plugin — 100 skills shipped together

Good fit Use it when the nightly ChatGPT sync reports an expired token, or to verify whether the current token is still valid.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/tonydzi/second-brain-starter-kit/local-chatgpt-token-heal
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 tonydzi/second-brain-starter-kit --skill local-chatgpt-token-heal
Clone the repo
git clone --depth 1 https://github.com/tonydzi/second-brain-starter-kit

Made for: Claude Code.

Or install second-brain-skills, the plugin that ships this one along with the rest of its 100 skills.

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 local-chatgpt-token-heal

README.md
[![agentmods](https://agentmods.dev/badge/skills/tonydzi/second-brain-starter-kit/local-chatgpt-token-heal/github.svg)](https://agentmods.dev/skills/tonydzi/second-brain-starter-kit/local-chatgpt-token-heal)
Your own site
<a href="https://agentmods.dev/skills/tonydzi/second-brain-starter-kit/local-chatgpt-token-heal"><img src="https://agentmods.dev/badge/skills/tonydzi/second-brain-starter-kit/local-chatgpt-token-heal/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 local-chatgpt-token-heal

Your own site · 80×15
<a href="https://agentmods.dev/skills/tonydzi/second-brain-starter-kit/local-chatgpt-token-heal"><img src="https://agentmods.dev/badge/skills/tonydzi/second-brain-starter-kit/local-chatgpt-token-heal.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 76 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,498 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. 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.00076 $0.01498
Opus 5 $0.00038 $0.00749
Sonnet 5 $0.00015 $0.00300
Haiku 4.5 $0.00008 $0.00150

Measured 3d ago against content hash 5b7eaa4200a3, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-12, from the pricing page.

Security

Grade A, and why

local-chatgpt-token-heal scanned grade A with 1 finding 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 3d 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.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

⚠️ GRABLI: a bare `curl -H "User-Agent: Mozilla/5.0"` to `/backend-api/...` returns **403 for BOTH dead AND live tokens** — Cloudflare bot-blocks the curl UA before the auth layer. That curl is a USELESS token test. The
skills/local-chatgpt-token-heal/SKILL.md · 71 lines

How it starts

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

OBJECTIVE: Get the ChatGPT nightly sync back to exit=0 by refreshing the dead bearer token — the correct, root-cause way (session cookie → fresh bearer), falling back to Chrome only when the cookie itself has died.

The root cause (why this skill exists)

The secrets\bearer.txt accessToken expires every ~5-9 days — that is OpenAI's design, there is no refresh-token for it. BUT the login session cookie (__Secure-next-auth.session-token, stored in secrets\session_token.txt) lives ~3 months and chatgpt.com/api/auth/session mints a fresh bearer from it on every call. So the fix is deterministic: cookie → new bearer, no browser, no LLM. The cookie also silently rotates (NextAuth rolling sessions) and token_heal.py captures the rotated one, so routine use keeps the cookie fresh indefinitely.

⚠️ GRABLI: a bare curl -H "User-Agent: Mozilla/5.0" to /backend-api/... returns 403 for BOTH dead AND live tokens — Cloudflare bot-blocks the curl UA before the auth layer. That curl is a USELESS token test. The authoritative check is token_heal.py --verify-only (urllib + full browser headers, reaches the real auth layer → 200/401).

LAYERS (do them in order, stop at the first that reaches exit=0)

L1 — deterministic re-mint (default; no browser, no LLM)

python "%IMPORTS_ROOT%\chatgpt\token_heal.py"     # PowerShell: use %IMPORTS%\chatgpt\token_heal.py
  • exit 0 → fresh bearer written + VERIFIED (HTTP 200), cookie rotated if server rotated it. DONE — go to "Finish".
  • exit 5 → session cookie dead/absent → do L2.
  • exit 6 → transient network/Cloudflare → wait a few min, retry L1 once; still 6 → note it and stop (not a token problem).

Note: nightly_sync.py already calls L1 automatically on pull exit 7 and retries the pull. So most of the time you never run this by hand — this skill is for when L1 itself returns 5 (cookie dead) and a human-in-the-loop Chrome step is needed, or when Anton runs /chatgpt-token-heal directly.

Read the full file on GitHub · 71 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. 3d ago Changed · +2 lines · -18 tokens per session 5b7eaa4200a3
  2. 12d ago First seen · 69 lines · 94 tokens per session scan A d367229d845f

Subscribe to this mod's changes

local-chatgpt-token-heal is a skill published in the GitHub repository tonydzi/second-brain-starter-kit (6 stars, last pushed 3d ago), licensed MIT. It adds 76 tokens to every session and 1,498 once invoked, about $0.0004 per session on Opus 5. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

wiki-lint

Run a deterministic, read-only health check on an Obsidian wiki. Use for lint, vault health check, audit wiki health, find orphans, find dead links, frontmatter audit, provenance audit, or wiki audit. Reports graph, link, frontmatter, provenance-ledger, empty-section, and stale-index findings; it does not reason…

AgriciDaniel/claude-obsidian · 79 tokens

wiki-ingest

Ingest supplied source material into an Obsidian vault with provenance and claim tracking: pasted text, files staged in the selected vault's inbox or .raw archive, or explicitly approved URLs. Use for a single source or bounded batch, not for saving an assistant answer. Triggers: ingest, ingest this file, ingest this…

AgriciDaniel/claude-obsidian · 88 tokens

autoresearch

Run a bounded, source-grounded research loop, draft a cited dossier, and optionally propose a separately reviewed canonical vault merge. Use when the user wants autonomous or deep research that may access the public web. Triggers: /autoresearch, autoresearch, research this topic, deep dive into, investigate, find…

AgriciDaniel/claude-obsidian · 80 tokens

canvas

Create, inspect, and update Obsidian JSON Canvas boards with text, file, link, group, and edge nodes. Use for canvas status, canvas lists, visual maps, zones, spatial layouts, adding vault notes or media to a .canvas file, and requests such as create canvas, add to canvas, or put this on the canvas.

AgriciDaniel/claude-obsidian · 72 tokens

defuddle

Plan and, with explicit network consent, use an optional external Defuddle cleaner to extract article-like HTTPS pages as Markdown. Use for defuddle, clean this URL, strip page clutter, readable Markdown from a web page, or preparing a web source for later wiki ingestion.

AgriciDaniel/claude-obsidian · 57 tokens

obsidian-bases

Explain, draft, and validate Obsidian Bases .base files with filters, formulas, properties, summaries, and table, card, or list views. Use for Obsidian Bases, database-like vault views, dynamic tables, reading lists, task trackers, filters, formulas, summaries, and .base file edits.

AgriciDaniel/claude-obsidian · 69 tokens