Claude Skills Guide

Claude Code Spacelift Platform Guide

Infrastructure as Code (IaC) has evolved significantly, and combining Claude Code with Spacelift creates a powerful workflow for managing cloud resources intelligently. This guide shows developers how to use Claude Code’s natural language capabilities with Spacelift’s policy engine to build smarter, more compliant infrastructure automation.

Understanding the Spacelift Integration

Spacelift is a sophisticated IaC management platform that brings policy-as-code, workflow automation, and collaborative infrastructure management to Terraform, Pulumi, and CloudFormation stacks. When you add Claude Code to this mix, you gain an intelligent partner that can interpret requirements, generate configuration, explain errors, and suggest optimizations.

The integration works through Spacelift’s exposed APIs and webhook system. Claude Code can interact with these endpoints to:

Setting Up the Connection

Before connecting Claude Code to Spacelift, ensure you have appropriate API credentials. Spacelift provides service accounts with scoped permissions for exactly this purpose.

# Store your Spacelift API token securely
export SPACELIFT_API_TOKEN="spacelift_v1_..."
export SPACELIFT_ACCOUNT="your-account-id"

You’ll want to create a dedicated service account in Spacelift with read-write access to the stacks you want Claude Code to manage. Avoid using admin credentials for daily operations—principle of least privilege applies here.

Practical Examples

Generating Infrastructure Configurations

Suppose you need to set up a new AWS ECS cluster with specific requirements. Instead of writing Terraform from scratch, describe your needs to Claude Code:

Create an ECS cluster on AWS with auto-scaling, 
Fargate launch type, and CloudWatch logging enabled

Claude Code can generate the appropriate Terraform configuration using the tdd skill for test-driven infrastructure development:

# Generated ECS Cluster Configuration
module "ecs_cluster" {
  source  = "terraform-aws-modules/ecs/aws"
  version = "~> 5.0"
  
  cluster_name = "production-cluster"
  
  cluster_configuration = {
    execute_command_configuration = {
      logging = "OVERRIDE"
      configuration = {
        cloud_watch_log_group_name = "/aws/ecs/${var.cluster_name}/execute-command"
      }
    }
  }
  
  fargate_capacity_providers = {
    default = {
      weight = 100
    }
  }
  
  autoscaling_capacity_providers = {
    FARGATE = {
      auto_scaling_group_arn = module.asg.autoscaling_group_arn
      managed_scaling = {
        maximum_scaling_step_size = 5
        minimum_scaling_step_size = 1
        status = "ENABLED"
        target_capacity = 70
      }
    }
  }
}

Policy Review Workflows

Spacelift’s policy engine uses Open Policy Agent (OPA) Rego language. Writing these policies can be challenging. Use the frontend-design skill to prototype policy UIs, or use Claude Code’s understanding of Rego to generate policies from natural language descriptions.

For example, to enforce tagging requirements:

package spacelift

mandatory_tags := {"Environment", "Owner", "CostCenter", "Project"}

deny[msg] {
  input.change.kind == "terraform"
  some resource_type
  resources := input.change.resource_changes[resource_type]
  some resource
  resource := resources[_]
  missing_tags := mandatory_tags - keys(resource.change.after.tags)
  count(missing_tags) > 0
  msg := sprintf("Missing mandatory tags on %s: %v", [resource.address, missing_tags])
}

keys(s) := {k | s[k]}

Troubleshooting Failed Deployments

When Spacelift runs fail, the error messages aren’t always intuitive. Claude Code can analyze the run logs and suggest fixes:

# Example: Analyzing a failed Terraform plan output
terraform plan -out=tfplan 2>&1 | grep -A 20 "Error:"

Claude Code interprets these errors in context—considering your existing infrastructure, recent changes, and known constraints—to provide actionable solutions rather than generic error messages.

Advanced Workflow Patterns

Automated Pull Request Reviews

Set up a workflow where Claude Code reviews every infrastructure change:

  1. Configure Spacelift to trigger on pull request events
  2. Have Claude Code analyze the proposed changes
  3. Generate a compliance report using the pdf skill for documentation

This creates an intelligent gate that catches configuration issues before they reach production.

Multi-Cloud Orchestration

For organizations using multiple cloud providers, Claude Code can manage complex dependencies across AWS, GCP, and Azure. The supermemory skill helps maintain context across these orchestration sessions, remembering which resources exist where and how they interrelate.

Security Considerations

When integrating Claude Code with Spacelift, follow these security practices:

Best Practices

Start small with non-critical stacks to build confidence in the workflow. Document your infrastructure patterns so Claude Code can generate consistent configurations. Use the tdd skill to write tests alongside your infrastructure code—this catches issues early and gives Claude Code better context when generating changes.

The combination of Claude Code’s contextual understanding and Spacelift’s policy enforcement creates infrastructure automation that’s both intelligent and compliant. As your infrastructure grows, this integration scales to manage hundreds of stacks while maintaining consistent governance.

Built by theluckystrike — More at zovo.one