Khaos-Brain: Skill for Codex

.agents/skills/kb-sleep-maintenance/SKILL.md

kb-sleep-maintenance is a skill for Codex from liuyingxuvka/Khaos-Brain. It costs 37 tokens per session (1,431 once invoked), scanned A, original, MIT.

An automatic maintenance cycle for a repository-managed predictive knowledge base. It runs Sleep first to decide and publish the canonical knowledge model, then runs Dream as an immutable simulation.

In plain words
What is it for?
Use it for the scheduled local maintenance cycle or when explicitly asked to run local knowledge-base maintenance.
Why use it?
It keeps knowledge-base maintenance ordered, serialized, and governed by one canonical writer instead of competing update processes.

Skill for Codex

Written for Codex: agents/openai.yaml present. Also seen: installed under .agents/ (shared by several agents).

This is liuyingxuvka/Khaos-Brain's own configuration. It tells Codex how to work on Khaos-Brain itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything Khaos-Brain configures →

Reuse

Borrowing it

Nothing to install: this file belongs to liuyingxuvka/Khaos-Brain. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/liuyingxuvka/Khaos-Brain/main/.agents/skills/kb-sleep-maintenance/SKILL.md
Clone the repo
git clone --depth 1 https://github.com/liuyingxuvka/Khaos-Brain

Made for: Codex.

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 kb-sleep-maintenance

