SKILL.md--- name: railway-environment description: Query, stage, and apply configuration changes for Railway environments. Use for ANY variable or env var operations, service configuration (source, build settings, deploy settings), lifecycle (delete service), and applying changes. Prefer over railway-status skill for any configuration or variable queries. license: MIT allowed-tools: Bash(railway:*) metadata: version: 1.0.0 author: Railway tags: [Railway, Environment, Configuration, Variables, Build, Deploy, Infrastructure, Settings] dependencies: [railway-cli] --- # Environment Configuration Query, stage, and apply configuration changes for Railway environments. ## Shell Escaping **CRITICAL:** When running GraphQL queries via bash, you MUST wrap in heredoc to prevent shell escaping issues: ```bash bash <<'SCRIPT' ${CLAUDE_PLUGIN_ROOT}/skills/lib/railway-api.sh 'query ...' '{"var": "value"}' SCRIPT ``` Without the heredoc wrapper, multi-line commands break and exclamation marks in GraphQL non-null types get escaped, causing query failures. ## When to Use - User wants to create a new environment - User wants to duplicate an environment (e.g., "copy production to staging") - User wants to switch to a different environment - User asks about current build/deploy settings, variables, replicas, health checks, domains - User asks to change service source (Docker image, branch, commit, root directory) - User wants to connect a service to a GitHub repo - User wants to deploy from a GitHub repo (create empty service first via railway-new skill, then use this) - User asks to change build or start command - User wants to add/update/delete environment variables - User wants to change replica count or configure health checks - User asks to delete a service, volume, or bucket - User says "apply changes", "commit changes", "deploy changes" - Auto-fixing build errors detected in logs ## Create Environment Create a new environment in the linked project: ```bash railway environment new <name> ``` Duplicate an existing environment: ```bash railway environment new staging --duplicate production ``` With service-specific variables: ```bash railway environment new staging --duplicate production --service-variable api PORT=3001 ``` ## Switch Environment Link a different environment to the current directory: ```bash railway environment <name> ``` Or by ID: ```bash railway environment <environment-id> ``` ## Get Context ```bash railway status --json ``` Extract: - `project.id` - for service lookup - `environment.id` - for the mutations - `service.id` - default service if user doesn't specify one ### Resolve Service ID If user specifies a service by name, query project services: ```graphql query projectServices($projectId: String!) { project(id: $projectId) { services { edges { node { id name } } } } } ``` Match the service name (case-insensitive) to get the service ID. ## Query Conf