Pick an agent, give it a repo it can run, let it declare the database, queue and cron job in the code, and ship to your own AWS or GCP account without handing it cloud credentials.

To build a backend with an AI coding agent and deploy it to your own cloud, give the agent a repo it can run locally, let it declare the database, queue and cron job in the application code, and ship through a reviewed pipeline that holds the cloud credentials. The agent writes and tests the change, and the pipeline provisions it.
With Encore, the infrastructure the agent declares is what gets provisioned in your AWS or GCP account.
Agents are good at writing handlers and migrations. They get stuck at the edges of the repo. Hosted app builders deploy to their own platform, which is fine for a prototype but not for a backend that has to live in your company's AWS account. Editor and cloud agents such as Cursor's cloud agents and GitHub's Copilot coding agent work on a branch and open a pull request, and you still have to connect the repo to hosting, a database and a pipeline.
Three things usually go wrong after that:
Encore is a backend framework with built-in infrastructure, and its platform deploys into your own AWS or GCP account. Teams bring their own coding agent, and Encore provides the local environment, the system context and the deploy controls.
Run in your terminal to get started locally.
The Encore skills teach Claude Code, Cursor, Codex or Copilot how to create services, databases, Pub/Sub, cron jobs, buckets and tests. The local MCP server, started with encore mcp start, gives the agent the application's services, APIs, database schemas and traces as tools. An agent can also do the whole setup itself if you tell it to read https://encore.dev/agents/getting-started.md.
Ask for a feature in product terms, for example: "Add an orders API with Postgres, send a confirmation when an order is placed, and cancel orders left pending for a day." A typical result is one service file plus a migration:
// orders/orders.ts
import { api, APIError } from "encore.dev/api";
import { SQLDatabase } from "encore.dev/storage/sqldb";
import { Topic, Subscription } from "encore.dev/pubsub";
import { CronJob } from "encore.dev/cron";
import log from "encore.dev/log";
// Local Postgres under `encore run`, RDS or Cloud SQL when deployed.
const db = new SQLDatabase("orders", { migrations: "./migrations" });
interface Order {
id: number;
email: string;
status: string;
}
interface OrderPlaced {
orderId: number;
email: string;
}
const orderPlaced = new Topic<OrderPlaced>("order-placed", {
deliveryGuarantee: "at-least-once",
});
// A public guest checkout keeps the tutorial short. Add auth: true or a rate limit
// before production, so nobody can create orders in bulk.
export const create = api(
{ expose: true, method: "POST", path: "/orders" },
async ({ email }: { email: string }): Promise<Order> => {
if (!email.includes("@")) throw APIError.invalidArgument("a valid email is required");
// The order commits only after the publish, so a failed publish stores nothing.
await using tx = await db.begin();
const order = await tx.queryRow<Order>`
INSERT INTO orders (email) VALUES (${email})
RETURNING id, email, status`;
await orderPlaced.publish({ orderId: order!.id, email });
await tx.commit();
return order!;
},
);
// The claim commits only after the send, so a redelivered message does nothing
// and a failed send rolls back and is retried.
const _confirm = new Subscription(orderPlaced, "send-confirmation", {
handler: async ({ orderId, email }) => {
await using tx = await db.begin();
const claimed = await tx.queryRow`
INSERT INTO confirmations (order_id) VALUES (${orderId})
ON CONFLICT DO NOTHING RETURNING order_id`;
if (!claimed) return;
// Call your email provider here and let its errors throw.
log.info("sending confirmation", { orderId, email });
await tx.commit();
},
});
export const expirePending = api(
{ expose: false, method: "POST", path: "/internal/expire-pending" },
async (): Promise<{ cancelled: number }> => {
const rows = await db.queryAll`
UPDATE orders SET status = 'cancelled'
WHERE status = 'pending' AND created_at < now() - interval '24 hours'
RETURNING id`;
return { cancelled: rows.length };
},
);
const _expire = new CronJob("expire-pending", {
title: "Cancel orders left pending for a day",
every: "1h",
endpoint: expirePending,
});
-- orders/migrations/1_create_orders.up.sql
CREATE TABLE orders (
id BIGSERIAL PRIMARY KEY,
email TEXT NOT NULL,
status TEXT NOT NULL DEFAULT 'pending',
created_at TIMESTAMPTZ NOT NULL DEFAULT now()
);
CREATE TABLE confirmations (
order_id BIGINT PRIMARY KEY REFERENCES orders (id)
);
The database, the topic, the subscription and the schedule are all in the diff, so the reviewer reads one pull request. The agent brings the change; Encore provides the local environment, the system context and the deploy controls, so the agent can add infrastructure in the same change as the logic and run it right away.
The agent runs the app and calls it, the way a developer would. You should see something like:
encore test runs the test suite against separate test databases, so a broken migration or a missing ON CONFLICT fails on the laptop. Cron jobs are managed by the Encore platform and run only in deployed cloud environments, not locally and not in preview environments, so the agent calls /internal/expire-pending directly to check it. Every request shows up as a trace in the local development dashboard, which the agent can read through the MCP server when a test fails.
Connect your AWS or GCP account once and push. The Encore platform provisions what the code declares in your account: RDS or Cloud SQL for the database, SNS and SQS or Google Cloud Pub/Sub for the topic, and the services on Fargate, EKS or Cloud Run. The cron job is run by the Encore platform, with no scheduler resource to create.
Each pull request gets a preview environment hosted by Encore, with its own database, so a reviewer tries the feature before merge. For production you can require deploy approval for any deploy that changes infrastructure. The agent's session never holds cloud keys. Pair this with deny rules for aws, gcloud and terraform in the agent config, such as Claude Code's permission rules, so the session cannot go around the pull request.
Verdict. Any of the major coding agents can write the backend. What decides whether it reaches production safely is the repo: whether the agent can run it, whether the infrastructure sits next to the code, and whether credentials stay out of the session. Encore covers all three, which makes it the shortest path from an agent's pull request to your own AWS or GCP account.
Start from a repo the agent can run locally, let it declare the database, queues and scheduled jobs in the application code, have it run the tests against local infrastructure, and open a pull request. With Encore, you bring your own coding agent; Encore provides the local environment, the system context and the deploy controls, and provisions those declarations in your AWS or GCP account, so the agent never needs cloud credentials.
Claude Code, Cursor, OpenAI Codex and GitHub Copilot's coding agent can all write a backend. The difference that matters more is the repo: an agent that can start the database and run the tests locally fixes its own mistakes, while one that cannot only guesses.
Yes. It should not do it with your credentials, though. Let the agent open a pull request and let a reviewed pipeline or platform hold the AWS role and do the deploy. That keeps a prompt-injected or confused session from changing production directly.
No. When the database, Pub/Sub topics, cron jobs and buckets are declared in the application code, the deploy provisions them, so there is no separate Terraform module for the agent to write.
Deploy to your cloud on AWS and Google Cloud
without managing infrastructure
Encore lets developers and agents define application infrastructure directly in code, then automatically provisions it from local development to production in your AWS or GCP account.