Skip to content

Commit d1e24b0

Browse files
committed
Add Claude Code skill and install command
Adds a cloudamqp-cli skill that teaches Claude Code how to use the CLI. Ships via `cloudamqp install skills` which embeds the skill files in the binary and copies them to ~/.claude/skills/cloudamqp-cli/.
1 parent 5935e4b commit d1e24b0

6 files changed

Lines changed: 480 additions & 0 deletions

File tree

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,16 @@ A command line interface for the CloudAMQP API that provides complete management
1212
- **User-Friendly**: Clear help messages, examples, and safety confirmations
1313
- **Error Handling**: Proper API error extraction and display
1414

15+
## Claude Code
16+
17+
Install skills to let Claude Code manage CloudAMQP instances on your behalf:
18+
19+
```bash
20+
cloudamqp install skills
21+
```
22+
23+
This copies skills to `~/.claude/skills/cloudamqp-cli/`. Claude Code discovers them automatically.
24+
1525
## Installation
1626

1727
### Pre-built binaries

cmd/install.go

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
package cmd
2+
3+
import (
4+
"embed"
5+
"fmt"
6+
"io/fs"
7+
"os"
8+
"path/filepath"
9+
10+
"github.com/spf13/cobra"
11+
)
12+
13+
//go:embed all:skills
14+
var skillsFS embed.FS
15+
16+
var installCmd = &cobra.Command{
17+
Use: "install",
18+
Short: "Install integrations",
19+
}
20+
21+
var installSkillsCmd = &cobra.Command{
22+
Use: "skills",
23+
Short: "Install Claude Code skills to ~/.claude/skills/",
24+
Long: `Install the CloudAMQP CLI skills for Claude Code.
25+
26+
Skills teach Claude how to use the cloudamqp CLI. After installation,
27+
Claude Code will automatically discover and use them.
28+
29+
Skills are installed to: ~/.claude/skills/cloudamqp-cli/`,
30+
RunE: func(cmd *cobra.Command, args []string) error {
31+
home, err := os.UserHomeDir()
32+
if err != nil {
33+
return fmt.Errorf("could not determine home directory: %w", err)
34+
}
35+
dest := filepath.Join(home, ".claude", "skills", "cloudamqp-cli")
36+
37+
err = fs.WalkDir(skillsFS, "skills/cloudamqp-cli", func(path string, d fs.DirEntry, err error) error {
38+
if err != nil {
39+
return err
40+
}
41+
// path relative to dest: strip "skills/cloudamqp-cli" prefix
42+
rel, err := filepath.Rel("skills/cloudamqp-cli", path)
43+
if err != nil {
44+
return err
45+
}
46+
target := filepath.Join(dest, rel)
47+
if d.IsDir() {
48+
return os.MkdirAll(target, 0755)
49+
}
50+
data, err := skillsFS.ReadFile(path)
51+
if err != nil {
52+
return err
53+
}
54+
return os.WriteFile(target, data, 0644)
55+
})
56+
if err != nil {
57+
return fmt.Errorf("failed to install skills: %w", err)
58+
}
59+
fmt.Printf("Skills installed to %s\n", dest)
60+
return nil
61+
},
62+
}
63+
64+
func init() {
65+
installCmd.AddCommand(installSkillsCmd)
66+
rootCmd.AddCommand(installCmd)
67+
}

