← back to Designer Wallcoverings
DW-Agents/dw-agents/generate-agent-commands.sh
103 lines
#!/bin/bash
# Generate slash commands for all DW-Agents
# Each agent gets a slash command that sets context to work within that agent
cd /root/claude/agents/dw-agents
for agent_dir in agent-*/; do
# Remove trailing slash
agent="${agent_dir%/}"
# Skip if not a directory
[ ! -d "$agent" ] && continue
# Extract agent name without prefix (e.g., "legal-team" from "agent-legal-team")
short_name="${agent#agent-}"
# Create command name (e.g., "legal" for "agent-legal-team")
cmd_name=$(echo "$short_name" | sed 's/-team$//' | sed 's/-agent$//' | sed 's/-/_/g')
# Get description from README if it exists
description="Work with the ${short_name} agent"
main_file=""
port=""
if [ -f "$agent/README.md" ]; then
# Extract purpose line
purpose=$(grep -A1 "^## Purpose" "$agent/README.md" | tail -1 | sed 's/^[[:space:]]*//')
[ ! -z "$purpose" ] && description="$purpose"
# Extract main file
main_file=$(grep -oP "(?<=\*\*Main File\*\*: ).*" "$agent/README.md" | head -1)
# Extract port
port=$(grep -oP "(?<=\*\*Port\*\*: )\d+" "$agent/README.md" | head -1)
fi
# Create the slash command file
commands_dir="$agent/.claude/commands"
mkdir -p "$commands_dir"
cat > "$commands_dir/work.md" <<EOF
The user wants to work with the **${short_name}** agent located at \`/root/claude/agents/dw-agents/${agent}\`.
## Agent Overview
${description}
EOF
if [ ! -z "$main_file" ]; then
echo "**Main File**: \`${main_file}\`" >> "$commands_dir/work.md"
fi
if [ ! -z "$port" ]; then
echo "**Port**: ${port}" >> "$commands_dir/work.md"
echo "**URL**: http://45.61.58.125:${port}" >> "$commands_dir/work.md"
fi
cat >> "$commands_dir/work.md" <<'EOF'
## What This Agent Does
EOF
# Add core responsibilities if they exist
if [ -f "$agent/README.md" ]; then
sed -n '/^## Core Responsibilities/,/^##/p' "$agent/README.md" | head -n -1 >> "$commands_dir/work.md"
fi
cat >> "$commands_dir/work.md" <<EOF
## When to Use This Command
Use this command when the user wants to:
- Browse, search, or modify code for the ${short_name} agent
- Understand how this agent works
- Debug issues with this agent
- Add features or improvements
- Check configuration or settings
- Review logs or troubleshoot problems
## Your Task
Set your working context to this agent's directory and help the user with whatever they need related to the ${short_name} agent.
**Working Directory**: \`/root/claude/agents/dw-agents/${agent}\`
EOF
echo "Created /${cmd_name} command for ${agent}"
done
echo ""
echo "✅ All agent slash commands created!"
echo ""
echo "Available commands:"
for agent_dir in agent-*/; do
agent="${agent_dir%/}"
[ ! -d "$agent" ] && continue
short_name="${agent#agent-}"
cmd_name=$(echo "$short_name" | sed 's/-team$//' | sed 's/-agent$//' | sed 's/-/_/g')
echo " /${cmd_name} - Work with ${short_name} agent"
done