Coding

Codex Thread Repair

Try it

Repair one local Codex task selected by title or thread ID

What it does

**Version**: 1.0.1 **License**: MIT **Author**: Evan Song · github.com/Songhonglei **Repository**: https://github.com/Songhonglei/better-agent-skills/tree/main/skills/codex-thread-repair

The skill document

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 `` 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 "/scripts/thread_repair.py" diagnose ""
    

    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 "/scripts/thread_repair.py" prepare ""
    

    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:

    python3 "/scripts/thread_repair.py" verify ""
    

    Also use the Codex task-reading tool to confirm that the formerly hidden recent turns are separate and readable.

  5. Keep the backup until the user confirms the UI. If rollback is required, have the user quit Codex and run:

    python3 "/scripts/thread_repair.py" rollback "" --reopen
    

Safety boundaries

  • Diagnosis and launcher preparation are read-only with respect to Codex state.
  • Mutation requires Codex Desktop, its renderer/services, and its app-server to be stopped.
  • Resolve the selected rollout to an absolute path under the selected Codex home's sessions/ directory. Refuse relative paths, symlink escapes, and database paths outside that directory.
  • Back up the target rollout plus consistent snapshots of state_5.sqlite, codex-dev.db, and .codex-global-state.json before replacement.
  • Preserve the original rollout byte-for-byte in the backup.
  • Auto-repair only the narrowly validated ordinal-regression/orphan-turn pattern. Refuse multiple regressions, ambiguous open turns, missing rollouts, malformed JSON, non-contiguous segments, active latest turns, or session-ID mismatches.
  • Preserve every original line except the top-level ordinal value after the repair boundary; insert exactly one turn_aborted event. Verify a normalized content hash before replacement.
  • Do not edit SQLite rows for this repair type. For provider mismatches, missing assignments, moved paths, or missing database rows, use recover-codex-project-chats instead.
  • On any post-replacement verification failure, restore the backed-up rollout automatically.

Commands

python3 "/scripts/thread_repair.py" resolve ""
python3 "/scripts/thread_repair.py" diagnose ""
python3 "/scripts/thread_repair.py" prepare ""
python3 "/scripts/thread_repair.py" apply "" --reopen
python3 "/scripts/thread_repair.py" verify ""
python3 "/scripts/thread_repair.py" rollback "" --reopen

--codex-home is a global option and must appear before the subcommand. prepare --output selects a new launcher path and refuses to overwrite an existing file. apply --reopen and rollback --reopen request reopening Codex; failure to reopen is reported as a warning without undoing a successful file operation.

Exit codes are 0 for success or no repair needed, 1 for an operational/safety error, 2 for an ambiguous selector or invalid CLI use, and 3 for an unsupported diagnosis or failed verification.

Report the resolved ID, UI title, rollout path, diagnosis, changed metadata, backup directory, integrity results, and UI verification outcome.

See CHANGELOG.md for release history.

Related skills

Generate and edit Draw.io, Mermaid, and Excalidraw diagrams from natural language using a structured JSON spec.

by nssa.io1.0k installs47 stars

Find why your productivity system keeps failing, then apply the smallest fix — capacity math, bottleneck routing, durable local notes.

by Iván1 installs

Fetch raw ad creative, app, ranking, and revenue data from AdMapix as structured JSON.

by fly0pants

Read and write Excel workbooks, worksheets, ranges, tables, and charts in OneDrive through Microsoft Graph with managed OAuth.

by byungkyu800 installs42 stars

Join a video meeting as an AI bot with voice, avatar, and screenshare across four operating modes.

by johnpatternai21 installs8 stars

More from songhonglei

Browse all skills

Recover lost agent session content and file changes from on-disk conversation logs. Streaming and OOM-safe on 700MB+ daily JSONL. Two commands: search.py for keyword search across recent sessions (with hit snippets, file-op listing, JSON for agent consumption); extract.py for pulling full write/edit content from a single session by ID prefix, with optional replay-rebuild for pure-edit sequences and safe restore-to-disk (refuses silent overwrites without --yes). Multi-agent aware via --agent main|all|a,b. Configurable data root via --root flag or SESSION_RECOVERY_ROOT env var (default ~/.openclaw/agents/). Trigger when user wants to find lost session content, recover files written by an agent, locate which session modified a file, search session history by keyword, or rebuild a file from an edit replay. Also triggers on 找回会话, 会话被覆盖, 历史会话搜索, 文件被删了, session 丢了, 找回某个文件, 重放编辑.

by blqbzf

小红书图文笔记自动发布技能。通过 ego-browser 自动化完成图片上传、标题填写、正文编辑、 话题标签、发布等全流程。附带 28 种多样式风格卡片生成器(含 3 种照片背景氛围主题), 卡片主题、布局、背景图、遮罩强度、模糊、颗粒等参数均可自由配置。 当用户要求发小红书、发布图文笔记、上传到小红书、小红书发帖或涉及小红书内容发布时触发此技能。 前置依赖:ego-browser (ego-lite) 已安装且正在运行,小红书账号已登录。

by songhonglei2 installs1 stars

Guided token optimization for AI agent workspaces. Triggers on phrases like "save tokens", "optimize tokens", "context window too large", "memory files too b...

by songhonglei2 installs1 stars

将 Markdown/纯文本内容智能分析、排版并导出为高分辨率精美长图或分享海报(内置 18 种视觉风格)。 当用户说「生成长图」「做海报」「文字转图片」「高颜值排版」「做大图」「make a poster」 「export as image」「generate image from text/markdown」等意图时触发本技能。

by songhonglei2 installs

Generic skill-quality auditor for any agent skill (Claude, OpenClaw, Cursor, etc.). Runs a 7-dimension static analysis (D1 process closure & idempotency, D2 tool/command conventions, D3 portability & defense, D4 skill usability, D5 security & op risk, D6 code & doc quality, D7 dependency & footprint) with explicit ERR / WARN severity, 120-point scoring (pass line 90 + zero ERR), and an opt-in `--fix` workflow that always backs up first. Two depths: L1 static (~2 min) and L2 dryRun (~5 min, read-only hub + reachability checks). Strict red lines — read-only by default, never executes the audited skill's writes. Use when the user asks to "audit a skill", "check skill quality", "is this skill ready to ship", "lint my skill", or runs this tool by name. Triggers also: "审计这个 Skill"、"检查 Skill 质量"、"Skill 能上线吗"、 "skill-deep-audit"、"审一下 xxx skill"。

by songhonglei1 installs1 stars

Turn any content — Markdown, plain text, images, tables, Excel (.xlsx), Word (.docx) — into a polished single-page HTML, pick one of 19 built-in themes, set the page Title and FavIcon, then publish it as a live page. When the input is already a well-designed HTML page (or an image with a clear layout), it switches to "layout inheritance" mode: the original layout is kept intact and only the colour theme is swapped, instead of tearing it apart and rebuilding. Use when the user says "turn this into a web page", "make this an HTML page", "convert this doc/table/Excel to HTML", "make it pretty", "把这个转成网页", "做成 HTML 页面", "内容转 HTML".

by songhonglei3 installs