context-hygiene

context-hygiene is a skill for Claude Code from wrg32786/aigent-os. It costs 39 tokens per session (625 once invoked), scanned A, original, MIT.

A scheduled cleanup method for two project memory files: an active-priorities list and a dated session log. It archives older session entries and checks that file contents have not changed unexpectedly.

In plain words
What is it for?
Use it to archive old session-log blocks, retain recent entries, preserve archive links, and validate the file structure before editing.
Why use it?
It keeps context manageable without rewriting unfamiliar content or deleting records without an archive.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter. Also seen: agent in frontmatter.

Needs its repository: it runs a file that does not travel with it, so clone the repository first. The line is node daemons/nightly-context-hygiene.mjs --root <aigent-root>.

Good fit Use it to archive old session-log blocks, retain recent entries, preserve archive links, and validate the file structure before editing.

Compare 6 skills from other repositories ↓
Install

Getting it into your agent

It runs from inside its repository, so the clone comes first — what it calls does not travel with the file alone.

Clone the repo
git clone --depth 1 https://github.com/wrg32786/aigent-os
agentmods
npx agentmods add skills/wrg32786/aigent-os/context-hygiene

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for context-hygiene

README.md
[![agentmods](https://agentmods.dev/badge/skills/wrg32786/aigent-os/context-hygiene.svg)](https://agentmods.dev/skills/wrg32786/aigent-os/context-hygiene)
Your own site
<a href="https://agentmods.dev/skills/wrg32786/aigent-os/context-hygiene"><img src="https://agentmods.dev/badge/skills/wrg32786/aigent-os/context-hygiene.svg" alt="Measured on agentmods" height="20"></a>
Per session 39 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 625 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector warn 7 Sept 2026
SkillSpector: 1 finding, up to high

These are SkillSpector’s own severities. On a checked sample its high-severity flags on skills were ~96% false positives — a documented command, a public API, a “never do X” rule — so we show them as a caution to read, not a verdict. Why →

  • high Anti-Refusal · line 55
    Skill instructs the agent to omit warnings, disclaimers, or ethical commentary. Stripping safety caveats hides risk from the user and is a common jailbreak preamble.
    Fix: Remove instructions that suppress warnings, disclaimers, or ethical commentary. Let the agent surface safety-relevant caveats to the user.
How audits are shown
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.1 $0.00039 $0.00625
Opus 5 $0.00019 $0.00313
Sonnet 5 $0.00008 $0.00125
Haiku 4.5 $0.00004 $0.00063

Measured 7d ago against content hash 7672f45c749b, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-08, from the pricing page.

Security

Grade A, and why

context-hygiene 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 7d ago.

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.

skills/context-hygiene/SKILL.md · 82 lines

How it starts

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

/context-hygiene

This is the sole bounded compaction exception to the Session Log chronicle. It runs only when invoked, never while the framework is being installed or tested against a real vault.

Precondition

  1. Read vault/memory/SESSION_LOG.md and vault/memory/ACTIVE_PRIORITIES.md.
  2. Hash both exact byte streams with SHA-256.
  3. Run:
node daemons/nightly-context-hygiene.mjs --root <aigent-root>

Green means no edit is needed. Red permits only the bounded archive below. Unreadable or unfamiliar content is a failure, not permission to rewrite.

Session Log archive

The executable target schema uses newest-first dated H2 blocks. A canonical block starts with ## YYYY-MM-DD - title and contains one nonempty occurrence of each field:

  • Objective
  • Completed
  • Decisions
  • Open threads
  • Next action

Archival rules:

  • Keep the newest five live dated blocks.
  • Move older whole blocks to vault/memory/SESSION_LOG_ARCHIVE_<YYYY-MM-DD>.md.
  • Preserve source text and order.
  • Preserve frontmatter, title, schema guidance, and archive links.
  • Dedupe by exact dated heading plus block hash.
  • Refuse a block whose boundary cannot be determined without judgment.

Active Priorities archive

The mechanically checkable live shape contains:

  • exactly one ## Operating Mode: <mode> heading;
  • one to five live bullet priorities under ## Tier 1, ## Tier 2, or ## Tier 3 headings;
  • no placeholder priority;
  • one valid Last reviewed: YYYY-MM-DD line; and
  • no embedded ## Archived section.

Move only content explicitly marked stale, superseded, or archived to vault/memory/ACTIVE_PRIORITIES_ARCHIVE_<YYYY-MM-DD>.md. If removal requires a human decision, preserve it and report the gate.

Compare-and-swap

Immediately before each write, hash the live source again. If either hash differs from the precondition hash, abort with CONTEXT_HYGIENE_RACE. Archive must be durable before the source is trimmed.

After writing, re-run the checker. Only its literal CONTEXT_HYGIENE PASS receipt may record the checkpoint green. Return archive paths and before/after hashes in bounded detail. Never touch another memory file.

Read the full file on GitHub · 82 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. 7d ago First seen · 82 lines · 39 tokens per session scan A 7672f45c749b

Subscribe to this mod's changes

context-hygiene is a skill published in the GitHub repository wrg32786/aigent-os (18 stars, last pushed today), licensed MIT. It adds 39 tokens to every session and 625 once invoked, about $0.0002 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-09-01.