launch-sync-environment-variables-from-env-example

작성자: contentstack

Fetch environment variables from a Contentstack Launch project, compare them with a local `.env.example` file, and patch the target environment to add any…

npx skills add https://github.com/contentstack/contentstack-agent-skills --skill launch-sync-environment-variables-from-env-example

Sync Launch environment variables from .env.example

Description

Fetch environment variables from a Contentstack Launch project, compare them with a local .env.example file, and patch the target environment to add any missing keys.

When to Use

Use when a Launch environment must match the keys defined in a local .env.example file. Use to audit missing environment variables before a deployment. Use to add missing variable names to a Launch environment without manually editing config.

User Problem

A Launch environment can drift from the variables expected by a frontend project. This skill checks the environment against .env.example and updates Launch when keys are missing.

Success Criteria

All keys present in .env.example exist in the target Launch environment. Missing keys are added through the Launch Projects/Environments API. The script reports what was missing and what was updated. No secrets are printed in logs.

Expected Inputs

  • Launch project UID
  • Launch environment UID
  • Path to local .env.example file
  • Launch API credentials or authenticated context
  • Optional: dry-run flag

Expected Outputs

  • List of keys found in .env.example
  • List of keys already present in Launch
  • List of missing keys that were patched
  • Summary of API calls made
  • Exit code indicating success or failure

Example User Requests

  • Generate a Node.js script that syncs Launch environment variables from .env.example.
  • Compare my Launch environment variables with .env.example and add any missing keys.
  • Write a script to patch missing Launch environment variables for project abc123 and environment dev456.

Workflow Summary

Read and parse the local .env.example file. Fetch the target Launch environment and its current variables. Compare keys from the file against keys in Launch. Build a minimal patch payload containing only missing keys. Call PATCH /projects/{project_uid}/environments/{environment_uid}. Report the changes and stop without exposing values.

Instructions

Parse input

Read the local .env.example file and extract variable names. Ignore comments, blank lines, and malformed entries.

Fetch Launch state

Use the Launch API to get the target project and environment, then read the current environment variables.

Compare keys

Compare .env.example keys against Launch keys. Identify only missing keys unless the user explicitly asks to update existing values.

Patch environment

Call PATCH /projects/{project_uid}/environments/{environment_uid} with the minimal update needed to add missing keys.

Report results

Return a concise summary of missing keys, patched keys, and any errors. Never print secret values or tokens.

Output Format

Use concise, machine-readable summaries. Do not print secret values from Launch or local files. Show missing keys and updated keys separately. Include the project UID and environment UID in the summary. If running in dry-run mode, clearly label that no changes were made.

Tooling Notes

Use the Launch API and Projects/Environments endpoints. Validate project and environment UIDs before patching. Avoid logging deployment tokens or environment secrets. Use the smallest possible PATCH payload. If the API returns validation errors, surface them without retrying blindly.

Security

Defaults

Never expose deployment tokens or environment secrets. Validate project and environment targets before patching. Do not print variable values in logs or output. Require explicit user intent before making any change. Prefer dry-run behavior unless the user asks to apply changes.

Destructive Actions

Treat any PATCH that changes Launch configuration as a destructive external action. Confirm the target project and environment before applying changes. Do not broaden the update beyond missing keys unless the user explicitly requests it.

Secrets

Never reveal secret values from .env.example or Launch. Log only key names and counts. Redact tokens, API keys, and environment values in all output.

Environment Variables

Read environment variables only as needed for authentication and target selection. Never echo env var values. Support loading from local .env.example for comparison only, not for secret disclosure.

Product Context

    • Product: Launch
    • Description: Contentstack Launch: hosting, deployment, edge delivery, serverless functions, environment management, and CI/CD for Contentstack-powered frontends.
    • Product safety rules: - Never expose deployment tokens or environment secrets.
  • Validate deployment targets before triggering.
  • Require confirmation for production deployments.
  • Never auto-deploy to production without review.
    • Default tools: ["Launch API", "Projects", "Environments", "Deployments", "Serverless Functions", "Edge Delivery", "Custom Domains"]
    • Default connectors: ["Launch Proxy", "GitHub", "CI/CD Pipelines"]

contentstack의 다른 스킬

brand-kit-assistant
contentstack
사용자에게 Contentstack Brand Kit 개념, 설정, 거버넌스 및 브랜드에 부합하는 AI 생성에 대해 조언합니다. API 관련 작업은 적절한 Brand Kit 기능으로 라우팅하거나...
official
cms-assets
contentstack
개발자들이 Contentstack에서 에셋을 구성, 전달 및 변환하는 방법에 대해 조언합니다. 폴더 구조, Image Delivery API 변환, 게시 등을 다룹니다.
official
cms-branches-aliases
contentstack
개발자들이 Contentstack 브랜치를 사용하여 격리된 콘텐츠 개발을 수행하고, 별칭을 통해 무중단 콘텐츠 배포를 구현할 수 있도록 조언합니다. 브랜치 전략, …을 다룹니다.
official
cms-data-modeling-best-practices
contentstack
개발자들이 Contentstack에서 가장 간단한 재사용 가능한 구조로 콘텐츠를 모델링하도록 안내합니다. 이 스킬은 콘텐츠 타입, 참조, 글로벌…을 사용해야 하는 시점을 설명합니다.
official
cms-entries
contentstack
개발자에게 Contentstack 항목의 효율적인 전달을 위한 쿼리, 현지화, 버전 관리, 게시 및 구조화에 대해 조언합니다. CDA 사용, 참조에 중점을 둡니다.
official
cms-environments-publishing
contentstack
개발자에게 환경 구성, 콘텐츠 게시, 전달 및 미리보기 토큰 사용, Sync API 활용, CDN 이해 등에 대해 조언합니다.
official
cms-live-preview-visual-builder-support-assistant
contentstack
Contentstack Live Preview 및 Visual Builder 구현을 진단하고 안내합니다. 미리보기 컨텍스트를 추적하고, 손상된 계약을 식별하며, 다음을 권장합니다…
official
cms-localization
contentstack
Contentstack 현지화에 대한 개발자 조언: 언어 설정, 폴백 체인, 현지화된 항목과 현지화되지 않은 항목, 현지화 불가능한 필드, 다중 로케일…
official