Memory Refiner
Overview
Use this skill to audit how Codex is configured and instructed, then suggest targeted improvements. This skill is Codex-specific: analyze Codex files and usage patterns, not Claude files.
When To Use
Use this skill when the user asks to:
- refine or optimize Codex memory, instructions, rules, or config
- analyze repeated session patterns or recurring corrections
- reduce context bloat or reorganize guidance for lazy loading
- separate global guidance from project-local overrides
Workflow
1. Collect Evidence
- Use the current conversation as the highest-signal short-term evidence.
- Treat interruption or abort notices in the current conversation (for example
Conversation interrupted or turn_aborted) as workflow signals, even if they do not appear in history.jsonl.
- Run
python3 scripts/scan_history.py --format markdown to summarize ~/.codex/history.jsonl.
- Look for repeated preferences, repeated corrections, interruption or abort signals, approval friction, context bloat, stale guidance, and recurring task patterns.
2. Audit Active Memory Surfaces
- Run
python3 scripts/list_memory_surfaces.py --cwd "$PWD" --format markdown.
- Read only the files that are relevant to the request.
- Include the current project's local
.codex/ when present.
- Include repo-local instruction files such as
AGENTS.md when present.
3. Apply Scope Precedence
Use this precedence when evaluating what should win for the current repo:
- Current project
.codex/
- Repo-local
AGENTS.md or similar repo-local instruction files
- Global
~/.codex
Flag shadowing, duplication, and conflicts across these scopes.
4. Synthesize Recommendations
- Separate findings by scope: global, project-local, and repo-local.
- Keep universal guidance project, language, framework, and technology agnostic unless repeated evidence strongly justifies specificity.
- Treat explicit user statements as higher priority than inferred preferences.
- Do not turn one-off incidents into permanent memory.
5. Suggest Before Applying
For each recommendation, provide:
- target file
- scope
- priority
- change type:
add, modify, move, delete, or split
- exact proposed change or diff-ready text
- a short rationale tied to evidence
Do not apply changes until the user approves the specific items.
6. Apply Approved Changes
- Apply only the approved subset.
- Re-check for conflicts after editing.
- Re-run surface discovery if the scope layout changed.
In Scope
~/.codex/AGENTS.md
~/.codex/instructions/**/*.md
~/.codex/rules/*.rules
~/.codex/config.toml
~/.codex/skills/*/SKILL.md
~/.codex/skills/*/agents/openai.yaml
- current project
.codex/**/*.{md,toml,rules,yaml,yml}
- current project
AGENTS.md
Out Of Scope By Default
- Claude config or Claude skills
- unrelated repositories'
.codex/ directories
- auth, sqlite, logs, tmp, sessions, caches, and shell history
- raw history dumps when a compact summary is enough
Output Style
- Be compact and evidence-based.
- Separate facts, assumptions, and recommendations.
- Prefer moving specialized guidance out of global or root files into lazy-loaded files when appropriate.
1---2name: memory-refiner3description: Use this skill when the user asks to refine Codex memory, improve Codex instructions or config, analyze session or history patterns, optimize context efficiency, or update global or project-local Codex guidance based on repeated interaction patterns.4---5
6# Memory Refiner
7
8## Overview
9
10Use this skill to audit how Codex is configured and instructed, then suggest targeted improvements. This skill is Codex-specific: analyze Codex files and usage patterns, not Claude files.
11
12## When To Use
13
14Use this skill when the user asks to:
15- refine or optimize Codex memory, instructions, rules, or config
16- analyze repeated session patterns or recurring corrections
17- reduce context bloat or reorganize guidance for lazy loading
18- separate global guidance from project-local overrides
19
20## Workflow
21
22### 1. Collect Evidence
23
24- Use the current conversation as the highest-signal short-term evidence.
25- Treat interruption or abort notices in the current conversation (for example `Conversation interrupted` or `turn_aborted`) as workflow signals, even if they do not appear in `history.jsonl`.
26- Run `python3 scripts/scan_history.py --format markdown` to summarize `~/.codex/history.jsonl`.
27- Look for repeated preferences, repeated corrections, interruption or abort signals, approval friction, context bloat, stale guidance, and recurring task patterns.
28
29### 2. Audit Active Memory Surfaces
30
31- Run `python3 scripts/list_memory_surfaces.py --cwd "$PWD" --format markdown`.
32- Read only the files that are relevant to the request.
33- Include the current project's local `.codex/` when present.
34- Include repo-local instruction files such as `AGENTS.md` when present.
35
36### 3. Apply Scope Precedence
37
38Use this precedence when evaluating what should win for the current repo:
39
401. Current project `.codex/`
412. Repo-local `AGENTS.md` or similar repo-local instruction files
423. Global `~/.codex`
43
44Flag shadowing, duplication, and conflicts across these scopes.
45
46### 4. Synthesize Recommendations
47
48- Separate findings by scope: global, project-local, and repo-local.
49- Keep universal guidance project, language, framework, and technology agnostic unless repeated evidence strongly justifies specificity.
50- Treat explicit user statements as higher priority than inferred preferences.
51- Do not turn one-off incidents into permanent memory.
52
53### 5. Suggest Before Applying
54
55For each recommendation, provide:
56- target file
57- scope
58- priority
59- change type: `add`, `modify`, `move`, `delete`, or `split`
60- exact proposed change or diff-ready text
61- a short rationale tied to evidence
62
63Do not apply changes until the user approves the specific items.
64
65### 6. Apply Approved Changes
66
67- Apply only the approved subset.
68- Re-check for conflicts after editing.
69- Re-run surface discovery if the scope layout changed.
70
71## In Scope
72
73- `~/.codex/AGENTS.md`
74- `~/.codex/instructions/**/*.md`
75- `~/.codex/rules/*.rules`
76- `~/.codex/config.toml`
77- `~/.codex/skills/*/SKILL.md`
78- `~/.codex/skills/*/agents/openai.yaml`
79- current project `.codex/**/*.{md,toml,rules,yaml,yml}`
80- current project `AGENTS.md`
81
82## Out Of Scope By Default
83
84- Claude config or Claude skills
85- unrelated repositories' `.codex/` directories
86- auth, sqlite, logs, tmp, sessions, caches, and shell history
87- raw history dumps when a compact summary is enough
88
89## Output Style
90
91- Be compact and evidence-based.
92- Separate facts, assumptions, and recommendations.
93- Prefer moving specialized guidance out of global or root files into lazy-loaded files when appropriate.