Claude Code-session-patcher — Claude Code skill: clean refusals
Finds AI refusals in Claude CLI, Claude and OpenCode session files and replaces them so you can resume the conversation.
npx skills add reason-machines/trending-skills --skill codex-session-patcher -a claude-codeWhat codex-session-patcher does
The skill scans session files for refusal phrases and swaps them for a cooperative reply, after which the session can be resumed as usual. Formats differ: Claude CLI and Claude store JSONL, OpenCode uses SQLite.
Under the hood there is a Python library with a parser, a refusal detector and a patcher, plus the codex-patcher CLI and a web dashboard with diff preview and live logs. Run --dry-run first to see exactly what would change before anything is written. LLM rewriting is optional and needs a key for an Anthropic-compatible API, set through an environment variable rather than pasted into the config.
A second feature injects CTF context into tool profiles and workspaces to lower the chance of a refusal in the first place. For Claude CLI the profile activates only on an explicit codex -p ctf launch and leaves normal sessions alone. OpenCode has no profile mechanism, so you have to start it from the generated workspace. Editing session files rewrites your conversation history, so on a real project preview the diff before applying it.
What it helps with
- clear a refusal from a session file and keep working
- preview the diff before touching any file
- rewrite a refusal with an LLM instead of a canned reply
- add your own phrases to refusal detection
- manage sessions from three tools in one dashboard
Example prompts for the agent
- clean the latest Claude session and show me the diff
- find refusals in my Claude session and replace them
- install the CTF profile for Claude
How to install codex-session-patcher
1Skills CLI (Vercel)
npx skills add reason-machines/trending-skills --skill codex-session-patcher -a claude-code2Manually: put the files in place
~/.claude/skills/codex-session-patcher/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/codex-session-patcher/
1Skills CLI (Vercel)
npx skills add reason-machines/trending-skills --skill codex-session-patcher -a codex2Manually: put the files in place
.agents/skills/codex-session-patcher/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add reason-machines/trending-skills --skill codex-session-patcher -a cursor2Manually: put the files in place
.cursor/skills/codex-session-patcher/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install reason-machines/trending-skills codex-session-patcher2Manually: put the files in place
.github/skills/codex-session-patcher/SKILL.md1Skills CLI (Vercel)
npx skills add reason-machines/trending-skills --skill codex-session-patcher -a gemini-cli2Platform CLI
gemini skills install https://github.com/reason-machines/trending-skills --path skills/codex-session-patcherManually: put the files in place
.devin/skills/codex-session-patcher/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add reason-machines/trending-skills --skill codex-session-patcher -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about codex-session-patcher
How do I install Claude-session-patcher in Claude?
Run npx skills add reason-machines/trending-skills --skill codex-session-patcher -a claude-code. The skill lands at ~/.claude/skills/codex-session-patcher/SKILL.md.
What does Claude-session-patcher do?
It detects refusal responses in Claude CLI, Claude and OpenCode session files and replaces them so the session can be resumed. It can also inject CTF context into tool configs.
Do I need an API key?
Only if you turn on LLM rewriting. The key for an Anthropic-compatible API goes into an environment variable such as OPENAI_API_KEY.