Agent skill

Codex Memory Trim

by Yu-Xiao-Sheng in 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…

MITAuto-check passedAgent Workflows

Install Codex Memory Trim

skills CLI
$ npx skills add Yu-Xiao-Sheng/codex-memory-trim --skill codex-memory-trim -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install Yu-Xiao-Sheng/codex-memory-trim codex-memory-trim --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/Yu-Xiao-Sheng/codex-memory-trim.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skill .claude/skills/codex-memory-trim && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
codex-memory-trim
GitHub stars
100
Token cost
~453 tokens
SKILL.md length
98 words
Files
6 (incl. scripts)
Skills in repo
1
Repo updated
First seen
Licence
MIT

At a glance

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…

  • The user asks to 精简/清理/整理/压缩 Codex 记忆
  • SKILL.md covers 共享事实(所有子技能依赖,不要重新推导) and 共享红线
  • Runs Shell and Python scripts from its folder; calls git, codex and python3

What it does

Codex Memory Trim is an agent skill from 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.

Its SKILL.md is about 450 tokens, which your agent loads only when the skill is triggered. The skill folder holds 7 other files, including scripts (for example `scripts/auto-trim.sh`, `scripts/collect.py` and `subskills/add-global.md`).

It sits in Agent Workflows. It works with Git and SQLite. The repository describes itself as: 给 Codex 全局记忆定期减负的 skill:检测重复、清理过期线程、压缩冗长表达、添加自定义全局规则 / A skill that puts Codex global memory on a periodic diet: dedupe, prune, compress, add global rules. The licence is MIT.

When your agent uses it

  • The user asks to 精简/清理/整理/压缩 Codex 记忆

Example prompts

  • “/codex-memory-trim”

Requirements

  • Python 3
  • A Bash shell

What it can do on your machine

Read from SKILL.md and the folder at commit 3a5742a. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Ships 2 files in scripts/ (Shell and Python), which the agent can run.

    Shell commands in SKILL.md call:

    • git
    • codex
    • python3

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md. Its commands use git, which can reach the network depending on how they are called.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Codex Memory Trim loads about 453 tokens when it runs. Until then it costs about 87 tokens; SKILL.md has 98 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~87
When it runs · the whole SKILL.md, loaded when a task matches
~453

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); the scripts in this folder are not scanned.

SKILL.md

The full file from Yu-Xiao-Sheng/codex-memory-trim at commit 3a5742a, republished under its MIT licence (© Yu-Xiao-Sheng). 98 words, ~453 tokens.

