codex-thread-repair

codex-thread-repair is a skill for Codex from Songhonglei/better-agent-skills. It costs 59 tokens per session (1,201 once invoked), scanned A, original, MIT.

A tool for diagnosing and repairing one damaged local Codex Desktop task. It works with missing, truncated, merged, or incorrectly ordered conversation turns without replacing the whole local state.

In plain words
What is it for?
Use it to inspect and repair a selected Codex task by its title or ID on a Mac with the required local files.
Why use it?
It addresses a broken individual task while preserving its existing messages and avoiding broad restoration of the Codex installation.

Skill for Codex

Written for Codex: agents/openai.yaml present. Also seen: mentions Codex.

Good fit Use it to inspect and repair a selected Codex task by its title or ID on a Mac with the required local files.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/songhonglei/better-agent-skills/codex-thread-repair
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 Songhonglei/better-agent-skills --skill codex-thread-repair
Clone the repo
git clone --depth 1 https://github.com/Songhonglei/better-agent-skills

Made for: Codex.

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 codex-thread-repair

README.md
[![agentmods](https://agentmods.dev/badge/skills/songhonglei/better-agent-skills/codex-thread-repair/github.svg)](https://agentmods.dev/skills/songhonglei/better-agent-skills/codex-thread-repair)
Your own site
<a href="https://agentmods.dev/skills/songhonglei/better-agent-skills/codex-thread-repair"><img src="https://agentmods.dev/badge/skills/songhonglei/better-agent-skills/codex-thread-repair/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 codex-thread-repair

Your own site · 80×15
<a href="https://agentmods.dev/skills/songhonglei/better-agent-skills/codex-thread-repair"><img src="https://agentmods.dev/badge/skills/songhonglei/better-agent-skills/codex-thread-repair.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 59 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,201 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.00059 $0.01201
Opus 5 $0.00030 $0.00600
Sonnet 5 $0.00012 $0.00240
Haiku 4.5 $0.00006 $0.00120

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

Security

Grade A, and why

codex-thread-repair 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 4d ago.

The scan reads SKILL.md. This mod also ships 2 executable files (scripts/thread_repair.py, tests/test_thread_repair.py), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

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/codex-thread-repair/SKILL.md · 90 lines

How it starts

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

Codex Thread Repair

Repair a specific local task without rewriting its message bodies or replacing the whole Codex state directory.

Dependencies

  • macOS with the Codex desktop app installed as /Applications/ChatGPT.app.
  • Python 3.10 or newer. The repair script uses only the Python standard library.
  • A local Codex state directory containing state_5.sqlite, sqlite/codex-dev.db, and the selected task's JSONL rollout. It defaults to $CODEX_HOME when set, otherwise ~/.codex.
  • Local read/write access to the selected rollout and Codex state. No network access or third-party Python package is required.

Workflow

  1. Resolve <skill-dir> as the directory containing this SKILL.md; never assume that the current working directory is the skill directory. Resolve and diagnose the user-supplied title or ID while Codex may remain open:

    python3 "<skill-dir>/scripts/thread_repair.py" diagnose "<title-or-id>"
    

    Exact UI-title matches come from local_thread_catalog; canonical rows and rollout paths come from state_5.sqlite. If a title is ambiguous, show the candidates and ask the user for an exact ID. Never choose by recency alone.

  2. Read references/repair-patterns.md when diagnosis is not healthy or supported_ordinal_orphan. Do not auto-repair an unrecognized structure.

  3. For supported_ordinal_orphan, explain the detected boundary and prepare one offline launcher:

    python3 "<skill-dir>/scripts/thread_repair.py" prepare "<title-or-id>"
    

    Tell the user to press Cmd+Q and then double-click the returned .command file. The launcher creates a targeted recovery set, applies the patch atomically, verifies it, and reopens Codex.

  4. After Codex restarts, verify both layers:

Read the full file on GitHub · 90 lines

Files

What ships with it

8 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

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. 4d ago First seen · 90 lines · 59 tokens per session scan A 721ea29975bc

Subscribe to this mod's changes

codex-thread-repair is a skill published in the GitHub repository Songhonglei/better-agent-skills (3 stars, last pushed 4d ago), licensed MIT. It adds 59 tokens to every session and 1,201 once invoked, about $0.0003 per session on Opus 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-09-08.