Inferensys

Prompt

Tekton Task and Pipeline YAML Prompt Template

A practical prompt playbook for generating valid, indentation-correct Tekton Task and Pipeline YAML with correct step sequencing, workspace bindings, parameter declarations, and result passing between tasks.
Developer doing prompt engineering on laptop, prompt variations visible on screen, casual coding session.
PROMPT PLAYBOOK

When to Use This Prompt

Understand the ideal user, required context, and boundaries for generating Tekton YAML with AI assistance.

This prompt is for CI/CD platform engineers who need to generate Tekton Task and Pipeline YAML from natural language descriptions or partial specifications. The ideal user understands Tekton's core concepts—Tasks, Pipelines, Workspaces, Parameters, and Results—but wants to accelerate manifest authoring by describing the desired behavior in plain language and receiving valid, parseable YAML in return. The prompt is designed for teams building on Tekton who want AI assistance that produces manifests ready for tkn CLI or kubectl apply without manual indentation fixes or schema corrections. You should have a clear description of the pipeline steps, inputs, outputs, and workspace requirements before invoking this prompt; vague requests like 'create a CI pipeline' will produce underspecified YAML that requires significant rework.

Use this prompt when you need valid YAML that enforces correct step ordering, workspace bindings, parameter declarations, and result passing between tasks. It is particularly effective for scaffolding new pipelines from scratch, converting existing shell-script-based CI logic into Tekton-native steps, or generating task definitions that must pass through a Tekton controller without schema rejection. The prompt includes implicit checks for common failure modes: missing image pull secrets, volume mount errors, incorrect result type declarations, and workspace binding mismatches between Pipeline and TaskRef definitions. For best results, provide the target Tekton API version (e.g., tekton.dev/v1beta1 or tekton.dev/v1), the container images for each step, and any parameter or workspace names you want to standardize across tasks.

Do not use this prompt for generating non-Tekton CI/CD configurations such as GitHub Actions workflows, GitLab CI pipelines, or Jenkinsfiles. Do not use it when the target cluster runs a Tekton version with breaking API changes not reflected in the prompt's constraints—always verify the generated YAML against your cluster's installed Tekton version with tkn version and a dry-run apply. Avoid this prompt for pipelines that require dynamic runtime resolution beyond Tekton's parameter and result system, such as conditional DAG branching based on external service state or multi-cluster fan-out that Tekton's controller cannot natively orchestrate. If your pipeline requires custom task resolution from remote catalogs, OCI bundles, or step-action injection, supplement the generated output with manual review of the resolver configuration. When in doubt, generate the scaffold with this prompt and then apply your organization's specific security context, service account bindings, and resource quota annotations as a post-generation step.

PRACTICAL GUARDRAILS

Use Case Fit

Where this Tekton YAML prompt template works well and where it introduces unacceptable risk. Use these cards to decide if the prompt fits your pipeline before you integrate it.

01

Good Fit: Scaffolding Standard CI Steps

Use when: You need to generate a Tekton Task or Pipeline from a known pattern (e.g., 'build-push-deploy'). The prompt excels at producing correct step sequencing, parameter declarations, and workspace bindings for common workflows. Guardrail: Always provide a concrete [PIPELINE_SPEC] with explicit step names, images, and commands. Vague descriptions produce vague YAML.

02

Bad Fit: Security-Sensitive Production Pipelines

Avoid when: The generated YAML will deploy directly to a production cluster without human review. The model can hallucinate image tags, omit imagePullSecrets, or misconfigure volume mounts. Guardrail: Generated YAML must pass a manual diff review and kubectl --dry-run=server validation before merging. Never auto-apply AI-generated Tekton resources.

03

Required Input: Explicit Workspace and Secret Bindings

Risk: The model will invent workspace names or skip service account bindings if not explicitly instructed, causing runtime failures. Guardrail: Your [INPUT] must specify required workspaces, service account names, and any image pull secrets. The prompt template should include a [SECRET_REFS] placeholder that forces the user to declare these before generation.

