Logo Context Memory Hygiene

Context Memory Hygiene

Cộng đồng
rlaope
context-memory-hygiene

Invoke when deciding what to load into context, what to persist across turns or sessions, and what to drop — reads only what the task needs, writes durable handoffs, avoids context pollution, and chooses when to re-derive versus recall.

Tổng quan

Nhà phát hànhrlaope
Kho mãultraprompt
Tên kỹ năngcontext-memory-hygiene
Sao
36
Bản fork
6
Tệp đi kèm
1
Giấy phépMIT
Liên kết
  • Hướng dẫn bằng Markdown

    Tệp SKILL.md được mô hình tải khi cần, nên chỉ tốn token khi có yêu cầu thực sự phù hợp.

  • Dùng được với mọi LLM

    Kỹ năng AI là Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên dùng được với GPT, Claude, Gemini, Grok hoặc mô hình cục bộ.

  • 1 tệp đi kèm

    Các tập lệnh, mẫu và tài liệu tham khảo mà mô hình có thể đọc khi làm việc. Các tệp chỉ cho phép đọc và không bao giờ được thực thi.

  • Mã nguồn mở

    Được rlaope công bố trên GitHub. Hãy đọc nội dung nguồn trước khi cài đặt.

Cài đặt

Cài đặt kỹ năng AI Context Memory Hygiene trong TypingMind để dùng với bất kỳ LLM nào, hoặc thêm vào một tác nhân AI khác có thể đọc SKILL.md.

1

Cài đặt trong TypingMind

TypingMind cài đặt kỹ năng trực tiếp từ thư mục GitHub — đọc SKILL.md, đóng gói các tệp tài nguyên và lưu kết quả trên máy.

  1. Mở ứng dụng và vào Plugin → Kỹ năng.
  2. Chọn "Cài đặt từ GitHub".
  3. Dán URL thư mục kỹ năng bên dưới và xác nhận.
    https://github.com/rlaope/ultraprompt/tree/main/skills/context-memory-hygiene
  4. Bật kỹ năng trong từng cuộc trò chuyện mà bạn muốn sử dụng kỹ năng đó.
Plugin → Kỹ năng → Thêm kỹ năng → Từ URL GitHub, sau đó dán URL thư mục và nhấn Tiếp tục.
2

Cài đặt trong tác nhân AI khác

Bất kỳ tác nhân AI nào đọc được định dạng Agent Skills đều có thể dùng kỹ năng này — hãy sao chép thư mục vào thư mục kỹ năng của tác nhân AI đó.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/rlaope/ultraprompt.git /tmp/ultraprompt
mkdir -p .claude/skills
cp -r /tmp/ultraprompt/skills/context-memory-hygiene .claude/skills/context-memory-hygiene
Khởi động lại Claude Code sau khi sao chép để ứng dụng nhận kỹ năng mới.

Sử dụng trong TypingMind

Bật Context Memory Hygiene trong bất kỳ cuộc trò chuyện nào trên TypingMind, mô hình sẽ tự xử lý phần còn lại. Tên và mô tả của kỹ năng nằm trong prompt hệ thống. Ngay khi có yêu cầu phù hợp, mô hình tự tải toàn bộ hướng dẫn — bạn không cần gọi thủ công và kỹ năng không tốn token cho đến khi thực sự được dùng.

Mô hình tự tải Context Memory Hygiene ngay khi có yêu cầu phù hợp.

Dùng được với mọi mô hình AI

Kỹ năng AI là các hướng dẫn Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên Context Memory Hygiene không bị giới hạn ở mô hình mà kỹ năng này được viết cho. Chỉ cần cài đặt một lần trong TypingMind rồi dùng với GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama hoặc mô hình cục bộ do bạn tự chạy — tất cả đều dùng khóa API của riêng bạn.

  • Chỉ tải khi cần

    Prompt hệ thống chỉ chứa tên và mô tả. Hướng dẫn được tải khi có yêu cầu phù hợp đầu tiên, nên kỹ năng chưa dùng không tốn chi phí.

  • Đổi mô hình ngay trong cuộc trò chuyện

    Vì kỹ năng là hướng dẫn chứ không phải mã, việc đổi mô hình không làm kỹ năng ngừng hoạt động — mô hình tiếp theo vẫn đọc cùng tệp SKILL.md.

Hướng dẫn của kỹ năng

Đây là nội dung SKILL.md mà mô hình tải. Hãy đọc trước khi cài đặt — kỹ năng là những hướng dẫn mà mô hình của bạn sẽ làm theo.

Context & Memory Hygiene

Status: v0.1 baseline draft — derived from the case catalog and axis definitions; awaiting trace evidence from Fable 5.1 case runs.

