Use Railway
Railway resource model
Railway organizes infrastructure in a hierarchy:
- Workspace is the billing and team scope. A user belongs to one or more workspaces.
- Project is a collection of services under one workspace. It maps to one deployable unit of work.
- Environment is an isolated configuration plane inside a project (for example,
production, staging). Each environment has its own variables, config, and deployment history.
- Service is a single deployable unit inside a project. It can be an app from a repo, a Docker image, or a managed database.
- Deployment is a point-in-time release of a service in an environment. It has build logs, runtime logs, and a status lifecycle.
Most CLI commands operate on the linked project/environment/service context. Use railway status --json to see the context, and --project, --environment, --service flags to override.
Preflight
Before any mutation, verify context:
command -v railway # CLI installed
railway whoami --json # authenticated
railway --version # check CLI version
railway status --json # linked project/environment/service
If the CLI is missing, guide the user to install it.
bash <(curl -fsSL cli.new) # Shell script (macOS, Linux, Windows via WSL)
brew install railway # Homebrew (macOS)
npm i -g @railway/cli # npm (macOS, Linux, Windows). Requires Node.js version 16 or higher.
If not authenticated, run railway login. If not linked, run railway link --project <id-or-name>.
If a command is not recognized (for example, railway environment edit), the CLI may be outdated. Upgrade with:
railway upgrade
Common quick operations
These are frequent enough to handle without loading a reference:
railway status --json # current context
railway whoami --json # auth and workspace info
railway project list --json # list projects
railway service status --all --json # all services in current context
railway variable list --service <svc> --json # list variables
railway variable set KEY=value --service <svc> # set a variable
railway logs --service <svc> --lines 200 --json # recent logs
railway up --detach -m "<summary>" # deploy current directory
Routing
For anything beyond quick operations, load the reference that matches the user's intent. Load only what you need, one reference is usually enough, two at most.
| Intent |
Reference |
Use for |
| Create or connect resources |
setup.md |
Projects, services, databases, templates, workspaces |
| Ship code or manage releases |
deploy.md |
Deploy, redeploy, restart, build config, monorepo, Dockerfile |
| Change configuration |
configure.md |
Environments, variables, config patches, domains, networking |
| Check health or debug failures |
operate.md |
Status, logs, metrics, build/runtime triage, recovery |
| Request from API, docs, or community |
request.md |
Railway GraphQL API queries/mutations, metrics queries, Central Station, official docs |
If the request spans two areas (for example, "deploy and then check if it's healthy"), load both references and compose one response.
Execution rules
- Prefer Railway CLI. Fall back to
scripts/railway-api.sh for operations the CLI doesn't expose.
- Use
--json output where available for reliable parsing.
- Resolve context before mutation. Know which project, environment, and service you're acting on.
- For destructive actions (delete service, remove deployment, drop database), confirm intent and state impact before executing.
- After mutations, verify the result with a read-back command.
Composition patterns
Multi-step workflows follow natural chains:
- First deploy: setup (create project + service), configure (set variables and source), deploy, operate (verify healthy)
- Fix a failure: operate (triage logs), configure (fix config/variables), deploy (redeploy), operate (verify recovery)
- Add a domain: configure (add domain + set port), operate (verify DNS and service health)
- Docs to action: request (fetch docs answer), route to the relevant operational reference
When composing, return one unified response covering all steps. Don't ask the user to invoke each step separately.
Setup decision flow
When the user wants to create or deploy something, determine the right action from current context:
- Run
railway status --json in the current directory.
- If linked: add a service to the existing project (
railway add --service <name>). Do not create a new project unless the user explicitly says "new project" or "separate project".
- If not linked: check the parent directory (
cd .. && railway status --json).
- Parent linked: this is likely a monorepo sub-app. Add a service and set
rootDirectory to the sub-app path.
- Parent not linked: run
railway list --json and look for a project matching the directory name.
- Match found: link to it (
railway link --project <name>).
- No match: create a new project (
railway init --name <name>).
- When multiple workspaces exist, match by name from
railway whoami --json.
Naming heuristic: app names like "flappy-bird" or "my-api" are service names, not project names. Use the directory or repo name for the project.
Response format
For all operational responses, return:
- What was done (action and scope).
- The result (IDs, status, key output).
- What to do next (or confirmation that the task is complete).
Keep output concise. Include command evidence only when it helps the user understand what happened.
1---2name: railway-operations3description: Operate Railway infrastructure: create projects, provision services and databases, deploy code, configure environments and variables, manage domains, troubleshoot failures, check status and metrics, and query Railway docs. Use this skill whenever the user mentions Railway, deployments, services, environments, build failures, or infrastructure operations, even if they don't say "Railway" explicitly.4---56# Use Railway78## Railway resource model910Railway organizes infrastructure in a hierarchy:1112- **Workspace** is the billing and team scope. A user belongs to one or more workspaces.13- **Project** is a collection of services under one workspace. It maps to one deployable unit of work.14- **Environment** is an isolated configuration plane inside a project (for example, `production`, `staging`). Each environment has its own variables, config, and deployment history.15- **Service** is a single deployable unit inside a project. It can be an app from a repo, a Docker image, or a managed database.16- **Deployment** is a point-in-time release of a service in an environment. It has build logs, runtime logs, and a status lifecycle.1718Most CLI commands operate on the linked project/environment/service context. Use `railway status --json` to see the context, and `--project`, `--environment`, `--service` flags to override.1920## Preflight2122Before any mutation, verify context:2324```bash25command -v railway # CLI installed26railway whoami --json # authenticated27railway --version # check CLI version28railway status --json # linked project/environment/service29```3031If the CLI is missing, guide the user to install it.3233```bash34bash <(curl -fsSL cli.new) # Shell script (macOS, Linux, Windows via WSL)35brew install railway # Homebrew (macOS)36npm i -g @railway/cli # npm (macOS, Linux, Windows). Requires Node.js version 16 or higher.37```3839If not authenticated, run `railway login`. If not linked, run `railway link --project <id-or-name>`.4041If a command is not recognized (for example, `railway environment edit`), the CLI may be outdated. Upgrade with:4243```bash44railway upgrade45```4647## Common quick operations4849These are frequent enough to handle without loading a reference:5051```bash52railway status --json # current context53railway whoami --json # auth and workspace info54railway project list --json # list projects55railway service status --all --json # all services in current context56railway variable list --service <svc> --json # list variables57railway variable set KEY=value --service <svc> # set a variable58railway logs --service <svc> --lines 200 --json # recent logs59railway up --detach -m "<summary>" # deploy current directory60```6162## Routing6364For anything beyond quick operations, load the reference that matches the user's intent. Load only what you need, one reference is usually enough, two at most.6566| Intent | Reference | Use for |67|---|---|---|68| Create or connect resources | [setup.md](references/setup.md) | Projects, services, databases, templates, workspaces |69| Ship code or manage releases | [deploy.md](references/deploy.md) | Deploy, redeploy, restart, build config, monorepo, Dockerfile |70| Change configuration | [configure.md](references/configure.md) | Environments, variables, config patches, domains, networking |71| Check health or debug failures | [operate.md](references/operate.md) | Status, logs, metrics, build/runtime triage, recovery |72| Request from API, docs, or community | [request.md](references/request.md) | Railway GraphQL API queries/mutations, metrics queries, Central Station, official docs |7374If the request spans two areas (for example, "deploy and then check if it's healthy"), load both references and compose one response.7576## Execution rules77781. Prefer Railway CLI. Fall back to `scripts/railway-api.sh` for operations the CLI doesn't expose.792. Use `--json` output where available for reliable parsing.803. Resolve context before mutation. Know which project, environment, and service you're acting on.814. For destructive actions (delete service, remove deployment, drop database), confirm intent and state impact before executing.825. After mutations, verify the result with a read-back command.8384## Composition patterns8586Multi-step workflows follow natural chains:8788- **First deploy**: setup (create project + service), configure (set variables and source), deploy, operate (verify healthy)89- **Fix a failure**: operate (triage logs), configure (fix config/variables), deploy (redeploy), operate (verify recovery)90- **Add a domain**: configure (add domain + set port), operate (verify DNS and service health)91- **Docs to action**: request (fetch docs answer), route to the relevant operational reference9293When composing, return one unified response covering all steps. Don't ask the user to invoke each step separately.9495## Setup decision flow9697When the user wants to create or deploy something, determine the right action from current context:98991. Run `railway status --json` in the current directory.1002. **If linked**: add a service to the existing project (`railway add --service <name>`). Do not create a new project unless the user explicitly says "new project" or "separate project".1013. **If not linked**: check the parent directory (`cd .. && railway status --json`).102 - **Parent linked**: this is likely a monorepo sub-app. Add a service and set `rootDirectory` to the sub-app path.103 - **Parent not linked**: run `railway list --json` and look for a project matching the directory name.104 - **Match found**: link to it (`railway link --project <name>`).105 - **No match**: create a new project (`railway init --name <name>`).1064. When multiple workspaces exist, match by name from `railway whoami --json`.107108**Naming heuristic**: app names like "flappy-bird" or "my-api" are service names, not project names. Use the directory or repo name for the project.109110## Response format111112For all operational responses, return:1131. What was done (action and scope).1142. The result (IDs, status, key output).1153. What to do next (or confirmation that the task is complete).116117Keep output concise. Include command evidence only when it helps the user understand what happened.