railway-cli-management

117
3
Source

Deploy, manage services, view logs, and configure Railway infrastructure. Use when deploying to Railway, managing environment variables, viewing deployment logs, scaling services, or managing volumes.

Install

mkdir -p .claude/skills/railway-cli-management && curl -L -o skill.zip "https://mcp.directory/api/skills/download/186" && unzip -o skill.zip -d .claude/skills/railway-cli-management && rm skill.zip

Installs to .claude/skills/railway-cli-management

About this skill

Railway CLI Management

Master Railway CLI for deployments, service management, log viewing, and infrastructure operations.

Quick Reference

Deployment

# Deploy current directory to linked service
railway up

# Deploy without attaching to logs
railway up --detach

# Deploy to specific service
railway up --service api

# Deploy to specific environment
railway up --environment production

# Redeploy latest deployment
railway redeploy

# Redeploy specific service
railway redeploy --service worker

# Skip confirmation
railway redeploy --yes

# Remove most recent deployment
railway down

# Remove deployment from specific service
railway down --service api

Service & Project Management

# List all projects
railway list

# Link to existing project (interactive)
railway link

# Link to specific project by ID
railway link <project-id>

# Show current project status
railway status

# Get status as JSON (includes deployment IDs!)
railway status --json

# Open project dashboard in browser
railway open

# Unlink current directory from project
railway unlink

# Link to specific service
railway service <service-name-or-id>

# Add new service to project
railway add

Getting Deployment IDs

Best Method:

# Get full project status including deployment IDs
railway status --json

# Extract specific deployment ID using jq
railway status --json | jq -r '.services.edges[0].node.serviceInstances.edges[0].node.latestDeployment.id'

# Get deployment ID for specific service
railway status --json | jq -r '.services.edges[] | select(.node.name=="api") | .node.serviceInstances.edges[0].node.latestDeployment.id'

Output Structure:

  • .services.edges[].node - Service info
  • .node.serviceInstances.edges[].node.latestDeployment.id - Latest deployment UUID
  • .node.serviceInstances.edges[].node.latestDeployment.meta - Commit info, build config, etc.

Logs

View Logs

# Stream logs for latest deployment
railway logs

# View logs for specific service
railway logs --service api

# View logs for specific environment
railway logs --environment production

# View deployment logs (startup/runtime)
railway logs --deployment

# View build logs
railway logs --build

# View logs for specific deployment by ID
railway logs <deployment-id>

# Get logs for specific service deployment
railway logs --service worker --deployment

# Output as JSON
railway logs --json

# Combine options
railway logs --service api --deployment --json

Logs Tips:

  • Default: Shows latest deployment logs
  • Deployment logs: Application startup and runtime output
  • Build logs: Compilation, dependencies, Nixpacks output
  • Use --json with jq for filtering

Environment Variables

# List all variables for active environment
railway variables

# List for specific service
railway variables --service api

# List for specific environment
railway variables --environment production

# Show as key=value format
railway variables --kv

# Output as JSON
railway variables --json

# Set variable(s)
railway variables --set "DATABASE_URL=postgres://..."

# Set multiple
railway variables --set "NODE_ENV=production" --set "LOG_LEVEL=debug"

# Run local command with Railway variables
railway run npm start

# Open subshell with Railway variables loaded
railway shell

Environments

# Link to environment (interactive)
railway environment

# Link to specific environment
railway environment production

# Create new environment
railway environment new

# Delete environment
railway environment delete <environment-name>

Scaling

# Scale service in linked environment
railway scale --us-west1 3

# Scale specific service
railway scale --service api --us-west1 2

# Scale across multiple regions
railway scale --us-west1 2 --europe-west4 1

# Available regions:
# --us-west1, --us-west2, --us-east4
# --europe-west4, --asia-southeast1

Volumes

# List volumes
railway volume list

# List for specific service
railway volume list --service api

# Add new volume
railway volume add

# Delete volume
railway volume delete <volume-id>

# Update volume
railway volume update <volume-id>

# Detach volume from service
railway volume detach <volume-id>

# Attach volume to service
railway volume attach <volume-id>

Database Connection

# Connect to database shell
railway connect

# Examples:
# - PostgreSQL: Opens psql
# - MongoDB: Opens mongosh
# - MySQL: Opens mysql
# - Redis: Opens redis-cli

Authentication

# Login to Railway account
railway login

# Logout
railway logout

# Check current user
railway whoami

Common Workflows

