Overview
This example demonstrates using Claude Code to automate Hetzner Cloud infrastructure using the hcloud CLI tool.
⚠️ Critical Security Requirement
Setup hcloud BEFORE Using Claude Code
You must configure hcloud yourself first. This ensures Claude can only access resources within a dedicated project, making it easy to revoke access when done.
Required Setup Steps:
- Create a dedicated Hetzner Cloud project for this work
- Generate an API token scoped to only that project
- Configure hcloud CLI with the token:
hcloud context create my-project - Verify it works:
hcloud server list
Why this matters: Claude will use whatever hcloud context is active. By creating a dedicated project, you limit what Claude can access. Delete the project when done to revoke all access.
What You Can Automate
- Creating and managing compute instances (VMs)
- Network configuration (firewalls, private networks)
- SSH key management
- Volume (storage) management
- Cost optimization and resource cleanup
Download CLAUDE.md
Add this file to your cloud automation project to guide Claude Code through Hetzner Cloud tasks.
Download cloud-provisioning.mdSample Prompts
Try these prompts with Claude Code when using this CLAUDE.md:
Discover Available Options
Show me what server types are available and their pricing. I want something small for testing.
Create Basic Server
Create a small Debian server in Nuremberg, name it 'demo-server', and add a firewall allowing only SSH from my IP
Network Configuration
Create a firewall called 'web-firewall' that allows SSH (22), HTTP (80), and HTTPS (443) from anywhere, and apply it to my server 'demo-server'
Resource Management
List all my servers with their IPs, types, and monthly costs. Then show me how to create labels for better organization.
Cleanup
Find all servers with label 'project:test' and show me the delete commands. Confirm the list before executing.
Tools & Documentation
Safety Guidelines
- 🎯 DEDICATED PROJECT - Create separate Hetzner project for testing
- 💰 START SMALL - Use CX11 or CX22 instances (€4-6/mo)
- 🏷️ TAG EVERYTHING - Use labels for easy identification
- 🧹 CLEANUP PROMPTLY - Delete resources when done to avoid charges
- 📸 SNAPSHOT FIRST - Take snapshots before major changes
- 💡 DELETE vs STOP - Stopped instances still cost money!