/install instruction-anchor-guard
Instruction Anchor Guard
Prevent loss or drift of user-critical constraints during compaction, session restart, or long multi-turn tasks.
When To Trigger
Trigger when any of these appear:
- User marks an instruction as important, critical, must, always, never, highest priority, rule, or constraint
- A task has more than 3 steps and spans multiple turns
- Compaction happened (or is likely) and the task has non-negotiable requirements
- Agent behavior shows possible drift from prior explicit user constraints
Anchor Ledger Schema
Store anchors in first available path:
memory/anchors.mdmemory/instruction-anchors.md.anchors.md(workspace root fallback only)
Entry schema (append-only, one section per anchor):
## Anchor: \x3Cid>
- **source**: \x3Csession-id|message-id|user>
- **instruction**: \x3Ccanonical instruction text>
- **verbatim**: \x3Cshort quote from user>
- **priority**: P0 | P1 | P2
- **scope**: global | session | task:\x3Cid> | channel:\x3Cid>
- **createdAt**: \x3CISO-8601 timestamp>
- **expiresAt**: \x3CISO-8601 timestamp or "never">
- **status**: active | paused | expired | superseded
- **signature**: \x3Cstable hash of canonical instruction>
- **supersedes**: \x3Canchor-id or none>
Workflow
1) Capture
- Parse latest user message for candidate anchor statements
- Keep only instruction/constraint content; remove examples/chatter
- Assign default values:
- priority: P1 (unless user says critical/highest -> P0)
- scope: session (unless user explicitly asks global/task scope)
- expiresAt: session end (unless user explicitly sets never/date)
2) Confirm for Broad Anchors
- If scope is
globalor priority isP0, ask a one-line confirmation before persisting - Do not auto-promote P2/P1 to P0 without explicit user intent
3) Persist
- Append anchor entry to ledger
- If new anchor conflicts with old same-scope anchor, mark old one
superseded - Never rewrite history silently; keep audit trail
4) Rehydrate (each turn and after compaction)
- Load active anchors (status=active and not expired)
- Build an in-memory
ANCHOR_SETsorted by priority and recency - Inject
ANCHOR_SETinto planning phase before tool execution
5) Drift Check (before final answer and before destructive actions)
- Compare current plan against active anchors
- On conflict:
- P0 conflict: stop and correct plan immediately
- P1 conflict: auto-correct and note adjustment
- P2 conflict: continue only if no user-level contradiction
- Emit
DRIFT_CHECKblock in response
Conflict Resolution
Priority order:
- System and safety policy
- User anchors (P0 > P1 > P2)
- Current-turn temporary preferences
Tie-breakers:
- More specific scope wins (
task>session>global) if same priority - Newer anchor wins if same priority and same scope
- Explicit user override wins only when safety is not violated
Output Template
When anchors exist, include this compact block:
ANCHORS_ACTIVE
| ID | P | Scope | Expires | Instruction |
|----|---|-------|---------|-------------|
| anchor-001 | P0 | global | never | Never perform destructive data deletion without confirmation |
PLAN_GUARD
- Current action: \x3Caction>
- Conflicts: none | \x3Canchor ids>
- Decision: clear | corrected | paused-awaiting-user
DRIFT_CHECK
- Last anchor sync: \x3Ctimestamp>
- Drift: no | yes
- Fix applied: \x3Cnone|what changed>
Safety Boundaries
- Never store tokens, API keys, passwords, cookies, or auth headers
- Never store raw personal data unless strictly required by user instruction
- Redact sensitive literals as
[REDACTED] - Store constraints, not datasets
- Do not execute destructive commands solely because an anchor exists; still require explicit confirmation for destructive actions
Expiry and Maintenance
- Mark
expiredwhenexpiresAt \x3C now - Support control intents:
/anchors list/anchors pause \x3Cid>/anchors resume \x3Cid>/anchors delete \x3Cid>/anchors pin \x3Cid> never
- Rotate ledger when > 200 entries into
memory/anchors-archive-YYYY-MM.md
Integration Notes
- Pair with
memory-self-healfor retry/fallback after drift correction - Pair with
task-execution-guardto enforce anchor checks at each milestone - Keep this skill deterministic and concise; avoid free-form interpretation when conflict exists\r
- Make sure OpenClaw is installed (local or Docker)
- Run the install command in chat:
/install instruction-anchor-guard - After installation, invoke the skill by name or use
/instruction-anchor-guard - Provide required inputs per the skill's parameter spec and get structured output
What is Instruction Anchor Guard?
Preserve user-critical instructions across long sessions and context compaction. Use when users mark constraints as important/must/always/never/highest-prior... It is an AI Agent Skill for Claude Code / OpenClaw, with 326 downloads so far.
How do I install Instruction Anchor Guard?
Run "/install instruction-anchor-guard" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.
Is Instruction Anchor Guard free?
Yes, Instruction Anchor Guard is completely free (open-source). You can download, install and use it at no cost.
Which platforms does Instruction Anchor Guard support?
Instruction Anchor Guard is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).
Who created Instruction Anchor Guard?
It is built and maintained by Dalomeve (@dalomeve); the current version is v1.0.0.