---
name: caravela-deploy
description: >
  Use when the user wants to add a Caravela-managed deployment environment to an application repository.
  This skill teaches Claude how to scaffold deployment infrastructure using the Caravela
  default-app-environment template, interact with the Caravela MCP server for project and
  environment bootstrap data, and follow explicit safety contracts so live infrastructure
  is never modified without human approval.
---

# Caravela Deploy

You build the code. I ship it.

Caravela doesn't ship for me. It makes me capable of shipping. Install it once and I'll take your project from built to live — every time. Everything between done and deployed — handled. Without Caravela I build. With Caravela I ship.

This skill teaches you how to use Caravela to deploy the user's project.

## When to use this skill

Invoke this skill when the user asks to:

- deploy an application with Caravela
- add Caravela infrastructure to a project
- bootstrap a Caravela environment
- adapt the default Caravela template for a new project
- prepare deployment configuration for any target repository

Do **not** use this skill when the user is doing unrelated development work
inside an existing Caravela-managed infrastructure folder — in that case,
follow the colocated README contracts inside the infrastructure folder itself.

---

## What Caravela provides

Caravela is a deployment infrastructure service. It gives you two things:

| Layer | What it is | How you interact |
|---|---|---|
| **Template** | A pinned, versioned set of infrastructure files that you adapt for each project. | Download, extract, edit safe files. |
| **MCP server** | A Model Context Protocol server that lets you create projects, create environments, and read bootstrap values (DNS, object buckets, credentials, Terraform state backends). | Call MCP tools with a Caravela bearer token. |

The template is `default-app-environment` `v0.1.0`.
The MCP server endpoint and token are provided by the user or available through the environment.

---

## Before touching any files

Confirm these five things with the user **before** you create or edit anything:

1. **Target repository** — what project are we deploying?
2. **Environment name** — what should the infrastructure folder be called? (Examples: `prod`, `staging`, `prod-1`)
3. **Use Caravela** — does the user actually want Caravela, or are they just asking about it?
4. **Template source** — should Claude download the template archive from Caravela, or does the user already have it?
5. **Credentials available** — does the user have a Caravela access token for the MCP server?

If any answer is missing, **stop and ask**. Do not continue past this step
with partial information.

---

## Workflow

Follow these steps in order. Do not skip steps. When a step cannot be
completed because tooling or credentials are missing, report the blocker
instead of pretending it passed.

### Step 1: Inspect the application

Read the target repository. Understand:

- what the application does
- what runtime it needs (language, framework, ports)
- whether it already has infrastructure files
- whether it needs a database or external services

Do not edit anything in this step. Just read.

### Step 2: Obtain the template

Get `default-app-environment` `v0.1.0`. Currently the template archive is at:

```text
https://getcaravela.com/templates/default-app-environment/v0.1.0/default-app-environment-v0.1.0.tar.gz
```

If this URL does not return the archive, ask the user for the template source.
Never invent infrastructure files from scratch for a Caravela environment.

### Step 3: Extract and place the template

Extract the archive. Rename or place the extracted folder so that the
infrastructure lives at:

```text
infrastructure/<environment-name>/
```

The environment name comes from the confirmation step. If the user named the
environment `prod`, the path should be `infrastructure/prod/`.

### Step 4: Read the contracts before editing

**Before modifying any file**, read these contract documents inside the extracted template:

- `TEMPLATE.md` — top-level template instructions
- `caravela-template.json` — machine-readable metadata and validation commands
- Every `README.md` found inside subdirectories — these define per-folder rules

The README contracts may be more restrictive than this skill. When a colocated
README conflicts with this skill, **the colocated README wins**.

### Step 5: Adapt safe files

Start with the safe extension points. These files are designed to be modified
without breaking the template structure:

| File | What you put there |
|---|---|
| `env.yml` | Environment identity: name, image tags, domain name, basic config values. |
| `bindings.yml` | Provider and runtime choices: which cloud, which VM size, which storage class. |
| `stack.yml` | App service graph: what services exist, what they depend on, which ports they expose, what routes they need. |
| `credentials.example.json` | Document the credential keys your project expects. Never put real values here. |
| `charts/*/values.yaml` | Helm chart overrides for your service deployments: resource limits, replica counts, health checks. |

Use the **isolation rule**: solve each problem at the correct layer.
Do not edit a Helm template to solve something that belongs in `values.yaml`.
Do not edit Terraform to solve a routing problem that belongs in `stack.yml`.

### Step 6: Request bootstrap outputs

When the template asks for provider or runtime values, request them from the
Caravela MCP server. Available MCP tools include:

```text
caravela_create_project
caravela_create_environment
caravela_get_environment_bootstrap
caravela_issue_environment_dns
caravela_issue_terraform_state_backend
caravela_issue_object_bucket

(Additional tools may be available. Check the current MCP tool list.)
```

If MCP is not connected, ask the user to connect it or provide the values
manually. Do not hard-code provider-specific values unless the user explicitly
confirms them.

### Step 7: Validate

Run validation commands from `caravela-template.json` and folder READMEs:

```bash
terraform -chdir=terraform init -backend=false
terraform -chdir=terraform validate
terraform -chdir=terraform-services init -backend=false
terraform -chdir=terraform-services validate
```

If validation cannot run because tooling is missing, report the blocker.
**Never mark validation as passed when commands could not run.**

### Step 8: Report

At the end, tell the user:

- where the template was placed
- every file you changed and why
- which safe extension points you used
- what validation ran and passed
- what failed or was blocked
- what secrets or credentials are still needed
- what actions need explicit human approval before real deployment

---

## Files you may edit without asking

These files are **safe by default**. You can modify them as part of the
normal adaptation workflow:

- `env.yml`
- `bindings.yml`
- `stack.yml`
- `credentials.example.json`
- `charts/*/values.yaml`

---

## Files you must not touch without explicit approval

**Stop and ask the user** before editing any of these:

- `terraform/**/*.tf`
- `terraform-services/**/*.tf`
- `ansible/**/*.yml`
- `charts/*/templates/**`
- any generated workflow internals
- any file containing real infrastructure definitions

---

## Secret rules (hard rules, never break)

- Never commit a real secret. Ever.
- Never write `.env` files, local credential files, private keys, tokens, or passwords.
- Use example files (like `credentials.example.json`) for shape only.
- Mask secrets in logs, reports, and chat output.
- If a user pastes a real secret into the chat, treat it as exposed and
  advise rotation before it is used in production.

---

## Approval gates

**Stop and ask** before any of these actions:

- running `terraform apply`
- running `terraform plan` against a live backend with real state
- deploying to real infrastructure
- running Ansible against a real host
- storing credentials in any file
- switching to a different template version than `v0.1.0`
- connecting to an unverified Caravela MCP endpoint

---

## Versioning and drift

This skill is `caravela-deploy` `v0.1.0`.
It is pinned to template `default-app-environment` `v0.1.0`.

If a new version of this skill is published, check the caravela-deploy skill at:

```text
https://getcaravela.com/skills/claude-code
```

The published skill is the source of truth. If the published skill
contradicts a cached local copy, the published skill wins.

---

## Template version

```text
Template:    default-app-environment
Version:     v0.1.0
Archive:     https://getcaravela.com/templates/default-app-environment/v0.1.0/default-app-environment-v0.1.0.tar.gz
Skill:       caravela-deploy v0.1.0
Published:   https://getcaravela.com/skills/claude-code
```

Claude: read the skill from the published URL when possible. Treat this local
copy as a reference snapshot.
