Based on Railway's and Anthropic's official docs, checked
How to deploy to Railway with Claude Code
Railway scores 5/5 on our Claude Code fit scale: its official plugin bundles the use-railway skill with a hosted MCP server. Railway is a platform that builds your code into a container, runs it as a long-lived service, and hands you a public HTTPS domain with TLS. Its official Claude Code plugin bundles the use-railway skill with a hosted MCP server, so Claude can deploy a service, check project status, and manage environments from your terminal. This guide takes you from the plugin to a live service with a domain, using only Railway's and Anthropic's official instructions.
1. Install the official Railway plugin
The Railway plugin packages the use-railway skill, Railway's hosted MCP server, supporting scripts, and hooks for managing Railway projects and deployments from your terminal. Install it from Anthropic's official marketplace. Claude Code adds that marketplace automatically the first time you start an interactive session, so no marketplace setup is needed. After installation, ask Claude Code to deploy a service, check project status, manage an environment, or do another task covered by the use-railway skill.
/plugin install railway@claude-plugins-officialThe hosted MCP connection does not require the Railway CLI. Install and authenticate the CLI only when you want Claude Code to use local project context or CLI workflows, which is step 2.
2. Install the Railway CLI and log in
The Railway CLI lets you interact with your Railway projects from the command line, and it needs Node.js version 16 or higher. Install it globally with npm, then log in. The login command opens a browser to authenticate with your Railway account. You can also install the CLI with agent support configured in one step, which runs railway setup agent to configure detected agent tools.
npm install -g @railway/cli railway loginOn a machine without a browser, such as an SSH session, use
railway login --browserless. For CI/CD pipelines, set environment variables instead of interactive login: RAILWAY_TOKEN for project-level actions, or RAILWAY_API_TOKEN for account-level actions.3. Create or link a project
The CLI can create a new project entirely from the command line. Open a terminal inside your local project and run railway init. It creates a new empty project with the name you provide, and that project is used for any later commands in this directory. If the project already exists in the dashboard, attach this directory to it with railway link instead. Either way, later commands in this directory now target that project, and you can check what is linked with railway status.
railway initYou need a Railway account first, and a valid GitHub account linked to it if you plan to deploy from a GitHub repo. Railway prompts you to link one if your account is not associated with one yet.
4. Deploy with railway up
Deploying your code is a single command. The CLI scans your project files, compresses them, and uploads them to Railway's backend for deployment, streaming the build and deploy logs while it works. Railway builds your code and runs it as a container. Your app should listen on the PORT variable Railway provides for your service, so the platform can route traffic to it.
railway upWhen the deploy finishes, run
railway opento jump to your project canvas in the browser. The canvas is mission control for your project: your infrastructure, environments, and deployments are all controlled from there. To redeploy the same code unchanged, use railway redeploy.5. Add variables and a database
Add variables in the dashboard: open your service, go to Variables, and add each key and value. Variables are scoped to the service, and Railway's templating syntax lets one service reference another's variables, so your app can read a database URL that lives on a different service. You can also set variables from the CLI with the railway variables command.
railway variables set DATABASE_URL=postgres://user:password@host:5432/dbnameNeed a database? Add a service from the project canvas and pick Postgres. Railway provisions a managed database and wires its connection variables into your project, so your app can read them as normal environment variables. Keep tokens such as RAILWAY_TOKEN and RAILWAY_API_TOKEN server-side only. Never put them in client code or a public repo.
6. Generate a domain and watch the logs
Railway services do not get a domain automatically, but setting one up is easy. In your service settings, under Networking, Public Networking, choose Generate Domain, and you get a *.up.railway.app address. You can also create one from the CLI with railway domain. Once the initial deployment is complete, your app is ready to go on that address.
railway domain railway logsFor your own domain, add a custom domain in the same panel. Railway shows you a CNAME record and a TXT record, and you must add both to your DNS provider. The CNAME routes traffic and the TXT verifies ownership: until the TXT record is in place and Railway verifies it, requests to the domain return a 404. DNS changes can take up to 72 hours to propagate worldwide. If anything fails during a deploy, read the build and deploy logs on the project canvas, and scroll the whole log, because the actual error is rarely at the bottom.
Source: https://docs.railway.com/networking/domains/working-with-domains
Deploy from GitHub instead
The CLI is not the only way in. In the dashboard, click New Project and choose the GitHub repo option, then search for your project and click it. Choose Deploy Now to start building right away, or Add Variables first and then click Deploy at the top of the canvas. Railway creates a new project for you and kicks off an initial deploy after the project is created. Every push to the connected branch redeploys, so your normal git workflow becomes your deploy workflow.
Railway also deploys pre-built Docker images from Docker Hub, GitHub Container Registry, RedHat Container Registry, and GitLab Container Registry, and its template marketplace offers hundreds of pre-configured templates, such as Umami, that deploy with a few clicks.
What the plugin adds beyond the CLI
The CLI runs commands. The plugin teaches Claude how to run your Railway infrastructure. The use-railway skill provides workflows for project setup, deployments, troubleshooting, environment configuration, networking, observability, and more. The hosted Railway MCP server connects Claude Code to Railway through OAuth without depending on local CLI state. And the auto-approve hook approves single Railway CLI and Railway API helper invocations that pass its shell safety checks, so routine commands do not stop for approval every time.
If you want the skill without the plugin, you can install the agent skill on its own when you do not need the hosted MCP configuration or hooks. And if you want direct access to Railway's hosted MCP tools without the plugin's terminal workflows, skill, or hooks, use the Railway connector for Claude instead.
Then just ask
With the plugin installed, you can hand the whole job to Claude in plain words. Try this prompt, and ask Claude to show you the plan before it changes files:
"Help me deploy to Railway in this project. Follow the Railway skills, keep secrets in environment variables, and show me the plan before changing files."
Next steps
How to deploy to Vercel with Claude Code
How to add Clerk authentication with Claude Code
How to add a Supabase database with Claude Code
How to set up Neon Postgres with Claude Code
Claude Code integrations: email, queues, workers and more
How to install Claude Code on macOS, Linux and Windows
Frequently asked questions
No. The hosted MCP connection does not require the Railway CLI. Install and authenticate the CLI when you want Claude Code to use local project context or CLI workflows.
Sources
- https://docs.railway.com/ai/claude-code-plugin · checked 2026-11-15
- https://docs.railway.com/quick-start · checked 2026-11-15
- https://docs.railway.com/guides/cli · checked 2026-11-15
- https://docs.railway.com/networking/domains/working-with-domains · checked 2026-11-15
- https://docs.railway.com/variables/reference · checked 2026-11-15
- https://code.claude.com/docs/en/mcp · checked 2026-11-15