04

Operational Risk: Result Passing Between Tasks

Risk: Tekton uses task results to pass data between tasks. The model may reference results that don't exist, use incorrect result names, or skip the $(tasks.<name>.results.<result>) syntax entirely. Guardrail: Validate generated pipelines with tkn pipeline describe or a schema linter. Add a post-generation check that every result reference matches a declared result in the producing task.

05

Operational Risk: Indentation and YAML Syntax Errors

Risk: YAML indentation errors are the most common failure mode. A single misplaced space in a multi-step pipeline breaks parsing. Guardrail: Pipe all generated output through yamllint or kubeconform before committing. The prompt should include a [CONSTRAINTS] section that explicitly demands 2-space indentation and no tabs.

06

Bad Fit: Dynamic Runtime Logic

Avoid when: Your pipeline requires complex conditional execution (e.g., 'run this step only if the previous task failed and the branch is main'). Tekton's when expressions and finally blocks are easy to misconfigure. Guardrail: For complex control flow, generate a skeleton pipeline and hand-write the conditional logic. Use the prompt only for structural scaffolding, not business logic.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A copy-ready prompt template for generating valid Tekton Task or Pipeline YAML manifests with strict structural constraints.

The prompt template below is designed to produce a syntactically valid Tekton YAML manifest for either a Task or a Pipeline resource. It forces the model to respect the Tekton API structure by requiring explicit fields for parameters, workspaces, steps (or tasks), and results. Use this template as the foundation for your generation workflow, replacing the square-bracket placeholders with concrete values from your CI/CD specification before sending it to the model.

text
Generate a Tekton [RESOURCE_TYPE] YAML manifest that conforms to the [API_VERSION] API. The output must be valid YAML with correct indentation, no trailing whitespace, and no markdown fences unless explicitly requested.

Resource requirements:
- Name: [RESOURCE_NAME]
- Description: [RESOURCE_DESCRIPTION]
- Labels: [LABELS]
- Annotations: [ANNOTATIONS]

Parameters:
[PARAMETERS]

Workspaces:
[WORKSPACES]

Steps (for Task) or Tasks (for Pipeline):
[STEPS_OR_TASKS]

Results to expose:
[RESULTS]

Additional constraints:
- Include imagePullSecrets if [IMAGE_PULL_SECRET] is specified
- Set serviceAccountName to [SERVICE_ACCOUNT_NAME]
- Add nodeSelector and tolerations if [NODE_CONSTRAINTS] are provided
- Ensure all step `image` fields are explicit and version-pinned
- Use `#!/usr/bin/env sh` shebang for script blocks unless [SCRIPT_SHELL] overrides
- For Pipeline definitions, enforce `runAfter` ordering where [TASK_ORDER] is specified
- Validate that all `workspace` bindings in Pipeline tasks reference declared Pipeline workspaces

Output only the YAML manifest.

To adapt this template, replace each placeholder with structured data from your pipeline specification system. For [PARAMETERS] and [WORKSPACES], provide YAML-formatted lists with name, description, and optional default fields. For [STEPS_OR_TASKS], supply the full step or task definitions including name, image, and script or args. The [LABELS] and [ANNOTATIONS] placeholders expect YAML map syntax. When wiring this into an application, pre-validate that all required placeholders are populated before sending the prompt to the model. After receiving the output, run it through kubectl --dry-run=client or a Tekton-specific linter to catch indentation errors, missing workspace bindings, or invalid API version references before applying it to a cluster.

IMPLEMENTATION TABLE

Prompt Variables

Required and optional inputs for the Tekton Task and Pipeline YAML prompt template. Each placeholder must be resolved before the prompt is sent to the model. Validation notes describe how to check that the supplied value is fit for purpose.

PlaceholderPurposeExampleValidation Notes

[PIPELINE_DESCRIPTION]

Natural language description of the CI/CD workflow to generate