When to apply

  • You are about to read files, dump logs, or pull in references and must decide how much to actually load.
  • The context window is filling and older content is at risk of being crowded out or compacted.
  • A session will resume later, or hand off to another agent, and state must survive the boundary.
  • You are unsure whether to trust a remembered value or re-derive it from the current source.
  • You caught yourself loading a whole file/log/repo to use one function or one line from it.
  • Work spans multiple sessions and you need a durable record that is not the transcript itself.

Core loop

  1. State what the current step actually needs. Before loading anything, name the specific fact, symbol, or slice the next action requires. "I need the signature of parseConfig", not "I need the config module". The need defines the read, not the file size.

  2. Read the minimum that satisfies the need. Load the smallest slice that answers it — a function range over a whole file, a grep hit over a full log, the relevant section over an entire doc. Broad reads spend context you will want later for reasoning.

  3. Distinguish durable facts from transient noise. As you work, separate the few facts worth keeping (the decision made, the interface agreed, the root cause found) from the bulk you can discard (intermediate output, explored-and-rejected paths, raw dumps). Only durable facts earn a place in persisted memory.

  4. Persist durable state outside the transcript. Write what must survive a resume or handoff into a real artifact — a handoff note, a state file, a scratch record — not just the conversation. Context can be compacted or lost; an artifact is recallable. Capture: goal, current state, what's done/verified, what's open, the next action.

  5. Drop what no longer pays rent. Actively let go of content whose job is done: closed sub-investigations, superseded plans, verbose output you already extracted the answer from. Keeping it "just in case" pollutes the context that steers you.

  6. On resume, re-ground before you trust recall. After a resume or compaction, re-read the handoff artifact and re-probe anything that may have changed, rather than acting on a possibly-stale memory of where things stood. Recall is a hypothesis until re-grounded.

  7. Choose re-derive vs recall by cost and staleness. Recall a fact if it is cheap-to-store and stable; re-derive it if it is stale-prone or cheaper to recompute than to have carried. A branch name, a file's current contents, a test result after edits — re-derive. A design decision or an interface contract — recall from the persisted note.

  8. Keep the working set lean. Periodically ask what is currently loaded that no longer serves the task, and shed it. A tight working set of exactly-relevant context outperforms a large one padded with residue.

Heuristics

  • Load the slice, not the file: a function range or grep hit beats reading the whole thing for one fact.
  • If you extracted the answer from a dump, drop the dump; keep the answer.
  • Anything that must outlive this session goes in an artifact, never only in the transcript.
  • A handoff note has five fields: goal, state, done/verified, open, next action — write all five.
  • Re-derive stale-prone facts (branch, file contents, test status after edits); recall stable ones (decisions, contracts).
  • After compaction or resume, treat every prior fact as unverified until re-grounded from an artifact or probe.
  • "Might need it later" is how context fills with noise; load on demand, not on speculation.
  • Prefer one lean reference over three overlapping ones; redundant context dilutes the signal that steers you.
  • Cost test for recall: if re-deriving is cheaper than the risk of acting on a stale memory, re-derive.
  • The transcript is not memory: important state survives only if you deliberately wrote it somewhere durable.
  • Summarize before you compact, not after: distill the durable facts into an artifact while the detail is still in context, because after compaction the detail you needed to summarize is already gone.
  • Load references at the moment of use, not at the start "to have them"; early bulk reads age into noise.

Anti-patterns

  • Load-everything. Reading an entire file, log, or module to use one symbol from it, crowding out the context you need for reasoning. → Corrective: name the need, load the slice that answers it, stop there.
  • Transcript-as-memory. Assuming important state is safe because it's "in the conversation", then losing it to compaction. → Corrective: persist durable facts into an artifact the moment they're established.
  • Stale recall after resume. Acting on a remembered branch, value, or file state that changed while you were away. → Corrective: re-read the handoff and re-probe changeable facts before the first action.
  • Hoarding. Keeping closed investigations, rejected paths, and raw output "just in case", polluting the working set. → Corrective: drop content once its answer is extracted; a lean context steers better.
  • Redundant re-derivation. Re-computing an expensive, stable fact every time instead of recording it once. → Corrective: persist stable decisions and contracts; re-derive only what actually goes stale.
  • Handoff amnesia. Ending a session or delegating without writing down goal/state/open/next. → Corrective: write the five-field handoff before the boundary, not after someone asks where things stood.

Relation to existing axes

  • vs exploration-strategy: exploration is about acquiring an accurate model of an unfamiliar codebase — what to read to understand it. Context-memory-hygiene is about managing what stays loaded, persisted, or dropped once acquired — the economics of the window and cross-session memory. Exploration decides what to learn; this decides what to keep, write down, and let go.
  • vs incremental-safety: incremental-safety keeps the system green across a sequence of edits. Context-memory-hygiene keeps the agent's working context clean and its cross-session memory intact. One guards the code's state between steps; the other guards the agent's state between turns and sessions.

Worked example

Illustrative construction, not a recorded run.

Task: "Continue the migration from the handoff — three tables done, four to go." Resumed session, context was compacted.

