agentleFS
marinvchmarinvch/Cortex/skills/migrate-legacy-engine/SKILL.md

migrate-legacy-engine

Skill1 starsChanged 18 days agoMITView on GitHub

Move a repo off the retired `.ai-os/` engine onto plain-files Cortex without losing its memory — harvest first, delete second.

  • Deletes or force-pushes

The file

We split this skill into the rules it gives an agent

12 rules. About 0 are common, 6 are distinctive, and 6 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈6

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 6

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Check git status is clean (or stash).

    line 28
  2. Very specific:

    If there's no new brain yet (AGENTS.md absent), run /setup-repo first — this ritual *enriches* the brain, it doesn't create it.

    line 30
  3. Distinctive:

    Read these, pull only durable, verified facts, and fold them in:

    line 84
  4. Distinctive:

    Dedupe: If AGENTS.md already says it, skip it.

    line 96
  5. Distinctive:

    Route to the right brief: If a fact is specific to a critical area that has (or should have) a scoped AGENTS.md leaf, put it in that leaf — …

    line 100
  6. Very specific:

    Do NOT copy engine *mechanics* (MCP tool names, get_session_context, session protocols) — those die with the engine.

    line 104
  7. Very specific:

    Before any rm, archive the full old-engine footprint so nothing is ever truly lost:

    line 112
  8. Very specific:

    Keep the tarball outside the repo (or add it to .gitignore).

    line 120
  9. Distinctive:

    Delete only what you backed up and harvested:

    line 123
  10. Very specific:

    .mcp.json / .vscode/mcp.json: remove just the entry that points into .ai-os/.

    line 127
  11. Very specific:

    No engine artifacts remain: Step 1 again, the command and the scan → legacyEngine is [] and the scan finds nothing.

    line 138
  12. Distinctive:

    Every registration from Step 1 points at a root that exists, or is gone.

    line 140

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

/migrate-legacy-engine — move the old brain into Cortex, then retire it safely

The earlier AI OS was an engine: a Node/MCP-server system that scattered generated context, a durable memory store, agents, and prompts across .ai-os/ and .github/. Cortex replaced it with plain files (AGENTS.md + shims + docs/decisions.md). This ritual moves any hand-verified knowledge out of the old engine into the new brain, then removes the old files.

The one rule: harvest before you delete

Engine memory is the only thing that isn't re-derivable from the code. Never rm an engine artifact until its knowledge is in AGENTS.md or docs/decisions.md. Re-generatable scaffolding (agents, prompts, dependency graphs, stack/architecture auto-dumps) can be dropped freely.

Step 0 — Confirm scope & require a clean git tree

  • Work ONLY inside the target repo (default: cwd). Never touch the personal vault.
  • If the cwd is not inside a git work tree (git rev-parse --show-toplevel fails), there is no target yet. Do not scan the directory you happen to be in: "no engine found" there answers a question nobody asked. Ask which repo is meant, and offer the git repos one level down as choices (ls -d */.git).
  • Check git status is clean (or stash). The migration is recoverable via git + the backup archive, but a clean tree makes the diff reviewable.
  • If there's no new brain yet (AGENTS.md absent), run /setup-repo first — this ritual enriches the brain, it doesn't create it.

Step 1 — Detect the old engine

The engine's two directories are read by a command, which writes nothing: node "${CLAUDE_PLUGIN_ROOT}/index/cortex-next.mjs" . --json. Its state.legacyEngine lists which of .ai-os (the MCP server) and .github/ai-os (config.json, manifest.json, context/, memory/, recommendations.md, tools.json) are there. Take that answer as it is and do not look for those two again.

