鱼皮AI导航
鱼皮AI导航
  • 主页
  • 社区
  • AI工具
  • AI知识库
  • AI提示词
  • MCP
  • Skills
  • AI学习资源
  • AI资讯
  • GitHub开源
登录/注册

environment

提供对 Railway项目环境的全生命周期配置管理能力,包括创建、切换与复制环境,查询和修改服务源码、构建部署参数、运行时变量、副本数量及健康检查等设置,并支持变更的分阶段暂存与一键应用。

效率工具商业与营销开发运维
访问 GitHub
文档Skills.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.
version
1.0.0
author
Railway
license
MIT
tags["Railway","Environment","Configuration","Variables","Build","Deploy","Infrastructure","Settings"]
dependencies["railway-cli"]
allowed-tools
Bash(railway:*)

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 Configuration

Fetch current environment configuration and staged changes.

▼
graphql
复制代码
query environmentConfig($environmentId: String!) { environment(id: $environmentId) { id config(decryptVariables: false) serviceInstances { edges { node { id serviceId } } } } environmentStagedChanges(environmentId: $environmentId) { id patch(decryptVariables: false) } }

Example:

▼
bash
复制代码
bash <<'SCRIPT' ${CLAUDE_PLUGIN_ROOT}/skills/lib/railway-api.sh \ 'query envConfig($envId: String!) { environment(id: $envId) { id config(decryptVariables: false) } environmentStagedChanges(environmentId: $envId) { id patch(decryptVariables: false) } }' \ '{"envId": "ENV_ID"}' SCRIPT

Response Structure

The config field contains current configuration:

▼
json
复制代码
{ "services": { "<serviceId>": { "source": { "repo": "...", "branch": "main" }, "build": { "buildCommand": "npm run build", "builder": "NIXPACKS" }, "deploy": { "startCommand": "npm start", "multiRegionConfig": { "us-west2": { "numReplicas": 1 } } }, "variables": { "NODE_ENV": { "value": "production" } }, "networking": { "serviceDomains": {}, "customDomains": {} } } }, "sharedVariables": { "DATABASE_URL": { "value": "..." } } }

The patch field in environmentStagedChanges contains pending changes. The effective configuration is the base config merged with the staged patch.

For complete field reference, see reference/environment-config.md.

For variable syntax and service wiring patterns, see reference/variables.md.

Get Rendered Variables

The GraphQL queries above return unrendered variables - template syntax like ${{shared.DOMAIN}} is preserved. This is correct for management/editing.

To see rendered (resolved) values as they appear at runtime:

▼
bash
复制代码
# Current linked service railway variables --json # Specific service railway variables --service <service-name> --json

When to use:

  • Debugging connection issues (see actual URLs/ports)
  • Verifying variable resolution is correct
  • Viewing Railway-injected values (RAILWAY_*)

Stage Changes

Stage configuration changes via the environmentStageChanges mutation. Use merge: true to automatically merge with existing staged changes.

▼
graphql
复制代码
mutation stageEnvironmentChanges( $environmentId: String! $input: EnvironmentConfig! $merge: Boolean ) { environmentStageChanges( environmentId: $environmentId input: $input merge: $merge ) { id } }

Important: Always use variables (not inline input) because service IDs are UUIDs which can't be used as unquoted GraphQL object keys.

Example:

▼
bash
复制代码
bash <<'SCRIPT' ${CLAUDE_PLUGIN_ROOT}/skills/lib/railway-api.sh \ 'mutation stageChanges($environmentId: String!, $input: EnvironmentConfig!, $merge: Boolean) { environmentStageChanges(environmentId: $environmentId, input: $input, merge: $merge) { id } }' \ '{"environmentId": "ENV_ID", "input": {"services": {"SERVICE_ID": {"build": {"buildCommand": "npm run build"}}}}, "merge": true}' SCRIPT

Delete Service

Use isDeleted: true:

▼
bash
复制代码
bash <<'SCRIPT' ${CLAUDE_PLUGIN_ROOT}/skills/lib/railway-api.sh \ 'mutation stageChanges($environmentId: String!, $input: EnvironmentConfig!, $merge: Boolean) { environmentStageChanges(environmentId: $environmentId, input: $input, merge: $merge) { id } }' \ '{"environmentId": "ENV_ID", "input": {"services": {"SERVICE_ID": {"isDeleted": true}}}, "merge": true}' SCRIPT

Stage and Apply Immediately

For single changes that should deploy right away, use environmentPatchCommit to stage and apply in one call.

▼
graphql
复制代码
mutation environmentPatchCommit( $environmentId: String! $patch: EnvironmentConfig $commitMessage: String ) { environmentPatchCommit( environmentId: $environmentId patch: $patch commitMessage: $commitMessage ) }

Example:

▼
bash
复制代码
bash <<'SCRIPT' ${CLAUDE_PLUGIN_ROOT}/skills/lib/railway-api.sh \ 'mutation patchCommit($environmentId: String!, $patch: EnvironmentConfig, $commitMessage: String) { environmentPatchCommit(environmentId: $environmentId, patch: $patch, commitMessage: $commitMessage) }' \ '{"environmentId": "ENV_ID", "patch": {"services": {"SERVICE_ID": {"variables": {"API_KEY": {"value": "secret"}}}}}, "commitMessage": "add API_KEY"}' SCRIPT