Agent does NOT trust its faded memory of "three done" → re-grounds first: re-reads the handoff artifact
    (.omc/handoffs/migration.md) for goal/state/done/open/next.
Handoff says tables A,B,C migrated; D next; interface contract = new `id` is uuid not int (a durable decision).
Agent re-derives the stale-prone facts rather than recalling: `git status` (working tree state) and a probe
    of which tables actually exist migrated in the DB — because those could have changed since the note.
Probe disagrees with the note: table C's migration is half-applied. The note was optimistic. Agent trusts
    the live probe over recall, fixes C first.
For table D, agent needs one thing: the source schema of D. Loads only that table's DDL, not the whole
    schema dump — keeps the window free for the reasoning.
After migrating D and verifying, agent extracts the result, DROPS the verbose migration log, and updates
    the handoff (state: A–D done+verified, E next, uuid-contract still holds).
Exit: durable contract recalled from artifact, stale progress re-derived by probe, working set kept to the
    one table in flight — no context spent on the four not-yet-touched tables.

Trace evidence

CaseSessionWhat it showed
awaiting case runs——

Tệp đi kèm

Mô hình đọc các tệp này khi cần trong lúc kỹ năng được tải. Các tệp được cung cấp ở dạng có thể đọc và không bao giờ được thực thi.

Câu hỏi thường gặp

Kỹ năng AI Context Memory Hygiene làm được gì?

Invoke when deciding what to load into context, what to persist across turns or sessions, and what to drop — reads only what the task needs, writes durable handoffs, avoids context pollution, and chooses when to re-derive versus recall.

Vì sao nên dùng Context Memory Hygiene trên TypingMind?

Vì bạn chỉ cần cài một lần rồi dùng với bất kỳ mô hình nào. Context Memory Hygiene là nội dung Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên cùng một kỹ năng có thể chạy trên GPT-5, Claude, Gemini, Grok hoặc mô hình trên thiết bị — và bạn có thể đổi mô hình ngay trong cuộc trò chuyện mà kỹ năng vẫn hoạt động. TypingMind dùng khóa API riêng của bạn, nên bạn thanh toán trực tiếp cho nhà cung cấp thay vì trả phí thuê bao theo suất người dùng, đồng thời kỹ năng và các cuộc trò chuyện vẫn nằm trong bộ lưu trữ của bạn.

Làm thế nào để cài Context Memory Hygiene trong TypingMind?

Mở Plugin → Kỹ năng → Cài đặt từ GitHub trong TypingMind rồi dán https://github.com/rlaope/ultraprompt/tree/main/skills/context-memory-hygiene. TypingMind đọc tệp SKILL.md, đóng gói các tệp đi kèm và cài đặt thành một kỹ năng mà bạn có thể bật cho từng cuộc trò chuyện.

Những mô hình AI nào có thể dùng Context Memory Hygiene?

Bất kỳ mô hình nào bạn kết nối trong TypingMind. Kỹ năng AI là các hướng dẫn bằng Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên GPT, Claude, Gemini, Grok và các mô hình chạy trên thiết bị đều có thể tải kỹ năng này khi có yêu cầu phù hợp.

Bạn có thể dùng Context Memory Hygiene với bao nhiêu mô hình AI?

Bao nhiêu cũng được. Miễn là mô hình hỗ trợ kỹ năng, bạn có thể dùng Context Memory Hygiene với mô hình đó — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama và nhiều mô hình khác — tất cả đều trên TypingMind với khóa API riêng của bạn.

Kỹ năng AI Context Memory Hygiene có miễn phí không?

Có. Kỹ năng này được rlaope phát hành trên GitHub theo giấy phép MIT. Bạn chỉ trả tiền cho nhà cung cấp AI của mình theo số token đã dùng.

Kỹ năng AI là gì?

Kỹ năng AI là một gói hướng dẫn có thể tái sử dụng, chỉ cho mô hình AI cách thực hiện một tác vụ cụ thể. Kỹ năng tuân theo định dạng mở Agent Skills: một tệp SKILL.md chứa tên và mô tả, cùng các tập lệnh, mẫu hoặc tệp tham khảo mà mô hình có thể cần. Mô hình chỉ đọc hướng dẫn khi yêu cầu của bạn phù hợp với kỹ năng, nên kỹ năng đã cài đặt không phát sinh chi phí cho đến khi được sử dụng.

Kỹ năng AI khác gì với plugin hoặc máy chủ MCP?

Plugin hoặc máy chủ MCP cung cấp cho mô hình các công cụ mới để gọi — mã được chạy ở đâu đó và trả về kết quả. Còn kỹ năng AI cung cấp kiến thức và quy trình: cách tiếp cận tác vụ, các bước cần thực hiện và tiêu chí của đầu ra tốt. Kỹ năng chỉ là nội dung Markdown, nên không cần máy chủ, khóa API hay môi trường thực thi và hoạt động với mọi mô hình.

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