agentleFS
way-platformway-platform/skills/spacelift-terraform/SKILL.md

spacelift-terraform

Skill4 starsChanged 10 months agoMITView on GitHub

Spacelift for Terraform GitOps. Use when working with Spacelift stacks, runs, policies, contexts, worker pools, drift detection, or spacectl CLI.

  • Reads credentials
  • Installs packages
  • Commits and pushes

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    All policies use Rego v1 (package spacelift).

    line 125

≈ “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

Spacelift

Spacelift orchestrates Terraform via GitOps: GitHub pushes trigger runs, policies govern behavior, contexts inject config, workers execute runs.

  • API: https://<account>.app.spacelift.io/graphql
  • Terraform provider: spacelift-io/spacelift
  • spacectl: brew install spacelift-io/spacelift/spacectl

Core Concepts

ConceptDescription
StackTerraform project unit: repo + branch + settings + state
RunExecution of terraform plan (proposed) or plan+apply (tracked)
PolicyOPA Rego rule set governing stack behavior (9 types)
ContextReusable bundle of env vars + mounted files + hooks
Worker PoolSet of runners executing runs (public Spacelift-hosted or private)
SpaceOrganizational boundary for access control and resource scoping

GitOps Workflow

feature branch push
  → push policy → propose
  → proposed run: terraform plan
  → commit status reported to PR

PR merged to tracked branch (e.g., main)
  → push policy → track
  → tracked run: terraform plan
  → if autodeploy: auto-apply
  → else: unconfirmed state → human confirms → apply

Run States

StateMeaning
QUEUEDWaiting for worker; approval policies evaluated here
INITIALIZINGWorker starting, downloading source
PLANNINGterraform plan running
UNCONFIRMEDPlan done, awaiting human confirm (or autodeploy blocked)
CONFIRMEDHuman confirmed, apply will start
APPLYINGterraform apply running
FINISHEDCompleted successfully
FAILEDRun failed at some phase
DISCARDEDManually abandoned

spacectl Quick Reference

Auth (CI/Agent — non-interactive)

export SPACELIFT_API_KEY_ENDPOINT=https://myorg.app.spacelift.io
export SPACELIFT_API_KEY_ID=$SECRET_KEY_ID
export SPACELIFT_API_KEY_SECRET=$SECRET_KEY_SECRET

GitHub Actions

- uses: spacelift-io/setup-spacectl@main
- run: spacectl stack deploy --id my-stack --auto-confirm --tail
  env:
    SPACELIFT_API_KEY_ENDPOINT: https://myorg.app.spacelift.io
    SPACELIFT_API_KEY_ID: ${{ secrets.SPACELIFT_API_KEY_ID }}
    SPACELIFT_API_KEY_SECRET: ${{ secrets.SPACELIFT_API_KEY_SECRET }}

Key Commands

spacectl stack list
spacectl stack deploy --id <stack> --auto-confirm --tail
spacectl stack task --id <stack> --tail 'terraform output -json'
spacectl run list --stack <stack>
spacectl run logs --stack <stack> --run <run-id>
spacectl run confirm --stack <stack> --run <run-id>
spacectl workerpool list
spacectl profile export-token          # get bearer token for API calls

Stack Settings Quick Reference

FieldKey Values
BranchTracked branch — pushes here trigger tracked runs
Project rootSubdirectory for Terraform root (monorepo)
Project globsSparse checkout paths (requires git checkout mode)
Autodeploytrue = auto-apply on clean plan
Autoretrytrue = retry proposed runs when state changes (private worker only)
Worker poolAssign private pool; required for drift detection
Runner imageCustom Docker image (default: public.ecr.aws/spacelift/runner-terraform:latest)
LabelsUsed by policies for auto-attach and filtering
Deletion protectionPrevent accidental stack deletion

Policy Types Quick Reference

TypeFires whenKey outputs
PushGit push or PR eventtrack, propose, ignore, cancel
PlanAfter terraform plandeny (fail), warn (require review)
TriggerTracked run reaches terminal statetrigger (stack IDs to cascade)
ApprovalRun enters queued/unconfirmedapprove, reject
LoginUser login attemptallow, deny, admin
Stack AccessStack access checkread, write, admin, deny
NotificationAny run state changenotification targets
TaskBefore task runsallow, deny
Run InitBefore run starts (deprecated)allow, deny

All policies use Rego v1 (package spacelift). Auto-attach via label autoattach:<label>.

Most Common Patterns

# Push: standard GitOps
track if input.push.branch == input.stack.branch
propose if not is_null(input.pull_request)
ignore if { not track; not propose }

# Plan: block deletions
deny contains sprintf("Deletion not allowed: %s", [c.entity.address]) if {
  some c in input.spacelift.run.changes; c.action == "deleted"
}

# Plan: manual review for drift
warn contains "Drift reconciliation requires manual approval" if {
  input.spacelift.run.drift_detection
}

# Approval: require 1 reviewer
approve if count(input.reviews.current.approvals) >= 1

Reference Files

FileRead when
references/github-terraform-workflow.mdSetting up GitHub App, branch tracking, PR status checks, push policy patterns, monorepo sparse checkout
references/stack-configuration.mdStack creation fields, VCS settings, Terraform settings, hooks, scheduling, stack dependencies
references/policies.mdAll 9 policy types with full input schemas, Rego v1 examples, workbench testing
references/spacectl.mdCLI installation, auth methods, stack/run/worker commands, CI agent patterns, GraphQL API
references/contexts-and-config.mdContext creation, auto-attach labels, priority/conflict resolution, .spacelift/config.yml, env var precedence
references/worker-pools.mdPrivate worker setup (CSR → pool → launch), config vars, network requirements, sizing
references/drift-detection.mdScheduling, reconciliation, plan/trigger policy integration, drift run limits
references/gcp-integration.mdSetting up GCP OIDC (WIF), native GCP integration, credential config JSON, Terraform provider auth, hierarchical space access, direct resource access
references/terraform-provider.mdTerraform provider config, resource+data source inventory, HCL schemas for all core resources, AWS integration setup, import IDs

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.