context-canary — скилл для Claude Code: следит за деградацией
Ставит в каждый ответ метку-канарейку с именем, счётчиком ходов и самооценкой контекста. Заметно, когда агент перестаёт держать ранние инструкции.
npx skills add JuliusBrussee/skills --skill context-canary -a claude-codeЧто делает context-canary
Скилл вешает на агента постоянную инструкцию: первая строка каждого ответа — короткая метка вида **Julius · t14 · ctx ok**. Три поля проверяют разное. Имя показывает, что сама инструкция ещё в рабочем контексте. Счётчик ходов растёт на единицу за ответ, и сбой в нумерации выдаёт границу суммаризации. Самооценка ctx ok / ctx aging / ctx thin — честная оценка того, помнит агент ранние решения или достраивает их заново.
Смысл в том, что деградация контекста идёт тихо. Модель не сообщает, что перестала внимать инструкциям из начала сессии, а компакция молча выбрасывает постоянные указания. Канарейка превращает это в бинарную проверку на каждом ходу. Сломалась метка — значит, слабеет хватка на ранний контекст, и настоящие сбои (забытые ограничения, нарушенные конвенции) уже близко.
Когда метка пропадает дважды подряд или ломается счётчик, скилл запускает протокол восстановления: остановиться, записать состояние в файл вроде HANDOFF.md, перечитать CLAUDE.md и постановку задачи, сверить понимание с пользователем и начать сессию заново с этого файла. Метка живёт только в разговоре — вариант, записанный в CLAUDE.md, переживает компакцию и потому измеряет другое, более слабое. Проверка односторонняя: пропавшая метка — сильный сигнал, а присутствующая почти ничего не гарантирует.
Какие задачи решает
- заметить, что агент перестал держать инструкции из начала сессии
- поймать момент, когда компакция выбросила постоянные указания
- отличить реальную потерю контекста от ощущения, что что-то не так
- сохранить состояние задачи перед перезапуском сессии
- отследить, на каком ходу поплыла непрерывность диалога
Примеры запросов агенту
- поставь канарейку на эту сессию, имя — Юлий
- проверь канарейку: контекст ещё живой?
- канарейка пропала, что случилось
Как установить context-canary
1Через Skills CLI (Vercel)
npx skills add JuliusBrussee/skills --skill context-canary -a claude-code2Вручную: положить файлы
~/.claude/skills/context-canary/SKILL.mdПапка скилла целиком; для одного проекта — .claude/skills/context-canary/
1Через Skills CLI (Vercel)
npx skills add JuliusBrussee/skills --skill context-canary -a codex2Вручную: положить файлы
.agents/skills/context-canary/SKILL.mdДля всех проектов — ~/.agents/skills/
1Через Skills CLI (Vercel)
npx skills add JuliusBrussee/skills --skill context-canary -a cursor2Вручную: положить файлы
.cursor/skills/context-canary/SKILL.mdCursor читает и .agents/skills/, и .claude/skills/
1GitHub CLI
gh skill install JuliusBrussee/skills context-canary2Вручную: положить файлы
.github/skills/context-canary/SKILL.md1Через Skills CLI (Vercel)
npx skills add JuliusBrussee/skills --skill context-canary -a gemini-cli2Командой платформы
gemini skills install https://github.com/JuliusBrussee/skills --path skills/context-canaryВручную: положить файлы
.devin/skills/context-canary/SKILL.mdСтарый путь .windsurf/skills/ тоже читается
Через Skills CLI (Vercel)
npx skills add JuliusBrussee/skills --skill context-canary -a opencodeClaude.ai
Упакуйте папку в zip и загрузите в Settings → Capabilities → Skills
По шагам, с командами для каждой платформы: Как установить скилл в Claude Code: пять способов
Из того же набора7
Похожие
Рядом в теме «Настройка агента: память, контекст, субагенты»
Все скиллы по теме «Настройка агента: память, контекст, субагенты» →Вопросы о context-canary
Как установить context-canary в Claude?
Через менеджер скиллов: npx skills add JuliusBrussee/skills --skill context-canary -a claude-code. Файл скилла окажется в ~/.claude/skills/context-canary/SKILL.md.
Что делает context-canary?
Добавляет в каждый ответ первую строку с именем пользователя, счётчиком ходов и самооценкой контекста. Когда метка пропадает или счётчик сбивается, скилл запускает протокол восстановления.
Чем сессионная канарейка отличается от постоянной?
Сессионная живёт только в разговоре и ловит компакцию, усечение и дрейф. Записанная в CLAUDE.md переживает компакцию, поэтому проверяет лишь внимание к файловым инструкциям — сигнал слабее.
Исходный текст
SKILL.md · MIT
--- name: context-canary description: Install a per-turn canary signal (e.g. starting every reply with the user's name and a turn counter) so silent context degradation becomes visible the moment it happens, and run a recovery protocol when the canary trips. Use when the user mentions a "canary", "context canary", or "canary check", asks to detect context rot / compaction / drift, says "you stopped using my name" or "did you lose context", asks "how degraded is your context", or wants an early-warning system for long agent sessions. --- # Context Canary A context canary is a trivially checkable standing instruction whose only job is to fail visibly. The classic form: "start every response with my name." The agent costs almost nothing to comply — so when the name disappears, that absence is data. The instruction didn't get harder; the agent's hold on its early-context instructions got weaker. Like the coal-mine canary, it dies first, before the failures you actually care about (forgotten constraints, ignored conventions, re-litigated decisions) start landing in your code. This works because context degradation is **silent and gradual**. Models don't announce that they've stopped attending to instructions from 80k tokens ago, and compaction summaries quietly drop standing instructions. The canary converts an invisible failure into a binary, per-turn, zero-effort check. The research behind why this happens — context rot, lost-in-the-middle, instruction drift, compaction loss — is in **[references/research.md](references/research.md)**. ## When to use this skill - Installing a canary at the start of a long or high-stakes session. - The user notices the canary stopped appearing and asks what happened. - The agent itself realizes it can no longer find its canary contract in context. - The user asks how trustworthy the current context still is. ## The canary contract When invoked, install the canary by stating the contract explicitly in one short message, then follow it. Default format — first line of every response from then on: ``` **Julius · t14 · ctx ok** ``` Three fields, each probing something different: | Field | Example | What its failure means | |---|---|---| | Name | `Julius` | The standing instruction itself fell out of effective context — adherence drift or compaction dropped it. | | Turn counter | `t14` | Increment by 1 every response. A reset, skip, or repeat means continuity broke — almost always compaction or a summarization boundary. | | Self-check | `ctx ok` / `ctx aging` / `ctx thin` | The agent's honest estimate. `aging`: the session is long and early details are getting summarized in its own working sense of the task. `thin`: the agent is reconstructing earlier decisions instead of remembering them. | Use the user's actual name (ask if unknown). If the user wants the minimal version, name-only is fine — it's the original trick and still catches the big failures. Never explain, apologize for, or decorate the canary line; it must stay byte-stable so a human can pattern-match it in half a second. **Session canary vs. standing canary.** A canary that lives only in the conversation tests whether *conversation* context survives (compaction, truncation, drift). A canary written into `CLAUDE.md` or agent memory survives compaction by design — which means it tests whether file-based instructions are being attended to, a different and weaker signal. Default to the session canary; that's the one that detects degradation. Offer the standing variant only if the user wants the habit across all sessions, and tell them what it no longer measures. ## Emission rules 1. Canary is the **first line** of every response, including short ones, error reports, and responses after tool calls. 2. Increment the counter every response. If unsure of the count, that uncertainty IS a signal — emit `t?` and flag it, never guess a plausible number. 3. The self-check must be honest. Reporting `ctx ok` by reflex defeats the entire instrument. 4. If at any point the canary contract cannot be found in context (you only know about it from a summary, or not at all), **declare a trip yourself** — don't wait for the user to notice. ## Trip protocol A trip is: the canary missing, malformed, a counter discontinuity, or an agent-side self-declaration. Calibrate before alarming — one missed canary on an otherwise coherent response is a warning (note it, resume the canary, keep going). **Two consecutive misses, a counter discontinuity, or the agent failing its own contract check is a confirmed trip.** Then: 1. **Stop trusting drifted state.** Do not barrel ahead on the current task using context you can no longer vouch for. 2. **Checkpoint.** Write the durable state somewhere outside the conversation: current goal, decisions made and why, files touched, what's verified vs. in-progress, next step. A `HANDOFF.md` or notes file in the repo works. 3. **Re-anchor.** Re-read the project instructions (`CLAUDE.md`, the original task statement) and the checkpoint. State back to the user, in three or four lines, what you believe the task and constraints are — so they can correct any drift cheaply. 4. **Reset deliberately.** Recommend the user start a fresh session (or run an explicit compact) seeded with the checkpoint file, rather than limping on. Degraded context doesn't heal; it compounds. 5. **Re-install the canary** with the counter reset to `t1`, noting the generation: `t1 (gen 2)`. Never silently resume the canary after a gap as if nothing happened — that destroys the instrument's credibility, which is all it has. ## What the canary does and doesn't tell you The test is one-sided. A **missing** canary is strong evidence of degradation. A **present** canary is weak evidence of health — a cheap stylistic habit can survive while harder constraints (architecture decisions, "never touch X") quietly rot, and a canary stuffed into memory files can outlive the context it was meant to monitor. Treat the canary as a smoke detector, not a structural inspection: when it fires, act; when it's quiet, stay reasonably suspicious in sessions past roughly 50% of the context window or after any compaction event. Pair it with the cheap structural habits that reduce what the canary has to catch: keep durable decisions in files instead of chat, compact at deliberate boundaries instead of waiting for forced compaction, and prefer fresh sessions per task over one immortal session. Details and sources in **[references/research.md](references/research.md)**.
© JuliusBrussee · MIT · JuliusBrussee/skills