cmd/skills/cloudamqp-cli/SKILL.md

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
---
2+
name: cloudamqp-cli
3+
description: Manage CloudAMQP instances, VPCs, teams, and RabbitMQ/LavinMQ configuration from the command line. Use when the user needs to create, configure, monitor, upgrade, or troubleshoot CloudAMQP message broker instances.
4+
allowed-tools: Bash(cloudamqp:*)
5+
---
6+
7+
# CloudAMQP CLI
8+
9+
## Quick start
10+
11+
```bash
12+
# list all instances
13+
cloudamqp instance list
14+
15+
# get instance details (includes connection URL and API key)
16+
cloudamqp instance get --id 1234
17+
18+
# create an instance and wait for it to be ready
19+
cloudamqp instance create --name=my-instance --plan=bunny-1 --region=amazon-web-services::us-east-1 --wait
20+
21+
# restart RabbitMQ on an instance
22+
cloudamqp instance restart-rabbitmq --id 1234
23+
24+
# delete an instance
25+
cloudamqp instance delete --id 1234
26+
```
27+
28+
## Authentication
29+
30+
Before running any commands, check that auth is configured — the CLI won't work without it and can't prompt interactively when run by an agent.
31+
32+
```bash
33+
# check if already configured
34+
cat ~/.cloudamqprc 2>/dev/null || echo "not configured"
35+
36+
# if not set up, ask the user for their API key, then write it:
37+
echo "YOUR_API_KEY" > ~/.cloudamqprc
38+
chmod 600 ~/.cloudamqprc
39+
```
40+
41+
The CLI checks in this order:
42+
43+
1. `CLOUDAMQP_APIKEY` environment variable
44+
2. `~/.cloudamqprc` file (plain text, just the key)
45+
3. Interactive prompt (won't work in agent context — use one of the above)
46+
47+
Base URL defaults to `https://customer.cloudamqp.com/api` (override with `CLOUDAMQP_URL`).
48+
49+
## Output
50+
51+
All commands support `-o json` for machine-readable output and `-o table` (default) for human-readable output. Use `-fields` to select specific columns.
52+
53+
## Commands
54+
55+
### Instance lifecycle
56+
57+
```bash
58+
cloudamqp instance create --name=<name> --plan=<plan> --region=<region> [--tags=<tag>...] [--vpc-id=<id>] [--wait] [--wait-timeout=20m]
59+
cloudamqp instance list [--details]
60+
cloudamqp instance get --id <id>
61+
cloudamqp instance update --id <id> [--name=<name>] [--plan=<plan>]
62+
cloudamqp instance delete --id <id> [--force]
63+
cloudamqp instance resize-disk --id <id> --disk-size=<gb> [--allow-downtime]
64+
```
65+
66+
### Copy settings between instances
67+
68+
```bash
69+
cloudamqp instance create --name=staging --plan=bunny-1 --region=amazon-web-services::us-east-1 \
70+
--copy-from-id=1234 --copy-settings=metrics,firewall,config,alarms,logs,definitions,plugins --wait
71+
```
72+
73+
Only works between dedicated instances (not shared plans).
74+
75+
### Node management
76+
77+
```bash
78+
cloudamqp instance nodes list --id <id>
79+
cloudamqp instance nodes versions --id <id>
80+
```
81+
82+
### Plugin management
83+
84+
```bash
85+
cloudamqp instance plugins list --id <id>
86+
```
87+
88+
### RabbitMQ configuration
89+
90+
```bash
91+
cloudamqp instance config list --id <id>
92+
cloudamqp instance config get --id <id> --key <key>
93+
cloudamqp instance config set --id <id> --key <key> --value <value>
94+
```
95+
96+
### Instance actions
97+
98+
```bash
99+
# restart
100+
cloudamqp instance restart-rabbitmq --id <id> [--nodes=node1,node2]
101+
cloudamqp instance restart-cluster --id <id>
102+
cloudamqp instance restart-management --id <id> [--nodes=node1,node2]
103+
104+
# start/stop
105+
cloudamqp instance start --id <id> [--nodes=node1,node2]
106+
cloudamqp instance stop --id <id> [--nodes=node1,node2]
107+
cloudamqp instance reboot --id <id> [--nodes=node1,node2]
108+
cloudamqp instance start-cluster --id <id>
109+
cloudamqp instance stop-cluster --id <id>
110+
111+
# upgrades (async, return immediately)
112+
cloudamqp instance upgrade-erlang --id <id>
113+
cloudamqp instance upgrade-rabbitmq --id <id> --version=<version>
114+
cloudamqp instance upgrade-all --id <id>
115+
cloudamqp instance upgrade-versions --id <id>
116+
```
117+
118+
### VPC management
119+
120+
```bash
121+
cloudamqp vpc create --name=<name> --region=<region> --subnet=<cidr> [--tags=<tag>]
122+
cloudamqp vpc list
123+
cloudamqp vpc get --id <id>
124+
cloudamqp vpc update --id <id> --name=<name>
125+
cloudamqp vpc delete --id <id>
126+
```
127+
128+
### Team management
129+
130+
```bash
131+
cloudamqp team list
132+
cloudamqp team invite --email=<email> [--role=<role>] [--tags=<tag>]
133+
cloudamqp team update --user-id=<id> --role=<role>
134+
cloudamqp team remove --email=<email>
135+
```
136+
137+
### Audit log
138+
139+
```bash
140+
cloudamqp audit [--timestamp=2024-01]
141+
```
142+
143+
### API key rotation
144+
145+
```bash
146+
cloudamqp rotate-key
147+
```
148+
149+
## Important behavior
150+
151+
- **Async operations**: Instance creation, disk resizes, and upgrades are async. Use `--wait` on create, or poll with `instance get --id <id>` until `ready: true`.
152+
- **Destructive commands** (delete, stop) prompt for confirmation. Use `--force` to skip in scripts.
153+
- **Multiple tags**: Use `--tags` multiple times: `--tags=prod --tags=web`.
154+
- **Shell completion**: Run `source <(cloudamqp completion zsh)` for tab completion of commands, instance IDs, plans, and regions.
155+
156+
## Plans and regions
157+
158+
Always fetch live data — don't guess plan names or regions:
159+
160+
```bash
161+
cloudamqp plans [--backend=rabbitmq|lavinmq]
162+
cloudamqp regions [--provider=amazon-web-services]
163+
```
164+
165+
## Specific tasks
166+
167+
* **Scripting and automation** [references/scripting.md](references/scripting.md)
168+
* **Instance upgrades and maintenance** [references/upgrades.md](references/upgrades.md)
169+
* **VPC and network setup** [references/vpc-setup.md](references/vpc-setup.md)
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# Scripting and automation
2+
3+
## JSON output for parsing
4+
5+
All commands support `-o json` for structured output. Combine with `jq` for extraction:
6+
7+
```bash
8+
# get connection URL for an instance
9+
cloudamqp instance get --id 1234 -o json | jq -r '.url'
10+
11+
# list instance IDs matching a tag
12+
cloudamqp instance list -o json | jq -r '.[] | select(.tags[]? == "production") | .id'
13+
14+
# get all instance names and plans
15+
cloudamqp instance list -o json | jq -r '.[] | "\(.id) \(.name) \(.plan)"'
16+
```
17+
18+
## Create and capture instance ID
19+
20+
```bash
21+
RESULT=$(cloudamqp instance create --name=temp --plan=lemming --region=amazon-web-services::us-east-1 -o json)
22+
INSTANCE_ID=$(echo "$RESULT" | jq -r '.id')
23+
echo "Created instance: $INSTANCE_ID"
24+
```
25+
26+
## Wait for instance readiness
27+
28+
Use the built-in `--wait` flag (default timeout: 15 minutes):
29+
30+
```bash
31+
cloudamqp instance create --name=my-instance --plan=bunny-1 \
32+
--region=amazon-web-services::us-east-1 --wait --wait-timeout=20m
33+
```
34+
35+
Or poll manually:
36+
37+
```bash
38+
while true; do
39+
STATUS=$(cloudamqp instance get --id "$INSTANCE_ID" -o json | jq -r '.ready')
40+
[ "$STATUS" = "true" ] && break
41+
sleep 30
42+
done
43+
```
44+
45+
## Skip confirmations
46+
47+
Use `--force` on destructive commands:
48+
49+
```bash
50+
cloudamqp instance delete --id 1234 --force
51+
```
52+
53+
## Environment-based configuration
54+
55+
```bash
56+
export CLOUDAMQP_APIKEY="your-api-key"
57+
cloudamqp instance list # no prompts
58+
```
59+
60+
## Batch operations
61+
62+
```bash
63+
# restart all instances tagged "staging"
64+
for ID in $(cloudamqp instance list -o json | jq -r '.[] | select(.tags[]? == "staging") | .id'); do
65+
echo "Restarting instance $ID"
66+
cloudamqp instance restart-rabbitmq --id "$ID"
67+
done
68+
```
69+
70+
## Clone an instance with full config
71+
72+
```bash
73+
cloudamqp instance create \
74+
--name=staging-copy \
75+
--plan=bunny-1 \
76+
--region=amazon-web-services::us-east-1 \
77+
--copy-from-id=1234 \
78+
--copy-settings=alarms,metrics,logs,firewall,config,definitions,plugins \
79+
--wait
80+
```

0 commit comments

Comments
 (0)