Codex Memory Guard logo

Codex Memory Guard

Community
wl1650918245
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.

Overview

Publisherwl1650918245
Repositorycodex-memory-guard
Skill namecodex-memory-guard
Stars
26
Forks
1
Bundled files
21
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 21 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by wl1650918245 on GitHub. Read the source before you install it.

Installation

Install the Codex Memory Guard AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/wl1650918245/codex-memory-guard/tree/main
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/wl1650918245/codex-memory-guard.git \
  .claude/skills/codex-memory-guard
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Codex Memory Guard in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Codex Memory Guard on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Codex Memory Guard is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

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, bounded post-HANDOFF transcript delta review, legacy pending compatibility, 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; review the bounded transcript delta after HANDOFF's recorded last write before closure, then widen transcript search only when the checkpoint is insufficient or conflicting.

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 participate in default recovery.
  • Read back every critical-memory write and verify content, source, scope, status, and invalidation or review conditions.

Hook behavior

  • PreCompact validates HANDOFF.md deterministically before writing the pending record. The record includes layout, active-task count, structure and length status, issues, last-write time, SHA-256, project scope, session and transcript evidence pointers, and recovery_required. It does not copy transcript contents or perform semantic summarization.
  • Hooks are opt-in per initialized project: if no ancestor contains MEMORY_WORKFLOW.md, they return without creating files.
  • SessionStart matching compact verifies project root, session, HANDOFF path and transcript pointer before trusting the record. It reads HANDOFF first, then reviews only transcript entries after the recorded HANDOFF last_write_at through the pre-compaction turn so a structurally valid but semantically stale checkpoint cannot silently skip last-minute confirmed state. A failed checkpoint or conflicting delta may require a wider targeted transcript repair.
  • After recovery, run scripts/close-pending.ps1 with the actual sources used. Schema v4 closure requires -DeltaChecked and records the delta turn count, critical updates found, whether HANDOFF changed, processed_at, repair status, resolved issues and final HANDOFF SHA-256. Legacy schema v3 awaiting_extraction records remain compatible. scripts/cleanup-pending.ps1 is dry-run by default and may delete only processed records older than its explicit retention threshold when -Apply is supplied.
  • Keep both hooks synchronous. The default installation timeout is 10 seconds because they perform local small-file operations only.
  • The command hook does not perform semantic extraction itself. Critical state should already be written through when confirmed; the deterministic pre-check and post-compaction closure are the fallback.

Inspect the bounded post-HANDOFF transcript delta:

powershell
powershell -NoProfile -ExecutionPolicy Bypass -File scripts/get-transcript-delta.ps1 -PendingPath C:\path\to\pending.json

The reader returns only user/assistant messages after the recorded HANDOFF write and through pending capture time, capped at 12 messages and 12000 characters by default. If truncated is true, continue with a targeted search before closure.

Deliberate boundaries

Keep this Skill a lightweight, deterministic task-continuity guard rather than turning it into a full memory platform.

  • The bounded transcript delta is a narrow stale-checkpoint safeguard. The Skill does not continuously infer semantic freshness from Git history, remote releases, issue trackers, file meaning, or every conversation turn; those probes add latency and still cannot prove that a checkpoint is semantically complete.
  • Long-term semantic recall through Codex memories, OpenViking, Trellis, vector databases, hybrid search, cloud storage, or custom MCP servers has been considered but is not implemented or required. Those systems solve broader cross-session retrieval and may be layered alongside this Skill when their privacy, operating cost, failure modes, and retrieval quality are acceptable.
  • Do not treat recalled backend content as confirmed project truth. HANDOFF remains the small resumable execution checkpoint; confirmed decisions and verified lessons remain reviewable project files; transcript and Git remain evidence.
  • Preserve offline degradation: if an optional memory backend is unavailable, the core HANDOFF, pending record, bounded transcript review, and closure workflow must still work.

There is currently no backend adapter contract. Do not imply that installing this Skill enables semantic search, vector storage, cross-project recall, or automatic knowledge extraction.

Validate a checkpoint:

powershell
powershell -NoProfile -ExecutionPolicy Bypass -File scripts/validate-handoff.ps1 -Path C:\path\to\project\HANDOFF.md

Close a processed recovery record:

powershell
powershell -NoProfile -ExecutionPolicy Bypass -File scripts/close-pending.ps1 -PendingPath C:\path\to\pending.json -SourcesUsed HANDOFF.md,'bounded transcript delta' -DeltaChecked -DeltaTurnCount 4 -CriticalUpdatesFound 1 -HandoffUpdatedFromDelta

Preview cleanup of processed records older than 14 days:

powershell
powershell -NoProfile -ExecutionPolicy Bypass -File scripts/cleanup-pending.ps1 -ProjectRoot C:\path\to\project

Commands

Initialize one project:

powershell
powershell -NoProfile -ExecutionPolicy Bypass -File scripts/initialize-memory-system.ps1 -Root C:\path\to\project -SingleProject

Initialize every immediate child project:

powershell
powershell -NoProfile -ExecutionPolicy Bypass -File scripts/initialize-memory-system.ps1 -Root C:\path\to\projects

Install global hooks and optionally initialize a project:

powershell
powershell -NoProfile -ExecutionPolicy Bypass -File scripts/install.ps1 -ProjectRoot C:\path\to\project

Remove only this Skill's global hooks:

powershell
powershell -NoProfile -ExecutionPolicy Bypass -File scripts/uninstall.ps1

Uninstall also removes only the marked codex-memory-guard block from global AGENTS.md; it preserves all other global rules and project memory files.

For schemas and acceptance checks, read references/memory-contract.md.

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Codex Memory Guard AI skill do?

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.

Why use Codex Memory Guard on TypingMind?

Because you install it once and use it with any model. Codex Memory Guard is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Codex Memory Guard in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/wl1650918245/codex-memory-guard/tree/main. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Codex Memory Guard?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Codex Memory Guard?

As many as you like. As long as a model supports skills, you can use Codex Memory Guard with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Codex Memory Guard AI skill free?

Yes. It is published on GitHub by wl1650918245 under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