Playbook

AI Context (AIC) Engineering - from ad-hoc context to systematic governance

Core proposition:

Rules, skills, agents and commands for an AI assistant constitute engineering artefacts analogous to code: they require a single source of truth, version control, explicit layers, automated checks and a change history.

Using this document

  • Executive Summary - the architectural formula, four supporting components and applicability threshold (when the investment is warranted).
  • Section 1 - why context degrades (eight systemic failure modes).
  • Section 2 - inputs and definitions (conceptual glossary).
  • Sections 3-5 - where the source of truth resides, and how the library and ownership layers are structured.
  • Sections 6-7 - capability map, inspectors, tests and the change lifecycle.
  • Sections 8-9 - principles and system maturity.
  • Section 10 - staged implementation and repository offboarding (exit path).
  • Section 11 - AIC roles and AI models (Composer / Grok / Sonnet / Opus; Opt: Flash / Luna).
  • Section 12 - summary overview for sections 1-11 and the conclusion.
  • Appendices - integration contracts: runbook, must-have, sync, MCP gate, integration glossary.

Executive Summary

Intended audience and contents

This document is intended for engineers, team leads and platform teams responsible for managing AI context across multiple repositories.

The approach is tool-agnostic: file and directory names are mapped onto the reader's stack (for example, .cursor/, AGENTS.md and IDE slash commands).

Modern agent environments read context from files stored alongside the code. This arrangement is effective for a single repository. Across five, ten or fifteen repositories, however, duplication, inconsistency and undocumented ad-hoc instructions accumulate unless context is governed systematically.

This playbook defines a universal architecture independent of any particular IDE or cloud vendor. Cursor, Claude Code, Copilot and equivalent tools are illustrative context carriers.

Four components

Working repository

The authoritative rules and skills reside alongside the code. Developers edit them within the working repository, without requiring central deployment for routine changes.

Central Library

A separate Git repository provides a mirror of every project, an Evolution-Log, an archive in place of deletion, and a cross-project index.

Structure

The architecture defines explicit artefact types (skills, rules and agents) and ownership layers (project, shared stack and external), with a default-deny policy for external context.

Control

A generated capability map, drift and ownership inspectors, and behavioural scenarios provide the equivalent of CI for context.

Applicability threshold: when the investment is warranted

The return on this approach is sharply non-linear with the number of repositories. Three of the eight failures in section 1 (duplication, index drift, invisible layers) do not arise with one or two repositories.

Scale (repos)What is warrantedWhat is not warranted
1-2Orientation document, critical minimum rules, skills-firstLibrary, mirrors, inspectors, snapshots, evals
3-5The same + library with history and archivingFull test pyramid, system metrics
5+Full contour: sync, map, inspectors, default-deny-
10+ or teamThe same + server overlay, regular runs-

Do not deploy the full contour in advance without demonstrated need. Introduce a library at the 3-5 repository scale and when the first real duplication emerges.

1. Problem: context grows faster than code

As the number of repositories increases, eight systemic failures become evident:

  1. Duplication. A single workflow ("audit", "release" or "deploy") is copied into every repository and diverges into multiple versions.
  2. Index drift. Manually maintained lists such as "22 commands, 14 rules" become obsolete immediately after publication.
  3. Lack of history. A deleted skill cannot be restored, and the instructions in effect at a given date cannot be determined.
  4. Invisible layers. Actual context = built-in IDE capabilities + user-global + plugins + MCP + project files. No comprehensive view exists.
  5. Bidirectional chaos. Changes are made in both the project and the central library, causing layer conflicts and obscuring the canonical version.
  6. Uncontrolled external context. Plugins and MCP servers are connected without demonstrated need, increasing prompt volume while remaining subject to an external release cycle.
  7. Untestable behaviour. Skill changes enter operational use without tests, and regressions become apparent only during an operational task.
  8. Fragility. Years of domain knowledge reside as instructions on a single storage device, without an off-site copy.
ProblemResponseSection
DuplicationCommon layers + overlap analysis (retire / adopt / hybrid)→ 5
Index driftGenerated maps + drift checker→ 6
No historyEvolution-Log, archive instead of deletion→ 4
Invisible layersMap of capabilities across all layers→ 6
Bidirectional chaosOne source of truth, push-only sync→ 3
External contextDefault-deny + version snapshots + gate→ 5, → App.
Unverifiable behaviourTest pyramid: static checks → smoke → evals→ 6
FragilityGit remote, 3-2-1 rule, test restore→ 4

Summary (Section 1)

Without systematic governance, AI context across multiple repositories degrades in eight ways: duplication, index drift, missing history, invisible layers, bidirectional chaos, uncontrolled external context, unverifiable behaviour and fragility. The required response comprises a home canon, a library mirror, default-deny layers and measurable controls: a capability map, inspectors and tests.

2. Inputs and definitions

A shared vocabulary for this document: without it, the same words denote different concepts across sections. Narrow terms for connecting a repository to the system (sync registration, MCP snapshots and related terms) are collected separately in the integration glossary.

TermDefinition
HomeThe project's working repository: the authoritative AI-context layer alongside the code (for example .cursor/). The sole place where the project overlay may be edited.
LibraryA separate git repository providing project mirrors, an Evolution-Log, an archive and a cross-project index. It does not replace home.
SSOTThe single authoritative version of an artefact: for the overlay, in home; for core/shared layers, in the library.
OverlayThe project context layer: skills, agents, rules, commands and orientation (AGENTS.md or equivalent).
Push-onlyOne-way publication of the overlay: home → library. Reverse edits from the library into a project are prohibited.
Core / sharedShared stack layers that reside in the library and are materialised into projects as pull layers; local edits in home are prohibited.
Default-denyExternal context (MCP servers, plugins, marketplace skills) must not enter a production workflow without an explicit adopt decision via the gate.
Capability mapA generated inventory of skills / rules / agents / commands by layer; it must not be maintained manually.
DriftA discrepancy between declared indexes (README / AGENTS / the map) and the files on disk.
Evolution-LogThe change log for agent infrastructure: who changed the stack, when and why.
ArchiveStorage for retired artefacts with date and metadata; deletion without a trace is prohibited.
Skill / Rule / Agent / CommandArtefact types: a multi-step workflow; a continuously active constraint; a narrowly scoped delegated role; an atomic operation without a skill wrapper.
3-2-1Backup policy: at least three copies, on at least two media, with at least one off-site; satisfied only by an actual backup-push and a verified restore.

