Self-Improving Codex
Use this skill when a Codex task surfaces non-trivial errors, corrections, missing capabilities, undocumented repo conventions, or repeatable workflows that should be captured before they fade into chat history.
Preconditions
- Prefer repositories that already use:
AGENTS.mddocs/work/knowledge/
- If those surfaces do not exist yet, use
agents-md-context-managerfirst.
Read first
AGENTS.mddocs/work/.current- the active task's
meta.yaml,status.md, anddecisions.md - the active task's
learning-log.mdwhen it already exists
Capture triggers
- unexpected command, tool, runtime, or integration failure
- user correction or clarified requirement
- self-correction after discovering the earlier approach was wrong
- newly discovered repo convention or undocumented rule
- repeatable workflow worth simplifying or reusing
- missing capability that blocked progress
Overall mechanism
This skill is the task-time capture layer in a four-stage loop:
- Task-time capture
- raw events go into
docs/work/<task>/learning-log.md
- raw events go into
- 24-hour triage
- the
self-improve-triageautomation dedupes, classifies, and promotes only confirmed learnings
- the
- Task-close durable sync
durable-knowledge-maintainermaps promoted learnings intoAGENTS.md,knowledge/, and task metadata
- 72-hour durable audit
weekly-durable-auditchecks for stale pending learnings, missing capture adoption, stale sources, and candidate drift
Architecture
flowchart LR
A["Task execution"] --> B["learning-log.md<br/>raw learnings"]
B --> C["24h self-improve-triage"]
C --> D["status.md + meta.yaml<br/>triage state"]
C --> E["Repo durable docs<br/>AGENTS.md + knowledge/"]
C --> F["Global candidate memory<br/>$CODEX_HOME/memories/durable-knowledge/skill-candidates/"]
D --> G["Task-close durable sync"]
G --> E
G --> F
E --> H["72h weekly-durable-audit"]
F --> H
C --> I["Guardrail<br/>only triaged or promoted learnings may flow onward"]
Storage model
learning-log.md: raw event capturestatus.md: short derived summary for the active taskmeta.yaml: durable review status and follow-upsAGENTS.md+knowledge/: stable repo rules and long-term knowledge$CODEX_HOME/memories/durable-knowledge/skill-candidates/: cross-task or cross-repo reusable workflow evidence
Workflow
- Resolve the active task through
docs/work/.current. - Create or update
docs/work/<task>/learning-log.md. - Capture only non-trivial learnings.
- skip noise such as obvious typos, transient retries with no insight, or details already captured elsewhere
- Append or update an entry using the fixed schema:
idtypelogged_atstatustriggersummarydetailsrelated_filespattern_keypromotion_targetsee_also
- Reuse the same
pattern_keywhen the same workflow or failure pattern appears across tasks. - Keep
status.mdaligned.- summarize new raw entries under
Learning Capture - summarize candidate or durable-doc destinations under
Promotion Queue - do not duplicate full event detail in
status.md
- summarize new raw entries under
- Triage each entry deliberately.
pending: captured but not yet confirmedtriaged: confirmed and mapped to the right durable targetpromoted: durable docs or global candidate records were actually updateddismissed: non-durable, superseded, or not worth keeping
- Promote safely.
- repo-local durable rules and knowledge updates go through
durable-knowledge-maintainer - cross-task or cross-repo workflows go through
skill-candidate-harvester - raw
pendingentries must not updateAGENTS.mddirectly
- repo-local durable rules and knowledge updates go through
- Before a task is marked complete, ensure relevant learning entries are no longer
pending.
Entry conventions
typeshould be one of:errorcorrectionworkflowconventionmissing_capability
triggershould be one of:unexpected_command_failureunexpected_tool_failureuser_correctionself_correctionrepo_convention_discoveredbetter_repeatable_workflowmissing_capability
promotion_targetexamples:knowledge-doc:pitfallsknowledge-doc:current-stateskill-candidate:installed-skill-copy-syncnone
Hard rules
- Do not treat every failure as a learning; only keep durable or reusable insight.
- Do not store raw learnings only in chat.
- Do not let
status.mdbecome a duplicate event log. - Do not promote an unconfirmed entry into
AGENTS.mdor a global skill candidate. - Do not invent recurrence; use
see_alsoandpattern_keyonly when the linkage is real.
Resources
- Entry template:
assets/learning-log-template.md - Triage and promotion guidance:
references/triage-and-promotion.md