Initial Project Setup

# Login
railway login

# Link to existing project
railway link

# Or create new project
railway init

# Link to service
railway service api

# Link to environment
railway environment production

# Check status
railway status

Deploy with Environment Variables

# Set variables
railway variables --set "NODE_ENV=production" --set "API_KEY=secret"

# Deploy
railway up

# Monitor logs
railway logs --deployment

Debug Failed Deployment

# Get deployment ID
DEPLOY_ID=$(railway status --json | jq -r '.services.edges[0].node.serviceInstances.edges[0].node.latestDeployment.id')

# View build logs
railway logs $DEPLOY_ID --build

# View deployment logs
railway logs $DEPLOY_ID --deployment

# Check full status
railway status --json | jq '.services.edges[].node.serviceInstances.edges[].node.latestDeployment'

Monitor Multiple Services

# Terminal 1: API logs
railway logs --service api --deployment

# Terminal 2: Worker logs
railway logs --service worker --deployment

# Or use JSON + jq for filtering
railway logs --service api --json | jq 'select(.level == "error")'

Extract Deployment Information

# Get all deployment IDs
railway status --json | jq -r '.services.edges[].node | {service: .name, deployment: .serviceInstances.edges[0].node.latestDeployment.id}'

# Get commit info for deployment
railway status --json | jq -r '.services.edges[].node.serviceInstances.edges[].node.latestDeployment.meta | {commit: .commitHash, message: .commitMessage}'

# Get service URLs
railway status --json | jq -r '.services.edges[].node | select(.serviceInstances.edges[0].node.latestDeployment.canRedeploy == true)'

Redeploy After Config Change

# Change variables
railway variables --set "NEW_VAR=value"

# Redeploy to pick up changes
railway redeploy --yes

# Or deploy fresh
railway up

Run Commands with Railway Environment

# Run migration
railway run npm run migrate

# Run seed script
railway run node scripts/seed.js

# Start local dev with production variables
railway run npm run dev

# Open shell with all variables
railway shell

Important Notes

Deployment Targets

  • Production: Linked to production environment
  • Preview: Branch-based deployments (configured in Railway dashboard)
  • Development: Local with railway run or railway shell

JSON Output

  • railway status --json is the most comprehensive command
  • Contains: services, deployment IDs, commit info, build config, service instances
  • Use jq for parsing and filtering

Environment Linking

  • Project, service, and environment are all linked separately
  • Use railway status to verify what you're linked to
  • Change with railway service, railway environment, railway link

Logs Behavior

  • Default: Latest deployment logs (5-minute window)
  • Deployment logs: Application output (stdout/stderr)
  • Build logs: Nixpacks, dependencies, compilation
  • JSON output: Structured logs for parsing

Railway.json Configuration

  • Stored in project root
  • Defines build/deploy configuration per service
  • Example:
{
  "$schema": "https://railway.app/railway.schema.json",
  "build": {
    "builder": "NIXPACKS",
    "buildCommand": "pnpm install && pnpm run build"
  },
  "deploy": {
    "startCommand": "node dist/index.js",
    "healthcheckPath": "/health",
    "healthcheckTimeout": 100,
    "restartPolicyType": "ON_FAILURE",
    "restartPolicyMaxRetries": 10
  }
}

Common Issues

  • No TTY errors: Command requires interactive input (use JSON output or flags)
  • Service not linked: Run railway service <service-name> first
  • Environment not linked: Run railway environment <env-name> first
  • Deployment not found: Use railway status --json to verify deployment ID exists

Examples from Real Projects

Saturn Backend (API + Worker)

# Check both services status
railway status --json | jq '.services.edges[] | {
  service: .node.name,
  deployment: .node.serviceInstances.edges[0].node.latestDeployment.id,
  commit: .node.serviceInstances.edges[0].node.latestDeployment.meta.commitHash
}'

# Get API deployment logs
railway logs --service api --deployment

# Get worker deployment logs
railway logs --service worker --deployment

# Redeploy both after config change
railway redeploy --service api --yes
railway redeploy --service worker --yes

Debug Production Issue

# Stream live logs with error filtering
railway logs --service api --deployment --json | jq 'select(.level == "error" or .level == "fatal")'

# Get recent deployment metadata
railway status --json | jq '.services.edges[] | select(.node.name == "api") | .node.serviceInstances.edges[0].node.latestDeployment.meta'

# Check health check configuration
railway status --json | jq '.services.edges[].node.serviceInstances.edges[].node.latestDeployment.meta.fileServiceManifest.deploy'