When to use: Single change, no need to batch, user wants immediate deployment.

When NOT to use: Multiple related changes to batch, or user says "stage only" / "don't deploy yet".

Apply Staged Changes

Commit staged changes and trigger deployments.

Note: There is no railway apply CLI command. Use the mutation below or direct users to the web UI.

Apply Mutation

Mutation name: environmentPatchCommitStaged

▼
graphql
复制代码
mutation environmentPatchCommitStaged( $environmentId: String! $message: String $skipDeploys: Boolean ) { environmentPatchCommitStaged( environmentId: $environmentId commitMessage: $message skipDeploys: $skipDeploys ) }

Example:

▼
bash
复制代码
bash <<'SCRIPT' ${CLAUDE_PLUGIN_ROOT}/skills/lib/railway-api.sh \ 'mutation commitStaged($environmentId: String!, $message: String) { environmentPatchCommitStaged(environmentId: $environmentId, commitMessage: $message) }' \ '{"environmentId": "ENV_ID", "message": "add API_KEY variable"}' SCRIPT

Parameters

FieldTypeDefaultDescription
environmentIdString!-Environment ID from status
messageStringnullShort description of changes
skipDeploysBooleanfalseSkip deploys (only if user explicitly asks)

Commit Message

Keep very short - one sentence max. Examples:

  • "set build command to fix npm error"
  • "add API_KEY variable"
  • "increase replicas to 3"

Leave empty if no meaningful description.

Default Behavior

Always deploy unless user explicitly asks to skip. Only set skipDeploys: true if user says "apply without deploying", "commit but don't deploy", or "skip deploys".

Returns a workflow ID (string) on success.

Auto-Apply Behavior

By default, apply changes immediately.

Flow

Single change: Use environmentPatchCommit to stage and apply in one call.

Multiple changes or batching: Use environmentStageChanges with merge: true for each change, then environmentPatchCommitStaged to apply.

When NOT to Auto-Apply

  • User explicitly says "stage only", "don't deploy yet", or similar
  • User is making multiple related changes that should deploy together

When you don't auto-apply, tell the user:

Changes staged. Apply them at: https://railway.com/project/{projectId} Or ask me to apply them.

Get projectId from railway status --json → project.id

Error Handling

Service Not Found

▼
text
复制代码
Service "foo" not found in project. Available services: api, web, worker

No Staged Changes

▼
text
复制代码
No patch to apply

There are no staged changes to commit. Stage changes first.

Invalid Configuration

Common issues:

  • buildCommand and startCommand cannot be identical
  • buildCommand only valid with NIXPACKS builder
  • dockerfilePath only valid with DOCKERFILE builder

No Permission

▼
text
复制代码
You don't have permission to modify this environment. Check your Railway role.

No Linked Project

▼
text
复制代码
No project linked. Run `railway link` to link a project.

Composability

  • Create service: Use railway-service skill
  • View logs: Use railway-deployment skill
  • Add domains: Use railway-domain skill
  • Deploy local code: Use railway-deploy skill
效率工具
商业与营销
开发运维

快捷安装

复制到终端去安装 Skill

npxskillsadddavila7/claude-code-templates--skill"environment"
站长:程序员鱼皮 老鱼简历 商务合作 增值电信业务经营许可证
2026 鱼皮AI导航 | 沪ICP备19026706号-6
站长:程序员鱼皮 老鱼简历 商务合作 增值电信业务经营许可证
2026 鱼皮AI导航 | 沪ICP备19026706号-6
🔥热门工具
朱雀AI检测朱雀AI检测
朱雀AI检测助手朱雀AI检测助手
LovartLovart
老鱼简历老鱼简历
WritePass官网WritePass官网
面多多面多多
CursorCursor
星月写作星月写作
朱雀AI检测助手朱雀AI检测助手
零感AI零感AI
Skills 推荐
retrieving-developer-knowledge
retrieving-developer-knowledge 用于搜索、获取和整合 Google 官方开发者文档,覆盖 Google Cloud、AI/Gemini、Android、Chrome、Web、Flutter、Go、Firebase 等平台,适用于查询 gcloud CLI 命令、API 语法、IAM 权限或架构对比等场景。
diff-intake
diff-intake 读取 PR 或分支差异,生成结构化 YAML 变更摘要,用于下游 analytics instrumentation 技能。适用于用户提交 PR 链接、分支对比或原始 diff 后需理解变更内容、评估分析覆盖或启动埋点流程的场景。
load-balancer-configurator
根据用户需求自动生成各类负载均衡器的生产级配置,覆盖 ALB、NLB、Nginx 和 HAProxy 等主流类型,适配不同协议、端口、健康检查及后端服务拓扑,支持直接集成到基础设施即代码流程中。
webapp-testing
提供本地 Web 应用的端到端测试能力,支持页面导航、元素交互、表单填写、动态等待、断言验证、截图捕获、浏览器日志收集及网络请求拦截,适用于前端功能验证与 UI 行为调试。
definition-of-done-generator
自动生成项目完成标准的规范定义与配置文件,提供符合企业级工作流要求的最佳实践指导,输出可直接投入生产环境的代码和验证结果,适用于需要标准化流程审批、合规审查及跨系统集成的复杂项目管理场景。