Validates Containerfile COPY commands and Kubernetes manifest paths for consistency. Automatically runs when working with Containerfiles or K8s manifests to ensure source paths exist and destinations match between files.
IMPORTANT: This skill executes automatically when working with Containerfiles or Kubernetes manifests.
This skill is automatically invoked when:
When this skill is invoked, you MUST:
Find all relevant files in the current context:
k8s/, manifests/, deploy/, .kube/, root directoryCOPY and ADD commandsls or test -fExtract Kubernetes manifest file references:
volumeMounts.mountPath in Deployments/StatefulSetsconfigMapKeyRef and secretKeyRefkubectl create configmap --from-file=)Cross-validate consistency:
Generate validation report with findings
find . -name "Containerfile" -o -name "Dockerfile" -o -name "*.containerfile" -o -name "*.dockerfile"
For each Containerfile, extract paths:
grep -E "^(COPY|ADD)" Containerfile
Parse format: COPY <source> <destination>
For each source path found:
ls -la <source-path> # Verify exists
find . -path "*/k8s/*.yaml" -o -path "*/manifests/*.yaml" -o -path "*/deploy/*.yaml" -o -name "*deployment.yaml" -o -name "*statefulset.yaml"
grep -A 5 "volumeMounts:" manifest.yaml
grep "mountPath:" manifest.yaml
Compare:
Present findings in this format:
## Container & K8s Validation Report
### Containerfiles Checked
- path/to/Containerfile
- path/to/Dockerfile
### Kubernetes Manifests Checked
- k8s/deployment.yaml
- k8s/configmap.yaml
### ✓ COPY Commands Validated
- ✓ COPY config/app.yaml /etc/config/app.yaml
- Source exists: config/app.yaml
- Used in: k8s/deployment.yaml (mountPath: /etc/config/app.yaml)
### ⚠ Issues Found
#### Missing Source Files
- ✗ COPY scripts/startup.sh /usr/local/bin/
- Source NOT found: scripts/startup.sh
- Action: Create file or remove COPY command
#### Missing COPY Commands
- ✗ File referenced in K8s but not copied to image
- Manifest: k8s/deployment.yaml
- Mount path: /etc/secrets/db-password
- Action: Add COPY command to Containerfile
#### Path Mismatches
- ✗ Path inconsistency detected
- Containerfile: COPY config/db.yaml /app/config/db.yaml
- K8s manifest: mountPath: /etc/config/db.yaml
- Action: Align paths in both files
### Recommendations
- Fix missing source files before building
- Add missing COPY commands for referenced files
- Ensure path consistency between Containerfile and manifests
- Consider generating files with RUN instead of COPY where appropriate
Scenario: User modifies Containerfile and k8s/deployment.yaml
Step 1: Detect files in context
ls -la Containerfile k8s/deployment.yaml
Step 2: Parse Containerfile
FROM python:3.11
COPY config/app.yaml /etc/config/app.yaml
COPY scripts/entrypoint.sh /usr/local/bin/
Step 3: Validate source paths
ls config/app.yaml # ✓ Exists
ls scripts/entrypoint.sh # ✗ NOT found
Step 4: Parse K8s manifest
volumeMounts:
- name: app-config
mountPath: /etc/config/app.yaml
- name: db-config
mountPath: /etc/config/database.yaml # Not in Containerfile!
Step 5: Generate report showing:
scripts/entrypoint.sh/etc/config/database.yaml used in manifestconfig/app.yaml → /etc/config/app.yamlWhen finding issues, suggest alternatives:
# Instead of: COPY scripts/startup.sh /usr/local/bin/
# Suggest:
RUN echo '#!/bin/bash\nset -euo pipefail\npython app.py' > /usr/local/bin/startup.sh && \
chmod +x /usr/local/bin/startup.sh
# Instead of: COPY config/app.yaml (then creating ConfigMap)
# Suggest: Create ConfigMap directly from local file
kubectl create configmap app-config --from-file=config/app.yaml
This skill enforces the Containerfile and Kubernetes manifest validation guidelines in CLAUDE.md:
If Containerfile is not in standard location:
If K8s manifests use Helm/Kustomize:
helm template or kustomize buildIf using multi-stage builds: