context-check command
Inspect context drift and refresh selected source-backed documents under existing authorization.
/ca:context-check$ca-context-check/ca-context-checkAvailability is read from each shipped host catalog. Preview-only commands are marked on the page.
What it does
Section titled “What it does”An optional, on-demand drift audit for the bypass case: a merge, a direct push, or a manual edit
outside a normal commit changed a tracked source file, so commit-gate’s auto-heal never got a
chance to fire (that heal runs automatically on every commit that touches a drift_trigger
source — this command is not that routine path). It reports every stale provenance-tracked doc,
then for each one offers a choice: reinspect the affected source, re-baseline supported unchanged claims, or defer.
An audit-only request is read-only until you select an action. A direct request for a scoped or full refresh already selects that work; there is no per-document approval ceremony. Use the safe writer’s preview and apply with current source identities, preserving unselected human content. The owner never stages or commits. The SessionStart drift line is the usual signal that this check is worth running.
/ca:context-checkTakes no arguments. Prefer /ca:status drift where the installed catalog declares it, or request a provenance drift audit directly. Both reach the same owner as this retained compatibility entry; neither selects repairs on your behalf.
Example
Section titled “Example”Illustrative output shape, not a captured host run:> /ca:context-check
Stale provenance-tracked docs (2): tech-stack: package.json (changed) security-controls: src/auth/session.py (missing)
For tech-stack: re-scout / re-baseline / defer?Legacy v1 entries with drift_trigger: true participate in the hash comparison. Managed v2
records also require their current document and source bindings to be assessed; missing or
unsupported coverage remains unknown. The helper
reports concrete paths as changed or missing; it does not compute a commit-age history from a
hash mismatch. Confirm missing-file versus unavailable-hash evidence before choosing a disposition.
A re-baseline updates an available recorded hash; it does not verify that a claim is still correct.
A missing source is not repaired by re-baselining. Deferring leaves the mismatch in place, without
creating a new decision or follow-up record. See Provenance and context drift.
When to reach for it
Section titled “When to reach for it”Skip it for routine maintenance — commit-gate’s auto-heal already covers the common case with no
manual step. Explicit full refresh of initialized context uses this same owner and keeps the
initialization marker; /ca:create-context owns initial population. A project-state snapshot
without a drift focus is /ca:status’s.
Related
Section titled “Related”Compatibility
Section titled “Compatibility”This compatibility route remains available for existing workflows. Use status drift for new work.
Route context
Section titled “Route context”Find this entry in the workflow atlas. Compare its related teaching maps, host spelling and context inputs. The exact procedure below remains the owner.
Source
Section titled “Source”Source — plugins/ca/commands/context-check.md (v3.7.0)
---description: "Inspect context drift and refresh selected source-backed documents under existing authorization."argument-hint: "(none)"disable-model-invocation: true---
# context-check
Inspect context drift or refresh selected source-backed documents. This includesdrift from a merge or external edit that commit-gate's Phase 5.5 auto-heal didnot cover, and an explicitly requested full refresh of initialized context.
This skill is NOT in the daily loop. Commit-gate auto-heal (Phase 5.5,`heal_worklist` for v1 and `v2_heal_worklist` for managed pairs) owns routinemaintenance. Reuse existing selection andauthorization for requested refresh; an audit-only request remains read-only.
<!-- catalog-compatibility-notice:start -->> Compatibility route. Prefer `/ca:status drift` for new explicit usage. The retained entry> and natural-language intent use this owner under> ${CLAUDE_PLUGIN_ROOT}/includes/command-compatibility.md.<!-- catalog-compatibility-notice:end -->
## Entry boundaries
Use this owner for a requested provenance drift audit, `/ca:status drift`, orthe explicit `/ca:context-check` compatibility entry. Explanation-only questionsand ordinary status snapshots remain read-only answers, not repair requests.Report first for an audit-only request. A direct request to refresh selecteddocuments or the full project context supplies that selection; reuse theexisting authorization instead of asking again per document. Never change anunselected derived document. This owner neither stages nor commits. Routinecommit-gate auto-heal is unchanged.
An **initialized refresh** belongs to this existing owner after an explicitselection. It is separate from initial population: do not call the initialized`/ca:create-context`/`/ca:init --brownfield` path, rerun the scaffolder,clear `<!--INITIALIZED-->`, or repeat context finalization. An ordinary statussnapshot and the initial `/ca:status drift` report are read-only. A declinedrefresh leaves every file unchanged.
## HTML knowledge repositories
Run `knowledge.py format` first (`${CLAUDE_PLUGIN_ROOT}/includes/knowledge.md`). When itreports `html`, use this section instead of the Markdown provenance flow below.
1. **Find what may be stale.** `knowledge.py stale` lists, per document, the records whose scoped paths or cited sources changed since that document's baseline commit. It is advisory: unlisted records are unaffected, and nothing is reset. A document with no baseline is reported as such, not as stale.2. **Report** the listed records and their changed paths before offering actions. An audit-only request stops here.3. **Refresh the selected records.** Reinspect only the changed paths those records rely on (the context-creation inspection and evidence rules apply), then `update` records whose claims changed, `add` newly observed ones and `retire` ones that no longer hold, each with its basis. An unchanged claim needs no write. A full refresh selected by the user covers all six categories.4. **Rebaseline** each document whose listed records were checked: `knowledge.py rebaseline <doc>`. Leave a deferred document's baseline alone so its records are listed again next time.
For an explicitly selected initialized brownfield acquisition, inspect therelevant source categories using the same evidence rules, then update onlyaffected observed knowledge. The existing `decompose` owner records theproject's intended target, delta, future phases and candidate work in itsseparate document. Preserve prior answers, ADR references, work IDs and theinitialized marker; record denied or uninspected scope as unknown. A candidateis not promoted by a context refresh. This extension does not make anordinary drift report a request to perform full acquisition.
Every write is a journaled, retry-safe engine operation; there is no preview toapprove and no provenance file to hand-write. `<!--INITIALIZED-->` and allhistory stay. Imported notes stay until a record replaces them.
## Pre-flight
Read these before computing drift:
1. `.codearbiter/.provenance/` — the per-doc provenance records. Load all records via `load_provenance_dir` from `${CLAUDE_PLUGIN_ROOT}/hooks/_provenancelib.py`.2. `.codearbiter/code-map.md` — coarse concern map; read to orient on which modules the stale docs govern.
## Flow
### Step 1 — Compute drift
Use `_provenancelib` helpers in this order:
1. `load_provenance_dir(root + "/.codearbiter/.provenance/")` — returns the provenance map `{doc: record}`.2. Collect all `drift_trigger: true` paths across all records.3. `batch_hash(paths, runner)` — hash every existing path in one git call.4. `compute_drift(provenance_map, current_hashes)` — returns a drift report `{doc: [{path, kind}]}` for docs that have stale sources.
Alternatively reuse the same logic as `startup_drift_line` by calling it fora human-readable summary, then inspecting `compute_drift` directly for detail.
The `entries`/Git-hash comparison above covers legacy v1 records only. Forevery enrolled v2 document, call `assess_context_provenance` with the boundedcurrent source/target snapshot and an action-boundary snapshot probe. Inspectits per-document states as well as aggregate coverage. A missing, corrupt orunsupported record, incomplete acquisition, partial hash or unchecked identityis unknown coverage, even when a neighboring v1 or v2 record is usable. Reportthe usable records and the unknowns separately; never turn an empty legacydrift report into a fresh verdict for v2. `v2_current` acknowledges matchingidentities only. `semantic: unverified` and `verified_fresh: false` remain inforce: only actual evidence can support a narrower semantic claim;changing hashes or choosing re-baseline does not perform that review.
Only if the relevant legacy drift report is empty and v2 coverage/identitieshave been checked without unknowns may this audit report no stale identities.That is not a claim that instruction-bearing facts are semantically verified.Only a separately explicit full initialized refresh selection may proceedwithout a stale-document list.
### Step 2 — Report stale docs
For each doc in the drift report, call `changed_scope(doc_provenance, drift)`to list its drifted paths. Present a concise report before offering actions:
```Stale docs (N): <doc>: <path1>, <path2> (changed | missing) ...```
Also present every enrolled v2 document's `v2_current`, `v2_stale` or unknownstate from Step 1. For `v2_stale`, derive a proposed affected scope from thatdocument's bounded evidence references and recheck the exact paths beforeselection; the legacy `changed_scope` list cannot discover v2 drift. Anunknown state needs a bounded recovery/inspection, not an inferred fresh orstale path. Do not offer an automatic write for an unbounded scope.
### Unsupported human content and owner reconciliation
An unsupported human Markdown layout, ambiguous duplicate anchor, unparseablecustom section or oversized document is a write refusal for that document, not a reason to erase it or abandon safetask-time reading. An unrelated unknown section in an otherwise supporteddocument remains unowned and byte-identical during a supported field update.Preserve exact bytes and report the specific unsupported or unowned span.Use the existing applicable instructions under their actual precedence for thecurrent task; referencing those instructions unchanged does not create a newnormative rule or require a new approval. Keep observed upstream conventionsand accepted ADR references source-scoped when they do not already govern thisproject. Surface a real conflict without silently displacing either source.
If the requested change would adopt or replace normative instructions, routethe proposal to its actual owner and obtain that owner's actual approval beforeany supported bounded update. Missing or legacy v1 provenance may use explicit native `adopt` with currentevidence and selected supported spans, preserving the old provenance preimage.An unsupported template still needs reconciliation through its actual owner ora supported writer transition. Its refusal never authorizes raw Write/Edit fallback or a regex rewrite.Task, question, audit, release and ADR files remain with their existing writers;do not normalize, recreate or edit their history during context refresh.
### Step 3 — Selected initialized refresh
Use the user's selected documents and affected scope. If only an audit wasrequested, offer reinspection, re-baseline and defer choices before writing.A request for full refresh already selects all five content documents and allsix logical categories; do not repeat that question. Record the selection andsource paths, then inspect only what those claims need. Keep the initializedmarker and prior history. Full inspection accounts for all six categories;incremental inspection does not claim a new full scan.
**re-scout / reinspect** — use direct bounded inspection or optional scopedagents for the selected claims. The context-creation evidence and gap rulesapply. When structured reports help, `join_scout_reports` tracks their declaredcoverage; a scoped result has `full_coverage: false`. The helper is not apermission or containment check. A missing report can be replaced by directinspection, but failed or uninspected work never becomes evidence of absence.Recheck changed source snapshots and resolve contradictions before theirclaims are written. Unrelated gaps do not hold independent selected work.
If claims still hold, a selected owned-field metadata refresh may keep documentbytes identical when current evidence changes the v2 provenance. Missingselection and unchanged proposed provenance refuse rather than claim a refresh.Surface the proposed content and provenance pair, inspect its source bindings,and apply within the selected authorization. Review consequential or disputedclaims independently when useful; a matching digest does not verify semantics.
**re-baseline** — the legacy v1 provenance choice may acknowledge a verifiedcosmetic change through its existing owner, where applicable. For an enrolledv2 content document, use only a selected owned field and the native boundedupdate with new, validated source evidence and changed proposed provenance.If no field is selected or the proposed pair is a true no-op, retain the stalepair and defer that selection. Never directly write the v2 provenance or usethe legacy `rebaseline` helper as a fallback for it.
**full refresh** — use bounded inspection across all six categories andsynthesize all five content documents from current evidence. Preserve unknownsand reconcile material user decisions under context-creation Phase 3–4. Do notenter its Phase 6 lock for an already initialized repository.
For a selected whole-document refresh, prepare a UTF-8 draft inside the workspacethat retains user-owned content outside the requested change. The installed CLIcollects bounded source hashes and chooses create/adopt/update from the currentpair. Substitute the actual inspected repository-relative source paths; repeat`--source` for each supporting file. For example:
```textpython "${CLAUDE_PLUGIN_ROOT}/hooks/init-codearbiter.py" --root "${CLAUDE_PROJECT_DIR}" --context-draft "context-code-map-draft.md" --document code-map --source "src/main.py"```
This retains an internal preview but does not change the content document orprovenance. Inspect the returned diff, then apply the exact returned referenceand digest:
```textpython "${CLAUDE_PLUGIN_ROOT}/hooks/init-codearbiter.py" --root "${CLAUDE_PROJECT_DIR}" --context-apply "<preview_ref>" --preview-sha256 "<preview_sha256>"```
The source list must support the draft; it is not an automatic semantic review.The convenience path records `semantic_review: unreviewed`. Use typed fieldpreviews below when only specific managed fields are selected.
For each selected document, send the typed preview through`python "${CLAUDE_PLUGIN_ROOT}/hooks/init-codearbiter.py" --root <exact-root> --context-request <request-file>`.The request uses `operation: preview` and a `preview` object. Native`context-preview` supports `create` for a genuinely absent document, explicit`adopt` for supported missing/v1 provenance, and `update` for a managed v2 pair.Supply the exact expected document/provenance hashes, selected fields, typedcontent and source evidence. Keep request files inside the workspace.
Inspect the returned diff and preserved content. Apply with `operation: apply`,`preview_ref` and `preview_sha256` through the same bridge;native `context-apply` rechecks the preview and current identities under itslock and writes the selected document/provenance pair together. No approvalreceipt, actor ticket or qualified scout profile is a prerequisite for ordinaryalready-authorized refresh. This is compare-and-swap protection, not a secondpermission system. A stale preview requires reinspection, never an overwrite.After a lost response, inspect the transaction and retry its identical requestand operation ID or use native recovery; do not start a duplicate write.
Read back the committed pair and confirm `<!--INITIALIZED-->` remains for`CONTEXT.md`. Keep unowned spans byte-identical and retain legacy provenancehistory. Task, question, audit, release and ADR history stay with their actualwriters. Never hand-write a provenance record or bypass a refused unsupportedshape. A missing safe writer stops that write, not authorized task-time reads.
**defer** — do nothing for this doc now. The drift line will reappear at thenext SessionStart. Use when the change is in-progress and the doc update shouldwait for a later commit.
After processing selections, summarize changed documents, deferred selections,the declared coverage, and whether the run was full or incremental. Keepunselected content, initialized state and prior history intact.
## Hard rule
This skill MUST NOT commit. If re-scout or re-baseline produces updated`.codearbiter/.provenance/` records, those file changes ride the nextuser-initiated commit through commit-gate normally. No staging, no commits here.