Skip to content

Commit 71b2ed6

Browse files
committed
add claude skills to create the maestro cluster
Signed-off-by: hchenxa <huichen@redhat.com>
1 parent 9f44c62 commit 71b2ed6

File tree

6 files changed

+563
-0
lines changed

6 files changed

+563
-0
lines changed

.claude/hooks/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
config.sh

.claude/hooks/config.sh.example

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
#
3+
# Deployment Monitor Hook Configuration
4+
#
5+
# Copy this file to config.sh and set your values:
6+
# cp config.sh.example config.sh
7+
#
8+
# Note: config.sh is gitignored to keep your webhook URL secure
9+
10+
# Slack Webhook URL for deployment notifications
11+
# Get this from: https://api.slack.com/messaging/webhooks
12+
# Example: https://hooks.slack.com/services/YOUR/WEBHOOK/URL
13+
SLACK_WEBHOOK_URL=""
14+
15+
# Optional: Customize notification behavior
16+
# NOTIFY_ON_START=false
17+
# NOTIFY_ON_PROGRESS=false
18+
# NOTIFY_ON_COMPLETE=true
19+
# NOTIFY_ON_FAILURE=true
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
#!/bin/bash
2+
#
3+
# Deployment Monitor Hook
4+
# This hook monitors long-running deployment processes and notifies when complete
5+
#
6+
# Usage: Can be called after triggering a deployment to monitor its progress
7+
#
8+
# Configuration:
9+
# Set SLACK_WEBHOOK_URL environment variable or create .claude/hooks/config.sh
10+
11+
set -e
12+
13+
HOOK_NAME="deployment-monitor"
14+
15+
# Load configuration if exists
16+
CONFIG_FILE="$(dirname "$0")/config.sh"
17+
if [ -f "$CONFIG_FILE" ]; then
18+
source "$CONFIG_FILE"
19+
fi
20+
21+
# Function to check if a process is still running
22+
check_process() {
23+
local pid=$1
24+
if ps -p "$pid" > /dev/null 2>&1; then
25+
return 0 # Process is running
26+
else
27+
return 1 # Process is not running
28+
fi
29+
}
30+
31+
# Function to monitor deployment
32+
monitor_deployment() {
33+
local start_time=$(date +%s)
34+
local max_wait_time=3600 # 1 hour max
35+
36+
echo "[$HOOK_NAME] Monitoring deployment process..."
37+
38+
while [ $(($(date +%s) - start_time)) -lt $max_wait_time ]; do
39+
# Check if deployment is complete by looking for success indicators
40+
# This is a placeholder - adjust based on actual deployment markers
41+
42+
# Sleep for 30 seconds before next check
43+
sleep 30
44+
45+
echo "[$HOOK_NAME] Deployment still in progress... (elapsed: $(($(date +%s) - start_time))s)"
46+
done
47+
48+
echo "[$HOOK_NAME] Maximum wait time reached"
49+
}
50+
51+
# Function to send Slack notification
52+
send_slack_notification() {
53+
local status=$1
54+
local message=$2
55+
local webhook_url=$3
56+
57+
if [ -z "$webhook_url" ]; then
58+
return 1
59+
fi
60+
61+
# Determine color based on status
62+
local color="good"
63+
local emoji=":white_check_mark:"
64+
if [[ "$status" == "FAILED" ]]; then
65+
color="danger"
66+
emoji=":x:"
67+
elif [[ "$status" == "COMPLETE" ]]; then
68+
color="good"
69+
emoji=":white_check_mark:"
70+
fi
71+
72+
# Create JSON payload
73+
local payload=$(cat <<EOF
74+
{
75+
"attachments": [
76+
{
77+
"color": "$color",
78+
"title": "$emoji Maestro Deployment $status",
79+
"text": "$message",
80+
"footer": "Maestro Deployment Monitor",
81+
"ts": $(date +%s)
82+
}
83+
]
84+
}
85+
EOF
86+
)
87+
88+
# Send to Slack
89+
curl -X POST -H 'Content-type: application/json' \
90+
--data "$payload" \
91+
"$webhook_url" \
92+
--silent --show-error
93+
}
94+
95+
# Function to send notification
96+
notify_completion() {
97+
local status=$1
98+
local message=$2
99+
100+
echo ""
101+
echo "=========================================="
102+
echo "[$HOOK_NAME] DEPLOYMENT $status"
103+
echo "Message: $message"
104+
echo "Time: $(date)"
105+
echo "=========================================="
106+
echo ""
107+
108+
# Send Slack notification if webhook is configured
109+
if [ -n "$SLACK_WEBHOOK_URL" ]; then
110+
echo "[$HOOK_NAME] Sending Slack notification..."
111+
if send_slack_notification "$status" "$message" "$SLACK_WEBHOOK_URL"; then
112+
echo "[$HOOK_NAME] Slack notification sent successfully"
113+
else
114+
echo "[$HOOK_NAME] Failed to send Slack notification"
115+
fi
116+
fi
117+
118+
# Also send system notification if available
119+
if command -v osascript &> /dev/null; then
120+
# macOS notification
121+
osascript -e "display notification \"$message\" with title \"Maestro Deployment $status\""
122+
elif command -v notify-send &> /dev/null; then
123+
# Linux notification
124+
notify-send "Maestro Deployment $status" "$message"
125+
fi
126+
}
127+
128+
# Main execution
129+
case "${1:-monitor}" in
130+
monitor)
131+
monitor_deployment
132+
;;
133+
notify)
134+
notify_completion "${2:-COMPLETE}" "${3:-Deployment finished}"
135+
;;
136+
*)
137+
echo "Usage: $0 {monitor|notify}"
138+
exit 1
139+
;;
140+
esac

