Loading...
Loading...
Debug, develop, and operate apps hosted on Railway (railway.com) from the CLI — list projects/services, tail and filter build/deploy/HTTP logs, read metrics, inspect and set variables, deploy from the current directory, redeploy / restart / roll back, run local commands with the service's env, SSH into containers, and open a DB shell. Authenticates via the `RAILWAY_TOKEN` environment variable (account token, or project-scoped token). Optional bundled scripts (`scripts/preflight.sh`, `scripts/debug.sh`, `scripts/smoke.sh`) are Onsager-specific wrappers — other repos can ignore them or fork. Triggers include "deploy to railway", "railway deploy this", "railway logs", "tail railway logs", "why is my railway service crashing", "why did the build fail on railway", "railway 500s", "railway latency", "show railway http logs", "redeploy on railway", "restart my railway service", "roll back railway", "set a railway env var", "list railway variables", "railway metrics", "is my railway service healthy", "connect to my railway postgres", "ssh into railway", "run this locally with railway env", "list railway projects/services/deployments", and (Onsager-specific) "check railway", "preflight", "smoke test", "is the deploy healthy".
npx skill4agent add onsager-ai/dev-skills railwayrailwayRAILWAY_TOKENrailway loginRAILWAY_TOKENrailwaywhich railwaynpm install -g @railway/cliservice listdeployment listlogs --filter--jsonecho "${RAILWAY_TOKEN:0:8}…"RAILWAY_TOKENrailway loginrailway listrailway link --workspacerailway listUnauthorizedrailway statusrailway logsrailway uprailway variable …UnauthorizedInvalid RAILWAY_TOKEN--project / --service / --environment--json-y--ci.railway/ ┌──────────┐
│ Discover │ list projects / services / deployments / env / vars
└────┬─────┘
▼
┌──────────┐ ┌──────────┐
│ Debug │◄──────►│ Metrics │ logs (build/deploy/http) + cpu/mem/p95
└────┬─────┘ └──────────┘
▼
┌──────────┐
│ Fix │ variables set / code edit / config change
└────┬─────┘
▼
┌──────────┐ ┌──────────┐
│ Deploy │───────►│ Verify │ up / redeploy / restart / down / roll back
└──────────┘ └──────────┘# Workspace-wide view (requires an account token).
railway list --json
# A single project's structure (project token works here too if you pass --project).
railway status --json --project "$PROJECT_ID"
# Services and environments inside that project.
railway service list --json --project "$PROJECT_ID" --environment production
railway environment list --json --project "$PROJECT_ID"
# Deployments for a specific service (most recent first).
railway deployment list \
--project "$PROJECT_ID" \
--service api \
--environment production \
--limit 20 --jsonproductionstagingstatusSUCCESSFAILEDBUILDINGDEPLOYINGCRASHEDREMOVED| Stream | Flag | Use when |
|---|---|---|
| Deploy / runtime | | The app is up but misbehaving, or it crashed after starting. |
| Build | | Deployment is |
| HTTP | | The symptom is a status code, a latency spike, a specific request. |
--lines--since--until# Last 200 deploy log lines, JSON for parsing.
railway logs \
--project "$PROJECT_ID" --service api --environment production \
--lines 200 --json
# Build logs for the failed deployment specifically.
railway logs --build "$DEPLOYMENT_ID" \
--project "$PROJECT_ID" --service api --environment production \
--lines 500
# Errors only in the last hour.
railway logs --since 1h --filter "@level:error" --lines 100 \
--project "$PROJECT_ID" --service api --environment production
# All 5xx HTTP responses in the last 30 minutes.
railway logs --http --since 30m --status ">=500" --lines 200 \
--project "$PROJECT_ID" --service api --environment production --json
# Slow GETs on a specific path.
railway logs --http --method GET --path /api/users \
--filter "@totalDuration:>=1000" --lines 50 --json \
--project "$PROJECT_ID" --service api --environment production
# Trace one request end-to-end.
railway logs --http --request-id "$REQUEST_ID" --lines 50 --json \
--project "$PROJECT_ID" --service api --environment production"two words"@level:error@level:warn@level:info@httpStatus@method@path@host@requestId@clientUa@srcIp@edgeRegion@upstreamAddress@upstreamProto@downstreamProto@responseDetails@deploymentId@deploymentInstanceId@totalDuration@responseTime@upstreamRqDuration@txBytes@rxBytes@upstreamErrors> >= < <= ..@httpStatus:200..299ANDOR---latestrailway logs# Compact summary for the linked service, last hour.
railway metrics --json \
--project "$PROJECT_ID" --service api --environment production
# Specific dimensions.
railway metrics --cpu --memory --since 6h --json \
--project "$PROJECT_ID" --service api --environment production
# HTTP percentiles + RPS for a path.
railway metrics --http --path /api/users --json --since 1h \
--project "$PROJECT_ID" --service api --environment production
# Table across every service in the project.
railway metrics --all --json \
--project "$PROJECT_ID" --environment production--json# Read — JSON includes raw values; redact before surfacing.
railway variable list --json \
--project "$PROJECT_ID" --service api --environment production
# Write — explicit confirmation required before running.
railway variable set "FEATURE_FLAG=on" \
--project "$PROJECT_ID" --service api --environment production
# Setting a variable triggers a redeploy by default; add --skip-deploys
# (top-level, before the subcommand) to set without redeploying.
# Delete.
railway variable delete FEATURE_FLAG \
--project "$PROJECT_ID" --service api --environment productionsetdeletepsrailway variable set --stdin KEYvariablerailway variable set "KEY=$(< file)"| Verb | Effect | Use when |
|---|---|---|
| Restart the latest deployment without rebuilding. | Process is wedged but the build artefact is fine. |
| Re-run the latest deployment (or | A transient failure or you want to redeploy the same artefact. Use |
| Upload the current working directory and deploy it. | The fix is a code change in this repo. |
# Restart (no rebuild). -y skips the confirmation dialog.
railway restart -y --json \
--project "$PROJECT_ID" --service api --environment production
# Redeploy the latest deployment.
railway redeploy -y --json \
--project "$PROJECT_ID" --service api --environment production
# Redeploy and pull the newest commit / image from the configured source.
railway redeploy -y --from-source --json \
--project "$PROJECT_ID" --service api --environment production
# Upload and deploy this directory. --ci streams build logs only, then exits;
# perfect for agent sessions (no interactive log attach).
railway up --ci \
--project "$PROJECT_ID" --service api --environment production \
--message "fix: bump httpx to 0.27 to pick up TLS bug fix"
# Remove the most recent deployment (rollback to whatever was before it).
railway down -y \
--project "$PROJECT_ID" --service api --environment productionrailway up --ciCI=true--ci# Quick verification loop.
railway deployment list --json --limit 3 \
--project "$PROJECT_ID" --service api --environment production
railway logs --lines 50 --since 2m \
--project "$PROJECT_ID" --service api --environment production# Run a one-shot command with the linked service's variables injected.
railway run --service api --environment production -- node scripts/migrate.js
# Open a subshell with the same env (interactive — only run when the user is at the terminal).
railway shell --service api --environment production --silent
# SSH into the running container of a service. -i picks an identity file if Railway
# can't find a usable key in ~/.ssh.
railway ssh \
--project "$PROJECT_ID" --service api --environment production
# One-shot remote command (non-interactive).
railway ssh \
--project "$PROJECT_ID" --service api --environment production \
-- ls /app
# Open a database shell against a Railway-managed DB service.
railway connect postgres \
--project "$PROJECT_ID" --environment productionrailway run envrailway run printenvrailway variable list --jsonUnauthorized. Please check that your RAILWAY_TOKEN is validrailway listrailway link --workspaceFAILED--buildrailway logs --build "$DEPLOYMENT_ID" --lines 500 \
--project "$PROJECT_ID" --service api --environment productionrailway deployment list --json --limit 5CRASHEDrailway logs --lines 200KeyError: 'DATABASE_URL'panic: required environment variable …railway variable list --jsonrailway variable set …$PORT0.0.0.0:$PORTpostgres.railway.internal$PORThealthcheckTimeoutrailway.jsonrailway.toml127.0.0.10.0.0.0railway logs --http --status 502 --lines 50SIGKILLout of memoryrailway metrics --memory --since 30m --jsonrailway.jsonresources.memoryrailway up--ci--cirailway variable set--skip-deploysrailway redeploy -y--skip-deploys--jsonjq--project--service--environment.railway/--lines--since--untilrailway variable listrailway run envrailway shellrailway downrailway restartrailway redeployrailway variable deleterailway environment deleterailway volume deleterailway deleteapiproduction…-yrailway up --ciscripts/onsager-ai/onsageronsagerONSAGER_RAILWAY_TOKENhttps://onsager-production.up.railway.appjustfile| Task | Command |
|---|---|
| Pre-deploy check | |
| Diagnose failure | |
| Verify live deploy | |
preflight.shCargo.lockpnpm-lock.yamllocalhostDATABASE_URLONSAGER_RAILWAY_TOKENdebug.sh [service]onsagerONSAGER_RAILWAY_TOKENsmoke.sh [base_url]curl/api/health/api/auth/me/api/nodes/api/sessionsagent-browser//sessions/nodes/settingshttps://onsager-production.up.railway.appagent-browserplan-dagrailway agent -p "<question>"railway mcp install