跳至正文
OpenAgentSkill
浏览已开放 · 目录记录日期 2026-11-21 · 自动更新和账户服务暂时关闭。
安全

codex-memory-guard

Guard task boundaries and preserve confirmed critical project state across Codex compaction. Use when a user wants topic-switch guidance, write-through critical memory, compact HANDOFF checkpoints, PreCompact and compact-resume hooks, four-layer Markdown memory initialization, or memory workflow auditing.

wl1650918245 · 已有 AI 审核记录

安装与使用

运行命令前先阅读来源与依赖说明。复制命令不会自动安装或执行。

npx skills add wl1650918245/codex-memory-guard --skill codex-memory-guard

技能说明


name: codex-memory-guard description: Guard task boundaries and preserve confirmed critical project state across Codex compaction. Use when a user wants topic-switch guidance, write-through critical memory, compact HANDOFF checkpoints, PreCompact and compact-resume hooks, four-layer Markdown memory initialization, or memory workflow auditing.

Codex Memory Guard

Keep tasks small enough to finish before compaction when practical. Persist confirmed critical state when it appears, keep the recovery checkpoint compact, and preserve a raw transcript reference as the final fallback.

This Skill does not prevent compaction or promise lossless retention of every chat detail. It makes confirmed critical decisions, constraints, verified lessons, blockers, and execution state durable, reviewable, and traceable.

Workflow

  1. Apply the task-boundary state machine when the current goal is unfinished. Compare the new input with the current goal before estimating its duration.
  2. Inspect the target project for existing AGENTS.md, memory files, and .codex/hooks.json.
  3. Run scripts/initialize-memory-system.ps1 for the target root. It creates all four memory layers when missing and preserves existing content.
  4. Run scripts/install.ps1 only after the user authorizes global installation. It installs the Hooks and safely upserts a marked policy block in the user's global AGENTS.md without replacing other rules.
  5. Tell the user to review and trust the new handlers through /hooks; never claim they are active before trust is confirmed.
  6. Verify with scripts/test.ps1 in an isolated temporary directory. The test covers multi-task and legacy HANDOFF validation, scope isolation, ready and recovery-required resume paths, pending closure and cleanup, installation, and scoped uninstall.
  7. After a real compaction, inspect memory/inbox/pending-*.json and the short HANDOFF.md; search the transcript selectively only when the checkpoint is insufficient.

Task boundary policy

Use these states: ACTIVE, BOUNDARY_CANDIDATE, CONTINUE_CURRENT, SWITCH_RECOMMENDED, and COMPLETED.

For each new input while the state is ACTIVE:

  1. Identify the single current goal from the conversation and short HANDOFF.md when present.
  2. Decide whether the input directly advances that goal.
  3. If it does not, decide whether it is still a goal-related clarification, objection, correction, implementation adjustment, same-deliverable addition, or result check.
  4. If neither applies and the input can open an independent discussion or action direction, enter BOUNDARY_CANDIDATE and give one lightweight reminder. Do this even when the new topic might end within one or two turns; do not require the user to label it as a test.

Treat the following as additional boundary evidence:

  • the project or working directory changes;
  • the final deliverable or acceptance criteria change;
  • two unrelated current goals would be needed in HANDOFF.md;
  • the unfinished current task would be displaced by another multi-turn task;
  • the new work has materially different permissions, risks, or side effects.

Ask whether the user wants a separate Codex task; do not create one without an explicit request. If the user stays, enter CONTINUE_CURRENT for that boundary and do not repeat the reminder unless a distinct boundary appears. If the user chooses a separate task, enter SWITCH_RECOMMENDED. When the current goal is closed, enter COMPLETED and do not warn merely because the next topic differs.

The short-tangent exemption applies only when the tangent is directly related to the current goal. A short but clearly unrelated topic is still a boundary candidate. Do not persist routine state labels; record only a boundary choice needed for reliable resume. For the normative transition table and examples, read references/task-boundary-state-machine.md when implementing, auditing, or testing boundary behavior.

Memory policy

  • Treat the transcript as evidence, not default model context.
  • Write confirmed critical information when it appears; do not wait for compaction. Explicit phrases such as "remember this", "this is final", "use this from now on", or equivalent require immediate persistence and a read-back confirmation with the destination path.
  • Critical information includes confirmed decisions, user constraints, acceptance criteria, verified lessons, active blockers, exact state required to resume, and facts whose loss would cause rework or duplicate side effects.
  • Keep exactly one HANDOFF.md per project. It contains only started, unfinished work that must survive compaction or a window change; the complete backlog belongs in GitHub Issues or the project's chosen tracker.
  • Do not impose a fixed active-task count. For each active task keep a short title, one or two sentences of background, current verified state, one next action, and optional Issue/Spec/report pointer, up to three key files, and the latest relevant Session ID as an evidence locator only. Target 1000-2000 Chinese characters and enforce a 3000-character hard limit.
  • Before editing HANDOFF.md, reread the latest file and update only the matching task entry. Read back after writing; if the file changed concurrently, reread and merge instead of overwriting other tasks. Remove completed, cancelled, or no-longer-resumable tasks promptly.
  • Use DECISIONS.md for confirmed decisions with source and invalidation conditions.
  • Use LESSONS.md only for practices verified in real work.
  • Route unconfirmed observations to memory/YYYY-MM-DD.md.
  • Create all four layers, but load only HANDOFF.md by default. Read other layers only when the current question needs them.
  • Never store credentials, tokens, or secrets in memory artifacts.
  • Preserve conflicting history and mark supersession; do not silently rewrite it.
  • Durable entries use explicit lifecycle states when applicable: active, superseded, archived, or revoked. Only active entries
阅读完整来源 ↗