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.

SKILL.md

≈107 tokens for metadata: the name and description. ≈1.6k when used: this file. ≈1k more on demand in 1 file.

Description uses 5.4% of example budget

Before choosing a Skill, your Agent reads its name and description. All available Skills share that space.

  • A shorter description leaves more room for other Skills. This entry exceeds our 1% size suggestion.

In our Claude Code example, all Skill names and descriptions share 8,000 characters. This Skill uses ≈429 characters, or 5.4%.

The 1% threshold is a size suggestion. Longer descriptions can still fit.

Your model, settings, and other Skills decide how much text your Agent can read.

Example settings and source

The example uses a 200k-token context and default Claude Code settings. The count includes the name, description, separators, and when_to_use when present. Codex also counts local file paths.

Skit's source and limits: Codex 0.160.1, Claude Code 2.1.292.

Migrate Railway Config as Code to IaC

Config as Code (railway.json / railway.toml) is deprecated. It stops being read on 2026-12-01 (hard cutoff), and new services can't opt in. The replacement is Infrastructure as Code: .railway/railway.ts evaluated by the Railway CLI.

Config as Code Infrastructure as Code
Scope One service's deployment Whole project/environment
File railway.json / railway.toml in the repo .railway/railway.ts
Evaluated At deploy time, overrides dashboard By CLI: railway config plan / apply

A service cannot be managed by both systems. railway config plan refuses to run while any targeted service still reads a CaC file; the error names the service. Migration means: get config into railway.ts, get CaC out of the deploy path (remove the file AND clear any custom config-path setting), then apply.

Step 1: Inventory what needs migrating

# Find every CaC file in the repo
find . -name "railway.toml" -o -name "railway.json" | grep -v node_modules

Also check each service's Settings page for a custom config file path (e.g. /backend/railway.toml): a file outside the default search locations still counts as CaC-managed, and its path must be cleared during migration.

Note the repo topology; it decides the output shape:

  • One repo holds all services in the environment: single railway.ts, no partial export.
  • Services live in separate repos: run the migration in each repo; each writes export const partial = "<service name>" so it owns only its slice.

Step 2: Migrate with the CLI (preferred)

# Preview the generated authoring file (writes nothing)
railway config migrate

# Write .railway/railway.ts AND clear the Railway Config File settings on the services
railway config migrate --apply

# Also delete the old railway.json / railway.toml files
railway config migrate --apply --delete-files

# Options
railway config migrate --service api --apply      # one service only; writes a named `partial` export
railway config migrate --lang py --apply          # Python (beta); --lang go for Go

Behavior to expect:

  • Monorepo: migrate finds every CaC file in the repository and merges them into one railway.ts. No partial export.
  • Single-service repo (--service or one file found): writes export const partial = "<service name>", matching how CaC applied per-service.
  • --apply clears the dashboard's "Railway Config File" setting so deploys stop reading the old file.

If railway config migrate isn't available in the installed CLI, use the manual path: railway config pull --force, translate fields per references/field-mapping.md, then continue at Step 3.

Step 3: Detach Config as Code completely

Both must happen or the service stays CaC-managed and plan keeps failing:

  1. Remove railway.json / railway.toml from the service's source repo (or use --delete-files).
  2. Clear the custom config file path in service Settings, if one was set. (--apply does this; the manual path requires doing it in the dashboard.)

Step 4: Review the plan to verify

railway config plan

A good migration plan shows only the settings you intentionally moved (e.g. build, start, healthcheck updates on migrated services). Red flags (do NOT apply):

  • Deletes of services, variables, volumes, or buckets you didn't intend
  • Changes to unrelated services
  • A plan still blocked by "managed by config file" errors, meaning a CaC file or custom path survived (Step 3)

If the CaC file had settings the DSL doesn't cover, config migrate preserves them. Diff the generated railway.ts against the old file field by field before deleting it (field-mapping reference below).

Step 5: Apply

railway config apply            # interactive confirm
railway config apply --yes      # non-interactive; + --confirm-destructive if the plan marks deletes

For a single-service (partial) migration, the first apply also claims ownership of the declared resources. It runs even when the plan shows no changes. That's expected.

Translating environments.* overrides

CaC environments.<name> blocks become ctx conditionals in defineRailway:

// railway.json: { "environments": { "staging": { "deploy": { "startCommand": "npm run staging" } } } }
const web = service("web", {
  start: ctx.isEnvironment("staging") ? "npm run staging" : "npm start",
});

CaC environments.pr applied to every ephemeral PR environment. There's no ctx.isPR; reproduce it by checking the ephemeral environment name via ctx.environment, or keep per-env conditionals for the environments you actually deploy.

Field mapping

Full CaC-to-DSL translation table (confirmed shorthands vs. fields handled by config migrate): references/field-mapping.md.

Working agreement

  • Always run railway config migrate (preview) before --apply. Read the generated file before it lands.
  • Never apply a plan you haven't reviewed. Destructive lines are marked; a stray --yes can't delete (needs --confirm-destructive), but a reviewed-wrong plan still can.
  • Delete old CaC files only after the plan is clean. They're the ground truth for the diff.
  • Secrets stay on Railway. Generated preserve() entries keep existing values; never paste secret values into railway.ts, and be deliberate about --include-variables (it decrypts non-sealed variables into source).
  • One authoring language per repo. Don't leave both railway.ts and railway.py in .railway/.
  • For multi-repo setups, repeat in every repo. A partial only covers its own slice.

Troubleshooting

Symptom Fix
plan stops: "service managed by railway.json/railway.toml" CaC file still in repo or custom config path still set. Finish Step 3
Migrated file has partial, now other repos' files fail Expected: once any partial is named, every file targeting that environment must export one
Plan shows unexpected deletes CaC config wasn't fully translated. Compare old file vs railway.ts, then re-plan
Plan shows tracing being removed SDKs don't support tracing yet; don't apply. See railway-iac skill

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