agent-skills/skills/deploy-to-vps/SKILL.md
2026-11-28 15:28:03 +02:00

5.7 KiB


name: deploy-to-vps description: Publish a website or an app (static site, Node.js, PHP or WordPress) on the user's Interweb Mozambique VPS: find the server and its IP through the Interweb Mozambique API, prepare the project with Docker Compose and Caddy for automatic HTTPS, copy it over SSH, start it and connect the domain. Use when the user says "deploy this to my VPS", "put my site online on my server" or "host this project on Interweb Mozambique".

Deploy to a Interweb Mozambique VPS

A guided task. The API finds and manages the server; the files go over SSH with the user's own access. Ready examples live in the templates repository: https://git.interweb.co.mz/interweb-mz/templates

Setup

  • API address: https://api.interweb.co.mz/v1. It is fixed for Interweb Mozambique: never ask the user for another address.
  • API key: always read it from the INTERWEB_API_KEY environment variable. Check it without printing it: test -n "$INTERWEB_API_KEY" && echo set || echo missing
  • If it is missing, ask the user to create a key in the API Center (https://www.meu.interweb.co.mz/api-center.php) with vps:read (plus dns:write to connect the domain, and vps:write only if a restart or backup is needed), then to run export INTERWEB_API_KEY="sandbox_..." and restart Claude Code (or the editor).
  • sandbox_ keys read the real account but only simulate writes and never charge. prod_ keys change the account and can charge. GET /v1/token gives the mode in data.mode and the permissions in data.permissions. Suggest a sandbox_ key for a first try.
  • Never print, log or commit the key, and never put it in code that runs in a browser or a mobile app. In code, read it from the environment.

Every request looks like this:

curl -sS "https://api.interweb.co.mz/v1/PATH" -H "Authorization: Bearer $INTERWEB_API_KEY" -H "Accept: application/json"

Rules

  • Before anything that charges, deletes data or cannot be undone, tell the user exactly what will happen (with the price, when the API gives one) and wait for a clear yes.
  • Send an Idempotency-Key header on purchases, sends and other POST requests that accept it, and reuse the same value if you retry the same request: IDEM=$(uuidgen 2>/dev/null || cat /proc/sys/kernel/random/uuid).
  • Lists come in pages: ?page=1&per_page=100, and meta.total_pages says how many there are.
  • Long operations answer 202 with an action_id. Follow them with GET /v1/actions/{action_id} every 10 to 20 seconds until status is done or failed.
  • Answer the user in the language they write in, and show amounts with the currency the API returns.

Steps

  1. Pick the server. GET /v1/servers and show name, ip, status, power_state and operating_system. If there are several, ask which one. If power_state is not running, offer to start it (manage-vps).
  2. Check access. Ask how the user connects (ssh root@<ip> or another user with a key). Never ask for the root password in the chat, and never generate a new one unless the user asks (manage-vps). Test with ssh -o BatchMode=yes USER@IP true.
  3. Prepare the project. Pick the closest template (static site, Node.js, PHP, WordPress) and add its docker-compose.yml, Caddyfile and .env.example to the project. Keep secrets in .env on the server only, and add .env to .gitignore.
  4. Suggest a backup of the server first (POST /v1/servers/{id}/backups) if it already runs other sites.
  5. Install Docker on the server if it is missing (docker --version). On Ubuntu or Debian, use the official Docker packages for that system. Ask before installing anything.
  6. Copy and start.
rsync -az --exclude .git --exclude node_modules --exclude .env ./ USER@IP:/srv/app/
ssh USER@IP 'cd /srv/app && test -f .env || cp .env.example .env'
ssh USER@IP 'cd /srv/app && docker compose up -d --build && docker compose ps'
  1. Connect the domain with the connect-domain skill (A record of @ and www to the server IP). Caddy gets the HTTPS certificate on its own once the domain points to the server and ports 80 and 443 are open.
  2. Check. curl -I https://mybusiness.co.mz and ssh USER@IP 'cd /srv/app && docker compose logs --tail=50'.

Rules

  • Do not open other ports, change the firewall, delete files or stop other containers on the server without asking.
  • Never copy .env, keys or database dumps into git or into the chat.
  • Updates: copy again and run docker compose up -d --build. To go back, keep the previous release folder or use a server backup.

Errors

Errors look like {"error": {"code", "message", "correlation_id", "details"}}. Act on code, never on the text of message.

HTTP code What to do
401 unauthorized The key is missing, wrong or revoked. Ask the user to check INTERWEB_API_KEY.
402 insufficient_credit Not enough account credit, and nothing was charged. Give the user details.add_funds_url.
403 insufficient_scope The key lacks a permission. Name it and ask for a key that has it.
403 spending_limit_exceeded The purchase goes over the key spending limit. Nothing was charged.
404 not_found Wrong id, or it is not in this account.
409 conflict and others Read details.reason and explain it in plain words.
422 validation_failed Fix the field named in details and try again.
429 rate_limited Wait for the Retry-After seconds, then try once more.
5xx internal_error, upstream_error Try again later. If the user contacts support, give them the correlation_id.

More