Codex Memory Curator
Goal
Audit Codex memories as user-owned durable state: expose stale, unsafe, duplicated, or misplaced entries; propose better destinations; add a structured cleanup plan when approval needs precision; and apply cleanup only after a report, backup, and explicit user approval.
Core principle
Memory is context, not truth. The latest user request, current repo files, AGENTS.md, package files, ADRs, and live evidence override stored memories.
When to use
- The user asks to review, audit, clean up, prune, rewrite, or remove Codex memories.
- The user mentions
~/.codex/memories, stale memories, memory pollution, or memories making Codex worse.
- The user wants to decide whether an entry belongs in memory,
AGENTS.md, repo docs, a skill, config, or deletion.
- The user wants to disable, tune, or audit Codex memory behavior.
When not to use
- Do not use for ordinary repo documentation cleanup unless Codex memories are part of the task.
- Do not use for generic prompt engineering that does not inspect memory files or memory config.
- Do not modify memories when the user only asked for review.
- Do not inspect unrelated personal files outside Codex memory/config paths and the current repo files needed to verify conflicts.
Inputs to inspect
- Codex home:
${CODEX_HOME:-$HOME/.codex} or the user-provided Codex home path.
- Memory files under
<codex-home>/memories.
- Memory config at
<codex-home>/config.toml when present.
- The current user request and current repo instructions/docs only when needed to verify conflicts.
references/classification-rubric.md when a classification is not obvious.
references/conflict-resolution.md when memory may conflict with current prompt, AGENTS.md, repo docs, package scripts, ADRs, source, or config.
references/config-modes.md when recommending memory config changes.
references/memory-store-anatomy.md when the memory directory contains multiple generated-state file types.
references/safe-editing-procedure.md before modifying memory files.
assets/review-report-template.md when report shape is unclear.
assets/cleanup-plan-template.md when a structured cleanup plan artifact is useful or requested.
Safety rules
Never silently delete, rewrite, truncate, or move memory files.
Ask exactly this before content-changing cleanup:
Do you want me to apply the safe cleanup now? I will back up the memory directory first.
Do not edit unless the user clearly approves that cleanup.
Back up the memory directory before approved edits and report the backup path.
Do not print full secrets, tokens, credentials, customer data, private identifiers, or sensitive personal data.
If secret-like data is found, redact values in output, identify file and line when possible, recommend removal, and recommend rotation for real credentials.
If the memory schema is unclear, do not edit the original file. Write a sibling .proposed.md cleanup plan instead.
Treat memory files as generated state unless local instructions prove otherwise. Do not rewrite append-only evidence to fix a stale curated claim.
Do not apply repo-specific assumptions globally. Prefer AGENTS.md or repo docs for repo rules.
Do not run broad destructive commands.
Workflow
Discover Codex home:
Use ${CODEX_HOME} when set; otherwise use the user's home directory plus .codex.
Inventory memory files without dumping contents:
node scripts/inventory-memories.mjs
Run the redacted risk scanner when looking for sensitive, stale, broad, local, repo-specific, or config-like entries:
node scripts/scan-memory-risks.mjs --json
Exit code 1 means findings were found, not that the scan failed. The scanner caps returned findings and skips generated evidence by default; raise --max-findings or add --include-generated-evidence only when needed.
Use scanner JSON as evidence; report counts and the highest-signal redacted findings instead of pasting the full payload.
Inspect <codex-home>/config.toml when present; read no more than the first 220 lines.
Classify memory mode as disabled, enabled but not injected, enabled and injected, external-context generation disabled, or unknown. Load references/config-modes.md for exact mode signals.
If multiple memory file types are present, load references/memory-store-anatomy.md before deciding what is safe to edit.
Read memory files in small chunks; avoid huge dumps and redact sensitive values.
Extract one atomic claim per row. Split compound entries before classification.
Verify conflicts against only the current repo files needed for the disputed claim. Load references/conflict-resolution.md when precedence is unclear.
Assign exactly one primary classification per atomic claim: KEEP, KEEP BUT REWRITE, MOVE TO AGENTS.md, MOVE TO REPO DOCS, MOVE TO SKILL, MOVE TO CONFIG, DELETE, or ASK USER.
Tag high-risk entries as useful context only: stale, duplicated, too-broad, too-specific, repo-specific, workflow, config, sensitive, conflicting, or useful.
Add confidence (high, medium, or low) and a proposed action to every entry.
Produce the review report before editing. Add a structured cleanup plan only when the user wants ID-by-ID approval, the schema is unknown, sensitive cleanup is proposed, or the edit set is large enough that a table is hard to approve safely.
If cleanup is approved, load references/safe-editing-procedure.md, run node scripts/backup-memories.mjs, apply only approved minimal edits by memory ID, re-read changed sections, and show a trimmed diff summary.
Classification checks
For each atomic claim, ask:
- Is this stable for months?
- Is this a personal preference or a repo rule?
- Could this mislead Codex in another repository?
- Is it phrased too strongly with
always, never, or must?
- Is it duplicated, stale, one-off, or conflicting?
- Does it contain sensitive data?
- Does a higher-precedence source contradict it?
- Would this be more precise as
AGENTS.md, repo docs, a skill, config, or deletion?
- Is it short enough to stay in memory?
Load references/classification-rubric.md for examples and detailed decision rules.
References
Read only when needed:
references/classification-rubric.md for detailed classification rules and rewrite examples.
references/conflict-resolution.md for precedence rules when memory conflicts with current repo evidence.
references/config-modes.md for memory config mode signals and TOML snippets.
references/example-review-report.md for report shape examples.
references/memory-store-anatomy.md for generated-state boundaries and common memory file buckets.
references/safe-editing-procedure.md before modifying memory files.
assets/review-report-template.md when a concise report template is useful.
assets/cleanup-plan-template.md when a structured cleanup plan is needed.
Scripts
Use only when needed. All scripts are non-interactive, use Node.js stdlib only, and accept --help.
node scripts/inventory-memories.mjs [--codex-home PATH] [--json]
node scripts/scan-memory-risks.mjs [--codex-home PATH] [--json] [--max-findings N] [--include-generated-evidence]
node scripts/backup-memories.mjs [--codex-home PATH]
inventory-memories.mjs is read-only and lists memory files with size/date metadata plus a best-effort file kind.
scan-memory-risks.mjs is read-only, redacts matching lines by default, labels risk categories, limits returned findings, skips generated evidence unless requested, and exits 1 when findings exist.
backup-memories.mjs creates a timestamped backup copy under Codex home; it does not edit or delete memory files.
Output format
Before edits, lead with this report shape:
# Codex Memory Review
## Top Decisions
1.
2.
3.
## Summary
- Memory files inspected:
- Entries extracted:
- Keep:
- Rewrite:
- Move to AGENTS.md:
- Move to repo docs:
- Move to skill:
- Move to config:
- Delete:
- Ask user:
## Highest-Risk Memories
| ID | Entry | Risk | Recommendation |
| --- | ----- | ---- | -------------- |
## Proposed Cleanup Table
| ID | Current memory | Classification | Risk tags | Confidence | Reason | Proposed action |
| --- | -------------- | -------------- | --------- | ---------- | ------ | --------------- |
## Conflict Notes
| ID | Higher source | Conflict | Recommendation |
| --- | ------------- | -------- | -------------- |
## Optional Cleanup Plan Artifact
- Plan path:
- Plan format: `assets/cleanup-plan-template.md`
- Omit this section for simple review-only work unless the user needs ID-by-ID approval.
## Config Recommendation
## Recommended Next Action
After approved edits, also include backup path, files changed, trimmed diff summary, and residual risks.
Completion criteria
- Relevant memory files and config were inventoried, or a missing-path message was reported.
- Entries were extracted as atomic claims.
- Each entry has exactly one primary classification.
- Each entry has risk tags, confidence, and a proposed action.
- The report distinguishes memory,
AGENTS.md, repo docs, skills, config, deletion, and ask-user cases.
- Conflicts cite the higher-precedence source that makes the memory stale or misplaced.
- Generated evidence files are treated as evidence unless approved sensitive-data cleanup requires changing them.
- A structured cleanup plan is provided when the user wants ID-by-ID approval, the schema is unknown, sensitive cleanup is proposed, or the edit set is large.
- No memory edit happened before explicit approval.
- Any approved edit has a backup path and verification diff summary.
Failure modes
- No memory directory: report that no local memories directory was found and suggest checking whether memories are enabled or
CODEX_HOME points elsewhere.
- Config missing: report that memory behavior may be controlled by app settings or defaults.
- Memory schema unknown: write proposed replacements to a sibling
.proposed.md file instead of editing the original.
- Sensitive data found: redact the value, identify file and line when possible, recommend removal, require backup before edits, and recommend rotation for real credentials.
- Conflicting rules: cite the conflict, prefer current prompt and repo instructions, then classify as rewrite, move, or delete.
- Backup failure: do not edit memory files.
Final output instruction
Stay skeptical and concise. Lead with top decisions and the cleanup report, not a long explanation. Give one concrete next action when action is needed.
Source: stark-ai-de/agent-skills — distributed by TomeVault.
1---2name: codex-memory-curator3description: Audit, review, clean up, and prune Codex memories. Use when the user asks about ~/.codex/memories, stale or noisy memories, memory pollution, cross-repo rule leakage, sensitive memory contents, memory config tuning, cleanup plans, or whether entries belong in memory, AGENTS.md, repo docs, skills, config, or deletion. Do not use for ordinary repo docs cleanup. Use when this capability is needed.4---56# Codex Memory Curator78## Goal910Audit Codex memories as user-owned durable state: expose stale, unsafe, duplicated, or misplaced entries; propose better destinations; add a structured cleanup plan when approval needs precision; and apply cleanup only after a report, backup, and explicit user approval.1112## Core principle1314Memory is context, not truth. The latest user request, current repo files, `AGENTS.md`, package files, ADRs, and live evidence override stored memories.1516## When to use1718- The user asks to review, audit, clean up, prune, rewrite, or remove Codex memories.19- The user mentions `~/.codex/memories`, stale memories, memory pollution, or memories making Codex worse.20- The user wants to decide whether an entry belongs in memory, `AGENTS.md`, repo docs, a skill, config, or deletion.21- The user wants to disable, tune, or audit Codex memory behavior.2223## When not to use2425- Do not use for ordinary repo documentation cleanup unless Codex memories are part of the task.26- Do not use for generic prompt engineering that does not inspect memory files or memory config.27- Do not modify memories when the user only asked for review.28- Do not inspect unrelated personal files outside Codex memory/config paths and the current repo files needed to verify conflicts.2930## Inputs to inspect3132- Codex home: `${CODEX_HOME:-$HOME/.codex}` or the user-provided Codex home path.33- Memory files under `<codex-home>/memories`.34- Memory config at `<codex-home>/config.toml` when present.35- The current user request and current repo instructions/docs only when needed to verify conflicts.36- `references/classification-rubric.md` when a classification is not obvious.37- `references/conflict-resolution.md` when memory may conflict with current prompt, `AGENTS.md`, repo docs, package scripts, ADRs, source, or config.38- `references/config-modes.md` when recommending memory config changes.39- `references/memory-store-anatomy.md` when the memory directory contains multiple generated-state file types.40- `references/safe-editing-procedure.md` before modifying memory files.41- `assets/review-report-template.md` when report shape is unclear.42- `assets/cleanup-plan-template.md` when a structured cleanup plan artifact is useful or requested.4344## Safety rules4546- Never silently delete, rewrite, truncate, or move memory files.47- Ask exactly this before content-changing cleanup:4849 ```text50 Do you want me to apply the safe cleanup now? I will back up the memory directory first.51 ```5253- Do not edit unless the user clearly approves that cleanup.54- Back up the memory directory before approved edits and report the backup path.55- Do not print full secrets, tokens, credentials, customer data, private identifiers, or sensitive personal data.56- If secret-like data is found, redact values in output, identify file and line when possible, recommend removal, and recommend rotation for real credentials.57- If the memory schema is unclear, do not edit the original file. Write a sibling `.proposed.md` cleanup plan instead.58- Treat memory files as generated state unless local instructions prove otherwise. Do not rewrite append-only evidence to fix a stale curated claim.59- Do not apply repo-specific assumptions globally. Prefer `AGENTS.md` or repo docs for repo rules.60- Do not run broad destructive commands.6162## Workflow63641. Discover Codex home:6566 Use `${CODEX_HOME}` when set; otherwise use the user's home directory plus `.codex`.67682. Inventory memory files without dumping contents:6970 ```bash71 node scripts/inventory-memories.mjs72 ```73743. Run the redacted risk scanner when looking for sensitive, stale, broad, local, repo-specific, or config-like entries:7576 ```bash77 node scripts/scan-memory-risks.mjs --json78 ```7980 Exit code `1` means findings were found, not that the scan failed. The scanner caps returned findings and skips generated evidence by default; raise `--max-findings` or add `--include-generated-evidence` only when needed.81 Use scanner JSON as evidence; report counts and the highest-signal redacted findings instead of pasting the full payload.82834. Inspect `<codex-home>/config.toml` when present; read no more than the first 220 lines.845. Classify memory mode as disabled, enabled but not injected, enabled and injected, external-context generation disabled, or unknown. Load `references/config-modes.md` for exact mode signals.856. If multiple memory file types are present, load `references/memory-store-anatomy.md` before deciding what is safe to edit.867. Read memory files in small chunks; avoid huge dumps and redact sensitive values.878. Extract one atomic claim per row. Split compound entries before classification.889. Verify conflicts against only the current repo files needed for the disputed claim. Load `references/conflict-resolution.md` when precedence is unclear.8910. Assign exactly one primary classification per atomic claim: `KEEP`, `KEEP BUT REWRITE`, `MOVE TO AGENTS.md`, `MOVE TO REPO DOCS`, `MOVE TO SKILL`, `MOVE TO CONFIG`, `DELETE`, or `ASK USER`.909111. Tag high-risk entries as useful context only: `stale`, `duplicated`, `too-broad`, `too-specific`, `repo-specific`, `workflow`, `config`, `sensitive`, `conflicting`, or `useful`.9212. Add confidence (`high`, `medium`, or `low`) and a proposed action to every entry.9313. Produce the review report before editing. Add a structured cleanup plan only when the user wants ID-by-ID approval, the schema is unknown, sensitive cleanup is proposed, or the edit set is large enough that a table is hard to approve safely.9414. If cleanup is approved, load `references/safe-editing-procedure.md`, run `node scripts/backup-memories.mjs`, apply only approved minimal edits by memory ID, re-read changed sections, and show a trimmed diff summary.9596## Classification checks9798For each atomic claim, ask:99100- Is this stable for months?101- Is this a personal preference or a repo rule?102- Could this mislead Codex in another repository?103- Is it phrased too strongly with `always`, `never`, or `must`?104- Is it duplicated, stale, one-off, or conflicting?105- Does it contain sensitive data?106- Does a higher-precedence source contradict it?107- Would this be more precise as `AGENTS.md`, repo docs, a skill, config, or deletion?108- Is it short enough to stay in memory?109110Load `references/classification-rubric.md` for examples and detailed decision rules.111112## References113114Read only when needed:115116- `references/classification-rubric.md` for detailed classification rules and rewrite examples.117- `references/conflict-resolution.md` for precedence rules when memory conflicts with current repo evidence.118- `references/config-modes.md` for memory config mode signals and TOML snippets.119- `references/example-review-report.md` for report shape examples.120- `references/memory-store-anatomy.md` for generated-state boundaries and common memory file buckets.121- `references/safe-editing-procedure.md` before modifying memory files.122- `assets/review-report-template.md` when a concise report template is useful.123- `assets/cleanup-plan-template.md` when a structured cleanup plan is needed.124125## Scripts126127Use only when needed. All scripts are non-interactive, use Node.js stdlib only, and accept `--help`.128129```bash130node scripts/inventory-memories.mjs [--codex-home PATH] [--json]131node scripts/scan-memory-risks.mjs [--codex-home PATH] [--json] [--max-findings N] [--include-generated-evidence]132node scripts/backup-memories.mjs [--codex-home PATH]133```134135- `inventory-memories.mjs` is read-only and lists memory files with size/date metadata plus a best-effort file kind.136- `scan-memory-risks.mjs` is read-only, redacts matching lines by default, labels risk categories, limits returned findings, skips generated evidence unless requested, and exits `1` when findings exist.137- `backup-memories.mjs` creates a timestamped backup copy under Codex home; it does not edit or delete memory files.138139## Output format140141Before edits, lead with this report shape:142143```md144# Codex Memory Review145146## Top Decisions1471481.1492.1503.151152## Summary153154- Memory files inspected:155- Entries extracted:156- Keep:157- Rewrite:158- Move to AGENTS.md:159- Move to repo docs:160- Move to skill:161- Move to config:162- Delete:163- Ask user:164165## Highest-Risk Memories166167| ID | Entry | Risk | Recommendation |168| --- | ----- | ---- | -------------- |169170## Proposed Cleanup Table171172| ID | Current memory | Classification | Risk tags | Confidence | Reason | Proposed action |173| --- | -------------- | -------------- | --------- | ---------- | ------ | --------------- |174175## Conflict Notes176177| ID | Higher source | Conflict | Recommendation |178| --- | ------------- | -------- | -------------- |179180## Optional Cleanup Plan Artifact181182- Plan path:183- Plan format: `assets/cleanup-plan-template.md`184- Omit this section for simple review-only work unless the user needs ID-by-ID approval.185186## Config Recommendation187188## Recommended Next Action189```190191After approved edits, also include backup path, files changed, trimmed diff summary, and residual risks.192193## Completion criteria194195- Relevant memory files and config were inventoried, or a missing-path message was reported.196- Entries were extracted as atomic claims.197- Each entry has exactly one primary classification.198- Each entry has risk tags, confidence, and a proposed action.199- The report distinguishes memory, `AGENTS.md`, repo docs, skills, config, deletion, and ask-user cases.200- Conflicts cite the higher-precedence source that makes the memory stale or misplaced.201- Generated evidence files are treated as evidence unless approved sensitive-data cleanup requires changing them.202- A structured cleanup plan is provided when the user wants ID-by-ID approval, the schema is unknown, sensitive cleanup is proposed, or the edit set is large.203- No memory edit happened before explicit approval.204- Any approved edit has a backup path and verification diff summary.205206## Failure modes207208- No memory directory: report that no local memories directory was found and suggest checking whether memories are enabled or `CODEX_HOME` points elsewhere.209- Config missing: report that memory behavior may be controlled by app settings or defaults.210- Memory schema unknown: write proposed replacements to a sibling `.proposed.md` file instead of editing the original.211- Sensitive data found: redact the value, identify file and line when possible, recommend removal, require backup before edits, and recommend rotation for real credentials.212- Conflicting rules: cite the conflict, prefer current prompt and repo instructions, then classify as rewrite, move, or delete.213- Backup failure: do not edit memory files.214215## Final output instruction216217Stay skeptical and concise. Lead with top decisions and the cleanup report, not a long explanation. Give one concrete next action when action is needed.218219---220> Source: [stark-ai-de/agent-skills](https://github.com/stark-ai-de/agent-skills) — distributed by [TomeVault](https://tomevault.io).221<!-- tomevault:4.0:skill_md:2026-06-16 -->