Index of every page on this site: llms.txt
All skills
sivarampg avatar

/railway-iac-migration

@ba3f473
Run it yourself

Migrate Railway Config as Code (railway.json / railway.toml) to Infrastructure as Code (.railway/railway.ts). Use when a repo has railway.json or railway.toml files, when the user mentions "config as code", "railway.toml", "railway.json", "migrate railway config", "railway config migrate", or before the Config as Code hard cutoff on 2026-12-01. For authoring IaC from scratch, use the railway-iac skill.

Use this Skill: https://skilld.dev/gh/sivarampg/railway-iac-skill/railway-iac-migration

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

referencesfield-mapping.md

≈1k tokens on demand. Your agent reads this file only when SKILL.md points to it.

Config as Code to Railway IaC field mapping

How each railway.json / railway.toml setting translates into service(name, { ... }) in .railway/railway.ts.

Legend

  • ✅ Documented shorthand: confirmed in the IaC reference
  • 🔧 Via railway config migrate: no documented shorthand; let the CLI translate it, or use the nested build: / deploy: object form (the docs confirm nested form for preDeployCommand; verify others via railway config plan)

Build section

CaC field IaC DSL Status / notes
build.buildCommand build: "cmd" ✅
build.builder (RAILPACK / DOCKERFILE) - 🔧 config migrate handles it; no documented service() key
build.watchPatterns - 🔧 same
build.dockerfilePath - 🔧 same (Dockerfile builds are also implied by a Dockerfile in the repo)
build.railpackVersion - 🔧 same; RAILPACK_VERSION variable also still works

Deploy section

CaC field IaC DSL Status / notes
deploy.startCommand start: "cmd" ✅
deploy.preDeployCommand (array) preDeploy: "cmd" (string) ✅ Or keep nested form deploy: { preDeployCommand: ["cmd"] }, which config pull renders
deploy.healthcheckPath healthcheck: "/path" ✅
deploy.healthcheckTimeout healthcheckTimeout: 300 ✅
deploy.multiRegionConfig replicas: { "us-west2": 2, ... } ✅ Drop the numReplicas wrapper: {region: {numReplicas: n}} becomes {region: n}
deploy.restartPolicyType / restartPolicyMaxRetries - 🔧 config migrate handles; verify in plan output
deploy.cronSchedule - 🔧 same
deploy.overlapSeconds / drainingSeconds - 🔧 same (CaC stored these as strings)

Things CaC had that IaC models differently

CaC concept IaC equivalent
environments.<name>.{build,deploy} ctx.isEnvironment("<name>") ? a : b (or ctx.environment === "<name>") inside defineRailway
environments.pr.* Conditional on the ephemeral environment's name via ctx.environment; no dedicated pr key
File picked up automatically at deploy Nothing reads .railway/ at deploy time; railway config apply (local or CI) pushes config to the environment
"Config in code overrides dashboard" Apply writes the values to the environment; there is one source of truth afterward, not per-deploy override

Dashboard settings CaC could express that IaC adds

Once migrated, the same file can also own things CaC never touched: source (GitHub repo/image), env variables (preserve(), ctx.shared, cross-resource refs), domains, volumeMounts, databases (postgres/redis/mysql/mongo), volume, bucket, group, and replicas as a plain number. Consider folding service Settings-page config (env vars, domains, sources) into railway.ts during migration. Running railway config pull first is an easy way to capture them.

Worked example

// railway.json (before)
{
  "build": { "builder": "RAILPACK", "buildCommand": "pnpm build" },
  "deploy": {
    "preDeployCommand": ["npm run db:migrate"],
    "startCommand": "pnpm start",
    "healthcheckPath": "/health",
    "healthcheckTimeout": 100,
    "restartPolicyType": "on_failure",
    "multiRegionConfig": { "us-west2": { "numReplicas": 2 } }
  },
  "environments": {
    "staging": { "deploy": { "startCommand": "pnpm start:staging" } }
  }
}
// .railway/railway.ts (the shape `railway config migrate` produces)
export default defineRailway((ctx) => {
  const web = service("web", {
    build: "pnpm build",
    start: ctx.isEnvironment("staging") ? "pnpm start:staging" : "pnpm start",
    preDeploy: "npm run db:migrate",
    healthcheck: "/health",
    healthcheckTimeout: 100,
    replicas: { "us-west2": 2 },
    // builder / restartPolicyType: rendered by `config migrate` in the
    // form the CLI accepts; don't hand-translate, diff against the old file
  });

  return project("my-project", { resources: [web] });
});

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No alerts1mo3 checks · Risk SAFE
  • Gen Agent Trust Hub1mo

    This skill provides a guide for migrating Railway configuration files (railway.json/toml) to the newer TypeScript-based Infrastructure as Code format (.railway/railway.ts). It uses the official Railway CLI and encourages security best practices like manual plan review and keeping secrets out of source code. The operations performed are standard for the intended migration task.

  • Socket1mo

    No alerts

  • Snyk1mo

    Risk: LOW · No issues

Signed by skilld at ba3f473. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 months ago.

Steadyupdated 2 months ago
metadata
{
  "version": "1.0.0"
}

README badge

README badge for sivarampg/railway-iac-skill/railway-iac-migration