Generate a GitHub Actions (or other CI) pipeline from the repo's real scripts, with least-privilege permissions, caching, concurrency and a gated deploy.
---
name: ci-pipeline-generator
description: Writes a CI/CD pipeline configuration (GitHub Actions first; GitLab CI, CircleCI, Jenkins or Azure Pipelines on request) that matches the repository's real build, test and deploy commands, with least-privilege permissions, caching, concurrency and a gated deploy job. Use when asked to add, fix or modernise a CI workflow, pipeline YAML, or automated deployment.
compatibility: Reads the repository to find build commands. Validation is best with actionlint (GitHub Actions) or the platform's own linter; pushing and running the pipeline is left to the user.
metadata:
version: "1.4.0"
---
# CI/CD Pipeline Generator
Generate a pipeline from what the repository actually does. Every `run:` line must be a command that exists in this repo (a package.json script, Makefile target or checked-in script).
## When not to use
- The user wants the pipeline executed or a deployment triggered. This skill writes and validates files only.
- Required secrets, environments or cloud credentials are unknown and the user will not name them. Leave clearly marked placeholders instead of guessing provider setup.
## Inputs to collect
- Platform (default GitHub Actions) and the branches/events that should trigger it.
- Runtime and version source (`.nvmrc`, `.node-version`, `engines`, `.python-version`, `go.mod`).
- Commands: install (`npm ci` when a lockfile exists), lint, test, build, and the build output path.
- Deploy target, the script or action that deploys, required secret names, and whether a protected environment with approvals exists.
## Workflow
1. Read the manifest and lockfile; list the scripts that exist. If `lint` or `test` is missing, omit that step and say so rather than inventing it.
2. Draft jobs: `test` → `build` → `deploy`. Each job runs on a fresh runner, so every job that needs repository files must check out the code, and every job that runs Node must set it up.
3. Security defaults:
- Top-level `permissions: contents: read`; grant more only to the job that needs it (for example `id-token: write` for OIDC cloud login).
- Read secrets only in the deploy job via `${{ secrets.NAME }}`; never echo them.
- Do not run deploys on `pull_request` events; gate with `if: github.event_name == 'push' && github.ref == 'refs/heads/main'` and an `environment:` so required reviewers apply.
- Pin actions to a full commit SHA for third-party actions, or at least to the current major tag of first-party `actions/*`. Look up current majors on each action's releases page instead of copying old examples.
4. Reliability: `concurrency` to cancel superseded PR runs while never cancelling an in-progress deploy; `timeout-minutes`; dependency caching via the setup action.
5. Artifacts: upload the build output with an explicit `name`, and download it with the same `name` and a `path`. Without `name`, download-artifact fetches every artifact into a directory named after each artifact, so paths like `dist/` will not exist.
6. Validate: parse the YAML, and run `actionlint .github/workflows/ci.yml` if available. Report anything you could not validate (secrets, environment protection, the deploy script itself).
7. Hand off: list required secrets/environments to create in repository settings and what to watch on the first run.
## Output format
1. The workflow file with its path (`.github/workflows/ci.yml`).
2. A short table: job → trigger → commands → secrets used.
3. Setup the user must do (secrets, environment protection rules), and validation results.
## Example (GitHub Actions, Node project with .nvmrc, build output in dist/, deploy via scripts/deploy.sh)
```yaml
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version-file: .nvmrc
cache: npm
- run: npm ci
- run: npm run lint
- run: npm test
build:
needs: test
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version-file: .nvmrc
cache: npm
- run: npm ci
- run: npm run build
- uses: actions/upload-artifact@v7
with:
name: dist
path: dist/
retention-days: 7
deploy:
needs: build
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
environment: production
concurrency:
group: deploy-production
cancel-in-progress: false
steps:
- uses: actions/checkout@v7
- uses: actions/download-artifact@v8
with:
name: dist
path: dist/
- name: Deploy
run: ./scripts/deploy.sh dist/
env:
DEPLOY_TOKEN: ${{ secrets.DEPLOY_TOKEN }}
```
Action majors shown were current on 2026-11-05 (checkout v7, setup-node v7, upload-artifact v7, download-artifact v8); confirm before use.
## Limitations
- actionlint checks syntax and expressions, not whether your deploy script works or secrets exist.
- Other platforms use different syntax for the same ideas (GitLab `rules:`/`needs:`/`environment:`); translate the structure, then validate with that platform's linter (for example GitLab's CI Lint).
Generate a compose.yaml for your app, database and cache with health-checked startup, named volumes and secrets in .env, validated with docker compose config.
Automate notifications and alerts
Automate report generation
Illustrative input and expected result. This example is a verification guide, not a recorded model run.
Content reviewed .
A Node app with .nvmrc, package-lock.json, npm scripts lint/test/build (output in dist/) and a checked-in scripts/deploy.sh needs CI that deploys only from main.
Add GitHub Actions CI for this repo: lint and test on every PR to main, build on main, then deploy dist/ with scripts/deploy.sh using the DEPLOY_TOKEN secret. Deploys must need approval.
A single .github/workflows/ci.yml with jobs test → build → deploy. Top-level `permissions: contents: read`; concurrency that cancels superseded PR runs but never an in-progress deploy; setup-node reading .nvmrc with npm cache; `npm ci`. The build uploads an artifact named dist. The deploy job runs only on push to main under `environment: production`, checks out the repo (so scripts/deploy.sh exists), downloads the artifact with `name: dist` and `path: dist/`, and reads DEPLOY_TOKEN only in that step. Includes a job/secret table, a note to create the production environment with required reviewers, and the actionlint result.
AI Agent Skills are reusable workflow packages that extend your AI coding assistant with multi-step capabilities. Install ci-pipeline-generator by following these steps.
SKILL.md inside, in the location documented by your client. Do not assume every AI application reads the same directory.Requires an Agent Skills-compatible client; supported locations and activation vary by version. Read the SKILL.md setup guide. MCP connects tools and data and does not, by itself, install a skill.