The command looks for nothing else, so an empty list is not "no engine". Each of these is still a scan by hand, and one of them present means the engine was installed:

  • An entry in .mcp.json / .vscode/mcp.json whose command or args point into .ai-os/. The path marks the engine's entry; the name does not. Cortex's own server was registered as ai-os until recently: an entry that runs …/mcp/server.js and carries CORTEX_ROOT (or AI_OS_ROOT, the older name for it) is a current Cortex registration under either name. It is not the engine. List it as "Cortex registration, kept" and leave it alone.
  • .github/agents/*.agent.md, .github/copilot/**, .github/instructions/*.instructions.md, .github/skills/**, .github/COPILOT_CONTEXT.md, .github/workflows/ai-os-*.yml
  • .vscode/*.chatprompt.md, .vscode/toolsets.json
  • An engine-style .github/copilot-instructions.md (references MCP tools like get_session_context)

List exactly what exists before touching anything.

Two more places hold the old setup and are not in the checked-out tree. Both checks are read-only.

Other branches. A branch that is not checked out can still carry the engine, and a memory.jsonl on a forgotten branch is exactly what this ritual exists to save. Scan every local and remote-tracking ref:

git for-each-ref --format='%(refname:short)' refs/heads refs/remotes | while read -r ref; do
  git ls-tree -r --name-only "$ref" 2>/dev/null |
    grep -E '(^|/)(\.ai-os/|\.github/(ai-os|agents|copilot|instructions)/|\.github/COPILOT_CONTEXT\.md$|\.github/workflows/ai-os-)|\.chatprompt\.md$|(^|/)toolsets\.json$|(^|/)memory\.jsonl$' |
    sed "s|^|$ref: |"
done

Report the hits per branch. Harvest from a branch with git show <ref>:<path>, without checking it out. Removing files from another branch is that branch's own change: name it to the user and leave it to them.

MCP registrations outside the repo. A server can be registered at user scope, where no file in the repo shows it. Run claude mcp list, then claude mcp get <name> for each server that could be either kind: it prints the scope, the command and the environment. Sort each into one of two:

  • The engine's: its command points into a .ai-os/ directory. It goes with the engine.
  • A Cortex registration: its command ends in mcp/server.js outside any .ai-os/, and it carries CORTEX_ROOT, or AI_OS_ROOT on one made under the older name. It is not the engine, whatever it is called, ai-os included. List it with its root. It is only this migration's business when that root is inside something Step 5 deletes, or inside a repo that is no longer there: then it will stop starting.

Step 2 — Harvest (high-signal → into the brain)

Read these, pull only durable, verified facts, and fold them in:

Source (old engine)What to takeWhere it goes (new brain)
.github/ai-os/memory/memory.jsonlEvery active fact (title + content). This is the crown jewels — hand-verified repo knowledge.AGENTS.md → ## Conventions / ## Gotchas / a new ## Security & data section
.github/ai-os/memory/session/failure-ledger.jsonlRecurring failure patterns, if non-emptyAGENTS.md → ## Gotchas
.github/ai-os/context/protected-blocks.mdThe @ai-os:protect convention, if used in codeAGENTS.md → ## Conventions (rename marker if desired)
.github/COPILOT_CONTEXT.md + config.json.persistentRules"MUST-ALWAYS" rulesAGENTS.md → ## Conventions (dedupe against what's already there)
.github/ai-os/context/{architecture,conventions,stack}.mdAnything TRUE not already in AGENTS.md. These are mostly auto-generated — cross-check, don't blindly copy.AGENTS.md (only the gaps)
.github/copilot/skills/*.md, .github/instructions/*.mdGenuine domain rules a human wroteAGENTS.md or a repo docs/ note

Rules while harvesting:

  • Dedupe. If AGENTS.md already says it, skip it.
  • Verify against the code. Memory can be stale. If a fact names a file/flag, confirm it still exists before promoting it. Drop or correct anything wrong.
  • Keep it factual and concise — one line per fact, evidence-based.
  • Route to the right brief. If a fact is specific to a critical area that has (or should have) a scoped AGENTS.md leaf, put it in that leaf — not root. (e.g. RAG/embedding facts → src/lib/AGENTS.md, webhook/raw-body facts → the webhooks leaf.) Offer to run /write-area-brief for areas the harvested memory clusters around. Global facts go in root; area facts go in the leaf.
  • Do NOT copy engine mechanics (MCP tool names, get_session_context, session protocols) — those die with the engine.

Step 3 — Record the migration

Append a dated entry to docs/decisions.md: what was migrated, how many memory facts were folded in, and what was removed. This is the audit trail.

Step 4 — Back up everything you're about to delete

Before any rm, archive the full old-engine footprint so nothing is ever truly lost:

tar -czf ai-os-engine-backup-$(date +%Y%m%d).tar.gz \
  .ai-os .github/ai-os .github/agents .github/copilot .github/instructions \
  .github/skills .github/COPILOT_CONTEXT.md .github/workflows/ai-os-*.yml \
  .github/copilot-instructions.md.bak* .vscode/*.chatprompt.md .vscode/toolsets.json \
  .mcp.json .vscode/mcp.json 2>/dev/null || true

Keep the tarball outside the repo (or add it to .gitignore). Git history is the second safety net.

Step 5 — Remove the old engine

Delete only what you backed up and harvested:

  • rm -rf .ai-os .github/ai-os .github/agents .github/copilot .github/instructions .github/skills
  • rm -f .github/COPILOT_CONTEXT.md .github/workflows/ai-os-*.yml
  • rm -f .vscode/*.chatprompt.md .vscode/toolsets.json (leave the user's own settings.json)
  • .mcp.json / .vscode/mcp.json: remove just the entry that points into .ai-os/. If it was the only entry, delete the file. An entry that runs Cortex's mcp/server.js stays, under the name ai-os too: Step 1 listed it as a Cortex registration.
  • .github/copilot-instructions.md: replace engine content with a shim → AGENTS.md (or leave the Cortex shim if /setup-repo already wrote one). Move old *.bak into the tarball.
  • A registration listed in Step 1 that is the engine's, or whose root you are deleting: repoint it or remove it, with the user's yes. claude mcp get <name> prints the exact remove command for its scope.
  • Clean stragglers: .gitignore lines that only referenced .ai-os/.github/ai-os; the eslint.config.mjs .ai-os/** ignore.

Step 6 — Verify

  • No engine artifacts remain: Step 1 again, the command and the scan → legacyEngine is [] and the scan finds nothing.
  • The branch scan is run again. Hits on other branches are listed as still there, never as cleaned.
  • Every registration from Step 1 points at a root that exists, or is gone.
  • AGENTS.md now contains the harvested facts; docs/decisions.md has the migration entry.
  • The backup tarball exists.
  • npm run lint (or the repo's lint) still passes.
  • Show the user the diff and the list of removed paths. Done.

Rules

  • Harvest-before-delete is non-negotiable.
  • Idempotent: safe to re-run; if nothing matches Step 1, report "no engine found" and stop.
  • One repo at a time. Never promote company code/data into the personal vault.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.