A Cloud Migration Your Ai Agents Cannot Drift Away From
Long migrations run by Ai agents fail the same way every time: the plan drifts, the rules get forgotten, and nobody reviews the work against the original scope. CogmemAi Migrate puts the scope in memory, enforces the rules before every command, and gates every phase with a review. One command turns a repository into a migration scope, a plan, a risk register and the cloud rules to go with it, in about two minutes.
npx cogmemai-mcp migrate assess --target aws
What One Command Produces
The inventory is computed on your machine. The scope and the plan are written for the team that will do the work and for the Ai agents that will help them, specific to what the inventory found, with every assumption marked.
The scope, as the project intent
Purpose, what moves, what stays, eight to twelve NEVER and MUST invariants (data residency, verification by counts and checksums, a single writer at cutover, rehearsed rollback, parity tests and dashboards before traffic, secrets reissued and never exported, source read-only thirty days before decommission), phases with a definition of done each, out of scope. Stored with set_intent, so every review and every judged guard call reads it.
MIGRATION.md
A components table (today, target, why), the phases with concrete steps and the gate for each, a risk register ranked by likelihood and impact with a mitigation per row, cost drivers with direction and order of magnitude, and the open questions the team must answer before phase two. Stored as memories too, so your Ai recalls the risks while it works.
The rules, installed
The migrate pack (16 process rules) and the target cloud's pack (AWS, Azure or Google Cloud) are installed for the project. Shell commands that break them are stopped before they run with no model call; plain-English actions are judged by guard_check; the end-of-turn review reads them all.
What Enforcement Looks Like
The DevSecOps demo, one hundred seconds: an agent tries to commit a secret, open a bucket, copy production data to a laptop and merge its own pull request, and is stopped each time. The cloud and migrate packs enforce the same way.
Three Commands, Start to Decommission
1. Assess
cd your-repo
npx cogmemai-mcp migrate assess --target aws
Inventory, scope as intent, MIGRATION.md, memories, rule packs. --dry-run prints the inventory and sends nothing. --target azure, gcp or other.
2. Work a phase under the rules
npx cogmemai-mcp guard test "aws s3 sync . s3://x --delete"
# denied: migrate_bulk_sync_never_deletes_without_dry_run
Your Ai agents do the work. Commands that break a rule are stopped before they run; actions in plain words are judged; the review at the end of each turn reads the scope.
3. Gate the phase
npx cogmemai-mcp migrate gate "Database migration"
# PASSED: coverage 88, 0 violations
Coverage 80 or more with no violations passes. Below that, the uncovered work and the violations are listed; do them and run it again. migrate status shows every gate on record.
No account yet? Get a free API key, run npx cogmemai-mcp setup, then the three commands above.
The 71 Rules
Each rule's first sentence is what the guard quotes when it blocks something. A pattern count means the rule is enforced on shell commands before they run, in that cloud's own CLI shapes; the rest are judged from their words. Install any pack alone with npx cogmemai-mcp rules install aws, azure, gcp or migrate.
Cloud migration (16 rules, rules install migrate)
The process rules for moving workloads between environments or clouds: inventory first, scope as the contract, one workload at a time, verified data, rehearsed cutover, tested rollback, gated phases, decommission last.
Inventory before any move
judgedNo migration work starts before the assessment is in CogmemAi: the inventory of services, data stores, integrations, secrets, scheduled jobs and traffic, the dependency map, and the scope document.
Run cogmemai-mcp migrate assess and read the result before touching anything. A migration without an inventory is a discovery exercise with production traffic as the test harness.
Scope document is the contract
judgedThe migration scope document (the project intent) is the contract: what moves, what stays, what must hold throughout, what is out of scope, and what done means for each phase.
Every change to it goes through set_intent with a reason, and every phase is reviewed against it. Work that is not in the scope is not migration work.
One workload at a time
judgedNEVER plan a big-bang cutover.
Workloads move one at a time, lowest risk first, each with its own phase gate, so a failure affects one system and the lesson improves the next move. A dependency that forces two workloads to move together is a finding to write down, not a reason to move everything.
Lift then modernize
judgedNEVER change the application and the infrastructure in the same step.
Move first with the smallest change that runs; modernize (managed services, containers, new frameworks) as a separate project afterwards, with its own scope. Two kinds of change in one cutover means a failure cannot be attributed.
Rollback rehearsed before each phase
judgedNo phase starts without a written rollback that has been rehearsed: how traffic returns to the source, how data written on the target during the window is reconciled, how long it takes, and who decides.
A rollback that has never run is a hope.
Data verified by counts and checksums
judgedData is verified on the target before cutover with row counts per table, checksums or hashes per partition, and a sample of records compared field by field, with the results stored as a memory.
"The copy finished without errors" is not verification.
Bulk sync never deletes without dry run
2 shell patternsNEVER run a bulk sync with a delete flag without a dry run first and a backup of the destination.
Sync tools with --delete remove whatever is missing on the source side, and a wrong path or a swapped argument empties the target.
Secrets reissued not copied
4 shell patternsNEVER export secrets from the source secret store to a file, a spreadsheet or a chat to move them.
Secrets are reissued in the target's secret manager (new credentials, new keys), the application is pointed at them, and the old ones are revoked after cutover. A migration is the moment every credential gets rotated for free.
Data residency preserved
judgedData stays in the residency class it has today unless the scope document says otherwise with the privacy owner's sign-off.
A migration never moves personal, health, payment or customer data to a region, country or provider the contracts do not allow, even temporarily, even for a staging copy.
Parity tests before traffic
judgedThe same test suite runs on the target with the same results before the first percent of traffic moves, plus a smoke test of every integration (payments, email, webhooks, scheduled jobs, third-party APIs) from the target network with the target's identities.
Differences are findings to resolve, not notes.
Observability before traffic
judgedDashboards, logs, alerts and an on-call owner exist for the target before it takes traffic, with the source's baseline numbers (latency, error rate, throughput, cost) written down for comparison.
A target with no dashboard cannot be judged healthy, so it cannot be cut over.
Cutover gradual with lowered ttl
judgedCutover is gradual (weighted DNS, a load balancer split or a feature flag) with DNS TTLs lowered at least a day ahead, a freeze on schema changes during the window, and a go or no-go call recorded with the numbers.
Raising a TTL back or lifting the freeze happens only after the phase gate passes.
Dual write or read only window
judgedDuring cutover the data has exactly one writer: either the source goes read-only for the final sync, or dual writes are in place with reconciliation.
NEVER let both sides accept writes without a reconciliation plan, because the divergence is silent and the fix is manual.
Source kept read only before decommission
2 shell patternsNEVER decommission, delete or wipe the source environment in the same change as the cutover.
The source stays read-only and backed up for at least thirty days after the phase gate passes, then is decommissioned as its own planned change with a named approver and a final backup verified restorable.
Cost baseline before and after
judgedThe source's monthly cost is written down before the move, a budget with alerts exists on the target before it takes traffic, and the first full month on the target is compared with the baseline and stored as a memory.
A migration that does not know what it saved or cost cannot be called finished.
Gate after every phase
judgedEvery phase ends with cogmemai-mcp migrate gate "<phase>": the work is reviewed against the scope document, and the phase passes only with coverage of at least 80 and no violations.
A gate that fails blocks the next phase; the fix is to do the work, not to lower the bar. Results are stored so the whole migration has a record.
AWS (20 rules, rules install aws)
Accounts, IAM, security groups, S3, RDS, EKS, backups, budgets and regions on AWS, in the shapes the aws CLI takes.
Root user locked down
1 shell patternNEVER use the AWS root user for daily work and never create access keys for it.
Root has hardware MFA, no keys, and is used only for the handful of tasks that require it, each one logged. Everything else goes through IAM Identity Center roles.
No long lived access keys
1 shell patternNEVER create long-lived IAM access keys for people or workloads.
People sign in through Identity Center with short sessions; workloads assume roles (instance profiles, IRSA, Lambda execution roles, OIDC from CI). A key that must exist is rotated on a schedule and scoped to one task.
No iam users
1 shell patternCreating an IAM user needs a written reason; the default is a role.
The only standing users are break-glass accounts with hardware MFA, and those are reviewed quarterly.
No admin or wildcard policies
1 shell patternNEVER attach AdministratorAccess, PowerUserAccess or a policy with Action "*" or Resource "*" to a user, role or group outside the break-glass role.
Permissions are scoped to the actions and resources the job needs, and permission boundaries cap what any role can grant.
Security groups no world admin ports
2 shell patternsNEVER open SSH, RDP or a database port to 0.0.0.0/0 or ::/0 in a security group.
Administrative access goes through Systems Manager Session Manager or a bastion behind SSO; databases are reachable only from the application's security group.
S3 public access block stays on
4 shell patternsNEVER remove or weaken the S3 Block Public Access settings at the account or bucket level, and never write a bucket policy with Principal "*".
Public content is served through CloudFront with origin access control, not from a public bucket.
Encryption at rest by default
2 shell patternsNEVER turn off EBS default encryption, and never create an RDS instance without encrypted storage.
Each data class has its own KMS key with a rotation schedule and a key policy that names who may decrypt.
Rds never publicly accessible
1 shell patternNEVER make an RDS instance or cluster publicly accessible.
Databases live in private subnets and are reached through the application tier, a bastion behind SSO, or Session Manager port forwarding.
Rds deletion protection and final snapshot
3 shell patternsNEVER delete a production database without a final snapshot, and never remove deletion protection as part of the same change that deletes.
Removing protection is its own reviewed change; the deletion is a second one, after the snapshot is verified restorable.
Backup plans cross region tested
2 shell patternsEvery tier-1 data store is in an AWS Backup plan with a cross-region copy and a quarterly restore test that is written down.
Deleting a backup vault, a recovery point or a snapshot is a reviewed change, never a cleanup task.
Detective controls stay on
3 shell patternsNEVER disable GuardDuty, Security Hub, Config or Inspector in any account.
They are organization-wide, delegated to the security account, and their findings have an owner. Turning one off to make a deploy pass is an incident.
Organization scps are the floor
1 shell patternNEVER detach or delete a service control policy, leave the organization, or move an account out of its organizational unit without the security owner's approval.
SCPs are the floor under every account: they deny disabling CloudTrail, creating root keys, leaving the org and using unapproved regions.
Approved regions only
2 shell patternsResources are created only in the approved regions for their data class, enforced by an SCP, and nothing with personal or regulated data is replicated across regions without the privacy owner's sign-off.
Cross-region replication and read replicas are changes, not defaults.
Private subnets no auto public ip
2 shell patternsWorkloads run in private subnets with egress through NAT or VPC endpoints; subnets do not auto-assign public IPs, and the only public addresses belong to load balancers and NAT gateways.
Attaching a public IP to an instance is an exception with a reason.
Eks private endpoint and irsa
1 shell patternNEVER expose an EKS API endpoint to 0.0.0.0/0.
The endpoint is private or restricted to the office and CI CIDRs, nodes are in private subnets, and pods get AWS permissions through IAM roles for service accounts, never through node instance profiles with broad rights.
Secrets in secrets manager only
2 shell patternsNEVER store a secret as a plain String parameter, in an environment variable definition, in user data or in a task definition.
Secrets live in Secrets Manager or SSM SecureString, are referenced by ARN, and rotate on a schedule.
Tags required on every resource
judgedEvery resource carries Owner, Environment, CostCenter and DataClass tags, enforced by a tag policy and Config rule.
Untagged resources are reported weekly and reaped after thirty days in non-production. A resource nobody owns is a cost and a risk at once.
Budgets before first workload
2 shell patternsEvery account has an AWS Budget with alerts at 50, 80 and 100 percent, routed to a person, before its first production workload.
Cost anomaly detection is on. Deleting a budget is a reviewed change.
Autoscaling has a ceiling
2 shell patternsEvery auto scaling group, Lambda concurrency setting and DynamoDB on-demand table has a ceiling that someone chose on purpose.
A runaway loop or a scraper should hit a limit and an alert, not the credit card. Raising a ceiling above a hundred instances is a reviewed change.
Cloudtrail org trail immutable
2 shell patternsThe organization trail covers every account and region, writes to a bucket in the security account with object lock and MFA delete, and is never the thing that gets turned off to save money.
Log file validation stays on.
Azure (18 rules, rules install azure)
Subscriptions, Entra roles, NSGs, storage accounts, SQL, Key Vault, AKS, Policy, locks and budgets on Azure, in the shapes the az CLI takes.
No owner role assignments
2 shell patternsNEVER assign Owner or User Access Administrator to a person, group or service principal; those roles live only on the break-glass accounts with Privileged Identity Management and approval.
Contributor at subscription scope needs the platform owner's sign-off; everything else is a scoped built-in or custom role on a resource group.
Managed identities over secrets
2 shell patternsWorkloads authenticate with managed identities or workload identity federation, never with a service principal secret or certificate pasted into configuration.
Creating or resetting a service principal credential needs a written reason and an expiry under ninety days.
Nsg no world admin ports
3 shell patternsNEVER create a network security group rule that allows SSH, RDP, SQL or any port from Internet, * or 0.0.0.0/0.
Administrative access goes through Azure Bastion or a jump host behind Entra sign-in; databases accept traffic only from the application subnet.
Storage no public blob access
2 shell patternsNEVER allow anonymous blob access on a storage account or set a container's public access to blob or container.
Public content is served through Front Door or a CDN with a private origin; everything else is reached with Entra identities or short-lived SAS tokens.
Storage https and tls12 only
1 shell patternNEVER turn off HTTPS-only or lower the minimum TLS version below 1.2 on a storage account, and never disable infrastructure encryption on accounts holding regulated data.
Shared key access is off where Entra authorization works.
Sql private endpoint only
2 shell patternsNEVER enable public network access on an Azure SQL server, database for PostgreSQL or MySQL flexible server, or add a firewall rule that spans the whole internet.
Databases are reached through private endpoints from the application virtual network.
Key vault is the only secret store
3 shell patternsNEVER delete or purge a Key Vault, disable its purge protection or soft delete, or put a secret anywhere other than Key Vault.
Apps read secrets through Key Vault references or managed identity; CI reads them at run time, never at build time into an image.
Policy assignments are the floor
1 shell patternNEVER delete or exempt an Azure Policy assignment at the management group level to make a deploy pass.
Policy enforces allowed locations, required tags, no public IPs, no public storage and diagnostic settings on everything. A deploy that Policy blocks is a deploy that needs a different design or a documented exception from the platform owner.
Allowed locations data residency
2 shell patternsResources are created only in the locations Policy allows for their data class, and paired-region replication (geo-redundant storage, SQL geo-replication, Cosmos multi-region) for regulated data needs the privacy owner's sign-off.
Residency is decided once, in the scope document, not per deploy.
Defender and diagnostics on
2 shell patternsNEVER set Defender for Cloud to the free tier on a production subscription or remove diagnostic settings that ship activity and resource logs to the central Log Analytics workspace.
The workspace is in the security subscription with retention of at least one year.
Resource locks on production
2 shell patternsNEVER remove a CanNotDelete or ReadOnly lock as part of the same change that deletes or modifies the locked resource, and never delete a production resource group.
Removing a lock is its own reviewed change with a rollback; the deletion follows after the backup is verified.
Aks private rbac entra
1 shell patternNEVER create or update an AKS cluster with RBAC disabled, local accounts enabled, or an API server open to 0.0.0.0/0.
Clusters are private or CIDR-restricted, use Entra integration with Azure RBAC, workload identity for pods, and Defender for Containers.
Backup vaults protected
3 shell patternsEvery production VM, database and file share is protected by a Recovery Services or Backup vault with soft delete and a quarterly restore test that is written down.
Disabling protection with data deletion, or deleting a vault, is a reviewed change, never a cleanup.
Budgets and cost alerts
1 shell patternEvery subscription has a Cost Management budget with alerts at 50, 80 and 100 percent routed to a person, before its first production workload, and an anomaly alert.
Deleting a budget is a reviewed change.
Tags required
judgedEvery resource group and resource carries Owner, Environment, CostCenter and DataClass tags, inherited where Policy allows and enforced by a deny policy where it does not.
Untagged resources are reported weekly and removed from non-production after thirty days.
Private endpoints for paas
judgedPlatform services (storage, SQL, Key Vault, Cosmos, Service Bus, container registry) are reached over private endpoints from the virtual network, with public network access disabled once the private endpoint works.
A service reachable from the internet is an exception with a reason and an expiry.
Entra mfa and conditional access
judgedEvery human sign-in to the portal, CLI or any administrative role requires phishing-resistant MFA through Conditional Access, and privileged roles are activated just in time through Privileged Identity Management with approval and a time limit.
Standing privileged assignments are reviewed monthly and removed.
Vm no public ip by default
1 shell patternVirtual machines are created without public IP addresses; inbound reaches them through a load balancer, Application Gateway or Bastion.
A VM that needs a public address is an exception with a reason, an NSG that allows only the needed port, and an expiry.
Google Cloud (17 rules, rules install gcp)
Projects, IAM, service accounts, VPC firewall, Cloud Storage, Cloud SQL, GKE, org policies, logging and budgets on Google Cloud, in the shapes gcloud and gsutil take.
No primitive roles
1 shell patternNEVER grant roles/owner or roles/editor on a project, folder or organization to a person, group or service account.
Those are break-glass roles. Everyone else gets predefined or custom roles scoped to the resources the job touches, granted to groups, with IAM Conditions and expiry where the role is sensitive.
No allusers bindings
2 shell patternsNEVER bind allUsers or allAuthenticatedUsers to any resource.
Public web content goes through a load balancer with Cloud CDN or Cloud Armor in front of a private backend; a bucket, function or service with an allUsers binding is an exposure, not a convenience.
No service account keys
1 shell patternNEVER create a user-managed service account key.
Workloads on Google Cloud attach a service account; everything outside uses workload identity federation. The organization policy disabling key creation stays on, and any key that exists is rotated and tracked to retirement.
Firewall no world admin ports
2 shell patternsNEVER create a VPC firewall rule that allows SSH, RDP, a database port or all protocols from 0.0.0.0/0.
Administrative access goes through Identity-Aware Proxy TCP forwarding; databases accept traffic only from the application's service account or subnet.
Buckets uniform access never public
2 shell patternsNEVER make a bucket or object public with an ACL, and never turn off uniform bucket-level access.
Buckets use uniform access with IAM, public access prevention enforced, and retention or versioning where the data class requires it.
Cloudsql private ip only
1 shell patternNEVER give a Cloud SQL instance a public IP or an authorized network of 0.0.0.0/0.
Instances use private IP on the shared VPC and are reached through the Cloud SQL Auth Proxy or private service connect with IAM database authentication.
Cloudsql backups and deletion protection
2 shell patternsNEVER turn off automated backups or point-in-time recovery on a production Cloud SQL instance, delete its backups, or remove deletion protection in the same change that deletes it.
Restores are tested quarterly and written down.
Org policies are the floor
1 shell patternNEVER delete or reset an organization policy constraint to make a deploy pass.
The floor is: domain restricted sharing, service account key creation disabled, resource location restriction, external IP access restricted, public access prevention on storage, and uniform bucket access required. A blocked deploy needs a different design or a documented exception from the platform owner.
Resource locations data residency
2 shell patternsResources are created only in the locations the organization policy allows for their data class; multi-region and dual-region storage, cross-region Cloud SQL replicas and multi-region Spanner or Firestore for regulated data need the privacy owner's sign-off.
Residency is decided in the scope document, not per deploy.
Audit logs central retained
1 shell patternAdmin Activity and Data Access audit logs are on for every service that holds data, aggregated through an organization sink to a log bucket in the security project with retention of at least one year and a lock.
Shortening retention under a year or deleting the bucket is an incident.
Gke private shielded workload identity
1 shell patternNEVER create or update a GKE cluster with public nodes, legacy authorization, unshielded nodes or a control plane open to 0.0.0.0/0.
Clusters are private, use Workload Identity for pods, Binary Authorization for images, and are reached through authorized networks or IAP.
Project deletion and liens
2 shell patternsNEVER delete a project or remove a lien from a production project as a cleanup task.
Deleting a project is a planned decommission with a backup, a thirty-day read-only period and a named approver; removing the lien is its own reviewed change.
Budgets before first workload
1 shell patternEvery billing account and every production project has a budget with alerts at 50, 80 and 100 percent routed to a person, before its first production workload.
Unlinking billing or deleting a budget is a reviewed change, because unlinking billing stops the workload.
Secret manager only
2 shell patternsNEVER put a secret into a Cloud Run, Cloud Functions or GKE environment variable, a startup script or a container image.
Secrets live in Secret Manager, are mounted or referenced by version, and rotate on a schedule. Destroying a secret version is a reviewed change.
Labels required
judgedEvery project and resource carries owner, environment, cost-center and data-class labels, and billing export to BigQuery is on so cost per label is a query, not a guess.
Unlabeled resources are reported weekly and removed from non-production after thirty days.
Vpc service controls for data
1 shell patternProjects that hold regulated data sit inside a VPC Service Controls perimeter with Private Google Access, so data cannot be copied to a bucket or dataset outside the perimeter by any identity, including an over-privileged one.
Perimeter changes are reviewed by the security owner.
Compute no external ip and shielded
1 shell patternCompute instances are created without external IPs and with Shielded VM on; inbound traffic reaches them through a load balancer or IAP, and egress goes through Cloud NAT.
An instance that needs an external address is an exception with a reason and an expiry.
Questions
What does cogmemai-mcp migrate assess actually do?
It reads the repository on your machine and builds an inventory: languages, frameworks, data stores, cloud SDKs, infrastructure as code, containers, CI, scheduled jobs, the names of environment variables, external hosts and any secret-looking files. Only names and counts leave your machine, never file contents and never a secret value. From that inventory it writes the migration scope document and stores it as the project's CogmemAi intent, writes MIGRATION.md with the components, phases, a ranked risk register, cost drivers and open questions, stores the plan and risks as memories, and installs the migrate rule pack plus the pack for the target cloud. About two minutes.
Does it migrate my systems for me?
No, and nothing credible does. The three big clouds give away assessment and code conversion tools, and the execution is a services business. What fails in long agent-run migrations is different: the plan drifts, the rules get forgotten, and nobody reviews the work against the original scope. CogmemAi Migrate is the memory, scope, guard and review layer on top of whatever tools and people do the moving.
What is a phase gate?
After each phase you run cogmemai-mcp migrate gate "<phase>". It gathers what changed (commits, files, your notes and the planned steps for that phase) and reviews it against the scope document: what was covered, what was missed, any violation of the invariants, and a coverage score. The phase passes at coverage 80 or more with no violations, and every result is stored, so the migration has a record from the first day to decommission.
Which clouds are covered?
AWS (20 rules), Azure (18) and Google Cloud (17), each written in that cloud's own CLI shapes: no root or primitive roles, no long-lived keys, no admin ports or databases open to the internet, no public buckets, encryption and backups and deletion protection, audit logs that are never disabled, org policies and SCPs as the floor, approved regions and data residency, budgets before the first workload. Choose any of them as the target, or "other" for a data center or a provider not listed.
Does the inventory send my code anywhere?
No. The inventory is computed locally and contains names and counts: dependency names, environment variable names (never values), hostnames referenced in the code, file names of things that look like secrets so you can check they are ignored, and sizes. node_modules, vendor, lockfiles and prose are skipped. Run migrate assess --dry-run to print exactly what would be sent, or migrate inventory to see it without calling anything.
What does it cost?
The inventory, the rule packs and the shell guard are included in every CogmemAi plan, including the free tier. The assessment and the phase gate are judged calls on the paid tiers and run through the MSGR gateway on your account's daily limit. Included in CogmemAi for Teams.
Start With the Assessment
Two minutes from a repository to a scope, a plan, a risk register and the rules. Included in CogmemAi for Teams.
