How to Migrate an AI Coding Assistant’s Context Without Losing Data

    A safe, tool-agnostic workflow for backing up, standardizing, testing, and migrating personal AI coding assistant settings, project rules, and long-term memories while protecting sensitive information and preserving rollback options.

    1. Understand the Risks and Boundaries

    Account restrictions may be triggered by a platform’s internal rules, which are often not disclosed to users. Some developers have reported account suspensions, but the specific cause should be confirmed through official communications. This article focuses only on migrating personal configuration that you are authorized to export. It does not analyze platform risk controls or cover ways to evade platform rules, share accounts, or bypass restrictions. Before starting, review the terms of service and data policies for the tools involved.

    A migration typically involves four main risks:

    1. Data loss at the source: If you can no longer sign in, locally stored or cloud-based configuration may become inaccessible. Back up the data before attempting any migration.
    2. Format incompatibility: Different tools may store the same rule in different structures. Direct copying can cause parsing errors or unexpected behavior.
    3. Exposure of sensitive information: Configuration files may contain access tokens, API keys, or internal service addresses. Treat these items separately during backup and migration.
    4. Overwriting existing target settings: Writing directly to a production configuration can conflict with or replace settings that are already working.

    2. Inventory Your Context Assets

    Before migrating, list everything that needs to be moved. Context assets generally fall into three categories:

    Category Description Common location (example; follow the tool’s documentation) Recommended handling
    Global instructions Language preferences, coding style, and general behavior rules Settings files in a user-level configuration directory Export as plain text and review line by line
    Project rules Framework versions, directory structure, and test coverage requirements Rule files in the project directory or a tool-specific directory Prefer migrating them as Markdown files stored in the repository
    Long-term memory Project background, past decisions, and solutions to recurring problems A tool-specific database or cache Export by entry, remove duplicates, and preserve timestamps

    Also mark two types of content separately:

    • Entries containing keys, tokens, or personal information. These should not be migrated.
    • Outdated or unused entries. These can be removed during the migration.

    3. Back Up Before Migrating

    The backup is the foundation of the entire process and must be completed before any conversion or transformation.

    1. Make a complete copy of the source configuration directory. Preserve the original file structure and do not modify the copy.
    2. Generate checksums, such as SHA-256 hashes, for the backup files so you can later confirm that they have not changed.
    3. Store the backup in a private Git repository or encrypted cloud storage with restricted access.
    4. Record the tool version, export date, and account status next to the backup for future troubleshooting.
    5. Keep the source snapshot read-only until the migration has been fully completed and verified. Do not delete it before then.

    4. Standardize the Data Mapping

    Because tools use different field names and data structures, first map the source data to an intermediate format. Then convert the intermediate format into the target tool’s structure. The following is an example mapping; verify each field against the actual source files.

    Source field Standard field Target field Conversion rule
    system_instructions global_rules Target tool’s global instructions Remove leading and trailing whitespace while preserving the original text
    Content of project rule files project_rules project_rules.md in the project root Preserve paragraph and heading structure
    memories[].text long_term_memory[].content Target memory entries Remove surrounding whitespace and deduplicate by text
    memories[].created_at long_term_memory[].timestamp Target timestamp field Convert consistently to ISO 8601 UTC
    memories[].uuid long_term_memory[].id Target entry ID Preserve the original ID and record the old-to-new mapping
    Tool-specific metadata metadata.source Do not write to the target Discard it or record it in the migration log

    The following code demonstrates the mapping logic. It is illustrative only and must be adjusted to match the real source data structure.

    1. from datetime import datetime, timezone
    2. def normalize_timestamp(value):
    3. """Convert multiple timestamp formats to an ISO 8601 UTC string."""
    4. if value is None:
    5. return None
    6. if isinstance(value, (int, float)):
    7. # Treat the value as Unix seconds by default.
    8. # If it is in milliseconds, divide it by 1000 first.
    9. return datetime.fromtimestamp(value, tz=timezone.utc).isoformat()
    10. text = str(value).strip().replace("Z", "+00:00")
    11. dt = datetime.fromisoformat(text)
    12. if dt.tzinfo is None:
    13. # Assume UTC when no time zone is provided and record this in the log.
    14. dt = dt.replace(tzinfo=timezone.utc)
    15. return dt.astimezone(timezone.utc).isoformat()
    16. def transform_memory(source_data):
    17. standard = {
    18. "global_rules": (source_data.get("system_instructions") or "").strip(),
    19. "long_term_memory": [],
    20. }
    21. seen = set()
    22. for mem in source_data.get("memories", []):
    23. text = (mem.get("text") or "").strip()
    24. if not text or text in seen:
    25. continue # Skip empty and duplicate entries
    26. seen.add(text)
    27. standard["long_term_memory"].append({
    28. "id": mem.get("uuid"),
    29. "content": text,
    30. "timestamp": normalize_timestamp(mem.get("created_at")),
    31. "metadata": {"source": "source_tool"},
    32. })
    33. return standard

    After conversion, count the resulting entries and manually inspect several samples. Confirm that no content has been truncated or unintentionally rewritten.

    5. Write to the Target Tool and Run a Trial

    When writing the data to the target tool, use the following process:

    1. Confirm which import methods the target supports, such as an official import function, configuration files, or an API. Check the version documentation and ensure that the target format matches the conversion script.
    2. Start by writing the data to a test project or sandbox. Do not immediately overwrite the production configuration.
    3. Set file permissions so that only the current user can read and write the files. Configuration files containing secrets should be readable and writable only by the owner.
    4. Write to a temporary file first. After validation succeeds, atomically replace the production file to avoid corruption from an incomplete write.
    5. Run a fixed set of test prompts. Prepare five to ten questions covering global instructions, project rules, and memory retrieval. Record whether the target tool behaves as expected for each one.
    6. Compare the number of entries and the key rules between the source and target.
    7. After switching officially, retain the source snapshot for at least one complete development cycle. Remove it only after confirming that the migration has not caused problems.

    If the trial fails, roll back as follows:

    1. Stop writing to the target.
    2. Restore the target’s original configuration from its backup and remove files added by the migration.
    3. Use the source snapshot to confirm that the original data is intact.
    4. Record the failed step, error message, and relevant sample data. Correct the mapping rules before trying again.

    6. Migration Checklist

    • The complete source backup is finished and checksums have been generated.
    • All assets have been inventoried, and sensitive information has been marked and excluded.
    • The field mapping has been checked against the actual source data.
    • The conversion script has passed tests with sample data.
    • The target has been tested in a sandbox or test environment.
    • The test prompt set has passed, or all differences have been documented and addressed.
    • The rollback procedure has been rehearsed once.
    • The source snapshot will be retained until verification is complete.

    7. Ongoing Protection

    After the migration, the more important goal is to reduce dependence on any single tool.

    First, store core architectural constraints and business rules in Markdown files inside the repository, such as project_rules.md. This allows a new AI assistant to understand the project quickly by reading files in the project root, even if you later change tools.

    Second, put rule files under Git version control and periodically back up the configuration to encrypted cloud storage. Before committing or backing up files, check that they do not contain API keys or access tokens.

    Third, review the data policies and permission documentation for the tools you use on a regular basis. If you need to inspect network traffic or file changes, do so only on devices you own or are authorized to manage, and follow your organization’s security policies. Obtain the necessary authorization before performing such checks.

    Accounts can encounter problems at any time. The most reliable approach is to back up your data in advance and keep critical rules independent of any single tool.