.claude/skills/README.md

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
# Maestro Claude Skills
2+
3+
This directory contains custom Claude Code skills for Maestro development and operations.
4+
5+
## Available Skills
6+
7+
### setup-maestro-cluster (SKILL.md)
8+
9+
Sets up a long-running Maestro cluster environment using Azure ARO-HCP infrastructure.
10+
11+
**Usage:**
12+
```bash
13+
/setup-maestro-cluster
14+
```
15+
16+
**What it does:**
17+
1. Verifies Azure CLI installation and login status
18+
2. Checks that you're logged into the "ARO Hosted Control Planes" Azure account
19+
3. Clones the ARO-HCP repository to a temporary location
20+
4. Sets required environment variables (USER, PERSIST, GITHUB_ACTIONS, GOTOOLCHAIN)
21+
5. Runs `make personal-dev-env` to deploy the environment
22+
6. Monitors and reports deployment status
23+
24+
**Prerequisites:**
25+
- Azure CLI installed (`brew install azure-cli` on macOS)
26+
- Logged into correct Azure account: `az login`
27+
- Valid Azure permissions for resource creation
28+
29+
**Environment Variables Set:**
30+
- `USER=oasis`
31+
- `PERSIST=true`
32+
- `GITHUB_ACTIONS=true`
33+
- `GOTOOLCHAIN=go1.24.4`
34+
35+
## Hooks
36+
37+
### deployment-monitor.sh
38+
39+
A hook that monitors long-running deployment processes and sends notifications.
40+
41+
**Features:**
42+
- Desktop notifications (macOS/Linux)
43+
- Slack notifications via webhook
44+
- Customizable status messages
45+
46+
**Configuration:**
47+
48+
To enable Slack notifications:
49+
50+
1. Create a Slack webhook:
51+
- Go to https://api.slack.com/messaging/webhooks
52+
- Create an Incoming Webhook for your channel
53+
- Copy the webhook URL
54+
55+
2. Configure the hook:
56+
```bash
57+
cd .claude/hooks
58+
cp config.sh.example config.sh
59+
# Edit config.sh and set your SLACK_WEBHOOK_URL
60+
```
61+
62+
3. Or set it as an environment variable:
63+
```bash
64+
export SLACK_WEBHOOK_URL="https://hooks.slack.com/services/YOUR/WEBHOOK/URL"
65+
```
66+
67+
**Usage:**
68+
```bash
69+
# Monitor a deployment
70+
.claude/hooks/deployment-monitor.sh monitor
71+
72+
# Send a completion notification
73+
.claude/hooks/deployment-monitor.sh notify "COMPLETE" "Deployment finished successfully"
74+
75+
# Send a failure notification
76+
.claude/hooks/deployment-monitor.sh notify "FAILED" "Deployment failed with errors"
77+
```
78+
79+
The hook will:
80+
1. Send a Slack notification (if configured) with color-coded messages
81+
2. Send desktop notifications on macOS (via osascript) or Linux (via notify-send)
82+
83+
## How Skills Work
84+
85+
Skills are invoked in Claude Code using the `/` prefix followed by the skill name. When you run a skill:
86+
87+
1. Claude Code reads the skill markdown file
88+
2. Executes the bash script in the Implementation section
89+
3. Returns the output to you in the chat
90+
91+
Skills are a powerful way to automate complex, multi-step workflows that you perform frequently.
92+
93+
## Creating New Skills
94+
95+
To create a new skill:
96+
97+
1. Create a new `.md` file in `.claude/skills/`
98+
2. Include these sections:
99+
- Title and description
100+
- Prerequisites
101+
- Usage example
102+
- Implementation (bash script in a code block)
103+
3. Make sure the bash script is well-commented and handles errors
104+
105+
See `SKILL.md` as an example.

0 commit comments

Comments
 (0)