Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Add official Railway database services (Postgres, Redis, MySQL, MongoDB). Use when user wants to add a database, says "add postgres", "add redis", "add database", "connect to database", or "wire up the database". For other templates (Ghost, Strapi, n8n), use the railway-templates skill.
.claude/skills/davila7-railway-database/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-04 | ✗→✓ | ▲ Improved | 32% | 0% |
| case-05 | ✗→✓ | ▲ Improved | 60% | 0% |
| case-11 | ✗→✓ | ▲ Improved | 37% | 0% |
| case-18 | ✗→✓ | ▲ Improved | 178% | 0% |
| case-21 | ✓→✗ | ▼ Worse | 6% | 0% |
Add official Railway database services. These are maintained templates with pre-configured volumes, networking, and connection variables.
For non-database templates, see the railway-templates skill.
ALWAYS check for existing databases FIRST before creating.
User mentions database
│
Check existing DBs first
(query env config for source.image)
│
┌────┴────┐
Exists Doesn't exist
│ │
│ Create database
│ (CLI or API)
│ │
│ Wait for deployment
│ │
└─────┬─────┘
│
User wants to
connect service?
│
┌─────┴─────┐
Yes No
│ │
Wire vars Done +
via env suggest wiring
skillBefore creating a database, check if one already exists.
For full environment config structure, see environment-config.md.
bashrailway status --json
Then query environment config and check source.image for each service:
graphqlquery environmentConfig($environmentId: String!) { environment(id: $environmentId) { config(decryptVariables: false) } }
The config.services object contains each service's configuration. Check source.image for:
ghcr.io/railway/postgres* or postgres:* → Postgresghcr.io/railway/redis* or redis:* → Redisghcr.io/railway/mysql* or mysql:* → MySQLghcr.io/railway/mongo* or mongo:* → MongoDB| Database | Template Code | |----------|---------------| | PostgreSQL | postgres | | Redis | redis | | MySQL | mysql | | MongoDB | mongodb |
Get project context:
bashrailway status --json
Extract:
id - project IDenvironments.edges[0].node.id - environment IDGet workspace ID (not in status output):
bashbash <<'SCRIPT' ${CLAUDE_PLUGIN_ROOT}/skills/lib/railway-api.sh \ 'query getWorkspace($projectId: String!) { project(id: $projectId) { workspaceId } }' \ '{"projectId": "PROJECT_ID"}' SCRIPT
bashbash <<'SCRIPT' ${CLAUDE_PLUGIN_ROOT}/skills/lib/railway-api.sh \ 'query template($code: String!) { template(code: $code) { id name serializedConfig } }' \ '{"code": "postgres"}' SCRIPT
This returns the template's id and serializedConfig needed for deployment.
bashbash <<'SCRIPT' ${CLAUDE_PLUGIN_ROOT}/skills/lib/railway-api.sh \ 'mutation deployTemplate($input: TemplateDeployV2Input!) { templateDeployV2(input: $input) { projectId workflowId } }' \ '{ "input": { "templateId": "TEMPLATE_ID", "serializedConfig": SERIALIZED_CONFIG, "projectId": "PROJECT_ID", "environmentId": "ENVIRONMENT_ID", "workspaceId": "WORKSPACE_ID" } }' SCRIPT
Important: serializedConfig is the exact object from the template query, not a string.
After deployment, other services connect using reference variables.
For complete variable reference syntax and wiring patterns, see variables.md.
Use the private/internal URL for server-to-server communication:
| Database | Variable Reference | |----------|-------------------| | PostgreSQL | ${{Postgres.DATABASE_URL}} | | Redis | ${{Redis.REDIS_URL}} | | MySQL | ${{MySQL.MYSQL_URL}} | | MongoDB | ${{MongoDB.MONGO_URL}} |
Important: Frontends run in the user's browser and cannot access Railway's private network. They must use public URLs or go through a backend API.
For direct database access from frontend (not recommended):
${{MongoDB.MONGO_PUBLIC_URL}})Better pattern: Frontend → Backend API → Database
bashbash <<'SCRIPT' # 1. Get context railway status --json # Extract project.id and environment.id # 2. Get workspace ID ${CLAUDE_PLUGIN_ROOT}/skills/lib/railway-api.sh \ 'query { project(id: "proj-id") { workspaceId } }' '{}' # 3. Fetch Postgres template ${CLAUDE_PLUGIN_ROOT}/skills/lib/railway-api.sh \ 'query { template(code: "postgres") { id serializedConfig } }' '{}' # 4. Deploy template ${CLAUDE_PLUGIN_ROOT}/skills/lib/railway-api.sh \ 'mutation deploy($input: TemplateDeployV2Input!) { templateDeployV2(input: $input) { projectId workflowId } }' \ '{"input": {"templateId": "...", "serializedConfig": {...}, "projectId": "...", "environmentId": "...", "workspaceId": "..."}}' SCRIPT
Use railway-environment skill to add the variable reference:
json{ "services": { "<backend-service-id>": { "variables": { "DATABASE_URL": { "value": "${{Postgres.DATABASE_URL}}" } } } } }
Successful deployment returns:
json{ "data": { "templateDeployV2": { "projectId": "e63baedb-e308-49e9-8c06-c25336f861c7", "workflowId": "deployTemplate/project/e63baedb-e308-49e9-8c06-c25336f861c7/xxx" } } }
Each database template creates:
| Error | Cause | Solution | |-------|-------|----------| | Template not found | Invalid template code | Use: postgres, redis, mysql, mongodb | | Permission denied | User lacks access | Need DEVELOPER role or higher | | Project not found | Invalid project ID | Run railway status --json for correct ID |
railway-environment skill to stage: DATABASE_URL: { "value": "${{Postgres.DATABASE_URL}}" }DATABASE_URL=${{Postgres.DATABASE_URL}}"railway-environment skill to add variable referencesrailway-service skillrailway-deployment skill| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-09 | fail→fail | 8,334 | 5,837 | -30% | 1 | 1 | 0% | 1,403 | 2,369 | +69% | 0 | 0 | — |
case-10 | pass→pass | 12,875 | 6,971 | -46% | 1 | 1 | 0% | 2,379 | 3,171 | +33% | 0 | 0 | — |
case-01 | fail→fail | 4,762 | 5,339 | +12% | 1 | 1 | 0% | 277 | 2,313 | +735% | 0 | 0 | — |
case-02 | fail→fail | 11,078 | 5,104 | -54% | 1 | 1 | 0% | 1,886 | 2,325 | +23% | 0 | 0 | — |
case-03 | fail→fail | 6,345 | 5,386 | -15% | 1 | 1 | 0% | 615 | 2,247 | +265% | 0 | 0 | — |
case-04 | fail→pass | 12,544 | 5,528 | -56% | 1 | 1 | 0% | 2,250 | 2,969 | +32% | 0 | 0 | — |
case-05 | fail→pass | 10,602 | 5,505 | -48% | 1 | 1 | 0% | 1,840 | 2,950 | +60% | 0 | 0 | — |
case-06 | pass→pass | 8,786 | 2,904 | -67% | 1 | 1 | 0% | 1,503 | 2,557 | +70% | 0 | 0 | — |
case-07 | pass→pass | 7,883 | 2,365 | -70% | 1 | 1 | 0% | 1,328 | 2,439 | +84% | 0 | 0 | — |
case-08 | fail→fail | 9,962 | 7,462 | -25% | 1 | 1 | 0% | 1,595 | 2,361 | +48% | 0 | 0 | — |
case-11 | fail→pass | 10,965 | 4,100 | -63% | 1 | 1 | 0% | 2,052 | 2,806 | +37% | 0 | 0 | — |
case-12 | pass→pass | 5,769 | 1,790 | -69% | 1 | 1 | 0% | 727 | 2,292 | +215% | 0 | 0 | — |
case-13 | pass→pass | 5,102 | 2,059 | -60% | 1 | 1 | 0% | 740 | 2,253 | +204% | 0 | 0 | — |
case-14 | pass→pass | 4,026 | 2,283 | -43% | 1 | 1 | 0% | 633 | 2,268 | +258% | 0 | 0 | — |
case-15 | pass→pass | 5,279 | 1,987 | -62% | 1 | 1 | 0% | 884 | 2,344 | +165% | 0 | 0 | — |
case-16 | pass→pass | 6,802 | 4,153 | -39% | 1 | 1 | 0% | 1,150 | 2,745 | +139% | 0 | 0 | — |
case-17 | pass→pass | 9,214 | 4,074 | -56% | 1 | 1 | 0% | 1,689 | 2,696 | +60% | 0 | 0 | — |
case-18 | fail→pass | 5,485 | 1,842 | -66% | 1 | 1 | 0% | 838 | 2,327 | +178% | 0 | 0 | — |
case-19 | pass→pass | 11,079 | 2,469 | -78% | 1 | 1 | 0% | 1,826 | 2,420 | +33% | 0 | 0 | — |
case-20 | fail→fail | 8,625 | 6,155 | -29% | 1 | 1 | 0% | 1,586 | 2,302 | +45% | 0 | 0 | — |
case-21 | pass→fail | 10,495 | 5,211 | -50% | 1 | 1 | 0% | 2,123 | 2,253 | +6% | 0 | 0 | — |
case-22 | pass→fail | 9,385 | 7,070 | -25% | 1 | 1 | 0% | 1,513 | 2,452 | +62% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted, and 14 counted toward the lift figure. The other 8 produced results that are not comparable between the two arms, so they are excluded from the headline rather than averaged into it. The headline lift of +9 percentage points is the difference between those two pass rates over the 14 comparable cases. 2 cases got worse with the skill loaded, and they are included in that figure.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.