agentleFS
dungnotnulldungnotnull/hybrid-harness-chaos-process-prm/skills/s04-pipeline-design/SKILL.md

harness-pipeline-design

Skill19 starsChanged 6 months agoMITView on GitHub

Design, scaffold, and review Harness CI/CD pipelines as production-ready YAML. Use this skill whenever the user mentions building, creating, modifying, or reviewing a Harness pipeline, CI stages, CD deploy stages, approval gates, rollback strategies, triggers, pipeline variables, input sets, or multi-service/multi-environment deployments. Also trigger when the user says "I want to deploy X to Y using Harness" or asks to "add a chaos step", "add a verification step", or "add an approval" to a pipeline.

The file

We split this skill into the rules it gives an agent

6 rules. About 0 are common, 4 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Before generating any pipeline, confirm:

    line 43
  2. Distinctive:

    If any item is unknown, surface a question to the user before generating YAML.

    line 51
  3. Distinctive:

    Run mental schema check:

    line 98
  4. Very specific:

    No hardcoded secrets (use <+secrets.getValue("...")> expressions)

    line 101
  5. Very specific:

    Read references/deploy-strategies.md for full Canary and Blue-Green templates.

    line 302
  6. Distinctive:

    When Harness AI is unavailable: Use static pipeline templates from s09 Template Library and manual YAML construction following Harness …

    line 387

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Harness Pipeline Design

Purpose

Produce complete, schema-valid Harness pipeline YAML that follows enterprise engineering standards: parameterized inputs, environment promotion, integrated verification, and chaos-ready stage structure.


Input Contract

InputSourceRequired
PRD / BA analysis outputs01 (workflow_context.prd)Yes
Service name, artifact source, stack infos01 contextYes
Environment tier list (dev/staging/prod)s01 context or userYes
Deploy strategy preferences02 taste (deployment category)No (defaults to Rolling)
Approval mechanism preferences02 taste (risk_tolerance)No
Observability tool preferences02 taste (observability)No
Harness account/project identifiersUser or CLAUDE.mdYes

Output Contract

OutputDestinationFormat
Pipeline YAML.commandcode/artifacts/pipeline-<service>.yamlYAML
Trigger config YAML.commandcode/artifacts/trigger-<service>.yamlYAML
Pipeline context (for s05, s12, s19)workflow_context.artifactsYAML object
Input set templates per env.commandcode/artifacts/inputset-<env>.yamlYAML

Prerequisites

Before generating any pipeline, confirm:

  • Harness Account ID and Organization / Project identifiers known
  • Target deployment type: Kubernetes / ECS / Lambda / VM / Custom
  • Artifact source: Docker registry / ECR / GCR / Nexus / Artifactory
  • Environment tiers required: dev → staging → preprod → prod
  • Approval mechanism: automatic / manual / JIRA / ServiceNow
  • Observability stack: Prometheus / Datadog / New Relic / AppDynamics

If any item is unknown, surface a question to the user before generating YAML.


Pipeline Anatomy

Pipeline
├── Variables (runtime inputs, expressions)
├── Stages
│   ├── CI Stage (Build + Test + Push)
│   │   ├── Steps: Clone → Build → Unit Test → SAST → Push
│   │   └── Caching: Intelligence cache / S3 cache
│   ├── CD Stage (Deploy)
│   │   ├── Service (artifact + manifests)
│   │   ├── Environment (infrastructure definition)
│   │   ├── Execution
│   │   │   ├── Pre-deployment: secrets sync, DB migration
│   │   │   ├── Deploy step: Rolling / Canary / Blue-Green
│   │   │   ├── Chaos step (optional, see chaos/01-experiment-design)
│   │   │   └── Verify step (CV — see harness/06-cv-verification)
│   │   └── Rollback (auto on failure)
│   └── Approval Stage (between envs)
└── Notification Rules (Slack / email / PagerDuty)

Workflow

Step 1 — Gather Parameters

Collect via conversation or structured input:

service_name:       # e.g., payment-service
artifact_image:     # e.g., gcr.io/myproject/payment-service
environments:       # [dev, staging, prod]
deploy_strategy:    # rolling | canary | blueGreen
k8s_namespace:      # e.g., payments
approval_type:      # none | manual | jira
chaos_enabled:      # true | false
cv_enabled:         # true | false