Build a Go app, run unit tests, build a Docker image, push to ECR, and deploy to a staging Kubernetes namespace

Must be non-empty and contain at least one action verb. Check length > 20 characters. Ambiguous descriptions cause hallucinated step names.

[OUTPUT_TYPE]

Specifies whether to generate a Task, Pipeline, or both

Pipeline

Must be one of: Task, Pipeline, both. Enum check before prompt assembly. Wrong value produces incorrect YAML kind field.

[NAMESPACE]

Target Kubernetes namespace for the generated resources

tekton-pipelines

Must match RFC 1123 DNS label rules: lowercase alphanumeric and hyphens, max 63 chars. Invalid namespace causes apply failure.

[IMAGE_REGISTRY]

Container registry base URL for image references in steps

123456789012.dkr.ecr.us-east-1.amazonaws.com

Must be a valid registry hostname. Check for protocol prefix (should be absent). Missing registry causes image pull failures at runtime.

[SERVICE_ACCOUNT]

ServiceAccount name for PipelineRun or TaskRun execution

tekton-builder

Must exist in target namespace or be creatable. Validate against kubectl get sa output. Missing SA causes permission denied errors.

[WORKSPACE_STORAGE_CLASS]

StorageClass for workspace PVCs when using volumeClaimTemplate

gp3

Must be a valid StorageClass in the cluster. Check with kubectl get sc. Invalid class causes PVC binding failure.

[SECRET_NAME]

Name of existing Kubernetes Secret for image pull or git credentials

ecr-registry-credentials

Must exist in target namespace. Validate with kubectl get secret. Missing secret causes ImagePullBackOff or git clone failure.

[TIMEOUT_MINUTES]

PipelineRun timeout in minutes before automatic cancellation

60

Must be a positive integer. Check type and range (1-1440). Missing timeout allows indefinite hung pipelines.

PROMPT PLAYBOOK

Implementation Harness Notes

Wire the Tekton YAML prompt into a CI/CD scaffolding tool with validation, retries, logging, and human approval gates.

Integrate this prompt into your internal developer platform or CI/CD scaffolding service where users request new Tekton Tasks or Pipelines. The application layer should collect user intent through a form, API payload, or existing pipeline specification, then populate the prompt's placeholders—[TASK_DESCRIPTION], [PIPELINE_DESCRIPTION], [PARAMETERS], [WORKSPACES], [STEPS], and [CONSTRAINTS]—before calling the LLM. Treat the LLM as an unreliable YAML generator: its output is a draft, not a deployable artifact. The harness is responsible for extracting, validating, and persisting only correct manifests.

After receiving the model response, strip any markdown code fences (yaml ... ) to isolate the raw YAML. Run immediate structural validation using kubectl apply --dry-run=client -f generated.yaml or an equivalent Tekton-aware schema validator. If validation fails, capture the exact error message and feed it back to the model in a retry prompt that includes the original request, the invalid YAML, and the parse error. Limit retries to a maximum of three attempts. Log every generation attempt—including input variables, output YAML, validation result, and retry count—to an append-only audit store for debugging and compliance. For production deployments, enforce a mandatory human approval step on any Pipeline or Task that references securityContext, volumeMounts with host paths, or secrets. Store approved manifests in a Git repository with a commit message that references the generation request ID and the approving user.