README.md
[![agentmods](https://agentmods.dev/badge/skills/liuyingxuvka/khaos-brain/kb-sleep-maintenance/github.svg)](https://agentmods.dev/skills/liuyingxuvka/khaos-brain/kb-sleep-maintenance)
Your own site
<a href="https://agentmods.dev/skills/liuyingxuvka/khaos-brain/kb-sleep-maintenance"><img src="https://agentmods.dev/badge/skills/liuyingxuvka/khaos-brain/kb-sleep-maintenance/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for kb-sleep-maintenance

Your own site · 80×15
<a href="https://agentmods.dev/skills/liuyingxuvka/khaos-brain/kb-sleep-maintenance"><img src="https://agentmods.dev/badge/skills/liuyingxuvka/khaos-brain/kb-sleep-maintenance.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 37 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,431 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.
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.00037 $0.01431
Opus 5 $0.00018 $0.00715
Sonnet 5 $0.00007 $0.00286
Haiku 4.5 $0.00004 $0.00143

Measured 12d ago against content hash 9d7f1f42b328, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-12, from the pricing page.

Security

Grade A, and why

kb-sleep-maintenance 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 12d 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.

.agents/skills/kb-sleep-maintenance/SKILL.md · 49 lines

How it starts

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

KB Sleep Maintenance

Sleep is the sole knowledge-decision and canonical model-generation owner. The scheduled local task is one serialized cycle: Sleep freezes and publishes first; only after an unblocked completed Sleep terminal does the same task run the existing immutable Dream simulation. Dream never publishes authority. Readable cards and the active index are deterministic projections of Sleep's authority.

Authority and entrypoint

Work from the repository root. Read PROJECT_SPEC.md, docs/maintenance_agent_worldview.md, docs/maintenance_runbook.md, and .agents/skills/local-kb-retrieve/MAINTENANCE_PROMPT.md. Current user instructions override repository defaults.

Run:

python .agents/skills/local-kb-retrieve/scripts/kb_sleep.py --json

The native lifecycle implementation owns all mutation, terminal validation, and its immutable run receipt. Do not create a parallel Sleep implementation or a second model writer.

Required behavior

  1. Acquire the independent local-cycle task lease and preserve the same run id through closure. The wrapper owns the complete local cycle; do not launch a separate Dream automation. Acquire the sole global KB writer only around mutation phases, delegate its exact token to the child phase, and release it promptly so the independent organization task can continue.
  2. Resume the exact open frozen batch before admitting later work. If no batch is open, freeze one finite ordered batch_plan with immutable item identities, input watermark and digest, current-generation identity, prior convergence streak, and tested batch-size bounds. The persistent batch_head binds the exact plan and checkpoint digests. Later arrivals never expand that batch.
  3. Give every settled frozen item exactly one verified completed disposition or one explicit blocked disposition with a named owner and executable reopen condition. Persist each item result and the batch checkpoint before continuing so a later Sleep reuses verified work and reprocesses at most the incomplete item.
  4. Create or reuse one stable candidate only when a bounded scenario-action-result relation and sufficient evidence exist. Represent it immediately as a LogicGuard model revision with a root Claim, explicit Context and Method, typed support or challenge nodes, and explicit gaps. Never invent Evidence, Warrant, Assumption, Rebuttal, or Limitation merely to fill the model.
  5. Keep trusted promotion evidence-dependent. Require current independent validation; weak or duplicated evidence never satisfies promotion.
  6. Park unresolved candidates with a machine-evaluable reopen condition and a seven-day decision boundary. Reopen exactly once only after a material qualifying evidence delta.
  7. Immediately exclude strong contradictory trusted knowledge and complete its downgrade review in this Sleep pass.
  8. Consume each typed Dream model-gap handoff exactly once, record one acknowledgement, and let Dream remain an immutable simulation owner only. Dream runs as the second phase of this task only after Sleep publishes cleanly; blocked or progress-saved Sleep leaves Dream not_run.
  9. Assemble exact model revisions into physically separated public, private, and candidate ModelMeshes. Admit a canonical cross-model relation only when qualifying non-AI provenance supports it. Co-use, lexical similarity, and retired related_cards values remain unresolved grounding proposals, never edges.
  10. Audit each important model for missing context, action, evidence, warrant, assumption, opposition/rebuttal, and boundary conditions. Give every absence one stable open disposition, required grounded input, and machine-readable reopen condition; never invent the missing content.
  11. Stage models, meshes, deterministic readable projections, the exact active index, and generation manifests away from the current generation. Validate the complete staged generation before one atomic pointer switch written last. Ordinary planning, progress_saved, timeout, or pre-activation failure keeps the prior validated generation readable and never treats pending work as current-generation corruption.
  12. Exclude rejected, merged, superseded, parked, retired, deprecated, history-only, provenance-incomplete, and contradicted records from retrieval projection.
  13. Commit the new watermark only after every frozen item is settled and dispositions, model/mesh publication, lifecycle review, handoff acknowledgements, exact index validation, and the final pointer switch are durable. progress_saved and failure keep the previous committed watermark unchanged.
  14. Do not require a human to read files, choose cards, or approve ordinary maintenance decisions. Escalate only a real safety or authority boundary.
  15. Stop starting new items at the 660-second native soft deadline, durably seal the checkpoint, release every delegated/global writer token, and return progress_saved before the outer hard timeout. The complete Sleep plus Dream cycle uses a 2400-second native timeout inside a 2700-second owner timeout, with larger aggregate and installer owners; timeout never means success and requires confirmed zero-descendant cleanup. One malformed item may settle as blocked only with a named owner and executable reopen condition; publish completed siblings as completed_with_blocks, never repeat them, and record only the Dream phase as not_run. The independent organization task is never cancelled or rewritten by local failure. The target-owned wrapper owns same-run terminalization; do not invoke a status helper or retry the child.

Read the full file on GitHub · 49 lines

Files

What ships with it

4 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

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. 12d ago First seen · 49 lines · 37 tokens per session scan A 9d7f1f42b328

Subscribe to this mod's changes

kb-sleep-maintenance is a skill published in the GitHub repository liuyingxuvka/Khaos-Brain (37 stars, last pushed 1mo ago), licensed MIT. It adds 37 tokens to every session and 1,431 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-08-30.

Related

Other skills, from other repositories

knowledge-base

Skill "knowledge-base" from Pinvou/pinvou-agent, covering ima knowledge base, operations, routing rules, examples and file upload guard.

Pinvou/pinvou-agent · 0 tokens

notes

Skill "notes" from Pinvou/pinvou-agent, covering ima notes, operations, write rules, examples and response handling.

Pinvou/pinvou-agent · 0 tokens

shodh-memory

Persistent memory system for AI agents. Use this skill to remember context across conversations, recall relevant information, and build long-term knowledge. Activate when you need to store decisions, learnings, errors, or context that should persist beyond the current session.

varun29ankuS/shodh-memory · 53 tokens

vault

Search, read, write, and manage files in the Kept conversation vault. Use when the user asks about past conversations, wants to save notes, needs to find specific content, or wants to organize their vault.

egroup-labs/kept · 45 tokens

knowledge-ingestion

A skill for saving links, social posts, videos, podcasts, screenshots, PDFs, local files, or text into an Obsidian knowledge base, a personal collection of searchable notes. The ingestion tools analyse and format the material for storage.

lyc403223157-source/knowledge-inbox · 112 tokens

personal-knowledge-ingestion

A skill for saving links, videos, social posts, local files, screenshots, PDFs, or text into an Obsidian vault, a folder used for personal notes and knowledge. It uses connected knowledge tools to process and format the saved item.

lyc403223157-source/knowledge-inbox · 86 tokens