railway-cli
Railway CLI
Operate the Railway platform from the command line. Covers the full lifecycle: authentication, project setup, deployment, services, variables, environments, logs, domains, volumes, functions, and local development.
Source of truth: Railway CLI Docs
Handling Missing Installation
Assume railway is installed. If a command fails with "command not found" or similar, install it before retrying:
# macOS (preferred)
brew install railway
# Any OS with Node.js >= 16
npm i -g @railway/cli
# Shell script (macOS / Linux / WSL)
bash <(curl -fsSL cli.new)
After install, verify with railway --version, then resume the original task.
Self-Discovery
The Railway CLI evolves across versions. When you encounter an unfamiliar subcommand or need to check current flags:
railway --help # Top-level commands
railway <command> --help # Subcommand flags and usage
Always prefer --help output over memorized flags when composing complex commands. This keeps behavior correct even as the CLI updates.
Authentication
railway login # Browser-based login
railway login --browserless # Token-based login (CI, SSH sessions)
railway logout
railway whoami # Verify current identity
CI/CD token auth (no interactive login):
RAILWAY_TOKEN— project-scoped actionsRAILWAY_API_TOKEN— account/workspace-scoped actions
RAILWAY_TOKEN=<token> railway up
Project Lifecycle
Create or link
railway init # Create new project (interactive)
railway link # Link cwd to existing project
railway unlink # Unlink cwd
Inspect
railway status # Current project/service/environment info
railway list # All projects in workspace
railway open # Open project in browser
Deployment
railway up # Deploy cwd
railway up --detach # Deploy without tailing logs
railway deploy --template postgres # Deploy from a template
railway redeploy # Redeploy latest deployment
railway restart # Restart service (no new build)
railway down # Remove latest deployment
Services
railway add # Add service (interactive)
railway add --database postgres # Add a database (postgres, mysql, redis, mongo)
railway add --repo user/repo # Add service from GitHub repo
railway service # Switch linked service (interactive)
railway scale # Scale service replicas
railway delete # Delete the project
Variables
railway variable list # List all variables
railway variable set KEY=value # Set a variable
railway variable set K1=v1 K2=v2 # Set multiple at once
railway variable delete KEY # Remove a variable
Environments
railway environment # Switch environment (interactive)
railway environment new <name> # Create environment
railway environment delete <name> # Delete environment
Local Development
railway run <cmd> # Run command with Railway env vars injected
railway shell # Open shell with Railway env vars
railway dev # Run services locally with Docker
railway run is useful for running migrations, seeds, or scripts that need production/staging credentials without .env files.
Logs & Debugging
railway logs # Stream live deployment logs
railway logs --build # View build logs
railway logs -n 100 # Last N lines
railway ssh # SSH into running service container
railway connect # Connect to database shell (psql, mysql, redis-cli, mongosh)
Networking
railway domain # Generate a Railway subdomain
railway domain example.com # Attach a custom domain
Volumes
railway volume list
railway volume add
railway volume delete
Functions
railway functions list
railway functions new
railway functions push
Utilities
railway completion bash # Generate shell completions (bash/zsh/fish)
railway docs # Open docs in browser
railway upgrade # Upgrade CLI to latest version
Global Flags
These flags work across most commands:
| Flag | Description |
|---|---|
-s, --service <name-or-id> |
Target a specific service |
-e, --environment <name-or-id> |
Target a specific environment |
--json |
Output as JSON (useful for scripting) |
-y, --yes |
Skip confirmation prompts |
-h, --help |
Show help |
-V, --version |
Show CLI version |
Common Workflows
First-time project setup
railway login
railway init # or: railway link
railway up
railway domain # get a public URL
railway logs # verify deployment
Add a database to an existing project
railway add --database postgres
railway connect # verify connectivity
railway variable list # check injected DATABASE_URL
Deploy with environment targeting
railway environment new staging
railway up -e staging
railway logs -e staging
Run a one-off command with prod vars
railway run -e production npx prisma migrate deploy
Additional Resources
For the full and most current reference, see reference.md or consult:
- Railway CLI Docs
railway --help/railway <command> --help- Railway CLI GitHub
More from miketromba/skills
legal-tos-privacy
Create bulletproof Terms of Service and Privacy Policy documents for SaaS applications. Infers company information from codebase/marketing site, conducts comprehensive audits, drafts documents, then asks user ONLY for missing details at the end. Minimizes user interaction. Use when the user needs to draft, review, or update legal documents (ToS, Terms of Service, Privacy Policy, legal pages). Triggers on requests for legal documents, terms drafting, privacy policy creation, "cover our bases legally", liability protection, or legal compliance for software products.
58calculator
Perform mathematical calculations (add, subtract, multiply, divide). Use when you need to do any numerical calculations — never do mental math. Supports batch operations.
12bun
Bun JavaScript runtime, bundler, package manager, and test runner documentation and guidance. Use when working with Bun - an all-in-one toolkit for developing JavaScript/TypeScript applications. Triggers on questions about Bun runtime, bun install, bun test, bun build, Bun.serve, Bun.file, Bun.spawn, bunfig.toml, Bun APIs, SQLite, S3, Redis, WebSockets, HTTP server, bundler configuration, hot reloading, macros, plugins, or ANY Bun-related development tasks.
8drizzle
Drizzle ORM TypeScript documentation and guidance. Use when working with Drizzle - a lightweight, type-safe TypeScript ORM for PostgreSQL, MySQL, SQLite, SingleStore, and MSSQL. Triggers on questions about Drizzle schema, migrations, drizzle-kit, queries, relations, joins, transactions, RLS, column types, database connections, or ANY Drizzle-related development tasks.
4supabase
Supabase backend-as-a-service platform documentation and guidance. Use when working with Supabase - an open-source Firebase alternative providing Postgres database, authentication, real-time subscriptions, edge functions, storage, and vector embeddings. Triggers on questions about Supabase setup, database, auth, RLS, edge functions, storage, realtime, pgvector, migrations, CLI, self-hosting, or ANY Supabase-related development tasks.
3openclaw
OpenClaw AI agent platform documentation and guidance. Use when working with OpenClaw - an open-source platform for deploying AI agents across messaging channels (Slack, Discord, Telegram, WhatsApp, iMessage, etc.). Triggers on questions about OpenClaw setup, configuration, hosting, channels, gateways, tools, plugins, multi-agent routing, sandboxing, CLI commands, deployment (Fly.io, Railway, Render, Docker), or ANY OpenClaw-related development tasks.
2