Summary (Section 2)

Conceptual frame: home is the overlay SSOT; the library provides mirror, log and archive; push and pull layers must not share paths; external context is default-deny; the capability map and drift checks measure context health.

3. The working repository is the single source of truth

Each project manages its AI context locally, in the directory that the IDE reads by default (for example, .cursor/ or its equivalent). This is not a copy derived from the central library; it is the authoritative version for that repository.

Contents of home

  • Skills - step-by-step workflows (audit, commit, migration and domain procedures).
  • Rules - mandatory restrictions (language of reports, pre-change protocol, prohibitions).
  • Agents - specialised roles for delegation.
  • Commands - operational entry points without a separate skill.
  • Orientation - AGENTS.md, CLAUDE.md or equivalent: the project's purpose, available skills and navigation paths.

Push-only sync

Changes are made only in the working repository and are then published unidirectionally to the central library. The reverse flow - editing a project's files in the library - is prohibited because it would establish two sources of truth.

Push-only sync from home to library Home repo edits flow one way into the library mirror; reverse edits from library are blocked. Home repo Edit and commit here Push-only Library mirror Read, archive, index ← reverse blocked Git PR in home Review before sync history / archive Snapshots retained

Notes

  • Home repo: the exclusive location for edits; the canon resides in the project.
  • Push-only: one-way publication to the library; reverse flow is prohibited.
  • history / archive: snapshots and retired skills remain in the library.

Minimum initial set