Download SKILL.mdSave it as .claude/skills/codex-memory-trim/SKILL.md (or your agent's skills folder). This skill also uses 5 other files; get the full folder from GitHub.
name
codex-memory-trim
description
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.

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 自身按效率优先执行:单次完成,不循环重复校验。

© Yu-Xiao-Sheng, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 5 other files (scripts) in skill of Yu-Xiao-Sheng/codex-memory-trim.

  • SKILL.md
  • scripts/auto-trim.sh
  • scripts/collect.py
  • subskills/add-global.md
  • subskills/compress.md
  • subskills/trim.md

Open the folder on GitHubat commit 3a5742a

Compare with similar skills

Codex Memory Trim next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Codex Memory Trim compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Codex Memory Trim this skillYu-Xiao-Sheng/codex-memory-trim100—~453Automated safety check: PassMIT
Bd To Br MigrationDicklesworthstone/beads_rust1.1k—~2.2kAutomated safety check: PassCustom licence
Foremergenaw103/foremerge538—~2.4kAutomated safety check: PassApache-2.0
Puppetmaster Agent Orchestrationprofessorpalmer/Puppetmaster467—~3.2kAutomated safety check: PassMIT
BrDicklesworthstone/beads_rust1.1k—~2.7kAutomated safety check: PassMIT
SkillhoneTencent/SkillHone168—~3.4kAutomated safety check: PassCustom licence

Similar skills

  • Bd To Br Migration

    Dicklesworthstone/beads_rust

    Migrate docs from bd (beads) to br (beadsrust). An agent skill from Dicklesworthstone/beads_rust.

    1.1k GitHub stars~2.2k tokensUpdated yesterday
    Agent WorkflowsAuto-check passed
  • Foremerge

    naw103/foremerge

    Coordinate parallel coding agents with Foremerge's local Git-compatible CLI and MCP server.

    538 GitHub stars~2.4k tokensUpdated 5 days ago
    Agent WorkflowsAuto-check passed
  • Puppetmaster Agent Orchestration

    professorpalmer/Puppetmaster

    Operates and supervises Puppetmaster, a multi-agent orchestrator, through its MCP tools or CLI, picking the right verb for edits, reviews, audits and long-running jobs.

    467 GitHub stars~3.2k tokensUpdated yesterday
    Agent WorkflowsAuto-check passed
  • Br

    Dicklesworthstone/beads_rust

    Official skill for beadsrust (br), a local-first, dependency-aware issue tracker for AI agents.

    1.1k GitHub stars~2.7k tokensUpdated yesterday
    DevelopmentAuto-check passed
  • Skillhone

    Tencent/SkillHone

    Local Issue, pull-request, and Wiki workbench for agent skills.

    168 GitHub stars~3.4k tokensUpdated 20 days ago
    DevelopmentAuto-check passed
  • Release

    ar-io/ar-io-node

    Drive the AR.IO Node release process end-to-end — preflight checks, prepare commit, finalize with image SHAs, test docker compose profiles, tag & publish, and post-release cleanup.

    127 GitHub stars~4.2k tokensUpdated yesterday
    DevOps & CloudAuto-check: notes

Works with

Categories

Questions about Codex Memory Trim

What does Codex Memory Trim 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…. Codex Memory Trim is an agent skill from Yu-Xiao-Sheng/codex-memory-trim.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).

When should I use Codex Memory Trim?

Codex Memory Trim fits situations like: the user asks to 精简/清理/整理/压缩 Codex 记忆.

How do I install Codex Memory Trim in Claude Code?

Run `npx skills add Yu-Xiao-Sheng/codex-memory-trim --skill codex-memory-trim -a claude-code`. Or copy the skill folder (skill in Yu-Xiao-Sheng/codex-memory-trim) into .claude/skills/codex-memory-trim in your project. Claude Code loads it when a task matches its description.

How do I install Codex Memory Trim in Codex?

Run `npx skills add Yu-Xiao-Sheng/codex-memory-trim --skill codex-memory-trim -a codex`. Or copy the skill folder (skill in Yu-Xiao-Sheng/codex-memory-trim) into .agents/skills/codex-memory-trim in your project. Codex loads it when a task matches its description.

Can I use Codex Memory Trim in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add Yu-Xiao-Sheng/codex-memory-trim --skill codex-memory-trim -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/codex-memory-trim, .gemini/skills/codex-memory-trim, .github/skills/codex-memory-trim and .opencode/skills/codex-memory-trim in your project.

What does Codex Memory Trim need to run?

Going by SKILL.md and its folder, Codex Memory Trim needs a shell and Python for the scripts in its folder and the command-line tools its instructions call (git, codex and python3). Our summary lists: Python 3; A Bash shell.

Does Codex Memory Trim access the network?

SKILL.md contains no URLs. Its commands use git, which can reach the network depending on how they are called. This is read from the text; nothing was executed.

Is Codex Memory Trim safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. The check reads SKILL.md only: the scripts in the folder are not scanned, so read them before running anything.

What licence does Codex Memory Trim use?

Codex Memory Trim is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Codex Memory Trim use?

About 453 tokens (SKILL.md is roughly 1.8k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Codex Memory Trim?

Skills that share tags, products or a category with Codex Memory Trim: Bd To Br Migration (Dicklesworthstone/beads_rust, 1.1k stars), Foremerge (naw103/foremerge, 538 stars), Puppetmaster Agent Orchestration (professorpalmer/Puppetmaster, 467 stars) and Br (Dicklesworthstone/beads_rust, 1.1k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Codex Memory Trim?

Yu-Xiao-Sheng (a GitHub user) maintains it in Yu-Xiao-Sheng/codex-memory-trim, which has 100 GitHub stars. The repository was last updated on August 25, 2026.

Source: Yu-Xiao-Sheng/codex-memory-trim on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.