More by CaptainCrouton89

View all →

reviewing-code

CaptainCrouton89

Systematically evaluate code changes for security, correctness, performance, and spec alignment. Use when reviewing PRs, assessing code quality, or verifying implementation against requirements.

899

fixing-bugs-systematically

CaptainCrouton89

Diagnose and fix bugs through systematic investigation, root cause analysis, and targeted validation. Use when something is broken, errors occur, performance degrades, or unexpected behavior manifests.

00

gathering-requirements

CaptainCrouton89

Systematically clarify user needs, preferences, and constraints before planning or implementation. Classifies work type, investigates existing systems, discovers edge cases and integration points, resolves assumptions, and creates detailed specifications. Use when building features, enhancements, or integrations where requirements need clarification.

00

executing-work-in-parallel

CaptainCrouton89

Coordinate concurrent task execution through agent delegation. Plan independent work, manage dependencies, and execute multiple agents simultaneously. Use when handling multiple unrelated tasks, research investigations, or layer-based implementations that can run concurrently.

00

writing-like-user

CaptainCrouton89

Emulate the user's personal writing voice and style patterns. Use when the user asks to write content in their voice, draft documents, compose messages, or requests "write this like me" or "in my style."

770

investigating-code-patterns

CaptainCrouton89

Systematically trace code flows, locate implementations, diagnose performance issues, and map system architecture. Use when understanding how existing systems work, researching concepts, exploring code structure, or answering "how/where/why is X implemented?" questions.

20

You might also like

flutter-development

aj-geddes

Build beautiful cross-platform mobile apps with Flutter and Dart. Covers widgets, state management with Provider/BLoC, navigation, API integration, and material design.

287790

drawio-diagrams-enhanced

jgtolentino

Create professional draw.io (diagrams.net) diagrams in XML format (.drawio files) with integrated PMP/PMBOK methodologies, extensive visual asset libraries, and industry-standard professional templates. Use this skill when users ask to create flowcharts, swimlane diagrams, cross-functional flowcharts, org charts, network diagrams, UML diagrams, BPMN, project management diagrams (WBS, Gantt, PERT, RACI), risk matrices, stakeholder maps, or any other visual diagram in draw.io format. This skill includes access to custom shape libraries for icons, clipart, and professional symbols.

213415

godot

bfollington

This skill should be used when working on Godot Engine projects. It provides specialized knowledge of Godot's file formats (.gd, .tscn, .tres), architecture patterns (component-based, signal-driven, resource-based), common pitfalls, validation tools, code templates, and CLI workflows. The `godot` command is available for running the game, validating scripts, importing resources, and exporting builds. Use this skill for tasks involving Godot game development, debugging scene/resource files, implementing game systems, or creating new Godot components.

211295

nano-banana-pro

garg-aayush

Generate and edit images using Google's Nano Banana Pro (Gemini 3 Pro Image) API. Use when the user asks to generate, create, edit, modify, change, alter, or update images. Also use when user references an existing image file and asks to modify it in any way (e.g., "modify this image", "change the background", "replace X with Y"). Supports both text-to-image generation and image-to-image editing with configurable resolution (1K default, 2K, or 4K for high resolution). DO NOT read the image file first - use this skill directly with the --input-image parameter.

219234

ui-ux-pro-max

nextlevelbuilder

"UI/UX design intelligence. 50 styles, 21 palettes, 50 font pairings, 20 charts, 8 stacks (React, Next.js, Vue, Svelte, SwiftUI, React Native, Flutter, Tailwind). Actions: plan, build, create, design, implement, review, fix, improve, optimize, enhance, refactor, check UI/UX code. Projects: website, landing page, dashboard, admin panel, e-commerce, SaaS, portfolio, blog, mobile app, .html, .tsx, .vue, .svelte. Elements: button, modal, navbar, sidebar, card, table, form, chart. Styles: glassmorphism, claymorphism, minimalism, brutalism, neumorphism, bento grid, dark mode, responsive, skeuomorphism, flat design. Topics: color palette, accessibility, animation, layout, typography, font pairing, spacing, hover, shadow, gradient."

171200

rust-coding-skill

UtakataKyosui

Guides Claude in writing idiomatic, efficient, well-structured Rust code using proper data modeling, traits, impl organization, macros, and build-speed best practices.

166173

Stay ahead of the MCP ecosystem

Get weekly updates on new skills and servers.