Loading...
Loading...
Create Railway projects, services, and databases with proper configuration. Use when user says "setup", "deploy to railway", "initialize", "create project", "create service", or wants to deploy from GitHub. Handles initial setup AND adding services to existing projects. For databases, use railway-railway-database skill instead.
npx skill4agent add davila7/claude-code-templates railway-newcommand -v railwayInstall Railway CLI:npm install -g @railway/cliorbrew install railway
railway whoami --jsonRunto authenticate.railway login
railway status --json (in current dir)
│
┌────┴────┐
Linked Not Linked
│ │
│ Check parent: cd .. && railway status --json
│ │
│ ┌────┴────┐
│ Parent Not linked
│ Linked anywhere
│ │ │
│ Add service railway list
│ Set rootDir │
│ Deploy ┌───┴───┐
│ │ Match? No match
│ │ │ │
│ │ Link Init new
└───────┴────────┴────────┘
│
User wants service?
│
┌─────┴─────┐
Yes No
│ │
Scaffold code Done
│
railway add --service
│
Configure if needed
│
Ready to deployrailway status --jsonUser: "create a vite app called foo and deploy to railway"
Project: Already linked to "my-project"
WRONG: railway init -n foo
RIGHT: railway add --service foocd .. && railway status --jsonrailway add --service <name>rootDirectoryrailway upidnameidnamerailway list --jsonrailway initrailway linkrailway initrailway init -n <name>-n, --name-w, --workspacerailway init--workspacerailway whoami --jsonworkspaces{ id, name }# User says: "create a project in my personal workspace"
railway whoami --json | jq '.workspaces[] | select(.name | test("personal"; "i"))'
# Use the matched ID: railway init -n myapp --workspace <matched-id>railway link -p <project>-p, --project-e, --environment-s, --service-t, --teamrailway add --service <name>railway add --reporailway add --service my-apisource.reposource.branchRAILPACK_STATIC_FILE_ROOTrailway variablesstartstartCommandrequirements.txtpyproject.tomlgo.mod/frontendpnpm --filter <package> buildnpm run build --workspace=packages/<package>yarn workspace <package> buildturbo run build --filter=<package>package.jsonrequirements.txtpyproject.tomlgo.modCargo.tomlindex.htmlpnpm-workspace.yamlpackage.jsonworkspacesturbo.jsonpackage.jsonCreate anfile in the root directory.index.html
npm create vite@latest . -- --template reactnpm create astro@latestCreatewith FastAPI app andmain.pywith dependencies.requirements.txt
Createwith HTTP server listening onmain.goenv var.PORT
Railway CLI not installed. Install with:
npm install -g @railway/cli
or
brew install railwayNot logged in to Railway. Run: railway loginNo workspaces found. Create one at railway.com or verify authentication.Project name already exists. Either:
- Link to existing: railway link -p <name>
- Use different name: railway init -n <other-name>Service name already exists in this project. Use a different name:
railway add --service <other-name>User: "create a simple html site and deploy to railway"
1. Check status → not linked
2. railway init -n my-site
3. Guide: create index.html
4. railway add --service my-site
5. No config needed (index.html in root auto-detected)
6. Use deploy skill: railway up
7. Use domain skill for public URLUser: "create a vite react service"
1. Check status → linked (or init/link first)
2. Scaffold: npm create vite@latest frontend -- --template react
3. railway add --service frontend
4. No config needed (Vite dist output auto-detected)
5. Use deploy skill: railway upUser: "add a python api to my project"
1. Check status → linked
2. Guide: create main.py with FastAPI, requirements.txt
3. railway add --service api
4. No config needed (FastAPI auto-detected)
5. Use deploy skillUser: "connect to my backend project and add a worker service"
1. railway list --json → find "backend"
2. railway link -p backend
3. railway add --service worker
4. Guide setup based on worker typeUser: "deploy to railway"
1. railway status → not linked
2. railway list → has projects
3. Directory is "my-app", found project "my-app"
4. Ask: "Found existing project 'my-app'. Link to it or create new?"
5. User: "link"
6. railway link -p my-app
7. Ask: "Create a service for this code?"User: "create a static site in the frontend directory"
1. Check: /frontend has its own package.json, no workspace config
2. This is isolated monorepo → use root directory
3. railway add --service frontend
4. Invoke environment skill to set rootDirectory: /frontend
5. Set watch paths: /frontend/**User: "add a new api package to this turborepo"
1. Check: turbo.json exists, pnpm-workspace.yaml exists
2. This is shared monorepo → use custom commands, NOT root directory
3. Guide: create packages/api with package.json
4. railway add --service api
5. Invoke environment skill to set buildCommand and startCommand (do NOT set rootDirectory)
6. Set watch paths: /packages/api/**, /packages/shared/**User: "deploy the backend package to railway"
1. Check: pnpm-workspace.yaml exists → shared monorepo
2. railway add --service backend
3. Invoke environment skill to set buildCommand and startCommand
4. Set watch paths for backend + any shared depsUser: "create a vite app in my-app directory and deploy to railway"
CWD: ~/projects/my-project/my-app (parent already linked to "my-project")
1. Check status in my-app → not linked
2. Check parent: cd .. && railway status → IS linked to "my-project"
3. DON'T init/link the subdirectory
4. Scaffold: bun create vite my-app --template react-ts
5. cd my-app && bun install
6. railway add --service my-app
7. Invoke environment skill to set rootDirectory: /my-app
8. Deploy from root: railway up