Manage Claude Code Commands (create, update, delete, list)
Creates, updates, deletes, and lists Claude Code commands with smart defaults.
/plugin marketplace add eLafo/ouroboros/plugin install ouroboros@hermes<operation|name> [args...]Manage Claude Code Commands with CRUD operations.
# Show usage
/commands
/commands help
# Smart default: create if not exists, update if exists
/commands my-command-name
# With description (for create)
/commands my-command "Deploy to environment"
/commands "Deploy to environment" # Infers name from description
# Explicit operations
/commands create my-command
/commands create my-command "Deploy to environment"
/commands update my-command
/commands delete my-command
/commands list
Determine operation from arguments:
OPERATION="$1"
ARTIFACT_NAME="$2"
DESCRIPTION="$3"
# Parse operation
case "$OPERATION" in
""|help)
echo "Usage: /commands <operation|name> [args...]"
echo ""
echo "Operations:"
echo " create <name> [description] - Create new Command"
echo " update <name> - Update existing Command"
echo " delete <name> - Delete Command"
echo " list - List all Commands"
echo ""
echo "Smart default:"
echo " /commands <name> - Create if not exists, update if exists"
echo " /commands <name> <desc> - Create with description"
echo " /commands \"<desc>\" - Create, infer name from description"
exit 0
;;
create)
# Explicit create
OPERATION="create"
ARTIFACT_NAME="$2"
DESCRIPTION="$3"
;;
update)
# Explicit update
OPERATION="update"
ARTIFACT_NAME="$2"
;;
delete)
# Explicit delete
OPERATION="delete"
ARTIFACT_NAME="$2"
;;
list)
# List all commands
OPERATION="list"
;;
*)
# Smart default logic
# If $1 contains spaces or starts with uppercase -> it's a description
if echo "$1" | grep -q " " || echo "$1" | grep -q "^[A-Z]"; then
OPERATION="create"
DESCRIPTION="$1"
ARTIFACT_NAME="" # Will be inferred
else
# $1 is a name
ARTIFACT_NAME="$1"
DESCRIPTION="$2"
# Check if command exists
if [ -f ".claude/commands/$ARTIFACT_NAME.md" ] || [ -f "$HOME/.claude/commands/$ARTIFACT_NAME.md" ]; then
OPERATION="update"
else
OPERATION="create"
fi
fi
;;
esac
Invoke command-builder skill (via /ouroboros:build-command):
if [ "$OPERATION" = "create" ]; then
if [ -n "$ARTIFACT_NAME" ] && [ -n "$DESCRIPTION" ]; then
echo "Creating Command: $ARTIFACT_NAME"
echo "Description: $DESCRIPTION"
elif [ -n "$ARTIFACT_NAME" ]; then
echo "Creating Command: $ARTIFACT_NAME"
elif [ -n "$DESCRIPTION" ]; then
echo "Creating Command from description: $DESCRIPTION"
else
echo "Creating new Command"
fi
fi
Delegation: Use /ouroboros:build-command command which delegates to command-builder skill:
Pass: $ARTIFACT_NAME and $DESCRIPTION (if provided)
Invoke command-builder with update context:
if [ "$OPERATION" = "update" ]; then
echo "Updating Command: $ARTIFACT_NAME"
# Find the command location
if [ -f ".claude/commands/$ARTIFACT_NAME.md" ]; then
COMMAND_PATH=".claude/commands/$ARTIFACT_NAME.md"
elif [ -f "$HOME/.claude/commands/$ARTIFACT_NAME.md" ]; then
COMMAND_PATH="$HOME/.claude/commands/$ARTIFACT_NAME.md"
else
echo "Error: Command '$ARTIFACT_NAME' not found"
exit 1
fi
echo "Found at: $COMMAND_PATH"
fi
Delegation: Invoke command-builder with update context:
Pass: $ARTIFACT_NAME and $COMMAND_PATH
Delete a Command with confirmation:
if [ "$OPERATION" = "delete" ]; then
echo "Deleting Command: $ARTIFACT_NAME"
# Find the command location
if [ -f ".claude/commands/$ARTIFACT_NAME.md" ]; then
COMMAND_FILE=".claude/commands/$ARTIFACT_NAME.md"
elif [ -f "$HOME/.claude/commands/$ARTIFACT_NAME.md" ]; then
COMMAND_FILE="$HOME/.claude/commands/$ARTIFACT_NAME.md"
else
echo "Error: Command '$ARTIFACT_NAME' not found"
exit 1
fi
echo "Found at: $COMMAND_FILE"
echo ""
echo "⚠️ WARNING: This will permanently delete the Command."
echo ""
read -p "Type 'yes' to confirm deletion: " CONFIRM
if [ "$CONFIRM" = "yes" ]; then
rm "$COMMAND_FILE"
echo "✅ Deleted: $COMMAND_FILE"
else
echo "❌ Deletion cancelled"
fi
fi
List all Commands:
if [ "$OPERATION" = "list" ]; then
echo "Claude Code Commands"
echo "===================="
echo ""
# Project commands
if [ -d ".claude/commands" ]; then
echo "Project Commands (.claude/commands/):"
find .claude/commands -name "*.md" -exec sh -c '
COMMAND_NAME=$(basename {} .md)
DESCRIPTION=$(grep "^description:" {} | head -1 | cut -d: -f2- | xargs)
echo " ✓ $COMMAND_NAME"
echo " $DESCRIPTION"
' \;
echo ""
fi
# User commands
if [ -d "$HOME/.claude/commands" ]; then
echo "User Commands (~/.claude/commands/):"
find "$HOME/.claude/commands" -name "*.md" -exec sh -c '
COMMAND_NAME=$(basename {} .md)
DESCRIPTION=$(grep "^description:" {} | head -1 | cut -d: -f2- | xargs)
echo " ✓ $COMMAND_NAME"
echo " $DESCRIPTION"
' \;
fi
fi
For CREATE operation:
For UPDATE operation:
For DELETE operation:
For LIST operation: