learning_ai_common_plat/.windsurf/workflows/repo_update-agent-docs.md
saravanakumardb1 c04ee5f054 feat(agent-docs): single-source-of-truth pattern for agent instructions
Establish a single canonical source for ecosystem-wide AI agent behavior
rules, eliminating duplication across the 8 agent-config files that each
repo used to maintain.

New canonical sources (this repo only):
- AI.dev/SKILLS/agent-behavior-guidelines.md  (Karpathy + ByteLyst rules)
- AI.dev/SKILLS/agent-onboarding.md           (read-order index)

Generator rewrite (scripts/update-agent-docs.sh):
- Deletes legacy files that duplicated AGENTS.md:
    .cursorrules, .windsurfrules, .clinerules, CLAUDE.md
- Regenerates .github/copilot-instructions.md as a thin pointer (no rules).
- Regenerates .aider.conf.yml and .editorconfig.
- Idempotently prepends a canonical-behavior-pointer block to AGENTS.md.
- Supports --dry-run and --no-commit flags.

Drift check (scripts/check-agent-docs-drift.sh):
- Fast marker-based check across all repos.
- Verifies legacy files absent, AGENTS.md pointer present, copilot/aider/
  editorconfig markers intact.

Workflow doc updated: .windsurf/workflows/repo_update-agent-docs.md

Repos.txt: added learning_ai_talk2obsidian (was missing from canonical list).

This repo's own agent files are migrated by the same generator:
- Removed: .cursorrules, .windsurfrules, .clinerules, CLAUDE.md
- Updated: AGENTS.md (pointer block prepended)
- Updated: .github/copilot-instructions.md (rewritten as pointer)
- Updated: .aider.conf.yml (canonical format)

Karpathy attribution: behavior rules adapted from
https://github.com/multica-ai/andrej-karpathy-skills
2026-05-23 11:55:19 -07:00

4.4 KiB

description
Regenerate AI agent docs across all repos (single source of truth pattern)

Update Agent Docs Across Workspace

Maintains AI agent docs across the ByteLyst workspace using a single source of truth pattern with zero duplication.

Architecture

learning_ai_common_plat/AI.dev/SKILLS/
├── agent-behavior-guidelines.md   ← SINGLE source of truth for behavior rules
└── agent-onboarding.md            ← Read-order index for agents

<each repo>/
├── AGENTS.md                       ← Repo-specific only. Auto-prepended with
│                                     "Read first" pointer to canonical file.
├── .github/copilot-instructions.md ← Thin pointer (no rules). Auto-generated.
├── .aider.conf.yml                 ← Aider config pointing to AGENTS.md. Auto-generated.
└── .editorconfig                   ← Editor config. Auto-generated.

DELETED across all repos (content was duplicated AGENTS.md):
├── CLAUDE.md
├── .cursorrules
├── .windsurfrules
└── .clinerules

Steps

  1. Edit the canonical sources when behavior rules change:

    # ecosystem-wide agent behavior (Karpathy + ByteLyst)
    open learning_ai_common_plat/AI.dev/SKILLS/agent-behavior-guidelines.md
    
    # read-order index
    open learning_ai_common_plat/AI.dev/SKILLS/agent-onboarding.md
    

    These are referenced (not copied) by every repo's AGENTS.md, so changes take effect immediately — no regeneration needed when only behavior rules change.

  2. Run the generator to delete legacy files / refresh pointers / sync configs:

    cd /Users/sd9235/code/mygh/learning_ai_common_plat
    ./scripts/update-agent-docs.sh --dry-run    # preview
    ./scripts/update-agent-docs.sh              # apply + commit per repo
    ./scripts/update-agent-docs.sh --no-commit  # apply without committing
    

    Reads learning_ai_common_plat/.windsurf/workflows/repos.txt as the canonical list of managed repos.

  3. Verify no drift:

    bash scripts/check-agent-docs-drift.sh
    

    Exits 1 if any repo has drifted from the canonical generator output. Suitable for CI.

  4. Review changes per repo:

    while IFS= read -r repo; do
      [[ -z "$repo" || "$repo" =~ ^# ]] && continue
      echo "── $repo ──"
      git -C /Users/sd9235/code/mygh/"$repo" log -1 --oneline
    done < /Users/sd9235/code/mygh/learning_ai_common_plat/.windsurf/workflows/repos.txt
    
  5. Push (when ready):

    while IFS= read -r repo; do
      [[ -z "$repo" || "$repo" =~ ^# ]] && continue
      git -C /Users/sd9235/code/mygh/"$repo" push
    done < /Users/sd9235/code/mygh/learning_ai_common_plat/.windsurf/workflows/repos.txt
    

Files generated per repo

File Type Tool(s)
AGENTS.md Hybrid Codex, Claude, Cursor, Windsurf, Cline
.github/copilot-instructions.md Pointer GitHub Copilot
.aider.conf.yml Config Aider
.editorconfig Config All editors

AGENTS.md is hybrid: the body is hand-maintained (repo-specific content), but the generator idempotently prepends a <!-- BEGIN: canonical-behavior-pointer --> block at the top. The block is the only auto-managed region; everything else is left alone.

Files deleted by the generator

File Reason
CLAUDE.md Duplicated AGENTS.md. Claude Code reads AGENTS.md by default.
.cursorrules Duplicated AGENTS.md. Cursor reads AGENTS.md.
.windsurfrules Duplicated AGENTS.md. Windsurf reads AGENTS.md.
.clinerules Duplicated AGENTS.md. Cline reads AGENTS.md.

Notes

  • Safe to run repeatedly (idempotent).
  • Only commits when actual changes exist in the repo.
  • The script never touches the body of AGENTS.md outside the marker block.
  • For workspaces that include learning_ai_common_plat as a sibling (default for Windsurf/Cascade), the canonical guidelines file resolves via the relative path written into each AGENTS.md pointer.