codex-cleanse
Preview or archive local Codex sessions after seven days without activity. Use for an on-demand session cleanup or a local scheduled archive run across a selected Codex home.
- License 许可
- MIT
- 最近更新
- 2026-11-15
- Stars
- ★ 7
- Forks
- 1
01 前言 Front Matter
- name
- codex-cleanse
- description
- Preview or archive local Codex sessions after seven days without activity. Use for an on-demand session cleanup or a local scheduled archive run across a selected Codex home.
02 资源文件 4
- 脚本config/constants.mjs657 B
- 脚本config/constants.test.mjs1.7 KB
- 脚本scripts/cleanse.mjs19.5 KB
- 脚本scripts/cleanse.test.mjs36.2 KB
03 SKILL.md 正文
Codex cleanse
Run scripts/cleanse.mjs with Node.js from this skill directory. Select the account with --codex-home <absolute path>. Without that flag, the command uses CODEX_HOME, then the current user's .codex directory. Use --codex-path <absolute executable path> when Codex is outside the supported native install locations.
Preview first:
node scripts/cleanse.mjs --stdio --codex-home <absolute path>
Archive the eligible sessions after reviewing the preview:
node scripts/cleanse.mjs --stdio --codex-home <absolute path> --apply
The default cutoff is seven days. --inactive-days <number> changes it. When the local Codex app's task listing is available, repeat --exclude-thread-id <UUID> for the current task and each active desktop task. Run the command on demand when the user requests archiving. The command starts a separate local app-server process and cannot see other clients' runtime status. It checks the stored activity time and rollout file modification time before each archive request.
The command lists indexed sessions through thread/list and discovers other session IDs from rollout filenames under the selected home's sessions directory.
It reads their metadata through thread/read without opening conversation content.
It re-reads each candidate, checks its activity time, rollout file modification time, exclusions, and unarchived descendants, then calls thread/archive for eligible leaves before parents.
It confirms archived IDs through a final archived listing or a native read of the archived path for sessions omitted from that listing.
After option parsing succeeds, the command writes one JSON report to stdout and progress to stderr. Option-parsing errors produce a stderr diagnostic and exit with code 1 before starting the Codex server.
Zero-byte rollout files count as emptyRollout skips because the native API cannot read their metadata.
Discovery failures stop archive writes and exit with a nonzero status.
An archive candidate failure stops later archive requests. Earlier requests still receive readback.
Archive and readback failures remain in the report and produce a nonzero exit status.
After a successful apply run archives sessions, refresh the active task exclusions and run again. Stop when a successful run reports zero archives.
Run the archive task on the local machine with the app and selected account available. A cloud task cannot read this machine's Codex home. Codex session archiving leaves managed worktrees in place. The desktop setting at Settings > Worktrees > General > Automatically delete old worktrees controls separate worktree cleanup by retained count.
04 同仓库更多 Skills
update
Fast-forwards a local repository's main branch to a remote's main after confirming the repo path and source remote through AskUserQuestion. Use when the user says '/update', 'update main', 'fast-forward main', 'sync main from origin', 'pull latest main into <path>', or 'bring main up to date'.
source-command-sr-loop
Converging cleanup loop: repeat /simplify until clean, then repeat /code-review --fix until clean
skill-builder
Skill lifecycle: classify, scaffold, write via the skill-writer-agent, self-audit, compose sub-skills, polish description triggers, enforce deterministic scripts. Triggers: build a skill, new skill workflow, improve this skill, optimize skill description, skill development lifecycle, skill modularity, skill composition, description trigger catalog, deterministic skill scripts.
session-tidy
Audit, clean, and consolidate session logs in the Obsidian vault. Fixes format drift, resolves orphaned next-steps, updates stale statuses, and generates project rollup summaries. Use when session logs feel cluttered or before starting a new project milestone. Triggers on '/session-tidy', 'tidy sessions', 'clean up session logs', 'session audit'.
session-log
Logs a session report as an HTML page, tracks vault context, extracts decisions, and outputs a /rename command. Use for /session-log, 'journal this session', 'log this work', 'session report', 'summarize/log/record this session', 'save session', 'capture session', or 'document what we did'.
run-claude-dev-env
Build, install, run, and test the claude-dev-env installer. Use when asked to run claude-dev-env, install the Claude Code config into ~/.claude, drive the installer, smoke-test it against a sandbox, or run its test suite.