railway-environment

Query, stage, and apply Railway environment configuration changes via GraphQL and CLI.

30.5k|3.5k|Updated Jul 4, 2025
One-click install
npx skills add https://github.com/davila7/claude-code-templates --skill railway-environment
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: railway-environment
Source: https://github.com/davila7/claude-code-templates/tree/main/cli-tool/components/skills/railway/environment
Command: npx skills add https://github.com/davila7/claude-code-templates --skill railway-environment

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires railway-cli, and includes references (resource) components.

What problem does it solve?

Managing Railway environment configuration—variables, build settings, deploy settings, and service lifecycle—requires juggling CLI commands and GraphQL mutations, and mistakes like shell escaping errors or unapplied staged changes cause failed deployments.

Core Features & Use Cases

  • Environment Management: Create, duplicate, and switch Railway environments, including service-specific variables during duplication.
  • Configuration Staging & Apply: Stage changes with environmentStageChanges (merge support) or apply immediately with environmentPatchCommit, then commit staged changes via environmentPatchCommitStaged.
  • Variable & Service Operations: Query rendered variables, update env vars, change build/start commands, replica counts, health checks, and delete services.
  • Use Case: A build fails due to a wrong build command. Ask the assistant to fix it—it queries the current config, stages the corrected buildCommand, and applies the change to trigger a new deployment.

Quick Start

Ask the assistant to add an environment variable like API_KEY to your Railway service and apply the change immediately.

Frequently Asked Questions about railway-environment

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I update environment variables on Railway?

Stage variable changes with the environmentStageChanges GraphQL mutation or apply immediately with environmentPatchCommit, passing the service ID and variable key-value pairs. Use railway variables --json to view rendered runtime values.

How do I apply staged changes in Railway from the CLI?

There is no railway apply CLI command. Use the environmentPatchCommitStaged GraphQL mutation with the environment ID and an optional commit message, which commits staged changes and triggers deployments by default.

Can I duplicate a Railway environment with different variables?

Yes. Run railway environment new staging --duplicate production and add --service-variable flags, for example --service-variable api PORT=3001, to override variables for specific services during duplication.

Why do Railway GraphQL queries fail in bash?

Multi-line commands break and exclamation marks in GraphQL non-null types get escaped by the shell. Wrap the railway-api.sh call in a heredoc (bash <<'SCRIPT' ... SCRIPT) to prevent escaping issues.

When should I not auto-apply Railway configuration changes?

Skip auto-apply when the user says stage only or don't deploy yet, or when batching multiple related changes that should deploy together. Staged changes can be applied later via the web UI or the commit mutation.