environment by railwayapp/railway-skills
npx skills add https://github.com/railwayapp/railway-skills --skill environment使用 CLI 读取和编辑 Railway 环境配置。
需要 Railway CLI v4.27.3+ 版本。通过以下命令检查:
railway --version
如果版本低于 4.27.3,请升级:
railway upgrade
当用户询问“配置是什么”或“显示配置”时:
railway environment config --json
呈现内容:来源(仓库/镜像)、构建设置、部署设置、每个服务的变量。
当用户询问“有哪些变量”或“显示环境变量”时:
使用相同的命令 —— railway environment config --json 包含每个服务的变量和共享变量。
要获取已渲染(已解析)的变量值:railway variables --json
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
new 技能创建空服务,然后使用此功能)在链接的项目中创建新环境:
railway environment new <name>
复制现有环境:
railway environment new staging --duplicate production
包含特定于服务的变量:
railway environment new staging --duplicate production --service-variable api PORT=3001
将当前目录链接到不同的环境:
railway environment <name>
或通过 ID:
railway environment <environment-id>
JSON 输出 —— 项目/环境 ID 和服务列表:
railway status --json
提取信息:
project.id —— 项目 IDenvironment.id —— 环境 ID纯文本输出 —— 链接的服务名称:
railway status
显示 Service: <name> 行,其中包含当前链接的服务。
从环境配置中获取服务 ID:
railway environment config --json | jq '.services | keys'
通过状态将服务 ID 映射到名称:
railway status --json
project.services 数组包含每个服务的 { id, name }。与来自 environment config 的服务键进行匹配。
获取当前环境配置:
railway environment config --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": "..." } }
}
有关完整字段参考,请参阅 reference/environment-config.md。
有关变量语法和服务连接模式,请参阅 reference/variables.md。
environment config 返回未渲染的变量 —— 模板语法如 ${{shared.DOMAIN}} 会被保留。这对于管理/编辑是正确的。
要查看运行时出现的已渲染(已解析)值:
# 当前链接的服务
railway variables --json
# 特定服务
railway variables --service <service-name> --json
使用时机:
将 JSON 补丁传递给 railway environment edit 以应用更改。该补丁将与现有配置合并并立即提交,触发部署。
railway environment edit --json <<< '<json-patch>'
附带提交信息:
railway environment edit -m "description of change" --json <<< '<json-patch>'
设置构建命令:
railway environment edit --json <<< '{"services":{"SERVICE_ID":{"build":{"buildCommand":"npm run build"}}}}'
添加变量:
railway environment edit -m "add API_KEY" --json <<< '{"services":{"SERVICE_ID":{"variables":{"API_KEY":{"value":"secret"}}}}}'
删除变量:
railway environment edit --json <<< '{"services":{"SERVICE_ID":{"variables":{"OLD_VAR":null}}}}'
删除服务:
railway environment edit --json <<< '{"services":{"SERVICE_ID":{"isDeleted":true}}}'
设置副本数:
railway environment edit --json <<< '{"services":{"SERVICE_ID":{"deploy":{"multiRegionConfig":{"us-west2":{"numReplicas":3}}}}}}'
添加共享变量:
railway environment edit --json <<< '{"sharedVariables":{"DATABASE_URL":{"value":"postgres://..."}}}'
在单个补丁中包含多个字段,以原子方式应用它们:
railway environment edit -m "configure build, start, and env" --json <<< '{"services":{"SERVICE_ID":{"build":{"buildCommand":"npm run build"},"deploy":{"startCommand":"npm start"},"variables":{"NODE_ENV":{"value":"production"}}}}}'
如果 railway environment edit 未被识别,请升级 CLI:
railway upgrade
Service "foo" not found in project. Available services: api, web, worker
常见问题:
buildCommand 和 startCommand 不能相同buildCommand 仅对 NIXPACKS 构建器有效dockerfilePath 仅对 DOCKERFILE 构建器有效You don't have permission to modify this environment. Check your Railway role.
No project linked. Run `railway link` to link a project.
service 技能deployment 技能domain 技能deploy 技能每周安装次数
824
仓库
GitHub 星标数
212
首次出现时间
2026 年 1 月 20 日
安全审计
安装于
opencode689
codex680
gemini-cli643
claude-code614
github-copilot612
amp559
Read and edit Railway environment configuration using the CLI.
Requires Railway CLI v4.27.3+. Check with:
railway --version
If below 4.27.3, upgrade:
railway upgrade
When user asks "what's the config" or "show configuration":
railway environment config --json
Present: source (repo/image), build settings, deploy settings, variables per service.
When user asks "what variables" or "show env vars":
Same command — railway environment config --json includes variables per service and shared variables.
For rendered (resolved) variable values: railway variables --json
new skill, then use this)Create a new environment in the linked project:
railway environment new <name>
Duplicate an existing environment:
railway environment new staging --duplicate production
With service-specific variables:
railway environment new staging --duplicate production --service-variable api PORT=3001
Link a different environment to the current directory:
railway environment <name>
Or by ID:
railway environment <environment-id>
JSON output — project/environment IDs and service list:
railway status --json
Extract:
project.id — project IDenvironment.id — environment IDPlain output — linked service name:
railway status
Shows Service: <name> line with the currently linked service.
Get service IDs from the environment config:
railway environment config --json | jq '.services | keys'
Map service IDs to names via status:
railway status --json
The project.services array contains { id, name } for each service. Match against the service keys from environment config.
Fetch current environment configuration:
railway environment config --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": "..." } }
}
For complete field reference, see reference/environment-config.md.
For variable syntax and service wiring patterns, see reference/variables.md.
environment config returns 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:
# Current linked service
railway variables --json
# Specific service
railway variables --service <service-name> --json
When to use:
Pass a JSON patch to railway environment edit to apply changes. The patch is merged with existing config and committed immediately, triggering deploys.
railway environment edit --json <<< '<json-patch>'
With a commit message:
railway environment edit -m "description of change" --json <<< '<json-patch>'
Set build command:
railway environment edit --json <<< '{"services":{"SERVICE_ID":{"build":{"buildCommand":"npm run build"}}}}'
Add variable:
railway environment edit -m "add API_KEY" --json <<< '{"services":{"SERVICE_ID":{"variables":{"API_KEY":{"value":"secret"}}}}}'
Delete variable:
railway environment edit --json <<< '{"services":{"SERVICE_ID":{"variables":{"OLD_VAR":null}}}}'
Delete service:
railway environment edit --json <<< '{"services":{"SERVICE_ID":{"isDeleted":true}}}'
Set replicas:
railway environment edit --json <<< '{"services":{"SERVICE_ID":{"deploy":{"multiRegionConfig":{"us-west2":{"numReplicas":3}}}}}}'
Add shared variable:
railway environment edit --json <<< '{"sharedVariables":{"DATABASE_URL":{"value":"postgres://..."}}}'
Include multiple fields in a single patch to apply them atomically:
railway environment edit -m "configure build, start, and env" --json <<< '{"services":{"SERVICE_ID":{"build":{"buildCommand":"npm run build"},"deploy":{"startCommand":"npm start"},"variables":{"NODE_ENV":{"value":"production"}}}}}'
If railway environment edit is not recognized, upgrade the CLI:
railway upgrade
Service "foo" not found in project. Available services: api, web, worker
Common issues:
buildCommand and startCommand cannot be identicalbuildCommand only valid with NIXPACKS builderdockerfilePath only valid with DOCKERFILE builderYou don't have permission to modify this environment. Check your Railway role.
No project linked. Run `railway link` to link a project.
service skilldeployment skilldomain skilldeploy skillWeekly Installs
824
Repository
GitHub Stars
212
First Seen
Jan 20, 2026
Security Audits
Gen Agent Trust HubFailSocketPassSnykFail
Installed on
opencode689
codex680
gemini-cli643
claude-code614
github-copilot612
amp559
Azure 升级评估与自动化工具 - 轻松迁移 Functions 计划、托管层级和 SKU
59,200 周安装
股票分析工具 - 一键生成NVDA、TSLA、AAPL等股票情感分析报告
759 周安装
spec-miner:AI代码规范挖掘器 - 从代码库自动提取需求与文档
760 周安装
销售线索筛选框架指南:提升转化率,优化销售流程 | 销售效率工具
760 周安装
hairy-utils:JavaScript/TypeScript 核心工具库 | 异步处理、类型检查、函数式编程
761 周安装
设计系统构建指南:Figma、Airbnb专家框架,助您规模化产品设计
761 周安装
Claude智能体开发指南:创建自主AI助手,掌握agent-development核心技巧
762 周安装