Codex Memory Trim logo

Codex Memory Trim

Community
Yu-Xiao-Sheng
codex-memory-trim

Manage Codex's native global memory (~/.codex/memories) with three sub-procedures - trim (audit + dedupe + three-layer cleanup), compress (rewrite verbose memories into concise form), and add-global (add a custom global rule/preference). Use when the user asks to 精简/清理/整理/压缩 Codex 记忆, 去重, 简化冗长记忆, 添加/写入/修改全局记忆 or a global rule.

Overview

PublisherYu-Xiao-Sheng
Repositorycodex-memory-trim
Skill namecodex-memory-trim
Stars
95
Forks
2
Bundled files
5
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.

  • 5 bundled files

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

  • Open source

    Published by Yu-Xiao-Sheng on GitHub. Read the source before you install it.

Installation

Install the Codex Memory Trim 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/Yu-Xiao-Sheng/codex-memory-trim/tree/main/skill
  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/Yu-Xiao-Sheng/codex-memory-trim.git /tmp/codex-memory-trim
mkdir -p .claude/skills
cp -r /tmp/codex-memory-trim/skill .claude/skills/codex-memory-trim
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Codex Memory Trim 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 Trim 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 Trim 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 全局记忆管理(trim / compress / add-global)

按用户需求只读取对应子技能文件执行,不要全量加载:

用户意图读取
清理/去重/删除过期记忆subskills/trim.md
压缩冗长表达、简化措辞subskills/compress.md
添加自定义全局记忆/规则subskills/add-global.md

共享事实(所有子技能依赖,不要重新推导)

  • 分层:sessions/*.jsonl(不可变原始证据)→ raw_memories.md / rollout_summaries/(整理输入,由 ~/.codex/memories_1.sqlite 表 stage1_outputs 重新渲染,手改会被还原)→ MEMORY.md(检索层)/ memory_summary.md(会话启动时注入的快照,文件头 v1)。
  • usage_count(stage1_outputs 列)= 检索命中次数,是保留/删除的核心依据。
  • ~/.codex/memories/.git 是整理基线:Phase 2 以 HEAD→工作区 diff 决定巩固内容。任何手工修改必须以 git 提交收尾,且提交前工作区若不干净、或 git log 顶部是新的 "Initialize Codex git baseline"(刚跑过自动整理),必须先读 diff 合并新内容,禁止覆盖。
  • 巡检脚本(只读):python3 ~/.codex/skills/codex-memory-trim/scripts/collect.py。
  • 记忆快照是会话启动时一次性注入;修改只对新会话(或 codex fork)生效。
  • 备份模板:mkdir -p ~/.codex/backups && TS=$(date +%Y%m%d-%H%M%S) && tar czf ~/.codex/backups/memories-before-trim-$TS.tar.gz -C ~/.codex memories && cp ~/.codex/memories_1.sqlite ~/.codex/backups/memories_1-before-trim-$TS.sqlite

共享红线

  • 永不动 sessions/*.jsonl、extensions/ad_hoc/notes/ 既有文件内容(note 只能新增或按用户原话修订)、.git 内部对象(正常 commit 除外)。
  • 禁用 codex debug clear-memories(全量重置)。整理任务(collect.py 中 consolidate_global)运行中不写文件。
  • 动手前必备份,结束必提交:cd ~/.codex/memories && git add -A && git -c user.name="Codex" -c user.email="noreply@openai.com" commit -m "<一句话>",收尾 git status --short 必须为空。
  • 本 skill 自身按效率优先执行:单次完成,不循环重复校验。

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 Trim AI skill do?

Manage Codex's native global memory (~/.codex/memories) with three sub-procedures - trim (audit + dedupe + three-layer cleanup), compress (rewrite verbose memories into concise form), and add-global (add a custom global rule/preference). Use when the user asks to 精简/清理/整理/压缩 Codex 记忆, 去重, 简化冗长记忆, 添加/写入/修改全局记忆 or a global rule.

Why use Codex Memory Trim on TypingMind?

Because you install it once and use it with any model. Codex Memory Trim 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 Trim in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/Yu-Xiao-Sheng/codex-memory-trim/tree/main/skill. 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 Trim?

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 Trim?

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

Is the Codex Memory Trim AI skill free?

Yes. It is published on GitHub by Yu-Xiao-Sheng 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 👇