--- name: anchor-protocol description: Persistent project orientation and trajectory alignment protocol for AI coding agents. Enforces pre-flight orientation, active constraints, rejected path avoidance, and progressive architectural crystallization without session history pollution. version: 1.0.0 license: Apache-2.0 author: VorteXpert Labs (https://github.com/vortexpert-labs) compatibility: ["claude-code", "gemini-cli", "antigravity", "cursor", "copilot", "cline", "windsurf", "universal-agents"] metadata: tier: 0 cache_optimization: prefix_preserving --- # Anchor Protocol Universal Agent Skill **Organization:** [VorteXpert Labs](https://github.com/vortexpert-labs) **Author:** [Sabber Ahamad Emon](https://github.com/sabber-ahamad-emon) ## 1. Core Purpose The Anchor Protocol provides persistent, crystallized project orientation across multi-session AI development. It prevents goal drift, decision amnesia, and zombie re-exploration while keeping prompt overhead bounded to $\mathcal{O}(1)$ (~400 tokens) via progressive disclosure. ## 2. Epistemic Invariants - **Code** is the authority on *what is currently implemented*. - **Anchors (`.anchors/`)** are the authority on *project stage, goals, active constraints, and negative boundaries*. - **Rule of Supremacy:** Never modify working code to match a stale anchor without explicit human confirmation. ## 3. Universal Bootstrap Protocol (When Asked to Install/Init) When instructed by a user to *"Add/integrate Anchor Protocol from https://github.com/vortexpert-labs/anchor-protocol"*: 1. **Check for Existing Repository Assets:** - If `.anchors/INDEX.md` is absent, create `.anchors/` and copy/generate `schema.json` and `INDEX.md`. - In existing codebases, scan manifest files (`package.json`, `go.mod`, `Cargo.toml`, `pyproject.toml`) and establish 3–5 initial anchors (`STAGE`, `DECISION`, `CONSTRAINT`, `BOUNDARY`). 2. **Inject Platform Adapter Non-Destructively:** - Identify the host agent environment and inject the standard delimited adapter block into the appropriate file (`AGENTS.md`, `CLAUDE.md`, `.cursor/rules/anchor-protocol.mdc`, `.github/copilot-instructions.md`, `.windsurfrules`, or `.clinerules`): ```markdown ## Project Orientation & Anchor Protocol This repository uses the **Anchor Protocol** for persistent project orientation. - **Canonical Index:** `.anchors/INDEX.md` - **Pre-flight Sequence:** Inspect `.anchors/INDEX.md` before executing multi-file architectural changes. - **Invariant Rules:** Obey all `ACTIVE` constraints and never re-attempt `REJECTED_PATH` anchors. - **Crystallization:** When establishing a consequential architectural decision or discovering a fatal flaw in an approach, draft an anchor in `.anchors/ANC-XXXX-[slug].md` with `status: PROPOSED`. - **Anti-Pollution:** Never write raw conversation transcripts, bug stack traces, or temporary logs to `.anchors/`. ``` ## 4. Standard Agent Operating Procedure (AOP) ### Phase 1: Pre-flight Orientation 1. Inspect `.anchors/INDEX.md` before generating plans or multi-file edits. 2. Ingest `INDEX.md` to identify: - Current **Project Stage** (`PROTOTYPE`, `ALPHA`, `PRODUCTION`, `MAINTENANCE`). - Active **Goals** and non-negotiable **Constraints**. - Prohibited approaches (`REJECTED_PATH`). 3. If user prompts conflict with an `ACTIVE` constraint, flag the conflict immediately and request guidance before writing code. ### Phase 2: In-flight Execution & Targeted Consultation 1. When modifying a subsystem governed by a specific anchor, read that targeted `ANC-XXXX.md` file using file-reading tools. 2. Do NOT read all anchor files by default; utilize progressive disclosure to minimize context bloat. ### Phase 3: Crystallizing Consequential Anchors When an architectural decision, project stage transition, or failed technical approach is established: 1. Apply the **4-Question Litmus Test**: - Is it durable across $>3$ weeks? - Is the rationale invisible from code syntax alone? - Does it prevent future agents from repeating a failed path? - Can it be stated in 1–3 dense invariant propositions? 2. If YES, draft an anchor in `.anchors/ANC-XXXX-[slug].md` with: - `status: PROPOSED` (or `ACTIVE` if user confirmed) - `authority: AGENT_PROPOSED` - Concise claims and rationale. 3. Update `.anchors/INDEX.md` with the new anchor entry. ### Phase 4: Anti-Patterns ("What NOT to Anchor") - Do NOT record raw session transcripts or journals ("Today we ran tests..."). - Do NOT record bug stack traces or temporary typos. - Do NOT duplicate code syntax or schemas in markdown. - Do NOT copy generic third-party library manuals.