Deployment Artifact Generator — Kubernetes
This skill generates deployment artifacts for a custom application:
- Dockerfile — A production-ready, multi-stage container build file placed in the
application root folder.
- Kubernetes manifests — Manifest files stored directly in the application's own
k8s/ folder for a single target environment. Since the k8s/ folder is gitignored,
each machine maintains its own independent copy of the manifests with environment-specific
ConfigMap/Secret values (hostnames, credentials, resource limits).
Note: Only custom applications (from # Custom Applications in CLAUDE.md) are processed.
3rd party supporting applications and external services are NOT containerized by this skill.
Inputs
/depgen-k8s <application> [environment]
| Argument |
Required |
Example |
Description |
<application> |
Yes |
hub_middleware |
Application name — must be a custom application from CLAUDE.md |
<environment> |
No |
home_server |
Target environment name — must match a Kubernetes environment in CLAUDE.md |
If <environment> is omitted:
- If CLAUDE.md defines exactly one Kubernetes environment → auto-select it.
- If CLAUDE.md defines multiple Kubernetes environments → list them and ask the user to specify.
The environment name is matched case-insensitively against the environment headings in CLAUDE.md, accepting snake_case, kebab-case, or title-case input (e.g., home_server, home-server, Home Server).
No version: or module: arguments — deployment is application-level.
Input Resolution
The application name is matched against root-level application folders:
- Strip any leading
<number>_ prefix from folder names (e.g., 1_hub_middleware → hub_middleware)
- Match case-insensitively against the provided application name
- Accept snake_case, kebab-case, or title-case input
- Verify the application is listed under
# Custom Applications in CLAUDE.md — reject if it is a 3rd party application or external service
- If no match found, list available custom applications and stop
Auto-Resolved Paths
| File |
Resolved Path |
| CLAUDE.md |
Project root CLAUDE.md |
| ENVIRONMENT.md |
Project root ENVIRONMENT.md |
| SPECIFICATION.md |
<app_folder>/context/specification/SPECIFICATION.md |
| Source code |
<app_folder>/ (pom.xml, composer.json, package.json, etc.) |
| Application config |
Stack-dependent (see detection) |
| K8s manifests output |
<app_folder>/k8s/ (gitignored — each machine maintains its own copy) |
PRD.md Extended Sections
Before generating deployment artifacts, check PRD.md for the following extended sections:
Architecture Principle
If PRD.md contains an # Architecture Principle section, extract patterns that affect deployment:
| Pattern |
Deployment Impact |
| "Stateless" |
Deployment uses RollingUpdate strategy without sticky sessions; no PVC needed for session storage |
| "Container based deployment" |
Validates this skill's applicability |
| "Scale out" / "horizontally scalable" |
Generate HorizontalPodAutoscaler (HPA) manifest targeting CPU 70% |
| Specific resource constraints (e.g., "max 256Mi per pod") |
Use as default resource limits in K8s manifests |
| "Message driven" / "message queue" |
Readiness probe should verify message queue connectivity |
If absent, use defaults from SPECIFICATION.md and CLAUDE.md (existing behavior).
High Level Process Flow
If PRD.md contains a # High Level Process Flow section:
- Process flows reveal inter-system dependencies (message queues, external service endpoints)
- Validate that the environment variable list and ConfigMap/Secret values include all dependencies mentioned in process flows
- If a flow references an external system not in the
Depends on list, log a warning
If absent, derive dependencies from CLAUDE.md only (existing behavior).
Pre-Requisites
Before running this skill, the following must exist:
- Source code — The application must be implemented (not just context artifacts)
- SPECIFICATION.md — The technical specification must exist (generated by a
specgen-* skill)
- Externalized configuration — The application config must use environment variables
(e.g.,
${ENV_VAR:default} in Spring Boot, env('VAR') in Laravel, process.env.VAR in Node.js)
If any are missing, stop and inform the user.
Workflow
Phase 0: Validate Inputs
Resolve application folder from the provided name
Verify the application is a custom application in CLAUDE.md (not 3rd party or external service)
Verify source code exists (at least one of: pom.xml, composer.json, package.json)
Verify <app_folder>/context/specification/SPECIFICATION.md exists
Read CLAUDE.md (already in context) for project-level information
Detect environments from CLAUDE.md's # Environment section:
- Each
## <Environment Name> heading under # Environment is an environment
- For each environment, extract:
- Environment name (e.g., "Home Server")
Domain field (e.g., localhost, home.server)
Deployment Type field (e.g., Manual, Kubernetes)
IP field (from SSH Configuration or direct IP field) if present — needed for hostAliases generation in Phase 3
- If no environments are defined, stop with error: "No environments found in CLAUDE.md
# Environment section."
Select target environment — filter to Kubernetes environments and select one:
- Filter environments to those with
Deployment Type: Kubernetes.
- If no environment has
Deployment Type: Kubernetes, stop with error: "No Kubernetes environments found in CLAUDE.md. This skill only generates K8s manifests for environments with Deployment Type: Kubernetes."
- If the user provided an
<environment> argument, match it against the Kubernetes environments (case-insensitively, accepting snake_case, kebab-case, or title-case).
- If matched → use it as the target environment.
- If not matched → list available Kubernetes environments and stop.
- If no argument was provided:
- If exactly one Kubernetes environment exists → auto-select it.
- If multiple exist → list them and ask the user to specify.
- Record the selected environment's Domain and IP for Phase 3.
Phase 1: Detect Application Stack
Step 1 — Identify Stack
Check the application root for build files:
| File Found |
Stack |
Build Tool |
pom.xml |
spring-boot |
Maven |
composer.json |
laravel |
Composer |
package.json (no pom.xml or composer.json) |
nodejs |
npm / pnpm |
If none found, stop with error: "Cannot determine application stack."
If multiple found (e.g., pom.xml + package.json), prioritize: pom.xml > composer.json > package.json
(the package.json is likely for frontend or E2E tests, not the main app).
Step 2 — Extract Stack-Specific Metadata
If spring-boot:
- Read
pom.xml:
<java.version> → JDK version for base image
<artifactId> → image name
<version> → image tag
frontend-maven-plugin presence → has frontend build step
jte-maven-plugin presence → has JTE precompilation
spring-boot-maven-plugin → executable JAR packaging
- Read
src/main/resources/application.yml:
- Extract all
${ENV_VAR:default} patterns via regex \$\{([^:}]+)(?::([^}]*))?\}
server.port default → exposed container port
- Read
.env (if exists) → local dev values for reference
If laravel:
- Read
composer.json:
require.php → PHP version for base image
require.laravel/framework → Laravel version
name → image name
- Read
.env.example or scan config/*.php:
- Extract all
env('VAR', 'default') patterns via regex env\('([^']+)'(?:,\s*'?([^')*]*)'?)?\)
APP_PORT or default 8000 → exposed container port
- Check for
vite.config.js or webpack.mix.js → has frontend build step
- Check for
package.json in app root → Node.js needed for frontend build
If nodejs:
- Read
package.json:
engines.node → Node.js version for base image
name → image name
version → image tag
scripts.build → build command (e.g., tsc, tsup, vite build, next build)
scripts.start → start command
- Scan source files or
.env for process.env.VAR patterns
- Check for
tsconfig.json → TypeScript build step
- Determine framework: Express, Fastify, NestJS, Next.js, etc.
Step 3 — Common Detection (All Stacks)
From CLAUDE.md → extract the "Depends on" list for the target application:
| Dependency Pattern |
External Service |
| References MongoDB |
MongoDB required |
| References MySQL / HC Database / SC Database |
MySQL required |
| References PostgreSQL |
PostgreSQL required |
| References Hub Single Sign On / Keycloak |
Keycloak required |
| References RabbitMQ / Message Queue |
RabbitMQ required |
| References Redis / Hub Cache |
Redis required |
| References SMTP / Mailcatcher |
SMTP service required |
| References Meilisearch / Hub Search Engine |
Meilisearch required |
From SPECIFICATION.md → extract:
- Technology stack table (versions)
- Environment variable reference table (if present)
Step 4 — Classify Environment Variables
For each detected environment variable, classify as ConfigMap or Secret:
Secret (sensitive — stored in K8s Secret):
- Variable name contains
PASSWORD, SECRET, KEY, TOKEN, CREDENTIAL
- Variable name contains
ADMIN_USERNAME (admin-level credentials)
- Variable name is a database connection URI containing credentials
ConfigMap (non-sensitive — stored in K8s ConfigMap):
- Everything else: hostnames, ports, log levels, feature flags, queue names, CORS origins
Step 5 — Determine Health Check
| Stack |
Default Health Endpoint |
Condition |
| Spring Boot |
/actuator/health |
If spring-boot-starter-actuator in pom.xml |
| Spring Boot |
/ (HTTP 200/302 check) |
If no actuator |
| Laravel |
/health or / |
Custom route or root |
| Node.js |
/health or / |
Custom route or root |
Check if a health endpoint is explicitly defined in the source code. If not, use the
default for the stack.
Step 6 — Present Detection Summary
Before generating, present findings to the user for confirmation:
Application Stack Detection:
- Stack: Spring Boot 3.5.7 (Java 21)
- Artifact: hub-middleware:1.0.3
- Frontend Build: Yes (Vite via frontend-maven-plugin)
- JTE Precompile: Yes (jte-maven-plugin)
- Exposed Port: 8080
- Health Check: /actuator/health (actuator present)
External Services:
- MongoDB 7.0.6 (Hub Core Database)
- Keycloak 26.5.3 (Hub Single Sign On)
- RabbitMQ 3.11.9 (HC + SC Adapter Message Queues)
- Mailcatcher 0.8.1 (SMTP)
Environment Variables: 25 detected
- ConfigMap: 18 (hostnames, ports, log levels, queue names, flags)
- Secret: 7 (passwords, admin credentials)
If the user disagrees, allow overrides before proceeding.
Phase 2: Generate or Update Dockerfile
- Check if
<app_folder>/Dockerfile already exists
- If it exists (UPDATE mode):
- Read the existing Dockerfile
- Compare detected values against what the Dockerfile currently has:
- Base image version (e.g., Java version changed in pom.xml)
- Exposed port (e.g., server.port default changed)
- Environment variable defaults (e.g., new env vars added)
- Build commands (e.g., frontend build step added or removed)
- Preserve any lines marked with
# CUSTOM: comments — these are manual overrides
by the user/DevOps that should not be replaced
- Update only the parts that changed, keeping the overall structure intact
- Log what was changed (e.g., "Updated Java version from 17 to 21",
"Added MAIL_HOST env var")
- If it does not exist (CREATE mode):
- Select the Dockerfile pattern from
references/dockerfile-<stack>.md
- Substitute detected values (Java version, artifact name, port, etc.)
- Write the Dockerfile to
<app_folder>/Dockerfile
The Dockerfile MUST:
- Use a multi-stage build (build stage + runtime stage)
- Use specific version tags for base images (not
latest)
- Run as a non-root user in the runtime stage
- NOT copy
.env, context/, e2e/, or test files into the image
- Include a
HEALTHCHECK instruction if a health endpoint is available
- Include comments explaining each significant instruction
- Include a
LABEL version="{version}" instruction using the application version extracted
from pom.xml (<version>), composer.json (version), or package.json (version)
- Include a build argument
ARG APP_VERSION={version} that can be overridden at build time
via docker build --build-arg APP_VERSION=1.0.3
Read references/dockerfile-spring-boot.md, references/dockerfile-laravel.md, or
references/dockerfile-nodejs.md for the complete Dockerfile template per stack.
Phase 3: Generate or Update Kubernetes Manifests
Kubernetes manifests are stored directly in <app_folder>/k8s/ (no per-environment
subfolders). Since the k8s/ folder is gitignored, each machine maintains its own
independent copy with values specific to the target environment selected in Phase 0.
3a. Ensure Folder Structure
- Check if
<app_folder>/k8s/ exists. If not, create it.
Example folder structure:
hub_middleware/
Dockerfile
k8s/
namespace.yaml
configmap.yaml
secret.yaml
deployment.yaml
service.yaml
ingress.yaml (optional)
3b. Generate Manifests
Generate individual YAML files inside <app_folder>/k8s/ using values from the target
environment selected in Phase 0:
namespace.yaml — Namespace resource (use project code from CLAUDE.md in lowercase,
e.g., urp). Shared across all applications — identical content for every environment.
configmap.yaml — Non-sensitive environment variables (from Step 4 classification).
Values may differ per environment — use defaults from .env for local development;
use TODO placeholders for other environments where values are not known.
secret.yaml — Sensitive environment variables (from Step 4 classification),
base64-encoded. Values use TODO placeholders for all non-local environments.
deployment.yaml — Container spec with:
- Versioned image tag (e.g.,
image: hub-middleware:1.0.3), NOT latest
envFrom referencing ConfigMap and Secret
- Resource requests/limits (sensible defaults: 256Mi-512Mi memory, 250m-500m CPU)
- Readiness and liveness probes using the detected health endpoint
- Non-root
securityContext
hostAliases (conditional): If the environment's Domain from CLAUDE.md is referenced
in ConfigMap values AND is not localhost, add hostAliases mapping the Domain to
the environment's IP address. This is needed because K8s pod DNS cannot resolve custom
domains defined only in the host machine's /etc/hosts. See references/k8s-patterns.md.
service.yaml — ClusterIP service exposing the application port
ingress.yaml (optional) — if the application is a web application or API with
external access. Only generate if the environment's CLAUDE.md description suggests
external access (e.g., mentions domain, IP, or ingress).
Read references/k8s-patterns.md for the complete manifest templates per resource type.
3c. Environment-Specific Values
When generating manifests for the target environment:
- ConfigMap and Secret values: Read
ENVIRONMENT.md from the project root. If ENVIRONMENT.md
contains environment-specific credentials (organized by environment), use the matching
values for the target environment. If values are not found, use TODO as placeholder.
- Resource limits: Use sensible defaults. If the CLAUDE.md environment description
mentions resource constraints, adjust accordingly.
- Ingress hostnames: Derive from the target environment description in CLAUDE.md if
available (e.g., IP address, domain name). Use
TODO if not specified.
3d. Create or Update Logic
For the <app_folder>/k8s/ folder:
If a manifest file does not exist (CREATE mode):
- Generate the file from the detected values and templates
- Write to
<app_folder>/k8s/<resource>.yaml
If it already exists (UPDATE mode):
- Read the existing manifest
- Compare detected values against what the manifest currently has:
- New or removed environment variables → update configmap.yaml and secret.yaml
- Image version changed → update deployment.yaml image tag
- Port changed → update service.yaml and deployment.yaml container port
- Health endpoint changed → update probes in deployment.yaml
- New dependencies → add init containers or environment variables
- Preserve any lines or resources marked with
# CUSTOM: comments
- Update only the parts that changed
- Log what was changed
3e. Namespace Consistency
All manifests use the same namespace (derived from the project code in CLAUDE.md's
# Project Detail → Project Code in lowercase, e.g., urp).
3f. Docker Build Reference
Include a comment block at the top of deployment.yaml:
# Application: <Application Name>
# Environment: <Target Environment Name>
# Build: docker build -t <image-name>:<version> <app_folder>/
# Tag: docker tag <image-name>:<version> <image-name>:latest
# Apply: kubectl apply -f <app_folder>/k8s/
---
3g. Update .gitignore
The k8s/ folder contains environment-specific manifests with ConfigMap values,
base64-encoded Secrets, hostnames, and credentials that MUST NOT be committed to
version control. After generating or updating the K8s manifests, ensure the
application's .gitignore excludes the k8s/ folder:
- Read
<app_folder>/.gitignore. If it does not exist, create it.
- Check if
k8s/ (or an equivalent pattern like k8s/**) is already listed.
- If not already present, append the following block:
# Kubernetes manifests — environment-specific configs and secrets
k8s/
- If already present, do nothing — do not duplicate the entry.
- Do NOT remove or modify any other entries in
.gitignore.
Constraints
These constraints are non-negotiable:
Custom applications only — This skill only processes applications listed under
# Custom Applications in CLAUDE.md. 3rd party applications and external services are
NOT containerized by this skill.
Stack-agnostic output — The skill must work for Spring Boot, Laravel, and Node.js
applications. All stack-specific logic is gated behind the detection in Phase 1.
Real values from context — Every manifest and Dockerfile must use the actual
application name, port, environment variables, and dependency versions from the project's
context files. No placeholder <TODO> values except for legitimately unknown production
values (registry URL, domain name).
ConfigMap/Secret separation — Sensitive values must NEVER appear in ConfigMaps.
The classification logic in Phase 1 Step 4 must be applied consistently.
Non-root containers — All Dockerfiles must run the application as a non-root user.
Multi-stage builds — All Dockerfiles must use multi-stage builds to minimize the
runtime image size. Build tools (Maven, Composer, npm dev dependencies) must NOT be
in the final image.
No .env in containers — The .env file is for local development only. Container
environments receive configuration via K8s ConfigMap + Secret injection.
Flat K8s manifest folder — Kubernetes manifests live directly in <app_folder>/k8s/
with separate YAML files per resource type (no per-environment subfolders). The k8s/
folder is gitignored — each machine maintains its own copy with values specific to
the target environment. Run the skill once per environment on the target machine.
Idempotent — supports both create and update — If Dockerfile or manifest already
exists, read it first, detect what changed, and update only the affected parts. Preserve
any manual customizations marked with # CUSTOM:. If the file does not exist, create
from scratch. Always log what was created or changed.
Single-pass execution — This skill completes in one pass (Dockerfile + manifest).
No Ralph Loop needed.
Production-safe defaults — Dockerfile and K8s manifests must default to
production-safe values. Dev-specific settings (JTE dev mode, DevTools, debug logging)
must be OFF by default in the container, overridden only via explicit environment
variables.
Versioned image tags — Kubernetes Deployment manifests must reference versioned
image tags (e.g., hub-middleware:1.0.3), never latest.
1---2name: depgen-k8s3description: Generate a Dockerfile and Kubernetes manifests for an application targeting a single environment. Supports Spring Boot (Java), Laravel (PHP), and Node.js application stacks. Auto-detects the stack from project files (pom.xml, composer.json, package.json), reads CLAUDE.md dependencies, SPECIFICATION.md tech stack, and the application's externalized environment variables. Generates a Dockerfile in the application root folder and Kubernetes manifest YAML files directly in `<app_folder>/k8s/` (no per-environment subfolders — the k8s/ folder is gitignored, each machine maintains its own copy). Standardized input: application name (mandatory), environment (optional). Use this skill whenever the user asks to create deployment artifacts, Dockerfiles, Kubernetes manifests, or containerize an application. Also trigger when the user says things like "deploy this app", "containerize this", "create a Dockerfile", "generate k8s manifests", or any request for deployment-related artifacts.4---56# Deployment Artifact Generator — Kubernetes78This skill generates deployment artifacts for a custom application:9101. **Dockerfile** — A production-ready, multi-stage container build file placed in the11 application root folder.122. **Kubernetes manifests** — Manifest files stored directly in the application's own13 `k8s/` folder for a **single target environment**. Since the `k8s/` folder is gitignored,14 each machine maintains its own independent copy of the manifests with environment-specific15 ConfigMap/Secret values (hostnames, credentials, resource limits).1617**Note:** Only custom applications (from `# Custom Applications` in CLAUDE.md) are processed.183rd party supporting applications and external services are NOT containerized by this skill.1920## Inputs2122```23/depgen-k8s <application> [environment]24```2526| Argument | Required | Example | Description |27|----------|----------|---------|-------------|28| `<application>` | Yes | `hub_middleware` | Application name — must be a custom application from CLAUDE.md |29| `<environment>` | No | `home_server` | Target environment name — must match a Kubernetes environment in CLAUDE.md |3031If `<environment>` is omitted:32- If CLAUDE.md defines exactly **one** Kubernetes environment → auto-select it.33- If CLAUDE.md defines **multiple** Kubernetes environments → list them and ask the user to specify.3435The environment name is matched **case-insensitively** against the environment headings in CLAUDE.md, accepting snake_case, kebab-case, or title-case input (e.g., `home_server`, `home-server`, `Home Server`).3637No `version:` or `module:` arguments — deployment is application-level.3839### Input Resolution4041The application name is matched against root-level application folders:421. Strip any leading `<number>_` prefix from folder names (e.g., `1_hub_middleware` → `hub_middleware`)432. Match case-insensitively against the provided application name443. Accept snake_case, kebab-case, or title-case input454. Verify the application is listed under `# Custom Applications` in CLAUDE.md — reject if it is a 3rd party application or external service465. If no match found, list available custom applications and stop4748### Auto-Resolved Paths4950| File | Resolved Path |51|------|---------------|52| CLAUDE.md | Project root `CLAUDE.md` |53| ENVIRONMENT.md | Project root `ENVIRONMENT.md` |54| SPECIFICATION.md | `<app_folder>/context/specification/SPECIFICATION.md` |55| Source code | `<app_folder>/` (pom.xml, composer.json, package.json, etc.) |56| Application config | Stack-dependent (see detection) |57| K8s manifests output | `<app_folder>/k8s/` (gitignored — each machine maintains its own copy) |5859## PRD.md Extended Sections6061Before generating deployment artifacts, check PRD.md for the following extended sections:6263### Architecture Principle6465If PRD.md contains an `# Architecture Principle` section, extract patterns that affect deployment:6667| Pattern | Deployment Impact |68|---|---|69| "Stateless" | Deployment uses `RollingUpdate` strategy without sticky sessions; no PVC needed for session storage |70| "Container based deployment" | Validates this skill's applicability |71| "Scale out" / "horizontally scalable" | Generate HorizontalPodAutoscaler (HPA) manifest targeting CPU 70% |72| Specific resource constraints (e.g., "max 256Mi per pod") | Use as default resource limits in K8s manifests |73| "Message driven" / "message queue" | Readiness probe should verify message queue connectivity |7475If absent, use defaults from SPECIFICATION.md and CLAUDE.md (existing behavior).7677### High Level Process Flow7879If PRD.md contains a `# High Level Process Flow` section:80- Process flows reveal inter-system dependencies (message queues, external service endpoints)81- Validate that the environment variable list and ConfigMap/Secret values include all dependencies mentioned in process flows82- If a flow references an external system not in the `Depends on` list, log a warning8384If absent, derive dependencies from CLAUDE.md only (existing behavior).8586---8788## Pre-Requisites8990Before running this skill, the following must exist:91- **Source code** — The application must be implemented (not just context artifacts)92- **SPECIFICATION.md** — The technical specification must exist (generated by a `specgen-*` skill)93- **Externalized configuration** — The application config must use environment variables94 (e.g., `${ENV_VAR:default}` in Spring Boot, `env('VAR')` in Laravel, `process.env.VAR` in Node.js)9596If any are missing, stop and inform the user.9798## Workflow99100### Phase 0: Validate Inputs1011021. Resolve application folder from the provided name1032. Verify the application is a custom application in CLAUDE.md (not 3rd party or external service)1043. Verify source code exists (at least one of: `pom.xml`, `composer.json`, `package.json`)1054. Verify `<app_folder>/context/specification/SPECIFICATION.md` exists1065. Read `CLAUDE.md` (already in context) for project-level information1076. **Detect environments** from CLAUDE.md's `# Environment` section:108 - Each `## <Environment Name>` heading under `# Environment` is an environment109 - For each environment, extract:110 - Environment name (e.g., "Home Server")111 - `Domain` field (e.g., `localhost`, `home.server`)112 - `Deployment Type` field (e.g., `Manual`, `Kubernetes`)113 - `IP` field (from SSH Configuration or direct IP field) if present — needed for `hostAliases` generation in Phase 3114 - If no environments are defined, stop with error: "No environments found in CLAUDE.md `# Environment` section."1151167. **Select target environment** — filter to Kubernetes environments and select one:117 1. Filter environments to those with `Deployment Type: Kubernetes`.118 2. If no environment has `Deployment Type: Kubernetes`, stop with error: "No Kubernetes environments found in CLAUDE.md. This skill only generates K8s manifests for environments with Deployment Type: Kubernetes."119 3. If the user provided an `<environment>` argument, match it against the Kubernetes environments (case-insensitively, accepting snake_case, kebab-case, or title-case).120 - If matched → use it as the target environment.121 - If not matched → list available Kubernetes environments and stop.122 4. If no argument was provided:123 - If exactly **one** Kubernetes environment exists → auto-select it.124 - If **multiple** exist → list them and ask the user to specify.125 5. Record the selected environment's Domain and IP for Phase 3.126127### Phase 1: Detect Application Stack128129#### Step 1 — Identify Stack130131Check the application root for build files:132133| File Found | Stack | Build Tool |134|---|---|---|135| `pom.xml` | `spring-boot` | Maven |136| `composer.json` | `laravel` | Composer |137| `package.json` (no `pom.xml` or `composer.json`) | `nodejs` | npm / pnpm |138139If none found, stop with error: "Cannot determine application stack."140141If multiple found (e.g., `pom.xml` + `package.json`), prioritize: `pom.xml` > `composer.json` > `package.json`142(the `package.json` is likely for frontend or E2E tests, not the main app).143144#### Step 2 — Extract Stack-Specific Metadata145146**If `spring-boot`:**147- Read `pom.xml`:148 - `<java.version>` → JDK version for base image149 - `<artifactId>` → image name150 - `<version>` → image tag151 - `frontend-maven-plugin` presence → has frontend build step152 - `jte-maven-plugin` presence → has JTE precompilation153 - `spring-boot-maven-plugin` → executable JAR packaging154- Read `src/main/resources/application.yml`:155 - Extract all `${ENV_VAR:default}` patterns via regex `\$\{([^:}]+)(?::([^}]*))?\}`156 - `server.port` default → exposed container port157- Read `.env` (if exists) → local dev values for reference158159**If `laravel`:**160- Read `composer.json`:161 - `require.php` → PHP version for base image162 - `require.laravel/framework` → Laravel version163 - `name` → image name164- Read `.env.example` or scan `config/*.php`:165 - Extract all `env('VAR', 'default')` patterns via regex `env\('([^']+)'(?:,\s*'?([^')*]*)'?)?\)`166 - `APP_PORT` or default `8000` → exposed container port167- Check for `vite.config.js` or `webpack.mix.js` → has frontend build step168- Check for `package.json` in app root → Node.js needed for frontend build169170**If `nodejs`:**171- Read `package.json`:172 - `engines.node` → Node.js version for base image173 - `name` → image name174 - `version` → image tag175 - `scripts.build` → build command (e.g., `tsc`, `tsup`, `vite build`, `next build`)176 - `scripts.start` → start command177- Scan source files or `.env` for `process.env.VAR` patterns178- Check for `tsconfig.json` → TypeScript build step179- Determine framework: Express, Fastify, NestJS, Next.js, etc.180181#### Step 3 — Common Detection (All Stacks)182183From `CLAUDE.md` → extract the "Depends on" list for the target application:184185| Dependency Pattern | External Service |186|---|---|187| References MongoDB | MongoDB required |188| References MySQL / HC Database / SC Database | MySQL required |189| References PostgreSQL | PostgreSQL required |190| References Hub Single Sign On / Keycloak | Keycloak required |191| References RabbitMQ / Message Queue | RabbitMQ required |192| References Redis / Hub Cache | Redis required |193| References SMTP / Mailcatcher | SMTP service required |194| References Meilisearch / Hub Search Engine | Meilisearch required |195196From `SPECIFICATION.md` → extract:197- Technology stack table (versions)198- Environment variable reference table (if present)199200#### Step 4 — Classify Environment Variables201202For each detected environment variable, classify as ConfigMap or Secret:203204**Secret** (sensitive — stored in K8s Secret):205- Variable name contains `PASSWORD`, `SECRET`, `KEY`, `TOKEN`, `CREDENTIAL`206- Variable name contains `ADMIN_USERNAME` (admin-level credentials)207- Variable name is a database connection URI containing credentials208209**ConfigMap** (non-sensitive — stored in K8s ConfigMap):210- Everything else: hostnames, ports, log levels, feature flags, queue names, CORS origins211212#### Step 5 — Determine Health Check213214| Stack | Default Health Endpoint | Condition |215|---|---|---|216| Spring Boot | `/actuator/health` | If `spring-boot-starter-actuator` in pom.xml |217| Spring Boot | `/` (HTTP 200/302 check) | If no actuator |218| Laravel | `/health` or `/` | Custom route or root |219| Node.js | `/health` or `/` | Custom route or root |220221Check if a health endpoint is explicitly defined in the source code. If not, use the222default for the stack.223224#### Step 6 — Present Detection Summary225226Before generating, present findings to the user for confirmation:227228```229Application Stack Detection:230- Stack: Spring Boot 3.5.7 (Java 21)231- Artifact: hub-middleware:1.0.3232- Frontend Build: Yes (Vite via frontend-maven-plugin)233- JTE Precompile: Yes (jte-maven-plugin)234- Exposed Port: 8080235- Health Check: /actuator/health (actuator present)236237External Services:238- MongoDB 7.0.6 (Hub Core Database)239- Keycloak 26.5.3 (Hub Single Sign On)240- RabbitMQ 3.11.9 (HC + SC Adapter Message Queues)241- Mailcatcher 0.8.1 (SMTP)242243Environment Variables: 25 detected244- ConfigMap: 18 (hostnames, ports, log levels, queue names, flags)245- Secret: 7 (passwords, admin credentials)246```247248If the user disagrees, allow overrides before proceeding.249250### Phase 2: Generate or Update Dockerfile2512521. Check if `<app_folder>/Dockerfile` already exists2532. **If it exists** (UPDATE mode):254 - Read the existing Dockerfile255 - Compare detected values against what the Dockerfile currently has:256 - Base image version (e.g., Java version changed in pom.xml)257 - Exposed port (e.g., server.port default changed)258 - Environment variable defaults (e.g., new env vars added)259 - Build commands (e.g., frontend build step added or removed)260 - Preserve any lines marked with `# CUSTOM:` comments — these are manual overrides261 by the user/DevOps that should not be replaced262 - Update only the parts that changed, keeping the overall structure intact263 - Log what was changed (e.g., "Updated Java version from 17 to 21",264 "Added MAIL_HOST env var")2653. **If it does not exist** (CREATE mode):266 - Select the Dockerfile pattern from `references/dockerfile-<stack>.md`267 - Substitute detected values (Java version, artifact name, port, etc.)268 - Write the Dockerfile to `<app_folder>/Dockerfile`269270The Dockerfile MUST:271- Use a **multi-stage build** (build stage + runtime stage)272- Use **specific version tags** for base images (not `latest`)273- Run as a **non-root user** in the runtime stage274- **NOT** copy `.env`, `context/`, `e2e/`, or test files into the image275- Include a `HEALTHCHECK` instruction if a health endpoint is available276- Include comments explaining each significant instruction277- Include a `LABEL version="{version}"` instruction using the application version extracted278 from `pom.xml` (`<version>`), `composer.json` (`version`), or `package.json` (`version`)279- Include a build argument `ARG APP_VERSION={version}` that can be overridden at build time280 via `docker build --build-arg APP_VERSION=1.0.3`281282Read `references/dockerfile-spring-boot.md`, `references/dockerfile-laravel.md`, or283`references/dockerfile-nodejs.md` for the complete Dockerfile template per stack.284285### Phase 3: Generate or Update Kubernetes Manifests286287Kubernetes manifests are stored directly in `<app_folder>/k8s/` (no per-environment288subfolders). Since the `k8s/` folder is gitignored, each machine maintains its own289independent copy with values specific to the target environment selected in Phase 0.290291#### 3a. Ensure Folder Structure2922931. Check if `<app_folder>/k8s/` exists. If not, create it.294295Example folder structure:296```297hub_middleware/298 Dockerfile299 k8s/300 namespace.yaml301 configmap.yaml302 secret.yaml303 deployment.yaml304 service.yaml305 ingress.yaml (optional)306```307308#### 3b. Generate Manifests309310Generate individual YAML files inside `<app_folder>/k8s/` using values from the target311environment selected in Phase 0:3123131. **`namespace.yaml`** — Namespace resource (use project code from CLAUDE.md in lowercase,314 e.g., `urp`). Shared across all applications — identical content for every environment.3152. **`configmap.yaml`** — Non-sensitive environment variables (from Step 4 classification).316 Values may differ per environment — use defaults from `.env` for local development;317 use `TODO` placeholders for other environments where values are not known.3183. **`secret.yaml`** — Sensitive environment variables (from Step 4 classification),319 base64-encoded. Values use `TODO` placeholders for all non-local environments.3204. **`deployment.yaml`** — Container spec with:321 - Versioned image tag (e.g., `image: hub-middleware:1.0.3`), NOT `latest`322 - `envFrom` referencing ConfigMap and Secret323 - Resource requests/limits (sensible defaults: 256Mi-512Mi memory, 250m-500m CPU)324 - Readiness and liveness probes using the detected health endpoint325 - Non-root `securityContext`326 - `hostAliases` (conditional): If the environment's Domain from CLAUDE.md is referenced327 in ConfigMap values AND is not `localhost`, add `hostAliases` mapping the Domain to328 the environment's IP address. This is needed because K8s pod DNS cannot resolve custom329 domains defined only in the host machine's `/etc/hosts`. See `references/k8s-patterns.md`.3305. **`service.yaml`** — ClusterIP service exposing the application port3316. **`ingress.yaml`** (optional) — if the application is a web application or API with332 external access. Only generate if the environment's CLAUDE.md description suggests333 external access (e.g., mentions domain, IP, or ingress).334335Read `references/k8s-patterns.md` for the complete manifest templates per resource type.336337#### 3c. Environment-Specific Values338339When generating manifests for the target environment:340341- **ConfigMap and Secret values**: Read `ENVIRONMENT.md` from the project root. If ENVIRONMENT.md342 contains environment-specific credentials (organized by environment), use the matching343 values for the target environment. If values are not found, use `TODO` as placeholder.344- **Resource limits**: Use sensible defaults. If the CLAUDE.md environment description345 mentions resource constraints, adjust accordingly.346- **Ingress hostnames**: Derive from the target environment description in CLAUDE.md if347 available (e.g., IP address, domain name). Use `TODO` if not specified.348349#### 3d. Create or Update Logic350351For the `<app_folder>/k8s/` folder:3523531. **If a manifest file does not exist** (CREATE mode):354 - Generate the file from the detected values and templates355 - Write to `<app_folder>/k8s/<resource>.yaml`3563572. **If it already exists** (UPDATE mode):358 - Read the existing manifest359 - Compare detected values against what the manifest currently has:360 - New or removed environment variables → update configmap.yaml and secret.yaml361 - Image version changed → update deployment.yaml image tag362 - Port changed → update service.yaml and deployment.yaml container port363 - Health endpoint changed → update probes in deployment.yaml364 - New dependencies → add init containers or environment variables365 - Preserve any lines or resources marked with `# CUSTOM:` comments366 - Update only the parts that changed367 - Log what was changed368369#### 3e. Namespace Consistency370371All manifests use the same namespace (derived from the project code in CLAUDE.md's372`# Project Detail` → Project Code in lowercase, e.g., `urp`).373374#### 3f. Docker Build Reference375376Include a comment block at the top of `deployment.yaml`:377378```yaml379# Application: <Application Name>380# Environment: <Target Environment Name>381# Build: docker build -t <image-name>:<version> <app_folder>/382# Tag: docker tag <image-name>:<version> <image-name>:latest383# Apply: kubectl apply -f <app_folder>/k8s/384---385```386387#### 3g. Update `.gitignore`388389The `k8s/` folder contains environment-specific manifests with ConfigMap values,390base64-encoded Secrets, hostnames, and credentials that MUST NOT be committed to391version control. After generating or updating the K8s manifests, ensure the392application's `.gitignore` excludes the `k8s/` folder:3933941. Read `<app_folder>/.gitignore`. If it does not exist, create it.3952. Check if `k8s/` (or an equivalent pattern like `k8s/**`) is already listed.3963. If **not already present**, append the following block:397398```gitignore399400# Kubernetes manifests — environment-specific configs and secrets401k8s/402```4034044. If already present, do nothing — do not duplicate the entry.4055. Do NOT remove or modify any other entries in `.gitignore`.406407## Constraints408409These constraints are non-negotiable:4104111. **Custom applications only** — This skill only processes applications listed under412 `# Custom Applications` in CLAUDE.md. 3rd party applications and external services are413 NOT containerized by this skill.4144152. **Stack-agnostic output** — The skill must work for Spring Boot, Laravel, and Node.js416 applications. All stack-specific logic is gated behind the detection in Phase 1.4174183. **Real values from context** — Every manifest and Dockerfile must use the actual419 application name, port, environment variables, and dependency versions from the project's420 context files. No placeholder `<TODO>` values except for legitimately unknown production421 values (registry URL, domain name).4224234. **ConfigMap/Secret separation** — Sensitive values must NEVER appear in ConfigMaps.424 The classification logic in Phase 1 Step 4 must be applied consistently.4254265. **Non-root containers** — All Dockerfiles must run the application as a non-root user.4274286. **Multi-stage builds** — All Dockerfiles must use multi-stage builds to minimize the429 runtime image size. Build tools (Maven, Composer, npm dev dependencies) must NOT be430 in the final image.4314327. **No `.env` in containers** — The `.env` file is for local development only. Container433 environments receive configuration via K8s ConfigMap + Secret injection.4344358. **Flat K8s manifest folder** — Kubernetes manifests live directly in `<app_folder>/k8s/`436 with separate YAML files per resource type (no per-environment subfolders). The `k8s/`437 folder is gitignored — each machine maintains its own copy with values specific to438 the target environment. Run the skill once per environment on the target machine.4394409. **Idempotent — supports both create and update** — If Dockerfile or manifest already441 exists, read it first, detect what changed, and update only the affected parts. Preserve442 any manual customizations marked with `# CUSTOM:`. If the file does not exist, create443 from scratch. Always log what was created or changed.44444510. **Single-pass execution** — This skill completes in one pass (Dockerfile + manifest).446 No Ralph Loop needed.44744811. **Production-safe defaults** — Dockerfile and K8s manifests must default to449 production-safe values. Dev-specific settings (JTE dev mode, DevTools, debug logging)450 must be OFF by default in the container, overridden only via explicit environment451 variables.45245312. **Versioned image tags** — Kubernetes Deployment manifests must reference versioned454 image tags (e.g., `hub-middleware:1.0.3`), never `latest`.