---
title: "Claude Code + Railway"
description: "Deploy with Claude Code on Railway. Agentic coding in your terminal. Understands your codebase, runs commands, and edits files."
url: https://railway.com/agents/claude
---

# Claude Code + Railway

Claude Code is Anthropic's agentic coding tool that operates directly in your terminal. It can understand your entire codebase, execute terminal commands, edit files across your project, and manage git operations. When paired with Railway, Claude Code can deploy your applications, manage environments, check logs, and handle your entire deployment workflow.

## Quick start

1. **Install Claude Code** — Install the Claude Code CLI globally

   ```
   npm install -g @anthropic-ai/claude-code
   ```

2. **Install Railway MCP Server** — Give Claude native access to Railway's API

   ```
   claude mcp add railway --transport http https://mcp.railway.com
   ```

3. **Start Claude Code** — Launch Claude Code in your project directory

   ```
   claude
   ```

4. **Deploy a full-stack app** — Claude will deploy railway.com/template/nextjs-ai-chatbot with a database and cache, all wired up automatically

   ```
   Deploy the Next.js AI Chatbot template with Postgres and Redis
   ```

## MCP configuration

Connect Claude Code to Railway with the remote MCP server. OAuth in the browser — no API keys to manage.

Setup guide: https://docs.railway.com/ai/remote-mcp-server#claude-code

## Railway integrations

- MCP Server: https://docs.railway.com/ai/remote-mcp-server
- CLI: https://docs.railway.com/reference/cli-api
- Claude Code Plugin: https://docs.railway.com/ai/claude-code-plugin

## Railway Skills

Install Railway Skills: `curl -fsSL railway.com/skills.sh | bash`

- `/status` — Status: Check Railway project status
- `/projects` — Projects: List, switch, and configure projects
- `/new` — New: Create projects, services, databases
- `/service` — Service: Manage existing services
- `/deploy` — Deploy: Deploy local code
- `/domain` — Domain: Manage service domains
- `/environment` — Environment: Manage config (vars, commands, replicas)
- `/deployment` — Deployment: Manage deployments (list, logs, redeploy, remove)
- `/database` — Database: Add Railway databases
- `/templates` — Templates: Deploy from marketplace
- `/metrics` — Metrics: Query resource usage
- `/railway-docs` — Railway Docs: Fetch up-to-date Railway documentation

## Example prompts

- "Deploy this project to Railway"
- "Add a Postgres database to my project"
- "Check the deployment logs and fix any errors"
- "Scale my service to 2 vCPUs and 1GB memory"
- "Set up a custom domain with SSL for my app"
- "Create separate staging and production environments"
- "Deploy an AI chatbot with Postgres for history and Redis for rate limiting"
- "Set up n8n with Postgres and Redis workers for workflow automation"
- "Deploy a Next.js SaaS starter with authentication and Stripe payments"
- "Create a high-availability Postgres cluster with read replicas and automatic failover"

## Common workflows

### Deploy a Postgres database

- Ask Claude to add Postgres to your project
- Claude creates the database service via MCP or CLI
- Claude retrieves connection string with `railway variables`
- Claude updates your code to use the database

### Deploy a new project

- Ask Claude to initialize a Railway project
- Claude runs `railway login` if needed
- Claude runs `railway init` to create project
- Claude runs `railway up` to deploy
- Claude checks logs with `railway logs`

### Debug a failing deployment

- Ask Claude to check your deployment logs
- Claude runs `railway logs` to fetch recent logs
- Claude analyzes the error and suggests fixes
- Claude applies the fix and redeploys

### Set up environment variables

- Ask Claude to configure production environment
- Claude lists current variables with `railway variables`
- Claude sets new variables with `railway variables set`
- Claude triggers redeploy with `railway up`

### Configure custom domain

- Ask Claude to set up a custom domain
- Claude runs `railway domain` to add the domain
- Claude provides DNS configuration instructions
- Claude verifies domain is working with `railway status`

## Tips for success

- Install the Railway MCP server for native Railway integration
- Or install the official plugin: /plugin install railway@claude-plugins-official
- Use `railway link` to connect Claude to an existing project
- Ask Claude to check `railway status` before deploying

## Frequently asked questions

### How do I give Claude Code access to Railway?

Install the Railway MCP server with `claude mcp add railway --transport http https://mcp.railway.com`. Claude will prompt you to authenticate via OAuth on first use, giving it native access to Railway's API for deployments, logs, and project management.

### Can Claude Code deploy to existing Railway projects?

Yes! Use `railway link` in your project directory to connect to an existing Railway project, then Claude can deploy and manage it.

### How do I debug a failed Railway deployment with Claude?

Ask Claude to check your deployment logs with `railway logs`. Claude will analyze errors, suggest fixes, and can automatically apply them and redeploy.

## Troubleshooting

**Issue:** Claude can't find the Railway CLI

**Solution:** Make sure Railway CLI is installed globally with `npm install -g @railway/cli` and is in your PATH.

**Issue:** MCP server connection fails

**Solution:** Run `claude mcp list` to verify the Railway MCP server is installed. Re-add it with `claude mcp add railway --transport http https://mcp.railway.com`.

**Issue:** Deploy fails with permission error

**Solution:** Run `railway login` to re-authenticate, or check that your Railway token has the correct permissions.

## Community resources

- Railway Discord: https://discord.gg/railway
- Claude Code GitHub: https://github.com/anthropics/claude-code
- Railway MCP Server: https://docs.railway.com/ai/remote-mcp-server

## Related agents

- [Codex](https://railway.com/agents/codex) — Lightweight terminal agent. Reads and writes files, executes commands, and browses the web.
- [Cursor](https://railway.com/agents/cursor) — AI-first code editor. Composer mode for multi-file edits and background agents.
- [OpenCode](https://railway.com/agents/opencode) — Open-source terminal agent. Works with 75+ LLMs, TUI interface, and provider-agnostic architecture.

Open this page in a browser: https://railway.com/agents/claude