Step 2 — Scaffold Pipeline YAML

Generate from the canonical template below. Replace <PLACEHOLDER> tokens.

Step 3 — Validate

Run mental schema check:

  • All identifier fields: [a-zA-Z_][a-zA-Z0-9_]* (no hyphens)
  • All name fields: human-readable, spaces allowed
  • No hardcoded secrets (use <+secrets.getValue("...")> expressions)
  • Expression syntax: <+pipeline.variables.X>, <+artifact.image>, <+env.name>

Step 4 — Output

Return complete YAML with inline comments explaining non-obvious fields.


Canonical Pipeline Template

# Generated by: hybrid-harness-chaos-process-prm
pipeline:
  name: <SERVICE_NAME>-pipeline
  identifier: <SERVICE_NAME>_pipeline
  projectIdentifier: <PROJECT_ID>
  orgIdentifier: <ORG_ID>
  description: "CI/CD pipeline for <SERVICE_NAME>"
  tags:
    managed-by: hcprm
    service: <SERVICE_NAME>

  variables:
    - name: imageTag
      type: String
      description: "Docker image tag to deploy"
      required: true
      value: <+input>
    - name: targetEnv
      type: String
      description: "Target environment"
      required: true
      value: <+input>.allowedValues(dev,staging,preprod,prod)

  stages:
    # ─────────────────────────────────────────────
    # Stage 1: CI — Build and Push
    # ─────────────────────────────────────────────
    - stage:
        name: Build
        identifier: Build
        type: CI
        spec:
          cloneCodebase: true
          caching:
            enabled: true
            paths:
              - node_modules
              - .gradle/caches
          execution:
            steps:
              - step:
                  name: Run Unit Tests
                  identifier: run_unit_tests
                  type: Run
                  spec:
                    connectorRef: account.dockerhub
                    image: node:20-alpine
                    command: |
                      npm ci
                      npm test -- --coverage
                    reports:
                      type: JUnit
                      spec:
                        paths:
                          - "**/junit.xml"
              - step:
                  name: Build and Push Image
                  identifier: build_push_image
                  type: BuildAndPushDockerRegistry
                  spec:
                    connectorRef: account.dockerhub
                    repo: <DOCKER_REPO>/<SERVICE_NAME>
                    tags:
                      - <+pipeline.variables.imageTag>
                      - latest

    # ─────────────────────────────────────────────
    # Stage 2: Deploy to Environment
    # ─────────────────────────────────────────────
    - stage:
        name: Deploy <ENV_NAME>
        identifier: Deploy_<ENV_IDENTIFIER>
        type: Deployment
        spec:
          deploymentType: Kubernetes
          service:
            serviceRef: <SERVICE_NAME>_svc
            serviceInputs:
              serviceDefinition:
                type: Kubernetes
                spec:
                  artifacts:
                    primary:
                      primaryArtifactRef: primary
                      sources:
                        - identifier: primary
                          spec:
                            tag: <+pipeline.variables.imageTag>
          environment:
            environmentRef: <ENV_IDENTIFIER>
            deployToAll: false
            infrastructureDefinitions:
              - identifier: <INFRA_IDENTIFIER>
          execution:
            steps:
              - stepGroup:
                  name: Pre-Deployment
                  identifier: pre_deployment
                  steps:
                    - step:
                        name: Sync Secrets
                        identifier: sync_secrets
                        type: ShellScript
                        spec:
                          shell: Bash
                          source:
                            type: Inline
                            spec:
                              script: |
                                echo "Syncing secrets for <+env.name>"
                                # Add secret sync logic here
                          onDelegate: true
              - step:
                  name: Rolling Deploy
                  identifier: rolling_deploy
                  type: K8sRollingDeploy
                  spec:
                    skipDryRun: false
                    pruningEnabled: true
              # ── Chaos Step (inject after deploy, before verify) ──
              # See chaos/01-experiment-design for full config
              # - step:
              #     name: Chaos Experiment
              #     identifier: chaos_experiment
              #     type: Chaos
              #     spec:
              #       experimentRef: <EXPERIMENT_ID>
              #       expectedResilienceScore: 80
              #
              # ── Continuous Verification ──
              # See harness/06-cv-verification for full config
              # - step:
              #     name: Verify Deployment
              #     identifier: verify_deployment
              #     type: Verify
              #     spec:
              #       isMultiServicesOrEnvs: false
              #       type: Canary
              #       monitoredServiceRef: <MONITORED_SERVICE>
              #       healthSources: []
              #       duration: 10m
            rollbackSteps:
              - step:
                  name: Rollback Deployment
                  identifier: rollback_deployment
                  type: K8sRollingRollback
                  spec: {}

    # ─────────────────────────────────────────────
    # Stage 3: Approval Gate (between envs)
    # ─────────────────────────────────────────────
    - stage:
        name: Approve Production
        identifier: Approve_Production
        type: Approval
        spec:
          execution:
            steps:
              - step:
                  name: Production Approval
                  identifier: production_approval
                  type: HarnessApproval
                  spec:
                    approvalMessage: |
                      Approve deployment of <+artifacts.primary.image>
                      to production environment?
                    includePipelineExecutionHistory: true
                    approvers:
                      minimumCount: 2
                      disallowPipelineExecutor: true
                      userGroups:
                        - account.SRE_Team
                        - account.Engineering_Leads
                    approverInputs:
                      - name: releaseNotes
                        defaultValue: ""
                    autoApproval:
                      action: REJECT
                      scheduledDeadline:
                        timeZone: UTC
                        time: "23:59"
        when:
          pipelineStatus: Success
          condition: <+pipeline.variables.targetEnv> == "prod"

