Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@ A command line interface for the CloudAMQP API that provides complete management
- **User-Friendly**: Clear help messages, examples, and safety confirmations
- **Error Handling**: Proper API error extraction and display

## Claude Code

Install skills to let Claude Code manage CloudAMQP instances on your behalf:

```bash
cloudamqp install skills
```

This copies skills to `~/.claude/skills/cloudamqp-cli/`. Claude Code discovers them automatically.

## Installation

### Pre-built binaries
Expand Down
67 changes: 67 additions & 0 deletions cmd/install.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package cmd

import (
"embed"
"fmt"
"io/fs"
"os"
"path/filepath"

"github.com/spf13/cobra"
)

//go:embed all:skills
var skillsFS embed.FS

var installCmd = &cobra.Command{
Use: "install",
Short: "Install integrations",
}

var installSkillsCmd = &cobra.Command{
Use: "skills",
Short: "Install Claude Code skills to ~/.claude/skills/",
Long: `Install the CloudAMQP CLI skills for Claude Code.

Skills teach Claude how to use the cloudamqp CLI. After installation,
Claude Code will automatically discover and use them.

Skills are installed to: ~/.claude/skills/cloudamqp-cli/`,
Comment on lines +22 to +31
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider setting Args: cobra.NoArgs on installSkillsCmd (and possibly installCmd) to match the rest of the CLI commands and to avoid silently accepting unexpected positional arguments (e.g. cloudamqp install skills extra).

Copilot uses AI. Check for mistakes.
RunE: func(cmd *cobra.Command, args []string) error {
home, err := os.UserHomeDir()
if err != nil {
return fmt.Errorf("could not determine home directory: %w", err)
}
dest := filepath.Join(home, ".claude", "skills", "cloudamqp-cli")

err = fs.WalkDir(skillsFS, "skills/cloudamqp-cli", func(path string, d fs.DirEntry, err error) error {
if err != nil {
return err
}
// path relative to dest: strip "skills/cloudamqp-cli" prefix
rel, err := filepath.Rel("skills/cloudamqp-cli", path)
if err != nil {
return err
}
target := filepath.Join(dest, rel)
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fs.WalkDir is walking embedded paths that always use forward slashes, but this code uses filepath.Rel with hard-coded / separators. On Windows releases, filepath.Rel("skills/cloudamqp-cli", path) can fail or produce incorrect rel values because filepath expects OS-specific separators. Use path.Rel (from path) or strings.TrimPrefix on the embedded path, then filepath.FromSlash when joining to the destination path.

Copilot uses AI. Check for mistakes.
if d.IsDir() {
return os.MkdirAll(target, 0755)
}
data, err := skillsFS.ReadFile(path)
if err != nil {
return err
}
return os.WriteFile(target, data, 0644)
})
if err != nil {
return fmt.Errorf("failed to install skills: %w", err)
}
fmt.Printf("Skills installed to %s\n", dest)
return nil
},
Comment on lines +22 to +62
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are existing command-level tests in cmd/command_test.go, but the new install skills behavior isn’t covered. Please add a unit test that runs installSkillsCmd with a temporary HOME/USERPROFILE and asserts that SKILL.md and the references/ files are created under ~/.claude/skills/cloudamqp-cli/.

Copilot uses AI. Check for mistakes.
}

func init() {
installCmd.AddCommand(installSkillsCmd)
rootCmd.AddCommand(installCmd)
}
169 changes: 169 additions & 0 deletions cmd/skills/cloudamqp-cli/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
---
name: cloudamqp-cli
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.
allowed-tools: Bash(cloudamqp:*)
---

# CloudAMQP CLI

## Quick start

```bash
# list all instances
cloudamqp instance list

# get instance details (includes connection URL and API key)
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The quick-start note says instance get “includes connection URL and API key”, but the CLI masks the URL password by default (requires --show-url to reveal) and it doesn’t print an API key. Please adjust this description so the skill doesn’t instruct users/agents to expect credentials that won’t appear.

Suggested change
# get instance details (includes connection URL and API key)
# get instance details (prints connection URL with password masked; use --show-url for full URL, does not print API key)

Copilot uses AI. Check for mistakes.
cloudamqp instance get --id 1234

# create an instance and wait for it to be ready
cloudamqp instance create --name=my-instance --plan=bunny-1 --region=amazon-web-services::us-east-1 --wait

# restart RabbitMQ on an instance
cloudamqp instance restart-rabbitmq --id 1234

# delete an instance
cloudamqp instance delete --id 1234
```

