gitlab-ci-patterns — Claude Code skill: CI/CD and install
This skill builds GitLab CI/CD pipelines with stages, caching, runners, and deployment patterns. Use it when your project needs automated tests, builds, or releases.
/plugin marketplace add wshobson/agents
/plugin install cicd-automation@claude-code-workflowsWhat gitlab-ci-patterns does
gitlab-ci-patterns lays out GitLab CI/CD pipelines for build, test, and deploy stages. Its examples cover a Node.js build with artifacts and dependency caching, Docker image build and push, coverage reports, manual production gates, and environment tracking. It also shows Kubernetes deployments, Terraform workflows, and generated child pipelines.
The skill includes GitLab templates for SAST, dependency scanning, and container scanning, plus a Trivy image check. Kubernetes deployment requires KUBE_URL, the file variable KUBE_CA_CERT_FILE, and a protected masked KUBE_TOKEN; the examples use kubectl. The Terraform flow uses TF_ROOT and TF_VERSION, while Docker jobs use Docker-in-Docker.
Install it when you are creating or restructuring GitLab CI/CD. Skip it for a project that does not use GitLab, since its patterns target GitLab pipeline configuration.
What it helps with
- build a multi-stage GitLab CI/CD pipeline
- cache dependencies and publish build artifacts
- push Docker images to the GitLab Registry
- separate staging and production Kubernetes deploys
- add Terraform plan/apply and security checks
Example prompts for the agent
- Build a GitLab CI/CD pipeline with build, test, and deploy stages for a Node.js project.
- Configure Docker build and push for `main` and tags.
- Set up staging and production Kubernetes deploys with a manual production apply.
How to install gitlab-ci-patterns
1Plugin marketplace
/plugin marketplace add wshobson/agents/plugin install cicd-automation@claude-code-workflowsThis installs the whole cicd-automation plugin with all its skills
2Skills CLI (Vercel)
npx skills add wshobson/agents --skill gitlab-ci-patterns -a claude-code3Manually: put the files in place
~/.claude/skills/gitlab-ci-patterns/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/gitlab-ci-patterns/
1Skills CLI (Vercel)
npx skills add wshobson/agents --skill gitlab-ci-patterns -a codex2Manually: put the files in place
.agents/skills/gitlab-ci-patterns/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add wshobson/agents --skill gitlab-ci-patterns -a cursor2Manually: put the files in place
.cursor/skills/gitlab-ci-patterns/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install wshobson/agents gitlab-ci-patterns2Manually: put the files in place
.github/skills/gitlab-ci-patterns/SKILL.mdPlatform CLI
gemini skills install https://github.com/wshobson/agents --path plugins/cicd-automation/skills/gitlab-ci-patternsManually: put the files in place
.devin/skills/gitlab-ci-patterns/SKILL.mdThe legacy .windsurf/skills/ path still works
Claude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
From the same set213
The whole set →Similar
Questions about gitlab-ci-patterns
How do I install gitlab-ci-patterns in Claude Code?
Run npx skills add wshobson/agents --skill gitlab-ci-patterns -a claude-code. The skill is placed at ~/.claude/skills/gitlab-ci-patterns/SKILL.md.
What does gitlab-ci-patterns do?
It provides patterns for GitLab CI/CD stages, caching, artifacts, manual deployments, and security checks. The examples also cover Docker, Kubernetes, Terraform, and child pipelines.
What is required for a Kubernetes deployment from GitLab CI?
The setup needs KUBE_URL, a file variable named KUBE_CA_CERT_FILE with the cluster CA certificate, and a protected masked KUBE_TOKEN. The deployment commands use kubectl.
Source text
SKILL.md · MIT
---
name: gitlab-ci-patterns
description: Build GitLab CI/CD pipelines with multi-stage workflows, caching, and distributed runners for scalable automation. Use when implementing GitLab CI/CD, optimizing pipeline performance, or setting up automated testing and deployment.
---
# GitLab CI Patterns
Comprehensive GitLab CI/CD pipeline patterns for automated testing, building, and deployment.
## Purpose
Create efficient GitLab CI pipelines with proper stage organization, caching, and deployment strategies.
## When to Use
- Automate GitLab-based CI/CD
- Implement multi-stage pipelines
- Configure GitLab Runners
- Deploy to Kubernetes from GitLab
- Implement GitOps workflows
## Basic Pipeline Structure
```yaml
stages:
- build
- test
- deploy
variables:
DOCKER_DRIVER: overlay2
DOCKER_TLS_CERTDIR: "/certs"
build:
stage: build
image: node:20
script:
- npm ci
- npm run build
artifacts:
paths:
- dist/
expire_in: 1 hour
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- node_modules/
test:
stage: test
image: node:20
script:
- npm ci
- npm run lint
- npm test
coverage: '/Lines\s*:\s*(\d+\.\d+)%/'
artifacts:
reports:
coverage_report:
coverage_format: cobertura
path: coverage/cobertura-coverage.xml
deploy:
stage: deploy
image: bitnami/kubectl:1.31
script:
- kubectl apply -f k8s/
- kubectl rollout status deployment/my-app
only:
- main
environment:
name: production
url: https://app.example.com
```
## Docker Build and Push
```yaml
build-docker:
stage: build
image: docker:24
services:
- docker:24-dind
before_script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
script:
- docker build -t $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA .
- docker build -t $CI_REGISTRY_IMAGE:latest .
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
- docker push $CI_REGISTRY_IMAGE:latest
only:
- main
- tags
```
## Multi-Environment Deployment
Set `KUBE_CA_CERT_FILE` as a GitLab file variable containing the cluster CA certificate,
and provide `KUBE_TOKEN` through a protected, masked CI variable. The file variable
contains a path that kubectl uses to verify the API server certificate. Protect both
`develop` and `main` so the deployment jobs can read the protected token.
```yaml
.deploy_template: &deploy_template
image: bitnami/kubectl:1.31
before_script:
- kubectl config set-cluster k8s --server="$KUBE_URL" --certificate-authority="$KUBE_CA_CERT_FILE" --embed-certs=true
- kubectl config set-credentials admin --token="$KUBE_TOKEN"
- kubectl config set-context default --cluster=k8s --user=admin
- kubectl config use-context default
deploy:staging:
<<: *deploy_template
stage: deploy
script:
- kubectl apply -f k8s/ -n staging
- kubectl rollout status deployment/my-app -n staging
environment:
name: staging
url: https://staging.example.com
only:
- develop
deploy:production:
<<: *deploy_template
stage: deploy
script:
- kubectl apply -f k8s/ -n production
- kubectl rollout status deployment/my-app -n production
environment:
name: production
url: https://app.example.com
when: manual
only:
- main
```
## Terraform Pipeline
```yaml
stages:
- validate
- plan
- apply
variables:
TF_ROOT: ${CI_PROJECT_DIR}/terraform
TF_VERSION: "1.6.0"
before_script:
- cd ${TF_ROOT}
- terraform --version
validate:
stage: validate
image: hashicorp/terraform:${TF_VERSION}
script:
- terraform init -backend=false
- terraform validate
- terraform fmt -check
plan:
stage: plan
image: hashicorp/terraform:${TF_VERSION}
script:
- terraform init
- terraform plan -out=tfplan
artifacts:
paths:
- ${TF_ROOT}/tfplan
expire_in: 1 day
apply:
stage: apply
image: hashicorp/terraform:${TF_VERSION}
script:
- terraform init
- terraform apply -auto-approve tfplan
dependencies:
- plan
when: manual
only:
- main
```
## Security Scanning
```yaml
include:
- template: Security/SAST.gitlab-ci.yml
- template: Security/Dependency-Scanning.gitlab-ci.yml
- template: Security/Container-Scanning.gitlab-ci.yml
trivy-scan:
stage: test
image: aquasec/trivy:0.58.0
script:
- trivy image --exit-code 1 --severity HIGH,CRITICAL $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
allow_failure: true
```
## Caching Strategies
```yaml
# Cache node_modules
build:
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- node_modules/
policy: pull-push
# Global cache
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- .cache/
- vendor/
# Separate cache per job
job1:
cache:
key: job1-cache
paths:
- build/
job2:
cache:
key: job2-cache
paths:
- dist/
```
## Dynamic Child Pipelines
```yaml
generate-pipeline:
stage: build
script:
- python generate_pipeline.py > child-pipeline.yml
artifacts:
paths:
- child-pipeline.yml
trigger-child:
stage: deploy
trigger:
include:
- artifact: child-pipeline.yml
job: generate-pipeline
strategy: depend
```
## Best Practices
1. **Use specific image tags** (node:20, not node:latest)
2. **Cache dependencies** appropriately
3. **Use artifacts** for build outputs
4. **Implement manual gates** for production
5. **Use environments** for deployment tracking
6. **Enable merge request pipelines**
7. **Use pipeline schedules** for recurring jobs
8. **Implement security scanning**
9. **Use CI/CD variables** for secrets
10. **Monitor pipeline performance**
## Related Skills
- `github-actions-templates` - For GitHub Actions
- `deployment-pipeline-design` - For architecture
- `secrets-management` - For secrets handling
© Seth Hobson · MIT · wshobson/agents