maintain-context

A maintenance workflow for the files that explain a project to coding agents, such as AGENTS.md, skills, and documentation. It checks whether those files still match the code and processes a learning inbox of discovered corrections and facts.

In plain words
What is it for?
Use it after a milestone, when context checks report errors or warnings, when the learning inbox has entries, or when project documentation needs a full review.
Why use it?
Out-of-date project instructions can quietly mislead an agent into using old commands, architecture, or rules. Regular checks remove stale information and preserve useful lessons.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/yangfan-code-star/context-dev/maintain-context
Any agent
npx skills add YangFan-Code-Star/context-dev --skill maintain-context
Clone the repo
git clone --depth 1 https://github.com/YangFan-Code-Star/context-dev

Made for: Claude Code, Codex.

Per session 98 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,003 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00098 $0.02003
Opus 5 $0.00049 $0.01001
Sonnet 5 $0.00020 $0.00401
Haiku 4.5 $0.00010 $0.00200

Measured yesterday against content hash ecc9e875fe23, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

maintain-context scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.agents/skills/maintain-context/SKILL.md · 126 lines

How it starts

The opening of the file, as written. The whole thing — 126 lines — stays where its author put it; the contents beside it link to each section on GitHub.

维护 agent 上下文

上下文文件的失效方式不是报错,而是安静地说谎:命令改了它还写着旧的,描述的架构已经不存在。而 agent 会照着旧信息自信地干活。所以需要定期体检。

流程

- [ ] 1. 跑自动检查脚本
- [ ] 2. 合并学习收件箱
- [ ] 3. 核对"事实类"内容
- [ ] 4. 核对"规则类"内容
- [ ] 5. 找缺口(孵化)
- [ ] 6. 删掉过期内容
- [ ] 7. 修文件并汇报

1. 自动检查

node scripts/audit-context.mjs

脚本查的是机械问题:AGENTS.md 行数与字节数、文档链接是否有效、技能 frontmatter 是否完整、TODO(init) 残留、上下文文件与代码的更新时间差、敏感文件是否被忽略、学习收件箱是积压还是长期闲置。

先把 error 全部修掉,warning 逐条判断。 其中 TODO(init) 是欠账:完整初始化应归零;轻量初始化留下的、带「轻量初始化未覆盖」的 TODO(init) 可以保留,由 /ship-change 按需补齐——体检会把轻量欠账单独计数,但它同样必须一直出现在 warning 里,不能被忘记。

2. 合并学习收件箱

把项目根目录的 docs/learning-inbox.md 里的条目逐条处理。对每条问同一个问题:「模型本来就猜得到吗?」 猜得到就删掉不合并——收件箱里塞进「要写测试」这种废话,是蒸馏环节的失误。

留下的,按条目类型分流,不要一律立即合并:

  • 已确认事实澄清):直接写进「建议去向」指向的文件,然后从收件箱里删掉这条。
  • 待观察模式纠正流程):先在收件箱里找有没有同类候选。没有 → 留在原地,等第二次出现再晋升;有 → 两条一起晋升为铁律或新技能,再删掉这两条。
  • 纠正里违反后果不可逆或不可发现的高风险规则:不必等第二次,立即升级为 AGENTS.md 铁律,并删掉该条。

合并时别照单全收:一条「纠正」如果和现有铁律重复,就强化现有那条而不是新增;一条「坑」如果只是环境一次性问题,记在 troubleshooting 但别升级成铁律。

这就是本体系唯一的数据来源——纠正信号,不靠自觉统计。 技能触发次数、文档读取频率没有可靠的 hooks 能自动记录,任何统计文件都只会漂移;而「agent 哪里不懂、被纠正了什么、卡了多久」是任务里自然产生的,天然可靠。

3. 核对事实类内容

AGENTS.md 逐行对照真实仓库:

声称 用什么核对
命令表 包管理文件里的 scripts / Makefile;并且真的跑一遍
目录地图 实际目录,看有没有新增顶层目录没写进去
术语表 代码里的实际命名
架构描述 docs/architecture.md 与实际的 import 关系
当前状态 docs/roadmap.md 与最近的提交

任何不一致,改文件,而不是改口径去迁就文件

4. 核对规则类内容

对每一条铁律问三个问题:

  1. 还成立吗? 描述的模式代码里还在用吗?换掉的技术要删掉对应规则,不要留着"历史参考"。
  2. 可执行吗? "注意性能"没法验证;"金额出现浮点数就是错的"可以验证。不可执行的改写或删掉。
  3. 值这个位置吗? AGENTS.md 每条铁律每次对话都花钱。只有"违反了会造成事故"的才配留下,其余降级进 docs/

对每个技能问:description 里有用户真实会说的话吗? 宿主只靠 namedescription 决定要不要加载正文,描述写成"帮助分析数据"这种,它永远不会被触发。

改动过任何一条铁律,就必须抽查 .agents/evals/behavior-cases.md 宿主不会加载 evals,没有任何脚本会跑它——人工抽查是它唯一的生效路径,不做它就只是一份没人读的散文。挑 3 条与本次改动最相关的用例,把「输入」原样发一遍,看反应是否落在「期望」里。用例已经被新铁律推翻的,当场改掉或删掉;铁律新增却没有对应用例的,补一条。这一步的结果写进汇报的「已修」。

5. 找缺口(孵化)

下面的阈值与第 2 步是同一套规则:同一个信号第二次出现,就从对话升级成文件。 第 2 步已经把「纠正 / 流程」类的待观察候选留在收件箱里,这里回顾的是那些还没进收件箱、只在对话里出现过的信号。

Read the full file on GitHub · 126 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 126 lines · 98 tokens per session scan A ecc9e875fe23

Subscribe to this mod's changes

maintain-context is a skill published in the GitHub repository YangFan-Code-Star/context-dev (2 stars, last pushed 14d ago), licensed MIT. It adds 98 tokens to every session and 2,003 once invoked, about $0.0005 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

dsh-plugin-dev

开发 DeepSeek Harness (DSH) 插件的标准与权威参考:编写/修改/审查/调试 DSH/Cordis 插件、服务、事件、插件配置、模型工具、LLM 适配器、三种角色拆分、打包安装、workspace 包、cordis.yml 组合时使用;提到 DSH 插件、Cordis、plugin、服务、事件、工具、适配器即触发。 The authoritative standard for developing DeepSeek Harness (DSH) plugins — create, modify, review or debug DSH/Cordis plugins, services, events…

zimodzh/dsh-plugin-dev-skills · 156 tokens

agent-handoff

Cross-platform skill for Codex, Claude Code, and DeepSeek Harness (DSH) that creates, updates, compacts, rotates, repairs, and reviews durable repository handoffs. Use when bootstrapping cross-session memory; creating or maintaining AGENTHANDOFF.md and .agent-handoff files; adding AGENTS.md or .claude/CLAUDE.md rules…

WeirdSky924/agent-handoff-skill · 105 tokens

acontext-installer

Install Acontext, Login & Init Acontext Project, Add Skill Memory to Agent.

memodb-io/Acontext · 22 tokens

storage-analyzer

对 macOS 做一次只读存储分析,产出交互式 HTML 报告。流程:扫描 → 分析分级 → 生成网页 → 打开。.

Azzygoatcoder/agent-useful-skills · 319 tokens

brainstorming

You MUST use this before any creative work - creating features, building components, adding functionality, or modifying behavior. Explores user intent, requirements and design before implementation.

Azzygoatcoder/agent-useful-skills · 37 tokens

writing-plans

Use when you have a spec or requirements for a multi-step task, before touching code.

Azzygoatcoder/agent-useful-skills · 21 tokens