Skip to content

BjornMelin/dev-skills / archive/skills/codex-session-cleanup

codex-session-cleanup

Verified

Safely scan, triage, quarantine, restore, and purge Codex session/history/state/memory artifacts for current repo, explicit roots, subrepos, Codex-home, or all sessions.

references/artifact-model.md

View on GitHub
# Codex Artifact Model

Codex cleanup spans storage surfaces under `CODEX_HOME`, defaulting to
`~/.codex`. The scanner separates scope roots from artifact families so one
workflow can handle a single repo, explicit roots, cwd subrepos, Codex-home
artifacts, or all sessions.

## Primary Surfaces

- `sessions/**/*.jsonl`: active rollout/session logs.
- `archived_sessions/*.jsonl`: archived rollout/session logs.
- `history.jsonl`: prompt history keyed by `session_id`.
- `session_index.jsonl`: lightweight thread id to thread name index.
- `state_5.sqlite`: thread metadata, goals, spawn edges, dynamic tools, memory
  stage outputs, agent jobs, and related state.
- `logs_2.sqlite`: structured logs keyed by `thread_id`.
- `memories/MEMORY.md`: memory registry.
- `memories/rollout_summaries/*.md`: generated memory summaries linked to
  session ids and rollout paths.
- `prune-quarantine/`: timestamped cleanup quarantines and scan reports.

## Scope Resolution

- `current`: current Git repository root when available; otherwise the cwd.
- `root`: one or more explicit `--root` values.
- `roots`: explicit roots from repeated `--root` and/or `--roots-file`.
- `cwd-subrepos`: Git repositories discovered under `--cwd`.
- `codex-home`: Codex-home artifact families not primarily owned by a repo.
- `all`: all repo-bound sessions plus requested Codex-home artifact families.

For repo-bound sessions, matching uses `threads.cwd` from `state_5.sqlite`.
Nested repositories default to longest-root-wins ownership.

## Artifact Families

- `sessions`: session JSONL, history/index JSONL, state/log SQLite rows.
- `memory`: memory registry plus linked rollout summaries; copy-first.
- `quarantine`: previous quarantine bundles; purge is separate.
- `logs`: local Codex log files/directories.
- `cache`: cache and temp directories.
- `generated`: generated images or other generated Codex outputs.
- `skills-agents-config`: skills, agents, AGENTS/config/hook files.

`auth.json`, `internal_storage/**`, and secret-like env files are protected
unless the user asks for a separate security-reviewed workflow.

## Quarantine Layout

Each apply creates:

- `manifests/manifest.json`: exact selected sessions and planned operations.
- `manifests/result.json`: actual mutations and integrity outcomes.
- `SHA256SUMS`: checksums for quarantined copies and backups.
- `db_backups/`: SQLite and history/index backups.
- `session_files/`: selected session JSONL files.
- `memory_rollout_summaries/`: copied or explicitly moved memory snapshots.

Plain Codex logs and broad config surfaces are report-only by default.
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 471kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 322kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 322kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 322kUpdated Claude CodeCodexVerifiedInstall