Ephemeral Pull Request Environment Engine Specification
Specify an automated on-demand preview environment engine that provisions and destroys branch infrastructure per pull request.
Use this template when engineering automated preview environments for feature testing and QA validation. It provides architecture blueprints for dynamic resource isolation, sanitised state seeding, and cost-controlled teardowns.
Role: Staff Site Reliability Engineer specializing in developer productivity engineering and ephemeral cloud infrastructure.
Context
- Cloud Infrastructure Provider: {{cloud_provider}}
- Infrastructure as Code Tooling: {{iac_framework}}
- Preview DNS & Ingress Strategy: {{dns_routing_strategy}}
- Maximum Environment TTL: {{max_ttl_hours}}
- Ephemeral Data Seeding Strategy: {{stateful_data_strategy}}
Task
Author an engineering specification for an on-demand ephemeral preview environment pipeline that automatically builds, deploys, and tears down branch-specific staging instances.
Method
- Define Pull Request lifecycle hooks triggering environment creation, updates, and destroy events.
- Architect resource isolation using dedicated namespaces or cloud accounts on {{cloud_provider}}.
- Specify automated dynamic DNS provisioning and SSL termination using {{dns_routing_strategy}}.
- Design database and stateful storage initialization using {{stateful_data_strategy}} without leaking sensitive data.
- Construct automated teardown orchestration triggered upon PR closure, merge, or {{max_ttl_hours}} expiry.
- Embed resource quota limits and cloud cost monitoring tags across all provisioned assets.
- Formulate notification mechanisms that post dynamic environment URLs and deployment logs directly into PR comments.
Constraints
- Infrastructure provisioning MUST execute via modular configurations written in {{iac_framework}}.
- Ephemeral environments MUST NOT persist beyond {{max_ttl_hours}} under any circumstance.
- Database seeding MUST NOT import unmasked production customer data.
- Teardown workers must operate idempotently to prevent orphaned resources on {{cloud_provider}}.
- Provisioning time from PR open to live URL must be specified with exact p90 latency targets.
Output format
- Lifecycle Orchestration Flow (PR Open, Synchronize, and Close workflows)
- IaC Provisioning & Ingress Architecture (technical spec with module layout and DNS mapping)
- Data Seeding & Sanitization Protocol (step-by-step database provisioning rules)
- Automated Cleanup & Governance Engine (TTL scheduler, sweeper jobs, and cost controls)
Self-review
- Verify that teardown logic completely eliminates orphaned cloud resources.
- Confirm data handling adheres strictly to zero-PII constraints.
- Ensure TTL logic accounts for both automated sweeper jobs and manual PR closure triggers.
- Check that all variable references are accurately embedded in the text.
Explicit role, a named task, and discrete steps the model can follow.
Background, inputs and variables the model needs before it starts.
Hard boundaries — what the model must and must not do.
A named, field-level shape for the response.
Ordered work items that force analysis before an answer.
Length and structure that travel across frontier models.
Signal density — instruction weight without padding.
Documented variables so the scaffold adapts to new inputs.
Quality bar, assumptions and behaviour when inputs are thin.
How much real usage the template has behind it.