ArtefactPurpose
AGENTS.mdAgent policy: MCP, skills-first, completion criteria
skills/<name>/SKILL.mdOne workflow per skill, with an explicit trigger
rules/*.mdcNon-negotiable rules (always in context)
Sync scriptCopies home → library and records a timestamped snapshot in history/

Channels and namespace (integration contract)

Each context file belongs to exactly one channel; assignment to multiple channels would create competing sources of truth:

  • Project overlay (push): the project's skills / rules / agents / commands are edited only in home and published to the library.
  • Core / shared (pull): common layers reside in the library and are materialised one way into projects; local edits in home are prohibited and detected by the ownership inspector.

Namespace-invariant: pull layers are materialised under a separate prefix or directory and are not mixed with the project overlay. Relative path matching between channels constitutes a model error; specificity on disk does not determine precedence.

Un-retire: reinstate an artefact from archive/ by recreating the file in home (the SSOT) and then running the normal push sync - never by editing the mirror.

Summary (Section 3)

The working repository is the exclusive location for editing the project overlay. The overlay is pushed to the library; core/shared is pulled from it. Channel paths must not overlap, and retired artefacts may be restored only through home.

4. Central Library

A separate Git repository does not replace home; it complements home in four ways:

  1. Mirror - a snapshot of the context of each project in a predictable structure (projects/<slug>/skills/).
  2. Evolution-Log - records who changed the stack, when and why, and constitutes the equivalent of a CHANGELOG for agent infrastructure.
  3. Archive - deleted skills do not disappear; they move to archive/ with a date.
  4. Cross-project index - identifies where problem X has already been solved without requiring a search of every repository.

Library structure (example)

ai-context-library/
├── projects/
│ ├── backend-api/
│ │ ├── skills/
│ │ ├── agents/
│ │ └── docs/AGENTS.md
│ ├── mobile-app/
│ │ └── ...
│ └── shared/
│ ├── register/ # pack: prose / workers (pull into homes)
│ └── svelte/ # pack: cross-Svelte stack (pull into homes)
├── Evolution-Log.md
├── history/ # timestamp snapshots after each sync
└── archive/ # retired skills with context

Backup

Apply the 3-2-1 rule: three copies of the data, on two types of media, with one copy off-site. At minimum, use a remote Git repository plus periodic export to object storage. Test recovery to a clean environment once per quarter.

Sync contract (for integration)

Each sync execution must be idempotent and produce a predictable result:

  1. Copy the project overlay to projects/<slug>/ (Sync class: full_overlay or skills_only - record it in the wiring).
  2. On updated: preserve the previous version in history/<timestamp>/ and write the diff to Evolution-Log.
  3. On removed: move to archive/<slug>/<timestamp>/ with a metadata file (who, when, where) - do not delete permanently.
  4. Write a machine-readable manifest.json for each run.
  5. Where configured, commit and push the library (backup-push). Before pushing, run git pull --rebase and use either a single writer or standard Git reconciliation.

Restore script (backup DoD): clone the library → clone home → restore the overlay from the mirror on a clean machine. A backup remains unverified until a test restore succeeds.

Caution

The library is a sensitive hub. Secrets (tokens, keys and internal URLs) must not be stored in context files. As teams expand, partition access through separate remotes or ACLs without relaxing the prohibition on secrets.

Summary (Section 4)

The library provides a mirror, Evolution-Log, archive and index. Sync is idempotent, writes a manifest and supports full_overlay / skills_only. The 3-2-1 requirement is satisfied only by an actual backup-push and a verified restore.

5. Structure and layers of ownership

Context is not a flat list of files; it comprises a set of layers with distinct owners and inclusion policies.

Artefact types

TypeWhen to useAnti-pattern
SkillMulti-step workflow with branchesDuplicate rule inside skill
RuleContinuously active constraintOverextended 100-line rule in place of a skill
AgentDelegation of specialised expertiseGeneral-purpose agent without bounded scope
CommandOne operation without a skill wrapperA command that duplicates a skill

Skills-first. Workflows belong in skills; commands are reserved for atomic operations without a skill wrapper. Shared stack packs live in the library under projects/shared/… and reach homes by pull - not by copy-paste into every overlay.

AIC blocks (the capability axis)

Orthogonal to ownership layers. Formula: (skills + agents + commands + rules) + (contexts + hooks) + (memory + navigation + inventory).

GroupBlockRole in integration
Primitivesskills / agents / commands / rulesCapabilities exercised by the agent; inventoried in the capability map
Modescontexts / hooksOperational modes of the agent; introduced after the must-have baseline
Controlmemory (AGENTS.md), navigation (AI-GUIDE), inventory (map)Entry point, router, drift control

Ownership layers

Context ownership layers Four nested ownership layers from external default-deny down to built-in IDE capabilities, with project priority over shared and external. External control External MCP, plugins - default-deny Shared stack Library projects/shared/ Project home Skills, rules, agents Built-in IDE Not editable Priority on conflict: project > shared > external

Notes

  • External: MCP, plugins and marketplace - admitted only through the gate (default-deny).
  • Shared stack: general-purpose skills in the library's projects/shared/<pack>/ packs.
  • Project home: the authoritative layer; in a conflict, the project wins.
  • Built-in IDE: built-in capabilities of the environment, not edited in the repository.

Overlap analysis

When the project and projects/shared/ contain similar skills, select one of three options:

  • Retire - the local copy is archived and the project adopts shared.
  • Adopt - shared is unsuitable; the project remains the canon and shared remains unchanged.
  • Hybrid - a specialised project skill calls the shared skill as a substep.

Default-deny for external context

Each MCP server, plugin and marketplace skill must pass a gate that establishes its necessity, owner, pinned version and contribution to the prompt. Connection to a production workflow without a registry entry is prohibited.

Must-have repository contract

This constitutes the minimum threshold for connecting a repository to the system. The full reusable checklist appears in → B. In summary:

  1. Orientation document with explicit SSOT string and mirror path
  2. Critical minimum always-on rules
  3. Workflow-skills for repeatable processes
  4. Operational commands (thin entry points)
  5. Audit profile (machine readable)
  6. Ownership config (paths and channels)
  7. Slug in the library matrix and in the sync script
  8. Evolution-Log (created by the first sync)
  9. Git remote exists; off-site copy is current after push
  10. Navigation guide (AI-GUIDE) - maintained and validated (validator = 0 errors)

Companion to item 10 (not a separate must-have). The / menu expands excessively (project, user, plugins, MCP, built-ins). Next to the guide, a human layer is required: a full inventory of those entries and an explicit priority-invocation order. AI-GUIDE stays situation → primitive and links to that layer; it does not duplicate priority lists. Diagrams and detail: → C.

Record the state of every repository in a repository × item matrix (Y/-); an approximate configuration state is not measurable.

Summary (Section 5)

The model combines ownership layers, AIC blocks and a ten-point must-have baseline. Priority is project > shared > core; external context is default-deny and must pass the gate. Resolve overlaps through retire / adopt / hybrid. A repository is integrated only when it meets the baseline and is wired into sync.

6. Control: map, inspectors, tests

Context without measurement degrades as predictably as code without CI. Three instruments form an inspection loop.

6.1 Capability Map

A generated document or JSON inventory records all skills, rules, agents and commands by layer. A script updates it during every sync; it is never maintained manually. It provides:

  • a complete inventory of the project and shared layers;
  • intersections (overlap) between layers;
  • connected MCPs and their tools;
  • discrepancies between home and the library mirror.

6.2 Inspectors

InspectorDetection scopeFrequency
Drift checkerIndexes in README/AGENTS do not match files on diskpre-commit / CI
Ownership checkA skill without an owner or a rule without a triggerweekly
Mirror diffHome has changed but sync has not been executedafter a merge to main
External gateNew MCP without registry entrywhen adding

6.3 Behaviour test pyramid

  1. Static checks - valid SKILL.md structure, required sections and no broken links.
  2. Smoke - the agent executes the skill's primary success path on a fixture repository.
  3. Evals - a set of tasks with expected artefacts (files, commands, report format).

Initial coverage should comprise static checks and one smoke test for each critical skill (for example, "safe-commit"). Evals should be added as the skills mature.

6.4 What to include in library CI (integration)

  • Index / capability-map drift (--fail-on-drift)
  • Wiring: every slug in the index has a sync entry
  • Ownership verification (push/pull channels, with no mirror-first edits)
  • Scored audit against the audit profile in strict mode
  • AI-GUIDE validation (0 errors)
  • Optional local check: mirror parity home ↔ library

6.5 Runtime context hygiene (above file SSOT)

[planned] - recommendations only; not a must-have item and not a CI gate.

File SSOT (sections 3-5) governs artefacts on disk. Runtime governs the context window during a long session:

  • Compaction - compact history: retain decisions and key facts; exclude repeating tool outputs.
  • Structured note-taking - progress in external memory (NOTES.md / memory), retrieved on demand.
  • Sub-agent condensed return - a subagent returns a short summary, not the full trace.

Correspondence: the test pyramid (§6.3) verifies behaviour; this hygiene reduces context rot during a session.

Summary (Section 6)

The map is generated during sync. Inspectors address drift, ownership, the mirror, the external gate and AI-GUIDE. Tests progress from static checks → smoke → evals. Library CI blocks a merge when drift or a scored-audit failure is detected.

7. Change lifecycle

Every change to AI context must follow the same lifecycle as a code change:

Context change lifecycle Four-step horizontal flow: propose in home, review with PR and drift checks, sync to library, verify with smoke and evals. Propose Edit in home Review PR + drift Sync Publish mirror Verify Smoke / evals ↻ Next change returns to Propose Home Gate Library Tests

Notes

  • Propose: edit the skill or rule in home and update AGENTS.md if necessary.
  • Review: open a PR and check drift, overlap and rule/skill duplication.
  • Sync: publish to the library, add an Evolution-Log entry and write a snapshot to history/.
  • Verify: run smoke tests or evals on the affected skill; if it regresses, roll back from the archive.

Stages

  1. Propose - edit the skill or rule in the working repository and update AGENTS.md if necessary.
  2. Review - open a PR with checks for drift, overlap and rule/skill duplication.
  3. Sync - the script publishes to the library, writes an Evolution-Log entry and stores the snapshot in history/.
  4. Verify - run a smoke test on the affected skill; if it regresses, roll back from archive/history.

Removal and retirement

Skills must never be deleted without a record: move them to archive/<date>-<name>/ and add an Evolution-Log entry stating the reason and replacement.

Summary (Section 7)

Every context change follows Propose → Review (PR + drift) → Sync (library + Evolution-Log) → Verify (smoke). Remove an artefact only through the archive, recording the reason and its replacement.

8. Principles

1. Context = code where the work is

SSOT and engineering discipline for AI artefacts; edit the overlay in home. Shared/core exception: SSOT resides in the library (projects/shared/<pack>/); homes receive pull/rollout only.

2. Nothing is lost

Archive instead of delete, plus journals and backup, yields full traceability.

3. Maps and indexes are generated

Manually maintained summaries become obsolete; a generated map renders total context visible: project overlays and packs under projects/shared/.

4. Automation detects overlaps - humans decide

Overlay↔shared overlap: retire / adopt / hybrid. Automation never merges or deletes on its own.

5. External is default-deny dependency

Every connection is an explicit decision with a snapshot. External ≠ shared: shared is the library's own common stack.

6. Behaviour is verified, not only form

Static checks detect structure; smoke and evals confirm meaning.

7. Minimum procedural overhead

One sync command; the map and checks are its secondary outputs.

8. One entry, one canonical address

A thin bootstrap declares SSOT and routes onward. Overlay and shared-pack must not share one relative path; alternatives are redirects, not duplicates.

9. Context is enriched from incidents

A solved problem is recorded in the library as a reusable pattern.

10. Instructions are exhaustive and versioned

No ellipses; changes ship with impact analysis; shared layers carry an explicit semantic version.

Summary (Section 8)

Ten principles: Context = code where the work is; Nothing is lost; Maps and indexes are generated; Automation detects overlaps - humans decide; External is default-deny dependency; Behaviour is verified, not only form; Minimum procedural overhead; One entry, one canonical address; Context is enriched from incidents; Instructions are exhaustive and versioned. These constitute completion criteria, not declarative claims.

9. Maturity and scale

The approach scales in stages. Implementation may proceed incrementally, but each level requires a sound foundation before progression to the next. The applicability threshold (when the investment is warranted) appears in the introduction; the table below is the staged maturity ladder after the decision to adopt.

StageSizeMinimumNext step
L0 - Start1-2AGENTS.md + 2-3 skills + 1 rulepre-commit drift on indexes
L1 - Discipline3-5Library mirror + sync script + Evolution-Logprojects/shared/ for shared stack
L2 - Control5+Capability map + overlap analysis + archive policysmoke tests for the top 3 skills
L3 - Platform10+ or teamCI gate, external registry, eval suitelibrary search index

Optional infrastructure evolution

  • L0-L1: a Git remote and manual or scheduled sync.
  • L2: a CI job for drift, plus a mirror diff after merge.
  • L3: a full-text index (Elasticsearch, SQLite FTS or a monorepo tool's native search facility) covering skills and Evolution-Log.

The team selects the tools. The canon specifies what must be measurable and repeatable, rather than prescribing a vendor.

Summary (Section 9)

Maturity advances in stages: L0 (1-2) → L1 library mirror (3-5) → L2 capability map and overlap analysis (5+) → L3 CI, external registry and search (10+ or team). Each level's foundations must be established before progression; tool selection is secondary.

10. Getting started

Deployment follows readiness stages, not a calendar. Each stage begins only after the previous stage's Definition of Done has been satisfied. The initial implementation should establish the SSOT in home, a library mirror and minimum quality controls.

Stage 1 - foundation in home

  1. Declare the working repository as the source of truth in an orientation document (AGENTS.md or equivalent) that defines the language policy, skills-first workflow and done criteria.
  2. Ensure that the repository has a Git remote - this requirement is mandatory.
  3. Capture 2-3 repeatable workflows as skills (for example, commit, audit and deployment).
  4. Add one always-on rule with non-negotiable restrictions (pre-change protocol, prohibitions).

Definition of Done - Stage 1

Home has an orientation document, a remote, at least two skills and one rule; an agent reading AGENTS.md can identify the canon and the skills to invoke.

Stage 2 - central library

  1. Create a separate library repository containing projects/<slug>/, history/ and archive/.
  2. Write a sync script that copies home → library, records a timestamped snapshot in history/ and adds an entry to Evolution-Log.
  3. Run the first sync and check that the mirror matches home.
  4. Perform one test restore: clone the library → restore the overlay into a clean copy of home.

Definition of Done - Stage 2

A single sync execution publishes the project to the library; history and Evolution-Log are updated, and restoration from the mirror has been verified manually. Editing a project's files in the library is prohibited.

Stage 3 - layers and discipline

  1. Mark ownership layers in AGENTS.md: project home, shared (if any), external (default-deny).
  2. Separate the types of artefacts: workflow → skill, restriction → rule, narrow role → agent, atomic operation → command.
  3. Complete the repository's must-have checklist (orientation, minimum rules, sync and archive instead of deletion) and note the gaps.
  4. When a second similar skill appears, perform an overlap analysis (retire / adopt / hybrid).

Definition of Done - Stage 3

Layers and conflict priorities are explicit; no MCP server is connected without a registry entry; every must-have item is complete or placed in the backlog with an owner.

Stage 4 - control

  1. Create a capability-map script that inventories skills / rules / agents / commands from the file system rather than from a manual list.
  2. Add a drift check: discrepancies between the map and references in AGENTS.md / README must block a merge or, at minimum, cause CI/pre-commit failure.
  3. Add one smoke test in which the agent performs a critical skill on a fixture repository.
  4. Commit external gate checklist (→ F) and a registry of connected MCPs/plugins.

Definition of Done - Stage 4

The map is generated during sync, drift is detected automatically, at least one key skill has a smoke test, and external context passes the gate. Subsequent development proceeds through the maturity stages in section 9 without omitting any level.

Repository offboarding (exit path)

The must-have baseline describes onboarding; the reverse operation is mandatory, otherwise orphans remain in indexes and wiring.

  1. Final sync - the mirror reflects the final home state.
  2. Overlay archive - projects/<slug>/archive/<slug>/<timestamp>/ with a meta file; deletion = archiving.
  3. Remove wiring - drop the slug from the sync script.
  4. Index and map - remove the row from the cross-project index; regenerate the capability map.
  5. Verify - drift = 0, ownership verify green, no orphans.

The archive and history/ are retained. Re-onboarding follows the same path as a new connection from home (read the archive if needed; do not edit-first in the mirror).

Summary (Section 10)

Implementation proceeds through readiness stages, not a calendar: foundation in home → library + sync + restore → layers and must-have baseline → map, drift, smoke and external gate. Each stage begins only after the previous stage's Definition of Done has been satisfied.

11. AIC roles and AI models

Operating policy for the system: which AIC roles every project must carry, and which parent model to select. This is not sync or wiring - reusable integration contracts remain in the appendices.

11.1 AIC roles

Codes in the table are portable job-shaped role identifiers. File names in a given home (skill / command / agent) may differ; what is required is the function and the must-have AIC form, not a slug match on disk. Mapping examples: dev-loop ↔ a restart/preview command; safe-commit ↔ a safe commit/push skill; ownership-check ↔ a home↔library ownership skill. Product-tied labels are not used as role codes.

AIC roleWhy it belongs in the projectMust-have AICTypical trigger
impact-check Impact check: impact analysis before edit, minimal diff Rule (always-on) + Skill "impact check", before any code/docs edit
dev-loop Dev-loop: start/restart the dev server, route smoke Command (+ Skill if the workflow is wider than one command) "dev-loop", local preview, smoke
safe-commit Safe commit: status/diff/log, artefacts, no secrets, no force Skill "safe-commit", release commit
code-reviewer Review diffs, architecture, regressions, and contracts before merge Agent + Skill "code review", PR, multi-file audit
ci-repair CI repair: isolate a failing build/check/test, minimal fix, re-run Agent + Command "ci-repair", red CI, failed check
evals Context test pyramid: static → smoke → evals on fixtures and target AI models Skill (+ Command / Agent for an atomic run) "evals", skill smoke test, eval suite, TDD / e2e
orchestrator Decompose a complex task, delegate to subagents and integrate the result Agent + Skill "break down the task", multi-step plan, parallel subagents
repo-audit Repo audit: docs, repo map, routes, pipelines, artefacts Skill (baseline / apply / verify) "repo-audit", full repo audit
aic-audit AIC audit: scored check of the skills/agents/commands/rules layer, dead links, duplicates Command (+ Skill when the scored workflow is a separate skill) "aic-audit", scored audit, context architecture
ownership-check Ownership check: compare home context to the library mirror - overlay drift, sync, history Skill (+ ownership-profile JSON; Command for an ops entry) "ownership-check", overlay vs library drift
update-docs Docs update: refresh orientation, navigation, indexes and changelogs after primitive changes Skill (+ Command where a thin entry is required) "update-docs", guide/AGENTS drift, release notes
code-cleaner Resolve drift, orphaned files, dead links, skill+command duplicates and obsolete material Agent + optional Command / inventory Skill "clear the context", drift, orphan files
best-practices Align with canon and industry practice; gap / adopt / hybrid Skill (+ Agent for narrow expertise) "best practices", canon check, gap analysis, plan-review
Any repeatable domain AIC role - subject to the same contract Agent and/or Skill; Command only without workflow duplication Explicit trigger in the navigation guide

Minimum AIC binding per role

AICRequiredRule
RuleImpactCheckAlways-on; do not duplicate a long workflow inside a rule
CommandDevLoop and ops entries (CiRepair, AicAudit, UpdateDocs, Evals)Atomic entry only; never duplicates the same workflow as a Skill
SkillRequired for most roles (SafeCommit, OwnershipCheck, RepoAudit and onward)Step-by-step workflow (when to use, DoD, Must/Never)
AgentCodeReviewer, Orchestrator, CiRepair, CodeCleanerNarrow expertise; session AI model is inherited, not pinned in frontmatter

11.2 AI models (LLM picker)

AI models are distinct from AIC roles: they are model families available in the picker (Grok, Opus and their peers). Agents / skills / commands do not pin model: in frontmatter; they inherit the parent session. Family names use (latest) exclusively - minor versions must not be pinned.

ON (4): Composer (latest), Grok (latest) High, Sonnet (latest) High, Opus (latest) High. Opt (not ON) - budget fallback (2): Gemini Flash (latest), GPT Luna (latest).

PoolModelsWhen
First-party (ON)Composer, GrokApproximately 80% of routine work: editing, commits, exploration, smoke tests, DevLoop, SafeCommit, UpdateDocs and CodeCleaner
API (ON)Sonnet, OpusAudits, rigorous reviews, complex policy work and Orchestrator on complex decision trees
Opt (budget)Gemini Flash, GPT LunaAfter first-party capacity is exhausted or under a tight API budget

Task / AIC role → AI model

Task or AIC roleParent AI modelPool
ImpactCheck (always in the background)inherits session-
DevLoop, SafeCommit, UpdateDocs, CodeCleanerComposer (latest)first-party
Explore / bulk read / MAPGrok (latest) Highfirst-party
CiRepair (simple failures)Composer (latest)first-party
CodeReviewer, RepoAudit, AicAudit, OwnershipCheck, Evals, BestPracticesSonnet (latest) HighAPI
Orchestrator (deep tree / hard policy)Opus (latest) HighAPI
CiRepair / redesign under hard policyOpus (latest) HighAPI
Budget explore fallbackGemini Flash (latest) or GPT Luna (latest)Opt

High is reserved for intensive exploration, audits or redesign. Routine work uses Composer without High. Model routing is defined by the table above; optionally mirrored as a local file in home. Orientation navigation links to that table (or local file) and does not duplicate prices or minor versions. AIC role codes in the table above remain portable - each repository defines the mapping onto on-disk skills / commands / agents.

Summary (Section 11)

AIC roles are portable job-shaped codes (home file names may differ); the must-have column defines the agent / skill / command / rule form. AI models: ON (4) Composer / Grok / Sonnet / Opus; Opt (2) Gemini Flash / GPT Luna - chosen as the session parent without frontmatter pins. Competitiveness rests on both loops - roles and the picker - reviewed against current practice rather than internal convention alone.

12. Summary overview and conclusion

Expand all

Concise summaries of sections 1-11 are consolidated here for reference. Identical summaries remain at the end of their respective sections. Reusable integration contracts appear in the appendices.

1 Problem

Without systematic governance, AI context across multiple repositories degrades in eight ways: duplication, index drift, missing history, invisible layers, bidirectional chaos, uncontrolled external context, unverifiable behaviour and fragility. The required response comprises a home canon, a library mirror, default-deny layers and measurable controls: a capability map, inspectors and tests.

2 Inputs and definitions

Conceptual frame: home is the overlay SSOT; the library provides mirror, log and archive; push and pull layers must not share paths; external context is default-deny; the capability map and drift checks measure context health.

3 Working repository

The working repository is the exclusive location for editing the project overlay. The overlay is pushed to the library; core/shared is pulled from it. Channel paths must not overlap, and retired artefacts may be restored only through home.

4 Central Library

The library provides a mirror, Evolution-Log, archive and index. Sync is idempotent, writes a manifest and supports full_overlay / skills_only. The 3-2-1 requirement is satisfied only by an actual backup-push and a verified restore.

5 Structure and layers

The model combines ownership layers, AIC blocks and a ten-point must-have baseline. Priority is project > shared > core; external context is default-deny and must pass the gate. Resolve overlaps through retire / adopt / hybrid. A repository is integrated only when it meets the baseline and is wired into sync.

6 Control and map

The map is generated during sync. Inspectors address drift, ownership, the mirror, the external gate and AI-GUIDE. Tests progress from static checks → smoke → evals. Library CI blocks a merge when drift or a scored-audit failure is detected.

7 Lifecycle

Every context change follows Propose → Review (PR + drift) → Sync (library + Evolution-Log) → Verify (smoke). Remove an artefact only through the archive, recording the reason and its replacement.

8 Principles

Ten principles: Context = code where the work is; Nothing is lost; Maps and indexes are generated; Automation detects overlaps - humans decide; External is default-deny dependency; Behaviour is verified, not only form; Minimum procedural overhead; One entry, one canonical address; Context is enriched from incidents; Instructions are exhaustive and versioned. These constitute completion criteria, not declarative claims.

9 Maturity and scale

Maturity advances in stages: L0 (1-2) → L1 library mirror (3-5) → L2 capability map and overlap analysis (5+) → L3 CI, external registry and search (10+ or team). Each level's foundations must be established before progression; tool selection is secondary.

10 Getting started

Implementation proceeds through readiness stages, not a calendar: foundation in home → library + sync + restore → layers and must-have baseline → map, drift, smoke and external gate. Each stage begins only after the previous stage's Definition of Done has been satisfied.

11 AIC roles and AI models

AIC roles are portable job-shaped codes (home file names may differ); the must-have column defines the agent / skill / command / rule form. AI models: ON (4) Composer / Grok / Sonnet / Opus; Opt (2) Gemini Flash / GPT Luna - chosen as the session parent without frontmatter pins. Competitiveness rests on both loops - roles and the picker - reviewed against current practice rather than internal convention alone.

Conclusion

The playbook remains current only while its layers, default-deny policy, capability map and tests are reviewed against current agent-platform practice, rather than solely against a team's internal conventions. Competitiveness depends on two concurrent loops: (1) AIC roles (§11.1), each with the required agent / skill / command / rule; and (2) AI models (§11.2) - ON (4) Composer / Grok / Sonnet / Opus and Opt (2) Gemini Flash / GPT Luna without frontmatter pins. The industry-alignment date (Appendix I) constitutes a checkpoint. When the picker or primitives change, the gate, templates, model-routing table (§11.2) and repo × checklist matrix must be updated; otherwise, the system will degrade more rapidly than the code.

Appendices - integration

Reusable contracts for connecting a repository to the system. Paths and filenames (.cursor/, AGENTS.md, CLAUDE.md) are illustrative; map the names onto the AI tooling stack in use. The conceptual model and operating policy appear in sections 1-11; these appendices cover operational procedures.

A. Runbook: connect the repository

The stages constitute a readiness sequence rather than a calendar schedule.

Step A - home + library framework

# Home: SSOT + remote
cd project
git remote -v # remote is required
$EDITOR AGENTS.md # "context-SSOT here" + path to mirror

# Library: separate repository
mkdir context-library && cd context-library
git init
mkdir -p projects external scripts docs history archive
git remote add origin 
git push -u origin HEAD

DoD A: home has a remote and an orientation document; the library repository is established and contains the required directories.

Step B - sync wiring

  1. Register the slug in the sync script (class full_overlay or skills_only).
  2. Implement sync: overlay → projects/<slug>/, history, archive, Evolution-Log, manifest.json.
  3. Run sync and ensure the mirror matches home.
  4. Perform one test restore in a clean directory.
  5. Enable opt-in backup-push (after pull --rebase).

DoD B: a single sync execution mirrors the project, writes history/archive/manifest, and demonstrates successful restoration.

Step C - must-have + control

  1. Complete checklist B and record any gaps in the repo × item matrix.
  2. Run the capability-map generator at the end of sync.
  3. CI: drift, wiring, ownership, scored-audit strict, AI-GUIDE validate.
  4. Create snapshots of external layers and apply gate E to every new MCP server or plugin.
  5. Run at least one smoke test per critical skill and add further evals in response to incidents.

DoD C: every context change must follow Propose → Review → Sync → Verify; degradation blocks a merge.

B. Reusable must-have checklist

Repo:  Date: ____ Responsible: ____

[ ] 1. Orientation document (AGENTS.md / CLAUDE.md)
       DoD: purpose, stack, explicit "context-SSOT here" statement, path to mirror.
[ ] 2. Critical minimum rules (always-on)
       DoD: language, prohibitions, edit policy; concise enough to remain always-on.
[ ] 3. Workflow skills
       DoD: repeatable processes as skills; no duplicate skill+command.
[ ] 4. Operational commands
       DoD: thin entry points (restart, pre-deploy); smoke test where applicable.
[ ] 5. Audit profile (JSON)
       DoD: expected architecture; scored-audit consumes the profile.
[ ] 6. Ownership config
       DoD: SSOT paths + push/pull channels; ownership-check detects violations.
[ ] 7. Wiring / index
       DoD: slug in the library matrix and in the sync script.
[ ] 8. Evolution-Log
       DoD: created by first sync; history is written from day one.
[ ] 9. Git remote + backup-push
       DoD: remote exists; off-site copy is current after push.
[ ] 10. AI-GUIDE (navigation)
       DoD: situation → primitive; maintained (current) and validator = 0 errors.
       Companion (not a separate item): human layer for «/» menu inventory + priority-invocation order;
       AI-GUIDE links to it and does not duplicate priority lists.

C. Slash UI catalog

Companion to must-have item 10 (AI-GUIDE), not a separate checklist item. The / menu mixes project, user, plugins, MCP and built-ins; a human layer is required: a full inventory of entries and an explicit priority-invocation order. AI-GUIDE stays situation → primitive and links to priorities without duplicating them.

Layers that fill the slash menu Five source layers feed one slash menu; a human catalog inventories them as sections A through D. Project Home overlay User Global cursor Plugins Vendor packs MCP Tool servers Built-in IDE native Slash menu in chat One mixed list Human slash catalog Inventory A-D by source A Skills B Commands C Agents D MCP

Notes

  • Menu sources are not one file on disk.
  • The catalog inventories skills, commands, agents and MCP separately.
Navigation guide versus slash catalog AI-GUIDE routes situation to a primitive; slash catalog inventories the slash menu and sets call-first priorities. Operator task Navigation guide Situation to primitive Slash catalog Inventory plus call-first Must-have item 10 Companion, not item 11

Notes

  • Item 10 is the navigation guide; the catalog is the companion.
  • Priority lists live only in the catalog.
Slash catalog lifecycle Priority seed feeds section E; disk scan builds A-D and F-H; home catalog is the live file; sync mirrors it into the library. Priority seed Section E only Disk scan A-D and F-H Home catalog Live slash doc Library Push mirror Refresh E only when seed must replace

Notes

  • Ordinary regeneration preserves the priorities section.
  • Overwrite priorities only with an explicit seed refresh.

The slash-menu catalog is stored in the working repository next to the orientation guide (typically under docs/: the catalog beside AI-GUIDE). File names, generators and CI gates are adapted to the team's tooling stack.

D. Library catalogue contract

context-library/
├── projects// # mirror overlay (skills, agents, rules, commands, docs)
├── projects/shared// # pull stack layer (namespace separated from overlay)
├── external/ # snapshots of MCP / plugins (version + hash)
├── scripts/ # sync, map, inspectors
├── docs/ # indexes, AI-GUIDE library-roles
├── history/ # timestamp snapshots before overwrite
├── archive/ # retired with metadata
├── Evolution-Log.md # or per-project log
└── manifest.json # each sync run
Sync classWhat is mirroredWhen
full_overlayskills, agents, rules, commands, docsStandard for production repositories
skills_onlyskills (+ orientation)Transitional; ownership checks identify orphaned artefacts

E. Artefact templates

E.1 Orientation document

#  - context for the AI agent

## Purpose


## Stack


## Context-SSOT
The authoritative version resides HERE, at <.cursor/ | .cloud/>.
Edits only here. Mirror (read-only): context-library/projects//.
DO NOT edit the mirror and DO NOT backport it into the project.

## Layer priority
project overlay > shared > core > user-level.
External / MCP / built-ins are not involved in resolving rule conflicts.

## Channels
- project overlay: push (home → library)
- core/shared: pull materialization (local edits are prohibited)

E.2 Always-on rules (minimum)

# Critical rules (always-on)
1. Language of communication: .
2. Prohibited actions: .
3. Edit policy: SSOT - this repo; core/shared are edited in the library.
4. Secrets MUST NOT be stored in context files.
5. Lists without "etc." / "..." - list in full.
6. Impact-before-change: explain the impact before changes.
7. One type of artefact - one location (no duplicates in other directories).

E.3 SKILL.md

---
name: 
description: 
---

# 

## When to use


## Steps
1. ...
2. ...

## Definition of Done
- [ ] 

## Must/Never
- MUST ...
- NEVER ...

## Links (lazy)
- references/
.md

Keep the body concise and place detailed material in references. Assign a low degree of freedom to destructive or operational commands and medium/high to heuristic workflows. Test the skill on the target models.

D.4 Audit profile (fragment)

{
  "repo": "",
  "repo_class": "product | library",
  "stack_mode": "",
  "required_categories": ["rules", "skills", "commands", "agents"],
  "rules": { "min_count": 1 },
  "skills": { "required_sections": ["When to apply", "Steps", "Definition of Done"] },
  "commands": { "smoke_testable": true }
}

D.5 Ownership config

{
  "repo": "<slug>",
  "ssot_paths": [".cursor/", "AGENTS.md"],
  "channels": {
    "project_overlay": "push",
    "core": "pull",
    "shared": "pull"
  },
  "mirror_path": "context-library/projects/<slug>/"
}

D.6 impact-check (example skill)

A reusable example of an always-on rule and its paired skill, presented in full as it appears in the application.

---
name: impact-check
description: Apply a strict pre-change critical checklist before editing code or docs. Use when user asks for "critical rule", "critical", "apply rules", or when starting implementation that needs impact, editing, and release-discipline safeguards.
disable-model-invocation: true
---

# Impact Check

Use this skill as a universal guardrail before making project changes.

## Goal

Enforce a consistent pre-change protocol:
- impact analysis before edits
- precise editing method
- documentation hygiene
- release/version discipline

## Mandatory Pre-Change Check

Before any edit, state:
1. current state
2. proposed change
3. impact:
   - affected files and functions
   - behaviour change
   - performance implications
   - risks

Then ask for confirmation when the repository policy requires it.

## Universal Constraints

- Do not abbreviate configuration or checklist items with `etc.`, `...`, `and so on`.
- Avoid truncating user-facing copy unless explicitly requested.

## Editing Discipline

- Prefer targeted edits over full rewrites.
- Keep diffs minimal and local to the requested change.
- Do not create extra documents unless required.
- Reuse existing documentation and repository files as source of truth.

## Release Discipline

When the workflow includes versioning:
- follow the repository's version bump process
- keep changelog/release artefacts in sync with policy
- do not invent ad-hoc version steps

## Quick Response Template

Use this short template before implementation:

```markdown
Critical check:
- Current state: ...
- Proposed change: ...
- Impact:
  - Files/functions: ...
  - Behaviour: ...
  - Performance: ...
  - Risks: ...
```

## When Not to Use

Skip this skill only when:
- the task is purely informational and no changes are requested
- the user explicitly asks to brainstorm without implementation

F. External context gate (MCP/plugin)

The default is deny. External context may be adopted only after every criterion has been satisfied:

Candidate: 

[ ] A documented task establishes the need; adoption is not precautionary.
[ ] Overlap analysis: no duplicate, or retire / adopt / hybrid is recorded.
[ ] Cost: always-on vs lazy; tokens / latency / attention.
[ ] Security: trusted source; tool poisoning / injection / exfiltration assessed.
[ ] Snapshot in external/ (version + hash + date).
[ ] Update checker; review the overlap decision during each update.
[ ] MCP: pin the tool-manifest hash (name + description + input schema); drift alert.
[ ] MCP: tool output = data, not instructions.
[ ] MCP: sandbox / least privilege; HITL on destructive / data-sharing.
[ ] MCP: multi-server = separate trust domains; no shadowing tools.

Decision: [ ] adopt [ ] hybrid [ ] retire-own [ ] deny
Who/When: ____

G. PR checklist for skill/rule

  • Change only in home (project overlay) or the library (core/shared)
  • Update AGENTS.md / AI-GUIDE when the inventory or policy changes
  • Do not duplicate rules and skills; resolve overlap explicitly
  • Drift and ownership checks pass
  • Sync + Evolution-Log scheduled after merge
  • Run a smoke test on the affected critical skill
  • Confirm that the diff contains no secrets

H. Health metrics (monthly)

  • Percentage of repositories with a current mirror (synced and with no open drift)
  • Number of unresolved overlaps (retire / adopt / hybrid)
  • Skills with smoke coverage (%)
  • Percentage of external-registry entries with a current review
  • Successful test restores from archive/library
  • Percentage of library inspector runs that fail in CI

I. Checking against best practices

The approach in sections 1-11 was aligned with industry practice on the review date, 2026-08-10. Sources may have changed subsequently.

PracticeHow this playbook covers itSources
Context as a governed resource - minimal high-signal set; "context rot" Cost of always-on context / default-deny (§5, Appendix F); capability map and lazy skills (§6, Appendix E.3) Anthropic - Effective context engineering; Mem0 - Context engineering guide
Hierarchy AGENTS.md / CLAUDE.md - concise root + progressively detailed layers Must-have item 1; orientation pattern (Appendix B, Appendix E.1) Packmind - Context engineering 2026
Progressive disclosure of skills - frontmatter → body → assets; degrees of freedom; test on target models Skills-first (Section 5); template SKILL.md (Appendix E.3) Anthropic - Agent Skills; Skill authoring best practices
MCP security as supply-chain security - allowlist, sandbox, HITL, pin hash, untrusted returns Default-deny + gate (§5, Appendix F): rug pull, tool poisoning, multi-server isolation OWASP - MCP Security Cheat Sheet; CSA - Agentic MCP security
Evals and CI gates - change-specific runs, regression gates and tracing Pyramid of static checks → smoke → evals (§6); CI inspectors (§6.4, Appendix A step C) Anthropic - Demystifying evals; Braintrust - AI agent evaluation

J. Glossary (integration)

TermMeaning
WiringRegistration of a project slug in the sync script and the library matrix
Sync classMirroring class: full_overlay or skills_only - recorded in wiring
ManifestMachine-readable manifest.json produced by each sync run
Tool manifest pinA hash of MCP tool descriptions (name + description + input schema) at adoption time
Scored auditA deterministic health assessment of context against the repository audit profile
External snapshotA frozen MCP / plugin capture under external/ with version, hash and date