Choose a model with strong YAML generation capabilities and low indentation error rates. If your platform supports it, use structured output modes (e.g., OpenAI's JSON mode with a YAML-as-JSON intermediate representation) to reduce syntax errors before converting to YAML. For high-risk environments, pair this prompt with a post-generation policy check that scans for missing imagePullSecrets, overly permissive securityContext settings, or workspace bindings that reference non-existent PersistentVolumeClaims. Do not apply generated manifests directly to a cluster without the dry-run and approval gates described above.

IMPLEMENTATION TABLE

Expected Output Contract

Fields, format, and validation rules for the generated Tekton Task or Pipeline YAML. Use this contract to build automated validation before the YAML is applied to a cluster.

Field or ElementType or FormatRequiredValidation Rule

apiVersion

string (e.g., tekton.dev/v1beta1)

Must match a supported Tekton API version. Reject unknown or deprecated versions.

kind

string (Task or Pipeline)

Must be exactly 'Task' or 'Pipeline'. Case-sensitive enum check.

metadata.name

string (RFC 1123 subdomain)

Must be a valid Kubernetes resource name: lowercase alphanumeric, hyphens, max 253 chars. Reject on pattern mismatch.

spec.params

array of {name, type, description, default}

If present, each param must have a non-empty name and a type of 'string' or 'array'. Default must match the declared type. Reject on type mismatch.

spec.steps[].image

string (container image reference)

Must be a non-empty string matching container image reference pattern. Reject empty or missing image fields. Warn if ':latest' tag is used.

spec.steps[].script or spec.steps[].command

string or array of strings

At least one of 'script' or 'command' must be present and non-empty per step. Reject steps with neither.

spec.workspaces

array of {name, description, optional, mountPath}

If present, each workspace must have a non-empty name. If mountPath is specified, it must be an absolute path. Reject relative paths.

spec.tasks[].taskRef.name or spec.tasks[].taskSpec

string or object

true (for Pipeline)

Each pipeline task must reference a Task by name or inline a TaskSpec. Reject tasks with neither. Reject tasks with both if they conflict.

PRACTICAL GUARDRAILS

Common Failure Modes

Tekton YAML generation fails in predictable ways—indentation errors, missing workspace bindings, and incorrect result passing. These cards cover the most common breakages and how to guard against them before the pipeline runs.

01

Indentation and YAML Syntax Errors

What to watch: The model produces YAML with inconsistent indentation, mixing tabs and spaces, or misaligning nested sequences under steps, params, or workspaces. Tekton controllers reject these manifests before execution. Guardrail: Pipe the generated YAML through yamllint or kubectl --dry-run=client -f - in your validation harness. Add a strict indentation rule in the prompt: 'Use exactly 2-space indentation throughout. No tabs.'

02

Missing Workspace Bindings in PipelineRuns

What to watch: The model generates a Pipeline with declared workspaces but omits the corresponding workspaces bindings in the PipelineRun, or references a workspace name that doesn't match the Pipeline declaration. The PipelineRun fails with a binding error. Guardrail: Add a post-generation check that iterates over spec.workspaces in the Pipeline and confirms each has a matching entry in the PipelineRun's spec.workspaces array. Prompt explicitly: 'For every workspace declared in the Pipeline, include a binding in the PipelineRun.'

03

Incorrect Result Passing Between Tasks

What to watch: The model references a task result like $(tasks.build.results.IMAGE_DIGEST) but the producing task doesn't declare that result in its spec.results, or the result name casing doesn't match. The pipeline fails at runtime with an unresolved variable error. Guardrail: Validate that every $(tasks.<name>.results.<result>) reference has a corresponding results entry in the referenced Task definition. Enforce exact case matching in the prompt: 'Result names are case-sensitive. Match the Task's results declaration exactly.'

04

Missing Image Pull Secrets

What to watch: The model generates steps that reference private container images but omits imagePullSecrets from the service account or PipelineRun, causing ImagePullBackOff errors. This is especially common when the prompt mentions a private registry but doesn't explicitly request secret configuration. Guardrail: Add a prompt constraint: 'If any step references an image from a registry other than Docker Hub or a public registry, include an imagePullSecrets reference in the PipelineRun service account or pod template.' Validate with a check that flags non-hub image references without corresponding secret configuration.

05

Volume Mount Path Collisions

What to watch: The model assigns the same mountPath to multiple volume mounts within a single step, or places a mount at a path that conflicts with the step's working directory or system paths. The step fails with mount errors or silently overwrites files. Guardrail: Add a uniqueness check across all volumeMounts within each step for duplicate mountPath values. Prompt: 'Ensure each volumeMount in a step uses a unique mountPath. Do not mount to /, /etc, /var/run, or the step's working directory.'

06

Parameter Type Mismatches in TaskRefs

What to watch: The model passes a string value to a Task parameter declared as type: array, or passes an array to a type: string parameter. Tekton validates parameter types and rejects the PipelineRun. Guardrail: Cross-reference every params value in the PipelineRun against the corresponding spec.params type declaration in the referenced Task. Prompt: 'Match parameter types exactly. If a Task declares a parameter as type: array, pass a YAML list. If type: string, pass a scalar value.'

IMPLEMENTATION TABLE

Evaluation Rubric

Test criteria for Tekton YAML outputs before integrating into a pipeline controller. Run these checks in CI or a pre-commit hook.

CriterionPass StandardFailure SignalTest Method

YAML Parse Validity

Output parses without errors using a strict YAML 1.2 parser

Parser throws a syntax error, indentation mismatch, or invalid mapping key

Run yq eval or Python ruamel.yaml safe_load; reject on any parse exception

apiVersion and kind Presence

Top-level apiVersion and kind fields are present and match Tekton CRD values (e.g., tekton.dev/v1)

Missing apiVersion or kind; value is a non-Tekton API group

JSON Schema validation against Tekton CRD schemas; check exact string match for known kinds (Task, Pipeline, TaskRun, PipelineRun)

Step Image References

Every steps[].image field contains a valid image reference with tag or digest

Empty image field, latest tag without explicit intent, or image name without registry prefix

Regex check for ^[a-zA-Z0-9._/-]+(:[a-zA-Z0-9._-]+|@sha256:[a-f0-9]{64})$; flag latest for human review

Workspace Bindings Completeness

Every workspaces declaration in a PipelineRun has a corresponding binding (persistentVolumeClaim, configMap, or emptyDir)

PipelineRun references a workspace name not declared in the Pipeline; binding type is missing or invalid

Parse Pipeline and PipelineRun YAML; cross-reference workspace names; confirm each has exactly one binding type

Parameter Declaration and Usage

All params used in task steps are declared in the Task or Pipeline spec.params with a type

Step references $(params.[NAME]) but [NAME] is not in spec.params; type mismatch (string vs array)

Extract all $(params.*) references via regex; diff against declared params list; check type field is present

Result Passing Between Tasks

Tasks that produce results declare them in spec.results; downstream tasks reference them with $(tasks.[TASK_NAME].results.[RESULT])

Result variable references a task name not in the Pipeline; result name not declared in upstream Task spec

Build a dependency graph from Pipeline runAfter and result references; verify each result path resolves to a declared result

Security Context Constraints

securityContext is set at pod or step level with non-root user, readOnlyRootFilesystem, and no privileged mode unless explicitly required

runAsUser: 0, privileged: true, or missing securityContext entirely on a step that mounts host volumes

Static analysis: scan for runAsUser: 0 and privileged: true; flag for approval; check that any hostPath volume has a corresponding securityContext

Image Pull Secret Reference

If imagePullSecrets is specified, the referenced secret name follows naming conventions and the field is at the correct spec level

imagePullSecrets references a secret with no name field; field placed inside a step instead of at pod template level

Schema validation: confirm imagePullSecrets is at spec.taskSpec or spec.pipelineSpec level; check name field is non-empty

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Use the base prompt with lighter validation. Focus on getting structurally correct YAML with proper indentation and required top-level fields (apiVersion, kind, metadata, spec). Accept broader step descriptions and manual parameter tuning.

Simplify the prompt by removing strict schema enforcement language. Replace [OUTPUT_SCHEMA] with a looser description: "Generate valid Tekton YAML with steps, params, and workspaces."

Watch for

  • Missing apiVersion or incorrect kind values (Task vs Pipeline)
  • Steps without image fields
  • Indentation errors from model output drift
  • Workspace declarations without corresponding step mounts
Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.