1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
---
name: ship-setup
description: Set up ship for the first time or add a new VPS host. Saves host config to ~/.config/ship/config.json and installs server dependencies. Use when configuring ship for the first time, or adding/changing a host.
argument-hint: "[host-nickname]"
---
# ship-setup
Configure ship and prepare a VPS for deployments.
## Companion Script
Server setup is handled by `setup.sh` in this skill's directory. It is idempotent,
handles all branching logic, and mirrors the behavior of the original `ship host init`
Go CLI command.
```
skills/ship-setup/setup.sh <ssh-host> <base-domain> <nickname> [--default]
```
## Config File
All ship skills read from `~/.config/ship/config.json`. The setup script creates or
updates it — never overwrites the whole file.
```json
{
"default": "prod",
"hosts": {
"prod": {
"host": "ubuntu@1.2.3.4",
"domain": "example.com"
},
"staging": {
"host": "ubuntu@5.6.7.8",
"domain": "staging.example.com"
}
}
}
```
## Steps
### 1. Read existing config
Check if `~/.config/ship/config.json` exists:
```bash
cat ~/.config/ship/config.json 2>/dev/null
```
If it exists, show the user the current hosts so they know what's already configured.
### 2. Get host details
If not already known, ask the user:
- **Nickname** — short name for this host (e.g. `prod`, `staging`)
- **SSH connection string** — e.g. `ubuntu@1.2.3.4` or an alias from `~/.ssh/config`
- **Base domain** — the domain pointing to this server (e.g. `example.com`)
- **Default?** — if this is the first host, make it default. Otherwise ask.
### 3. Run the setup script
```bash
bash ~/.claude/skills/ship-setup/setup.sh <ssh-host> <domain> <nickname> [--default]
```
The script will:
1. Test the SSH connection — stops early if it fails
2. Detect OS (Ubuntu/Debian only)
3. Install Caddy if not present
4. Configure the main Caddyfile if not already set up
5. Create required directories (`/etc/ship/env`, `/etc/ship/ports`, `/etc/caddy/sites-enabled`, `/var/www`)
6. Enable and start Caddy
7. Save the host to `~/.config/ship/config.json`
### 4. Confirm
Tell the user:
- Host nickname and SSH target saved
- Whether it's the default host
- That the server is ready for deployments
- How to add another host: `/ship-setup`
- How to deploy: `/ship-deploy`
## Notes
- Safe to run multiple times — all steps are idempotent
- The SSH host can be an alias from `~/.ssh/config`
- If a nickname already exists in config, the script overwrites it — confirm with the user first
- Default host is used by all other ship skills when no host is specified
|