Migrations Migrating from Heroku, Render, Hatchbox or Cloud 66? We move your production app within 48 hours →
Staging environments with an AI agent: create, deploy, test and promote ← Blog Agency playbooks • 4 min read

Staging environments with an AI agent: create, deploy, test and promote

Almokhtar Bekkour

Almokhtar Bekkour, Founder, Systems Architect

July 21, 2026 · 4 min read

Follow this on your own server. Start your 14-day trial

Staging gets skipped for two reasons: setting one up is a chore, and on platforms that bill per service, every staging copy is another line on the invoice. On Railyard, a staging environment is a copy of your app running on a server you already pay for, and an AI agent can set one up, deploy a branch to it and promote it in a few sentences.

This tutorial walks the full loop with Claude: create staging, deploy a branch, verify it, promote to production.

What you’ll need

  • Railyard connected to Claude (Customize → Connectors → Railyard → Connect), or Claude Code with claude mcp add --transport http railyard https://app.railyard.run/api/mcp.
  • Write access to create the environment and to promote. Deploying to staging afterwards only needs deploy.
  • A production app on Railyard. The examples use one called shop.

Step 1: Create the environment

> Create a staging environment for shop that tracks the develop branch.

Claude calls create_environment:

{ "name": "create_environment", "arguments": { "app": "shop", "environment": "staging", "git_ref": "develop" } }
Created shop-staging (staging of shop). Call deploy_app with app shop-staging to deploy it.

What you get:

  • A real copy, not a template. Build settings, processes, health checks, add-ons and variables are copied from shop, on the same server. Staging behaves like production because it’s configured like production.
  • Its own branch. git_ref points it at develop, while production stays on main.
  • Safe defaults. No custom hostname is carried over, so staging can’t answer on your production domain. Auto-deploy is off until you turn it on. And a staging environment sleeps when idle, so it isn’t holding memory on the server while nobody looks at it.
  • Linked to its parent. The environment knows it came from shop, which is what makes promotion possible later.

The name must be lowercase (staging, qa, preview-checkout). Creating an environment from an environment uses the original app as the base, so you never get shop-staging-qa.

Variables that should differ

Copied variables are a starting point. Point staging at test credentials before its first deploy:

> On shop-staging, set STRIPE_SECRET_KEY to the test key from my .env.staging, and DATABASE_POOL to 5.

set_env needs write access and is marked destructive, so Claude asks before each one. Sealed variables can’t be changed by an agent at all; change those in the dashboard.

Step 2: Deploy the branch

> Deploy shop-staging and tell me when it's up.

deploy_app builds the latest commit on develop. Claude follows it with get_deploy and deploy_logs, and when it’s done it gives you the staging URL. To test a specific commit instead of the branch head: “deploy shop-staging at 4be27aa”.

Step 3: Check it

Ask for the same checks you’d run by hand:

> Is shop-staging healthy? Any errors since the deploy? How fast is the checkout path?
  • list_processes: containers running, no restarts or crash loops
  • app_logs at level error, range: 1h: nothing new since the deploy
  • app_traffic: latency and errors per path, if you’ve sent test traffic

If staging has its own database, query_database can answer data questions against staging specifically (“did the migration backfill orders.region?”). That’s read-only and needs write access; see read-only SQL for agents.

Step 4: Promote to production

> Promote shop-staging to production.

promote_app does two things:

  1. Copies staging’s settings to shop. That covers build settings, processes and the other configuration you changed on staging. Variables are not copied across, because staging’s test keys must never overwrite production’s live ones.
  2. Deploys the exact commit staging last ran successfully to shop, through production’s normal pipeline, including deploy approval if production requires it.
Promoted shop-staging to shop: copied 2 setting(s) and started deploy #1240.

Production gets the commit you verified, not whatever is on main by now. That’s the point of promoting instead of “just deploying main”.

promote_app is marked destructive, since it changes production. Claude confirms with you first, and with write access only an admin or owner could have granted it.

Step 5: Follow production, and clean up

> Follow deploy #1240 and confirm shop is healthy.

Once production is on the new release, decide what happens to staging. It costs nothing while it sleeps, so most teams keep it. If you’d rather remove it, ask: deleting an app goes to Railyard’s approval queue, and an admin confirms it there.

Variations

  • One environment per feature. “Create a preview-checkout environment of shop on the checkout-redesign branch.” Each one is a cheap container on your server, not a new paid service.
  • A copy for an experiment. clone_app makes an independent copy named shop-copy that isn’t linked to production, for when you don’t plan to promote.
  • A template instead of a copy. For a clean extra service (a status page, analytics, a queue dashboard), list_templates and launch_template deploy one of Railyard’s one-click apps next to yours.

Why environments are cheap on Railyard

Platforms that bill per service charge for each staging copy separately. On Railyard you pay a flat price per team, and the environments run as containers on servers you already rent. Ten preview environments on a server with room to spare cost nothing extra, within your plan’s app limit, and an idle staging that sleeps isn’t even using that room.

That changes how often you’ll use staging. If it’s free and one sentence away, you stop skipping it.

Next: roll back a bad release from chat, or browse every tool in the MCP docs.

Why people pick Railyard for this

  • Your own cloud account. Deploy to DigitalOcean, Hetzner, Vultr, AWS, OVHcloud, or any Linux server over SSH, billed directly by your provider with no markup.
  • One flat price per team. Launch is $22 a month with 2 servers and 1 seat. Scale is $45 with 5 servers and 5 seats, Team is $79 with 10 servers and 15 seats, and Agency is $149 with 20 servers and unlimited seats. Unlimited apps on every plan, no charge per app, per deploy or per gigabyte, and a 14-day trial to start.
  • One-click templates. Deploy open-source apps, like databases, analytics and dev tools, to your own server in one click.
  • Managed databases. Postgres, MySQL and Redis with scheduled, restore-verified backups and point-in-time recovery.
  • Push-to-deploy. Deploy from GitHub, GitLab or the CLI, with automatic HTTPS and zero-downtime releases.

Staging that doesn't add to your bill.

Railyard environments are containers on servers you already pay for. Connect Claude and create, deploy and promote them in plain language.

14-day trial on every plan. One flat price per team, your servers at your provider's price.

Theme
Colors