Tool-Agnostic Migration for AI Coding: Portable Instructions, Rules, and Memory
A recent wave of account bans on an overseas AI coding assistant exposed a gap most teams overlook: the instructions, rules, and memory accumulated during AI-assisted development often live only inside a tool's private account space, with no version history and no migration path. This article explains how to treat these three asset types as tool-agnostic "source files" and compile them into context for any tool or model. It covers inventorying and layering assets, standardizing instructions and rules with unified metadata, externalizing and governing memory through standard tool-call interfaces and retrieval, building an adapter layer that compiles assets for different models, regression testing and change management, and security and compliance. By following the approach, teams can switch tools or models by adjusting adapter configuration alone, without rewriting prompts, while preserving years of engineering standards and project knowledge. A step-by-step roadmap and an acceptance checklist are included.
1. A Wave of Account Bans Exposes Non-Portable Assets
An overseas AI coding assistant recently hit a concentrated wave of account bans, and many developers lost access overnight. After the incident surfaced, some developers inspected the tool’s client and published the related detection logic. The tool’s team later responded on social platforms: this was an experiment that started in March, aimed at detecting violations such as account resale and model distillation, and the new version would roll back the related policy.
That response confirmed the community’s speculation. More importantly, it put a long-ignored question on the table: when the collaboration tool itself may become unavailable at any time, does everything we’ve accumulated on it still count as our own asset?
When planning a migration, teams usually think of code repositories, dependency manifests, and build scripts, but they easily overlook a special kind of asset: the instructions, rules, and memory built up during AI coding collaboration. These are scattered across a tool’s private configuration directories, in team members’ personal habits, and in one-off conversation logs. They are not versioned, and they have no executable migration path. Once an account is deactivated, these assets disappear with it.
Using a team that is currently going through the ban wave as a backdrop, this article discusses how to migrate these three asset types into an asset system that is independent of any specific tool or model. The goal is that when you switch tools or models, you don’t have to rewrite prompts, and the engineering standards and project knowledge a team has built over years remain fully intact.
2. Three Underestimated Assets: Instructions, Rules, and Memory
Before migrating, get a clear inventory. The context in AI coding collaboration roughly falls into three types, each with a different lifecycle and rate of change, so each should be modeled separately.
2.1 Instructions: The “Operating System” That Defines How the AI Works
Instructions are high-level conventions that tell the AI “in what role, and in what way” to work. They usually live in a global instruction file or a system-level prompt. Typical content includes:
- Role and goals: senior backend engineer, code reviewer, test designer, and so on;
- Output habits: which language to answer in by default, whether to give the conclusion first, whether code should include a brief explanation;
- Work style: restate your understanding before changing code, present a plan before acting on multi-file changes;
- Boundary constraints: which operations require explicit confirmation first, such as deleting files, changing configuration, or running a deployment.
2.2 Rules: Verifiable Engineering Constraints
Rules answer the question “what must be written a certain way to count as acceptable.” Common dimensions include:
- Code style: naming conventions, comment density, function length, exception handling;
- Architecture boundaries: the responsibilities of each layer, dependency direction between modules, and a ban on direct cross-layer access;
- Security and compliance: no hard-coded secrets, no bringing production data into debugging code;
- Engineering process: commit message conventions, testing requirements, code review checklists.
The value of rules lies in their verifiability. They should map as far as possible onto formatters, static analysis, and automated tests, so that “whether the AI followed the standard” can be judged automatically rather than by manual inspection.
2.3 Memory: Project Knowledge Accumulated Across Sessions
Memory is project knowledge retained across sessions. By purpose, it falls into four categories:
- Factual: repository structure, tech stack versions, build and startup commands;
- Decision: why a particular approach was chosen, which options were explicitly rejected and why;
- Experience: key parameters in build scripts, root causes of past failures and how to avoid them;
- Task: work in progress, outstanding items, next steps.
Unlike a one-off conversation, memory has a clear lifecycle: it is produced during collaboration, it gets revised, and it goes stale. So each memory entry should carry metadata such as source, timestamp, confidence, and validity period, laying the groundwork for later governance and retrieval.
2.4 How the Three Types Relate
The three are interconnected but should not be conflated:
- Instructions are the “operating system,” relatively stable, governing the underlying behavior of collaboration;
- Rules are the “compiler options,” determining whether the output is compliant, and checkable automatically;
- Memory is “persisted data,” continuously accumulating and updating as the project evolves.
One direct benefit of this layering: when you switch tools, you only need to replace how the instructions are executed; the rule files and the memory store can be reused as-is.
3. Why Aim for “Tool-Agnostic”
The ban wave is only the trigger. What really prompts a team to act is the design principle of being “tool-agnostic,” for three reasons.
First, vendor risk is objective. Account bans, service throttling, policy changes, model retirement, and product form adjustments can all catch a team that is deeply tied to a single tool off guard. And the later you migrate, the more private-format assets you’ve accumulated, and the higher the switching cost.
Second, there are three layers of hidden lock-in:
- Format lock-in: instructions and rules are stored in a tool’s private format, so switching tools means rewriting everything;
- Account lock-in: memory is stored in a server-side account space, cannot be exported, and cannot be brought into the team’s version control or permission system;
- Capability lock-in: prompt techniques are deeply coupled to a specific model, so switching models may break them.
Third, compliant use is the prerequisite for migration. The behaviors the experiment above aims to detect, such as account resale and model distillation, are themselves violations of the terms of service. Teams should insist on one account per person, with accounts procured and managed centrally by the team. Enterprise users should also pay attention to compliance requirements around code data leaving their environment. This article is not about how to evade risk controls; it is about giving a team the ability to migrate at any time while using tools legally and compliantly.
4. Migration Design: Portable Assets + an Adapter Layer
The core idea borrows from compilation: treat a tool’s private configuration as “compiled output,” and treat instructions, rules, and memory as tool-agnostic “source files.” The source files live in a repository owned by the team, and a lightweight adapter layer compiles them into the context each tool needs.
Here is a comparison before and after migration:
| Dimension | Before | After |
|---|---|---|
| Instruction storage | Tool-private config file | Portable instruction files in the team repo |
| Rule expression | Free-text paragraphs, bound to the tool | Structured rule set with metadata |
| Memory storage | Server-side account space, not exportable | Owned storage, searchable and auditable |
| Tool switching | Reconfigure everything; some assets lost | Swap one adapter |
| Change management | No versioning, no review | Version control and code review |
The overall architecture looks like this:
- Asset layer: instructions, rules, and memory, stored together in the team repo;
- Asset governance layer: version control, review process, conflict detection, quality checks, regression tests;
- Adapter layer: converts assets into prompts and context for different tools or models, and decides how memory is injected;
- Target tools: various AI coding tools, or coding assistants you build yourself by integrating model services.
The asset layer and governance layer are expanded below.
5. Step One: Inventory and Layered Migration
Start by doing a “context asset inventory.” You can begin from three sources:
- Config side: global instruction files, project-level rule files, and custom commands the tool supports;
- Process side: team code standards, review checklists, commit conventions;
- History side: conversation logs of key tasks, task lists, and notes.
Classify what you collect into three levels: global / team / project:
- Temporary preferences that apply only to an individual or a certain task need not be migrated;
- Standards shared across multiple projects should be promoted to team-level assets;
- Information unique to a project should stay in project-level assets.
A suggested directory structure, which any ordinary code repository can host:
ai-assets/├── instructions/│ ├── global.md # Global instructions│ └── project.md # Project-level instructions├── rules/│ ├── coding-style.md # Code style│ ├── security.md # Security and compliance│ └── review.md # Review requirements├── memory/│ ├── facts.jsonl # Factual memory│ ├── decisions.jsonl # Decision memory│ ├── lessons.jsonl # Experience memory│ └── tasks.jsonl # Task memory├── adapters/ # Adapter configs for each tool and model└── tests/ # Regression test cases
Memory uses a line-delimited JSONL format, which makes append writes and incremental retrieval easy. An example structure for a memory entry:
{"id": "dec-0007","type": "decision","scope": "payment-service","content": "Use a 'persist first, then notify asynchronously' pattern for refund callbacks, to avoid duplicate accounting caused by notification retries","sources": ["ADR-012", "commit a1b2c3d"],"confidence": 0.9,"created_at": "2025-06-12","expires_at": "2026-06-12"}
After migration, any tool and any model can read this asset set to obtain the same collaboration context.
6. Standardizing Instructions and Rules
6.1 Unified Metadata
So that different tools can load them correctly, it’s worth giving every instruction and rule file a unified metadata header. This makes it easier for the adapter layer to parse and easier to manage versions:
---id: coding-styleversion: 2.1.0scope: team # global | team | projectpriority: 100 # higher number = higher prioritytags: [style, quality]applies_to: ["src/**", "tests/**"]owner: platform-team---## Rules1. Every new public function must document its parameters and return value, and include at least one example.2. Never build query statements by directly concatenating user input in business code; always use parameterized queries.3. Never silently ignore a caught exception; log it or re-raise it with context.4. When behavior logic changes, add or update unit tests in sync; tests must cover normal, boundary, and error cases.## Exceptions- Files under auto-generated directories are exempt from rule 1.
Instruction files can also be split by task type, for example “requirement clarification,” “code refactoring,” “code review,” and “test generation.” Load only the file that matches the current task, to avoid stuffing all instructions into context at once.
6.2 Rule Conflict Detection and Context Budget
As the rule set grows, the most common problems are conflicts and a saturated context. It helps to add two automatic checks at commit time:
- Rule mutual-exclusion detection: warn when semantically similar rules are assigned different priorities, or when their scopes overlap;
- Context budget accounting: estimate the share of context taken by “instructions + rules + memory,” and prompt for splitting or moving to retrieval when it exceeds a threshold.
Illustrative code below; thresholds can be set to match your team’s situation:
# Illustrative code: rule conflict and context budget checksdef check_ruleset(rules):for i, a in enumerate(rules):for b in rules[i + 1:]:overlap = a.tags & b.tags # intersect tag setsif overlap and not ranges_conflict(a.scope, b.scope):if a.priority == b.priority:yield f"Rule {a.id} and {b.id} share the same priority; set a primary/secondary order"def check_budget(instructions, rules, memory_preview, limit_chars):used = sum(len(x.body) for x in instructions + rules) + len(memory_preview)if used > limit_chars:raise ValueError(f"Context budget exceeded: {used}/{limit_chars}; trim it or switch to on-demand retrieval")
6.3 Priority and Exceptions
Rules will inevitably disagree at times. For example, team standards may require “handle every exception at fine granularity,” while a global instruction requires “keep answers concise.” A suggested arbitration order:
ad-hoc user instruction > project rules > team rules > global instructions
Exceptions must be declared explicitly in the rule file. An explicit declaration beats letting the AI guess, because guessing often leads to the same question being handled differently across sessions.
7. Externalizing and Governing Memory
Memory is the hardest asset to migrate. If it lives only inside a tool’s account, switching tools means losing it. Four points to keep in mind when migrating.
7.1 External Storage, Reused Across Tools
Move memory from the server to storage the team owns, which can be JSONL files in a repository or a database. As the volume grows, you can lean on general cloud capabilities to scale:
- use object storage to hold memory snapshots and backups;
- use a vector retrieval service to support semantic recall;
- use a logging service to record memory reads and writes for auditing.
For example, a team can combine its own environment with general capabilities such as model services and vector retrieval from Baidu AI Cloud to build its own coding assistant. This both unifies access across multiple model services and keeps the memory layer fully under the team’s control. If you choose a public cloud approach, also evaluate compliance requirements around storage region and cross-border data transfer.
7.2 Read and Write via “Tool Call” Interfaces
Don’t try to force memory into a single tool’s private memory mechanism. Instead, expose the memory interface using standard tool calls. Any model or tool that supports tool calling can plug in, which naturally achieves cross-tool reuse:
{"name": "memory_search","description": "Search project memory by task description and return relevant facts, decisions, and experience","parameters": {"type": "object","properties": {"query": { "type": "string", "description": "A brief description of the current task" },"scope": { "type": "string", "description": "Project or module scope" },"top_k": { "type": "integer", "description": "Number of entries to return, default 5" }},"required": ["query"]}}
Similarly, you can provide two more interfaces: memory_write (write memory with source and confidence) and memory_update (revise or invalidate existing memory).
7.3 Retrieval and Injection
The value of memory lies in “being recalled at the right time.” A complete retrieval can be split into five steps:
- Extract keywords, file paths involved, and module names from the current task;
- Do keyword recall and vector recall within the corresponding project scope, then merge and deduplicate;
- Filter out entries that are expired or below the confidence threshold;
- Sort by relevance and truncate to control injection length;
- Annotate source and date in the injected text, for example “(source: ADR-012, 2025-06),” so the AI can judge how current the information is.
Illustrative code:
# Illustrative code: memory retrieval and injectiondef recall_memory(task, scope, top_k=5):keywords = extract_keywords(task) # keywords: module names, file paths, error messages, etc.candidates = merge_dedup(keyword_search(scope, keywords),vector_search(scope, task, top_k * 2))valid = [m for m in candidates if not is_expired(m) and m.confidence >= 0.6]valid.sort(key=lambda m: relevance(m, task), reverse=True)lines = [f"- [{m.type}] {m.content} (source: {m.sources[0]}, {m.created_at})"for m in valid[:top_k]]return "\n".join(lines) if lines else "(no relevant memory)"
It’s worth stressing that more memory is not better. Irrelevant memory not only wastes context but also disrupts the model’s judgment. Better to inject a few highly relevant entries than to dump the entire memory store in at once.
7.4 Write Strategy and Lifecycle
- Who can write: automatic extraction serves only as a candidate; before entering the formal memory store, it must be confirmed by a person or reach a certain recurrence count;
- What to write: only write information that has value across sessions, such as decision rationale, lessons learned from pitfalls, and stable project facts. Temporary debugging conclusions need not be written;
- How to deduplicate: run a similarity search before writing, and merge semantically similar entries into an update rather than appending endlessly;
- When to expire: set a validity period for time-sensitive memory and mark it for re-review automatically when it expires; entries that conflict with the latest code state are invalidated directly.
8. Adapter Layer: Compiling for Multiple Tools and Models
The adapter layer’s job is to read the portable assets and generate context according to the target tool’s or model’s requirements. Illustrative code:
# Illustrative code: compiling assets into contextclass ContextCompiler:"""Compile portable assets into the context a target tool/model needs."""def __init__(self, asset_root, adapter_config):self.assets = load_assets(asset_root)self.cfg = adapter_configdef compile(self, task):# 1. Merge instructions and rules by priority, and record rule sources for attribution in the outputbase = merge_by_priority(self.assets.instructions, self.assets.rules)# 2. Models differ in prompt style, length, and tool-call support; the adapter config decides output strategybase = self.cfg.postprocess(base, task)# For example: for models without tool-call support, statically concatenate memory retrieval results into context# for models with small context windows, further trim examples and exception notes from rules# 3. Dynamically retrieve memory for the current taskmemory = recall_memory(task.description, task.scope, self.cfg.memory_top_k)# 4. Emit a context structure aligned with the target toolreturn self.cfg.build_context(system=base, memory=memory, task=task)
The adapter config is stored as an ordinary config file, for example:
# adapters/model-small.yamltarget: model-smallmax_rule_chars: 3000 # limited context, cap rule lengthmemory_top_k: 3inject_rule_source: false # model lacks structured output; drop source annotationsstrip_examples: true # trim examples from rules
The adapter layer achieves three things:
- Source assets stay unchanged: however you switch tools, instructions and rules don’t need rewriting;
- Graceful degradation by capability: for models with smaller context windows or without tool-call support, it automatically trims rules and falls back to static concatenation;
- Multiple tools in parallel: team members can use different tools while sharing the same asset set.
9. Regression Testing and Change Management
Once the asset system is in place, the biggest risk is “silent degradation”: a seemingly harmless instruction change can make the AI miss a category of problems during code review. So the assets themselves need tests.
Maintain a set of regression cases for typical tasks. Each case contains an input, an expected behavior, and checkpoints:
# Illustrative code: asset regression testsCASES = [{"name": "Add a query endpoint","task": "Add an endpoint to query users by phone number in the user module","checkpoints": ["Uses parameterized queries, does not concatenate user input","Includes normal, boundary, and error tests","Provides a brief change description"]},{"name": "Code review","task": "Review this commit that contains an uncaught exception","checkpoints": ["Points out the exception handling issue", "Gives an actionable fix suggestion"]}]def run_regression(compiler, model_client, cases):results = []for case in cases:output = model_client.invoke(compiler.compile(case["task"]))passed = [cp for cp in case["checkpoints"] if judge(cp, output)]results.append((case["name"], len(passed), len(case["checkpoints"])))return results
As for the judge function, two suggestions:
- For things that can be decided by automated checks, such as “contains a test file” or “uses parameterized queries,” prefer script-based judgment;
- For things that are hard to judge automatically, such as whether a suggestion is reasonable, use human review or a “model review + human spot-check” approach.
This suite of tests applies equally when switching models or upgrading a model version: run the regression cases first before the actual switch to confirm the assets still take effect in the new environment.
In terms of process, manage the asset directory like an ordinary code repository:
- submit all changes through merge requests, reviewed by at least one maintainer;
- when modifying global instructions or team rules, update the regression cases in sync;
- version the rule set semantically, and attach change notes to each release recording which rules were added, revised, or deprecated.
10. Security, Compliance, and Permissions
Once assets are externalized, security responsibility returns to the team, with four points to focus on.
1. Zero sensitive information in storage
- Instructions, rules, and memory must not contain secrets, tokens, connection strings, internal addresses, and other sensitive information;
- run a sensitive-information scan before writing memory, and reject any write that matches a rule;
- real secrets are managed centrally by a secret-management capability, and code references only their aliases.
2. Tiered authorization
- Divide asset repo visibility by sensitivity level: public, internal, confidential;
- Assets used by confidential projects live in separate repositories, with access controlled by least privilege;
- The memory interface authorizes by project scope, preventing retrieval results from crossing authorization boundaries.
3. Guarding against prompt injection
External documents, web page content, and code comments can all carry malicious instructions. Injected memory is no different: a “memory” entry of unknown origin could induce the AI to perform a dangerous operation. To guard against this:
- annotate source and trustworthiness when injecting memory;
- for high-risk operations such as deleting files, changing configuration, or running deployments, always keep a human confirmation step.
4. Compliant use
- Insist on one account per person, procured and allocated centrally by the team; no sharing, resale, or top-up on someone else’s behalf;
- read the terms of service of the target tool and model service carefully before use;
- meet the regulatory requirements of your team’s industry and region on matters such as data transfer abroad and protection of personal information.
11. Rollout Roadmap and Acceptance Checklist
| Stage | Reference timeline | Main work | Deliverables |
|---|---|---|---|
| Inventory | Week 1 | Map the three asset types and classify them as global/team/project | Asset inventory, directory skeleton |
| Migration | Weeks 2–3 | Standardize instructions and rules, establish unified metadata, extract initial memory | First version of the asset repo |
| Integration | Week 4 | Build the adapter layer and memory interface, configure at least one alternative tool or model | A switchable context-compilation pipeline |
| Governance | Ongoing | Regression tests, conflict detection, periodic audits, switch drills | Change logs, test reports |
For acceptance, check against the following:
- Format-agnostic: assets are stored as generic text and structured data, with no tool-private format;
- One-step switch: after switching tools or models, only the adapter config changes; no need to modify instructions or rules;
- Portable memory: memory exports in full, with source and validity period, and is retrievable by different tools;
- Traceable changes: every asset change has a review record and a version number;
- No security gaps: sensitive-information scanning, tiered permissions, and confirmation for high-risk operations are all in place.
12. Common Misconceptions
- Treating migration as “copying prompts”: moving only instructions, without governing rules or organizing memory, quickly returns you to a fragmented state after the switch.
- Memory that only grows and never prunes: without deduplication and expiration, the memory store keeps ballooning, retrieval noise keeps increasing, and eventually every interaction slows down.
- Ignoring model differences: feeding the same asset set to models of differing capability without any adaptation produces uneven results.
- Emphasizing collection over verification: accumulating lots of assets but never running regression tests, then discovering at switch time that the rules have long since become invalid.
13. Conclusion
The ban wave will eventually subside, and per the official statement the experiment will be rolled back in the new version. But the lesson it leaves for developers will not date: in an era where AI is deeply involved in software development, instructions, rules, and memory have become a team’s core digital assets, no less important than the source code itself.
By freeing these assets from a tool’s account system, carrying them in a portable format, governing them with a unified standard, and connecting different tools and models through an adapter layer, a team gains more than the ease of “switching tools without regret.” It gains a sustainable engineering capability. Whichever category of AI coding tool you use, and whether the model service is deployed in the public cloud or in your own environment, this asset system grows along with the project.