## Authentication

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.

```bash
# check if already configured
cat ~/.cloudamqprc 2>/dev/null || echo "not configured"

# if not set up, ask the user for their API key, then write it:
echo "YOUR_API_KEY" > ~/.cloudamqprc
chmod 600 ~/.cloudamqprc
```

The CLI checks in this order:

1. `CLOUDAMQP_APIKEY` environment variable
2. `~/.cloudamqprc` file (plain text, just the key)
3. Interactive prompt (won't work in agent context — use one of the above)

Base URL defaults to `https://customer.cloudamqp.com/api` (override with `CLOUDAMQP_URL`).

## Output

All commands support `-o json` for machine-readable output and `-o table` (default) for human-readable output. Use `-fields` to select specific columns.
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This section claims all commands support -o json/-o table and -fields, but many commands (e.g., instance create, vpc create, team invite) don’t use the shared output.Printer and therefore ignore -o/-fields (and often print non-JSON prefixes). Please narrow the claim to the commands that actually support these flags, or update examples accordingly.

Suggested change
All commands support `-o json` for machine-readable output and `-o table` (default) for human-readable output. Use `-fields` to select specific columns.
For commands that support it, use `-o json` for machine-readable output and `-o table` (default) for human-readable output. Use `-fields` where available to select specific columns.

Copilot uses AI. Check for mistakes.

## Commands

### Instance lifecycle

```bash
cloudamqp instance create --name=<name> --plan=<plan> --region=<region> [--tags=<tag>...] [--vpc-id=<id>] [--wait] [--wait-timeout=20m]
cloudamqp instance list [--details]
cloudamqp instance get --id <id>
cloudamqp instance update --id <id> [--name=<name>] [--plan=<plan>]
cloudamqp instance delete --id <id> [--force]
cloudamqp instance resize-disk --id <id> --disk-size=<gb> [--allow-downtime]
```

### Copy settings between instances

```bash
cloudamqp instance create --name=staging --plan=bunny-1 --region=amazon-web-services::us-east-1 \
--copy-from-id=1234 --copy-settings=metrics,firewall,config,alarms,logs,definitions,plugins --wait
```

Only works between dedicated instances (not shared plans).

### Node management

```bash
cloudamqp instance nodes list --id <id>
cloudamqp instance nodes versions --id <id>
```

### Plugin management

```bash
cloudamqp instance plugins list --id <id>
```

### RabbitMQ configuration

```bash
cloudamqp instance config list --id <id>
cloudamqp instance config get --id <id> --key <key>
cloudamqp instance config set --id <id> --key <key> --value <value>
```

### Instance actions

```bash
# restart
cloudamqp instance restart-rabbitmq --id <id> [--nodes=node1,node2]
cloudamqp instance restart-cluster --id <id>
cloudamqp instance restart-management --id <id> [--nodes=node1,node2]

# start/stop
cloudamqp instance start --id <id> [--nodes=node1,node2]
cloudamqp instance stop --id <id> [--nodes=node1,node2]
cloudamqp instance reboot --id <id> [--nodes=node1,node2]
cloudamqp instance start-cluster --id <id>
cloudamqp instance stop-cluster --id <id>

# upgrades (async, return immediately)
cloudamqp instance upgrade-erlang --id <id>
cloudamqp instance upgrade-rabbitmq --id <id> --version=<version>
cloudamqp instance upgrade-all --id <id>
cloudamqp instance upgrade-versions --id <id>
```

### VPC management

```bash
cloudamqp vpc create --name=<name> --region=<region> --subnet=<cidr> [--tags=<tag>]
cloudamqp vpc list
cloudamqp vpc get --id <id>
cloudamqp vpc update --id <id> --name=<name>
cloudamqp vpc delete --id <id>
```

### Team management

```bash
cloudamqp team list
cloudamqp team invite --email=<email> [--role=<role>] [--tags=<tag>]
cloudamqp team update --user-id=<id> --role=<role>
cloudamqp team remove --email=<email>
```

### Audit log

```bash
cloudamqp audit [--timestamp=2024-01]
```

### API key rotation

```bash
cloudamqp rotate-key
```

## Important behavior

- **Async operations**: Instance creation, disk resizes, and upgrades are async. Use `--wait` on create, or poll with `instance get --id <id>` until `ready: true`.
- **Destructive commands** (delete, stop) prompt for confirmation. Use `--force` to skip in scripts.
- **Multiple tags**: Use `--tags` multiple times: `--tags=prod --tags=web`.
- **Shell completion**: Run `source <(cloudamqp completion zsh)` for tab completion of commands, instance IDs, plans, and regions.

## Plans and regions

Always fetch live data — don't guess plan names or regions:

```bash
cloudamqp plans [--backend=rabbitmq|lavinmq]
cloudamqp regions [--provider=amazon-web-services]
```

## Specific tasks

* **Scripting and automation** [references/scripting.md](references/scripting.md)
* **Instance upgrades and maintenance** [references/upgrades.md](references/upgrades.md)
* **VPC and network setup** [references/vpc-setup.md](references/vpc-setup.md)
80 changes: 80 additions & 0 deletions cmd/skills/cloudamqp-cli/references/scripting.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Scripting and automation

## JSON output for parsing

All commands support `-o json` for structured output. Combine with `jq` for extraction:

```bash
# get connection URL for an instance
cloudamqp instance get --id 1234 -o json | jq -r '.url'

# list instance IDs matching a tag
cloudamqp instance list -o json | jq -r '.[] | select(.tags[]? == "production") | .id'

Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cloudamqp instance list -o json (without --details) only outputs id/name/plan/region, so this example won’t have a .tags field to filter on. Update the example to use --details -o json, or switch to a workflow that fetches tags via instance get per ID.

Copilot uses AI. Check for mistakes.
# get all instance names and plans
cloudamqp instance list -o json | jq -r '.[] | "\(.id) \(.name) \(.plan)"'
```

## Create and capture instance ID

```bash
RESULT=$(cloudamqp instance create --name=temp --plan=lemming --region=amazon-web-services::us-east-1 -o json)
INSTANCE_ID=$(echo "$RESULT" | jq -r '.id')
echo "Created instance: $INSTANCE_ID"
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cloudamqp instance create ... -o json is shown as producing machine-readable JSON that can be piped to jq, but instance create currently prints a human prefix (e.g., "Instance created successfully:") before the JSON and doesn’t use the shared output formatter. This example will break in scripts as written; please adjust it to match the CLI’s actual output or make instance create honor -o json.

Copilot uses AI. Check for mistakes.
```

## Wait for instance readiness

Use the built-in `--wait` flag (default timeout: 15 minutes):

```bash
cloudamqp instance create --name=my-instance --plan=bunny-1 \
--region=amazon-web-services::us-east-1 --wait --wait-timeout=20m
```

Or poll manually:

```bash
while true; do
STATUS=$(cloudamqp instance get --id "$INSTANCE_ID" -o json | jq -r '.ready')
[ "$STATUS" = "true" ] && break
sleep 30
done
```

## Skip confirmations

Use `--force` on destructive commands:

```bash
cloudamqp instance delete --id 1234 --force
```

## Environment-based configuration

```bash
export CLOUDAMQP_APIKEY="your-api-key"
cloudamqp instance list # no prompts
```

## Batch operations

```bash
# restart all instances tagged "staging"
for ID in $(cloudamqp instance list -o json | jq -r '.[] | select(.tags[]? == "staging") | .id'); do
echo "Restarting instance $ID"
cloudamqp instance restart-rabbitmq --id "$ID"
done
```

## Clone an instance with full config

```bash
cloudamqp instance create \
--name=staging-copy \
--plan=bunny-1 \
--region=amazon-web-services::us-east-1 \
--copy-from-id=1234 \
--copy-settings=alarms,metrics,logs,firewall,config,definitions,plugins \
--wait
```
Loading
Loading