cicd-pipeline-generator
This skill should be used when creating or configuring CI/CD pipeline files for automated testing, building, and deployment. Use this for generating GitHub Actions workflows, GitLab CI configs, CircleCI configs, or other CI/CD platform configurations. Ideal for setting up automated pipelines for Node.js/Next.js applications, including linting, testing, building, and deploying to platforms like Vercel, Netlify, or AWS.
What this skill does
# CI/CD Pipeline Generator
## Overview
Generate production-ready CI/CD pipeline configuration files for various platforms (GitHub Actions, GitLab CI, CircleCI, Jenkins). This skill provides templates and guidance for setting up automated workflows that handle linting, testing, building, and deployment for modern web applications, particularly Node.js/Next.js projects.
## Core Capabilities
### 1. Platform Selection
Choose the appropriate CI/CD platform based on project requirements:
- **GitHub Actions**: Best for GitHub-hosted projects with native integration
- **GitLab CI/CD**: Ideal for GitLab repositories with complex pipeline needs
- **CircleCI**: Optimized for Docker workflows and fast build times
- **Jenkins**: Suitable for self-hosted, highly customizable environments
Refer to `references/platform-comparison.md` for detailed platform comparisons, pros/cons, and use case recommendations.
### 2. Pipeline Configuration Generation
Generate pipeline configs following these principles:
#### Pipeline Stages
Structure pipelines with these standard stages:
1. **Install Dependencies**
- Checkout code from repository
- Setup runtime environment (Node.js version)
- Restore cached dependencies
- Install dependencies with `npm ci`
- Cache dependencies for future runs
2. **Lint**
- Run ESLint for code quality
- Run TypeScript type checking
- Fail fast on linting errors
3. **Test**
- Execute unit tests
- Execute integration tests
- Generate code coverage reports
- Upload coverage to reporting services (Codecov, Coveralls)
4. **Build**
- Create production build
- Verify build succeeds
- Store build artifacts
5. **Deploy**
- Deploy to staging (develop branch)
- Deploy to production (main branch)
- Run post-deployment smoke tests
#### Caching Strategy
Implement effective caching to speed up builds:
```yaml
# Cache node_modules based on package-lock.json
cache:
key: ${{ hashFiles('package-lock.json') }}
paths:
- node_modules/
- .npm/
```
#### Environment Variables
Configure necessary environment variables:
- `NODE_ENV`: Set to `production` for builds
- Platform-specific tokens: Store as secrets
- Build-time variables: Pass to build process
### 3. Template Usage
Use provided templates from `assets/` directory:
**GitHub Actions Template** (`assets/github-actions-nodejs.yml`):
- Multi-job workflow with lint, test, build, deploy
- Matrix builds for multiple Node.js versions (optional)
- Vercel deployment integration
- Artifact uploading
- Code coverage reporting
**GitLab CI Template** (`assets/gitlab-ci-nodejs.yml`):
- Multi-stage pipeline
- Dependency caching
- Manual production deployment
- Automatic staging deployment
- Coverage reporting
To use a template:
1. Copy the appropriate template file
2. Place in the correct location:
- GitHub Actions: `.github/workflows/ci.yml`
- GitLab CI: `.gitlab-ci.yml`
3. Customize deployment targets, environment variables, and branch names
4. Add required secrets to platform settings
### 4. Deployment Configuration
#### Vercel Deployment
For GitHub Actions:
```yaml
- uses: amondnet/vercel-action@v25
with:
vercel-token: ${{ secrets.VERCEL_TOKEN }}
vercel-org-id: ${{ secrets.VERCEL_ORG_ID }}
vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }}
vercel-args: '--prod'
```
**Required Secrets**:
- `VERCEL_TOKEN`: Get from Vercel account settings
- `VERCEL_ORG_ID`: From Vercel project settings
- `VERCEL_PROJECT_ID`: From Vercel project settings
#### Netlify Deployment
```yaml
- run: |
npm install -g netlify-cli
netlify deploy --prod --dir=.next
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
```
#### AWS S3 + CloudFront
```yaml
- uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- run: |
aws s3 sync .next/static s3://${{ secrets.S3_BUCKET }}/static
aws cloudfront create-invalidation --distribution-id ${{ secrets.CF_DIST_ID }} --paths "/*"
```
### 5. Testing Integration
Configure test execution with proper reporting:
**Jest Configuration**:
```yaml
- name: Run tests with coverage
run: npm test -- --coverage --coverageReporters=text --coverageReporters=lcov
- name: Upload coverage
uses: codecov/codecov-action@v4
with:
files: ./coverage/lcov.info
flags: unittests
```
**Fail Fast Strategy**:
```yaml
# Run quick tests first
jobs:
lint: # Fails in ~30 seconds
test: # Fails in ~2 minutes
build: # Fails in ~5 minutes
needs: [lint, test]
deploy:
needs: [build]
```
### 6. Branch-Based Workflows
Implement different behaviors per branch:
**Feature Branches / PRs**:
- Run lint + test only
- No deployment
- Add PR comments with test results
**Develop Branch**:
- Run lint + test + build
- Deploy to staging environment
- Automatic deployment
**Main Branch**:
- Run lint + test + build
- Deploy to production
- Manual approval (optional)
- Create release tags
**Example**:
```yaml
deploy_staging:
if: github.ref == 'refs/heads/develop'
# Deploy to staging
deploy_production:
if: github.ref == 'refs/heads/main'
environment: production # Requires manual approval
# Deploy to production
```
## Workflow Decision Tree
Follow this decision tree to generate the appropriate pipeline:
1. **Which platform?**
- GitHub → Use `assets/github-actions-nodejs.yml`
- GitLab → Use `assets/gitlab-ci-nodejs.yml`
- CircleCI/Jenkins → Adapt GitHub Actions template
- Unsure → Consult `references/platform-comparison.md`
2. **What stages are needed?**
- Always include: Lint, Test, Build
- Optional: Security scanning, E2E tests, performance tests
- Add deployment stage if deploying from CI
3. **Which deployment platform?**
- Vercel → Use Vercel deployment examples
- Netlify → Use Netlify CLI approach
- AWS → Use AWS Actions/CLI
- Custom → Implement custom deployment script
4. **What triggers?**
- On push to main/develop
- On pull request
- On tag creation
- Manual workflow dispatch
5. **What environment variables needed?**
- Platform tokens (Vercel, Netlify, AWS)
- API keys for external services
- Build-time environment variables
- Feature flags
## Best Practices
### Security
- Store all secrets in platform secret management (never in code)
- Use least-privilege tokens (read-only when possible)
- Rotate secrets regularly
- Audit secret access permissions
- Never log secrets (use `***` masking)
### Performance
- Cache dependencies aggressively
- Parallelize independent jobs
- Use matrix builds for multi-version testing
- Fail fast: Run quick checks before slow ones
- Optimize Docker layer caching
### Reliability
- Pin exact Node.js versions (`18.x` not just `18`)
- Commit lockfiles (`package-lock.json`)
- Add retry logic for flaky external services
- Set reasonable timeouts (10-15 minutes max)
- Use `continue-on-error` for non-critical steps
### Maintainability
- Add comments explaining complex logic
- Use reusable workflows/templates
- Keep configs DRY (Don't Repeat Yourself)
- Version control all pipeline changes
- Document required secrets in README
## Common Patterns
### Multi-Environment Deployment
```yaml
deploy_staging:
environment: staging
if: github.ref == 'refs/heads/develop'
deploy_production:
environment: production
if: github.ref == 'refs/heads/main'
needs: [deploy_staging]
```
### Matrix Testing
```yaml
strategy:
matrix:
node-version: [16.x, 18.x, 20.x]
os: [ubuntu-latest, windows-latest]
```
### Conditional Steps
```yaml
- name: Deploy
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
run: npm run deploy
```
### Artifact Management
```yaml
- name: Upload build
uses: actions/upload-artifact@v4
with:
name: build-output
path: .next/
retenRelated in Web Dev
generating-lwc-components
IncludedLightning Web Components with PICKLES methodology and 165-point scoring. Use this skill when the user creates or edits LWC components, builds wire service patterns, or writes Jest tests for LWC. TRIGGER when: user creates/edits LWC components, touches lwc/**/*.js, .html, .css, .js-meta.xml files, or asks about wire service, SLDS, or Jest LWC tests. DO NOT TRIGGER when: Apex classes (use generating-apex), Aura components, or Visualforce.
tanstack-query
IncludedManage server state in React with TanStack Query v5. Set up queries with useQuery, mutations with useMutation, configure QueryClient caching strategies, implement optimistic updates, and handle infinite scroll with useInfiniteQuery. Use when: setting up data fetching in React projects, migrating from v4 to v5, or fixing object syntax required errors, query callbacks removed issues, cacheTime renamed to gcTime, isPending vs isLoading confusion, keepPreviousData removed problems.
document-processor-api
IncludedProcess documents with Nutrient DWS. Use when the user wants to generate PDFs from HTML or URLs, convert Office/images/PDFs, assemble or split packets, OCR scans, extract text/tables/key-value pairs, redact PII, watermark, sign, fill forms, optimize PDFs, or produce compliance outputs like PDF/A or PDF/UA. Triggers include convert to PDF, merge these PDFs, OCR this scan, extract tables, redact PII, sign this PDF, make this PDF/A, or linearize for web delivery.
nutrient-document-processing
IncludedProcess documents with Nutrient DWS. Use when the user wants to generate PDFs from HTML or URLs, convert Office/images/PDFs, assemble or split packets, OCR scans, extract text/tables/key-value pairs, redact PII, watermark, sign, fill forms, optimize PDFs, or produce compliance outputs like PDF/A or PDF/UA. Triggers include convert to PDF, merge these PDFs, OCR this scan, extract tables, redact PII, sign this PDF, make this PDF/A, or linearize for web delivery.
tanstack-query
IncludedManage server state in React with TanStack Query v5. Covers useMutationState, simplified optimistic updates, throwOnError, network mode (offline/PWA), and infiniteQueryOptions. Use when setting up data fetching, fixing v4→v5 migration errors (object syntax, gcTime, isPending, keepPreviousData), or debugging SSR/hydration issues with streaming server components.
accelint-nextjs-best-practices
IncludedNext.js performance optimization and best practices. Use when writing Next.js code (App Router or Pages Router); implementing Server Components, Server Actions, or API routes; optimizing RSC serialization, data fetching, or server-side rendering; reviewing Next.js code for performance issues; fixing authentication in Server Actions; or implementing Suspense boundaries, parallel data fetching, or request deduplication.