---
name: ibgib-create-server-app
description: Scaffolds the backend Node.js server for an ibgib full-stack application using serve-gib from @ibgib/node-gib, including WebSocket sync upgrade, Traefik Docker Compose, and server TypeScript configuration.
---

# Skill: ibgib-create-server-app

## What This Skill Does

Generates the backend server infrastructure for an `ibgib` server application or the server backend of a full-stack project. This includes:
- **`src/server/server.mts`**: Node.js HTTP/WebSocket server utilizing `serve-gib`, `getStandardServeGibHandlers()`, and `SyncUpgradeHandler`.
- **`tsconfig.server.json`**: TypeScript compiler configuration targeted for Node.js ESNext.
- **`Dockerfile`**: Lightweight Alpine container packaging the bundled server and static client SPA.
- **`docker-compose.yml`**: Local multi-container orchestration behind the Traefik reverse proxy with automatic local HTTPS (`*.localhost` and `local.ibgib.space` SSO loopback).

For architectural context, refer to [`docs/IBGIB_SERVER_APPS_GUIDE.md`](../../../docs/IBGIB_SERVER_APPS_GUIDE.md).

---

## Token Reference

| Token | Example value | How it's computed |
|---|---|---|
| `{{APP_NAME}}` | `my-app` | kebab-case application name |
| `{{APP_DIR_NAME}}` | `my-app` | Folder name |
| `{{APP_HUMAN_NAME}}` | `My App` | Natural language name |
| `{{PORT}}` | `3000` | Server port (default `3000`) |
| `{{DATA_DIR_REL}}` | `../../.data/my-app-space` | Local storage directory relative to server |
| `{{LOCAL_DOMAIN}}` | `my-app.localhost` | Local HTTPS subdomain |
| `{{APP_UUID}}` | `4b810a9c...` | Unique 32-char hex string from `generate-id.js` |

---

## Generation Steps

### 1. Confirm token values
Derive tokens from the developer's inputs and generate fresh UUIDs using `node .agents/skills/ibgib-create-client-app-core/generate-id.js`.

### 2. Generate files
Apply token substitutions to templates in `templates/` and write to the target application directory:

| Template file | Output file |
|---|---|
| `templates/server.mts.template` | `src/server/server.mts` |
| `templates/tsconfig.server.json.template` | `tsconfig.server.json` |
| `templates/Dockerfile.template` | `Dockerfile` |
| `templates/docker-compose.yml.template` | `docker-compose.yml` (or app service block) |

### 3. Update Build Script
Ensure the application's `build-[app-name].mts` script configures `tsconfigConfigs` for both client (`tsconfig.json`) and server (`tsconfig.server.json`), and builds the server entry point via `buildServer()`.