Deploy Strategy Variants

Read references/deploy-strategies.md for full Canary and Blue-Green templates.

Quick reference:

StrategyUse WhenRollback Speed
RollingLow risk, stateless servicesMedium (re-deploy old)
CanaryNeed traffic split validationFast (route 0% to canary)
BlueGreenZero-downtime, instant cutoverInstant (swap service selector)

Trigger Configuration

# Webhook trigger for main branch push
trigger:
  name: On Main Push
  identifier: on_main_push
  type: Webhook
  spec:
    type: Github
    spec:
      type: Push
      spec:
        connectorRef: account.github_connector
        repoName: <ORG>/<REPO>
        autoAbortPreviousExecutions: true
        payloadConditions:
          - key: targetBranch
            operator: Equals
            value: main
      headerConditions: []
  inputYaml: |
    pipeline:
      identifier: <SERVICE_NAME>_pipeline
      variables:
        - name: imageTag
          value: <+trigger.commitSha>

Expression Cheat Sheet

ExpressionResolves To
<+artifact.image>Full image URI
<+artifact.tag>Image tag
<+env.name>Environment name
<+env.type>PreProduction / Production
<+infra.namespace>Kubernetes namespace
<+pipeline.executionId>Current execution UUID
<+trigger.commitSha>Git commit SHA (webhook)
<+secrets.getValue("mySecret")>Secret value (never logs)
<+stage.output.outputVariables.X>Cross-stage output

AI Agent Integration

Autonomy Level

AspectLevelDescription
CurrentL2AI generates pipeline YAML from natural language
TargetL3AI generates and validates pipelines, human reviews

Harness AI Agent

Agent: Harness AI DevOps Agent (Claude Opus 4.5 via Vertex AI) Capabilities:

  • Natural language pipeline YAML generation across all modules
  • Error Analyzer (change impact + dependency checks + historical patterns + RCA + fix recommendations)
  • Pipeline Summarizer
  • Multi-stage pipeline creation validated with 50-stage pipelines

Human Gates

  • Pipeline approval before first deployment
  • Security-sensitive stage configuration
  • Production environment pipeline changes

Fallback

When Harness AI is unavailable: Use static pipeline templates from s09 Template Library and manual YAML construction following Harness schema documentation.


Success Criteria

  • Pipeline YAML passes harness pipeline lint (or manual schema review)
  • No hardcoded credentials
  • All stages have rollback steps
  • At minimum one health check or CV step before marking success
  • Trigger configured and tested

Common Pitfalls

  • Identifier contains hyphen → Harness will reject; use underscore
  • Missing when conditions → stages run unconditionally, including approval in dev
  • Hardcoded image tags → use <+pipeline.variables.imageTag> instead
  • No pruningEnabled → stale Kubernetes resources accumulate over time

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.