// Use this skill when creating automated multi-phase workflows for development tasks using claude-flow orchestration. Implements patterns for implementation kickoff, verification, retry loops, and failure recovery.
| name | creating-workflows |
| description | Use this skill when creating automated multi-phase workflows for development tasks using claude-flow orchestration. Implements patterns for implementation kickoff, verification, retry loops, and failure recovery. |
Comprehensive guidance for building automated development workflows using claude-flow orchestration, multi-agent coordination, and intelligent verification systems.
This skill should be triggered when:
Critical Requirement: Workflow scripts must not depend on interactive shell configuration.
Why: Shell aliases and functions don't propagate to subprocess environments (n8n workflows, cron jobs, systemd services).
jelmore provides a unified CLI for LLM invocations with shell context independence built-in. Use jelmore instead of calling LLM clients directly when building workflows.
Why Use jelmore in Workflows:
Location: /home/delorenj/code/jelmore
Basic Usage in Workflows:
# Instead of: npx claude-flow@alpha swarm "$objective" --claude
# Use jelmore with auto-inference:
uv run jelmore execute -p "$objective" --auto
# Instead of: gptme --model $KK "$task"
# Use jelmore with explicit client:
uv run jelmore execute -f task.md --client gptme --model-tier balanced
# For PR review workflows:
uv run jelmore execute --config pr-review.json --var PR_NUMBER=$pr_num --json
Implementation Patterns:
~/.local/bin/ with explicit PATH exportsSee:
ecosystem-patterns skill - jelmore architecture and patternsbloodbank-n8n-event-driven-workflows skill - Event-driven integration/home/delorenj/code/jelmore/CLI.md - Complete CLI referenceWorkflows split into distinct phases with different execution strategies:
When Phase 2 fails, retry Phase 1 with failure context:
Processes that don't properly report errors require explicit monitoring:
Critical: claude-flow@alpha v2.7.26+ does NOT support workflow execute command.
Available Commands:
swarm <objective> - Multi-agent coordination with parallel executionsparc <mode> - SPARC methodology (spec, architect, tdd, integration)stream-chain - Chain multiple Claude instances with context preservationagent <action> - Agent management (spawn, list, terminate)#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "${SCRIPT_DIR}/../.." && pwd)"
# Colors for output
GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'
# Parse CLI arguments
TASK_FILE="${PROJECT_ROOT}/TASK.md"
PHASE="all"
MAX_RETRIES=2
RETRY_ENABLED=true
DRY_RUN=false
# Parse flags (--task, --phase, --max-retries, --no-retry, --dry-run, --help)
# Implement usage() function
# Validate inputs
run_phase1() {
local attempt=$1
local context_override="${2:-$CONTEXT}"
echo -e "${GREEN}Running Phase 1: Implementation${NC}"
if [[ $attempt -gt 1 ]]; then
echo -e "${BLUE}Retry attempt $((attempt - 1))/${MAX_RETRIES}${NC}"
fi
# jelmore execution with JSON output
local jelmore_output
jelmore_output=$(uv run jelmore execute \
--file "$TASK_FILE" \
--auto \
--json 2>&1)
local exit_code=$?
# Parse jelmore response
if [[ $exit_code -eq 0 ]]; then
local session_name=$(echo "$jelmore_output" | jq -r '.session_name')
local execution_id=$(echo "$jelmore_output" | jq -r '.execution_id')
local log_path=$(echo "$jelmore_output" | jq -r '.log_path')
echo -e "${GREEN}โ Execution started${NC}"
echo " Session: $session_name"
echo " Execution ID: $execution_id"
echo " Logs: $log_path"
echo ""
echo " Attach: zellij attach $session_name"
# Store for later reference
export JELMORE_SESSION="$session_name"
export JELMORE_EXECUTION_ID="$execution_id"
export JELMORE_LOG_PATH="$log_path"
else
echo -e "${RED}Error: jelmore execution failed${NC}"
echo "$jelmore_output"
return 1
fi
return 0
}
Alternative: Phase 1 with Claude-Flow Swarm (Legacy Pattern)
run_phase1_legacy() {
local attempt=$1
local context_override="${2:-$CONTEXT}"
echo -e "${GREEN}Running Phase 1: Implementation${NC}"
if [[ $attempt -gt 1 ]]; then
echo -e "${BLUE}Retry attempt $((attempt - 1))/${MAX_RETRIES}${NC}"
fi
# Read task content
local task_content
if [[ -f "$TASK_FILE" ]]; then
task_content=$(cat "$TASK_FILE")
else
echo -e "${RED}Error: Task file not found: $TASK_FILE${NC}"
return 1
fi
# Build objective with context
local objective="$task_content"
if [[ -n "$context_override" ]]; then
objective="$objective\n\nAdditional Context: $context_override"
fi
# Execute swarm (opens Claude Code CLI)
npx claude-flow@alpha swarm "$objective" \
--strategy development \
--parallel \
--max-agents 5 \
--claude
return $?
}
run_phase2() {
echo -e "${GREEN}Running Phase 2: Verification${NC}"
local phase2_failed=false
# Step 1: Backend startup with log monitoring
echo -e "${BLUE}[Step 1/N] Starting backend...${NC}"
# Start process in background
your_start_command > /tmp/backend.log 2>&1 &
local backend_pid=$!
# Watch logs for success indicator (30s timeout)
local timeout=30
local elapsed=0
local backend_started=false
while [[ $elapsed -lt $timeout ]]; do
# Check for success pattern
if grep -q "SUCCESS_PATTERN" /tmp/backend.log 2>/dev/null; then
backend_started=true
echo -e "${GREEN}โ Backend started${NC}"
break
fi
# Check for error patterns
if grep -qi "error\|failed" /tmp/backend.log 2>/dev/null; then
echo -e "${RED}โ Backend errors detected${NC}"
cat /tmp/backend.log
phase2_failed=true
break
fi
sleep 1
elapsed=$((elapsed + 1))
done
if [[ "$backend_started" == "false" && "$phase2_failed" == "false" ]]; then
echo -e "${RED}โ Backend startup timed out${NC}"
cat /tmp/backend.log
phase2_failed=true
fi
if [[ "$phase2_failed" == "true" ]]; then
return 1
fi
# Step 2: Additional verification steps
# ...
echo -e "${GREEN}โ Phase 2 complete${NC}"
return 0
}
case "$PHASE" in
all|*)
ATTEMPT=1
PHASE1_SUCCESS=false
PHASE2_SUCCESS=false
while [[ $ATTEMPT -le $((MAX_RETRIES + 1)) ]]; do
echo -e "${YELLOW}โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ${NC}"
echo -e "${YELLOW}Workflow Attempt ${ATTEMPT}/$((MAX_RETRIES + 1))${NC}"
echo -e "${YELLOW}โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ${NC}"
# Phase 1 with retry context
RETRY_CONTEXT="$CONTEXT"
if [[ $ATTEMPT -gt 1 ]]; then
RETRY_CONTEXT="$CONTEXT | RETRY: Previous Phase 2 verification failed. Review logs and address failures."
fi
run_phase1 $ATTEMPT "$RETRY_CONTEXT"
PHASE1_EXIT=$?
if [[ $PHASE1_EXIT -ne 0 ]]; then
echo -e "${RED}Phase 1 failed with exit code $PHASE1_EXIT${NC}"
if [[ "$RETRY_ENABLED" == "false" || $ATTEMPT -gt $MAX_RETRIES ]]; then
echo -e "${RED}No more retries. Exiting.${NC}"
exit $PHASE1_EXIT
fi
ATTEMPT=$((ATTEMPT + 1))
continue
fi
PHASE1_SUCCESS=true
echo -e "${GREEN}โ Phase 1 completed${NC}"
# Phase 2
run_phase2
PHASE2_EXIT=$?
if [[ $PHASE2_EXIT -ne 0 ]]; then
if [[ $ATTEMPT -ge $((MAX_RETRIES + 1)) ]]; then
# Exhausted retries - provide guidance
echo -e "${YELLOW}โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ${NC}"
echo -e "${YELLOW}Retry Summary:${NC}"
echo " Total attempts: $ATTEMPT"
echo " Phase 1: ${GREEN}โ Success${NC}"
echo " Phase 2: ${RED}โ Failed${NC}"
echo -e "${BLUE}Next steps:${NC}"
echo " 1. Review Phase 2 logs"
echo " 2. Manually investigate failures"
echo " 3. Run Phase 2 only: $0 --phase 2"
echo " 4. Increase retries: $0 --max-retries 5"
exit $PHASE2_EXIT
fi
echo -e "${BLUE}Phase 2 Failed - Triggering Retry${NC}"
echo -e "${YELLOW}Looping back to Phase 1 with failure context...${NC}"
ATTEMPT=$((ATTEMPT + 1))
sleep 2
continue
fi
# Success
PHASE2_SUCCESS=true
break
done
# Final status
if [[ "$PHASE1_SUCCESS" == "true" && "$PHASE2_SUCCESS" == "true" ]]; then
echo -e "${GREEN}โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ${NC}"
echo -e "${GREEN}โ
Workflow completed successfully${NC}"
echo -e "${GREEN}โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ${NC}"
if [[ $ATTEMPT -gt 1 ]]; then
echo -e "${BLUE}Success after $((ATTEMPT - 1)) retry attempt(s)${NC}"
fi
exit 0
fi
;;
esac
if [[ "$DRY_RUN" == "true" ]]; then
echo -e "${YELLOW}DRY RUN MODE${NC}"
echo "Would execute Phase 1:"
echo " npx claude-flow@alpha swarm \"\$(cat $TASK_FILE)\" \\"
echo " --strategy development \\"
echo " --parallel \\"
echo " --max-agents 5 \\"
echo " --claude"
echo ""
echo "Would execute Phase 2:"
echo " 1. Start backend (with log monitoring)"
echo " 2. Build artifacts"
echo " 3. Run verification checks"
if [[ "$RETRY_ENABLED" == "true" ]]; then
echo ""
echo "Retry loop: Phase 2 failures retry Phase 1 (max $MAX_RETRIES attempts)"
fi
exit 0
fi
Problem: Process managers (mise, pm2, etc.) often return success even when compilation fails.
Solution: Monitor logs for explicit success indicators.
# Start process
mise start > /tmp/service.log 2>&1 &
# Monitor for success pattern
while [[ $elapsed -lt $timeout ]]; do
if grep -q "Accepted new IPC connection" /tmp/service.log; then
echo "โ Service started"
break
fi
if grep -qi "error|compilation failed" /tmp/service.log; then
echo "โ Service failed"
cat /tmp/service.log
exit 1
fi
sleep 1
elapsed=$((elapsed + 1))
done
Problem: Builds may appear successful but produce incomplete artifacts.
Solution: Explicitly verify required files exist.
required_files=(
"dist/manifest.json"
"dist/bundle.js"
"dist/styles.css"
)
for file in "${required_files[@]}"; do
if [[ ! -f "$file" ]]; then
echo "โ Required file missing: $file"
exit 1
fi
done
echo "โ All artifacts present"
Problem: Some verification steps can't be automated (UI testing, Chrome extension reload).
Solution: Provide clear instructions and wait for confirmation.
echo -e "${BLUE}[Step N/N] Manual Verification Required${NC}"
echo -e "${YELLOW}Please complete these steps:${NC}"
echo " 1. Open chrome://extensions"
echo " 2. Enable 'Developer mode'"
echo " 3. Find extension and click 'Reload'"
echo " 4. Test on target page"
echo ""
echo -e "${YELLOW}Press Enter when complete, or Ctrl+C to abort...${NC}"
read -r
echo -e "${GREEN}โ Manual verification complete${NC}"
Problem: Retries without context repeat the same mistakes.
Solution: Append failure information to task context.
RETRY_CONTEXT="$CONTEXT"
if [[ $ATTEMPT -gt 1 ]]; then
RETRY_CONTEXT="$CONTEXT | RETRY: Previous Phase 2 verification failed. Specific failure: $FAILURE_REASON. Review verification logs at $LOG_PATH and address these issues."
fi
run_phase1 $ATTEMPT "$RETRY_CONTEXT"
Problem: Failures without guidance leave users stuck.
Solution: Provide actionable next steps on failure.
if [[ $MAX_RETRIES_EXHAUSTED == true ]]; then
echo -e "${YELLOW}โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ${NC}"
echo -e "${YELLOW}Retry Summary:${NC}"
echo " Total attempts: $ATTEMPT"
echo " Phase 1 status: ${GREEN}โ Success${NC}"
echo " Phase 2 status: ${RED}โ Failed${NC}"
echo ""
echo -e "${BLUE}Next steps:${NC}"
echo " 1. Review Phase 2 logs in $LOG_DIR"
echo " 2. Check backend/service status: ps aux | grep service"
echo " 3. Run Phase 2 only: $0 --phase 2"
echo " 4. Increase retries: $0 --max-retries 5"
echo " 5. Contact team if issue persists: #dev-support"
fi
Create a comprehensive markdown document (e.g., workflow-name.md) with:
Create a concise one-page reference (e.g., QUICK-REFERENCE.md) with:
Create README.md in workflows directory with:
After execution, generate report with:
-t, --task FILE Task specification file (default: TASK.md)
-c, --context STRING Additional context for requirements
-p, --phase PHASE Run specific phase only (1, 2, etc.)
-s, --skip-verification Skip Phase N verification
-r, --max-retries N Max retry attempts on failure (default: 2)
--no-retry Disable retry loop (fail immediately)
-d, --dry-run Show what would be executed
-h, --help Show help message
usage() {
cat <<EOF
Usage: $0 [options]
Execute the ${WORKFLOW_NAME} workflow
Phases:
Phase 1: ${PHASE1_DESCRIPTION}
Phase 2: ${PHASE2_DESCRIPTION}
Options:
-t, --task FILE Task specification file (default: TASK.md)
-c, --context STRING Additional context
-p, --phase PHASE Run specific phase (1 or 2)
-r, --max-retries N Max retries (default: 2)
--no-retry Disable retry loop
-d, --dry-run Preview without execution
-h, --help Show this message
Examples:
# Full workflow with retry
$0 --task TASK.md
# Phase 1 only
$0 --task TASK.md --phase 1
# Disable retry
$0 --task TASK.md --no-retry
# Preview execution
$0 --task TASK.md --dry-run
EOF
exit 1
}
Always implement and test dry-run mode:
./workflow-script.sh --dry-run
# Should show commands without executing
# Verify output matches expected execution plan
Test each phase independently:
# Test Phase 1 in isolation
./workflow-script.sh --task TASK.md --phase 1
# Test Phase 2 in isolation (requires Phase 1 artifacts)
./workflow-script.sh --phase 2
Test retry behavior with intentional failures:
# Modify Phase 2 to fail temporarily
# Run full workflow
./workflow-script.sh --task TASK.md
# Verify:
# - Phase 1 executes
# - Phase 2 fails
# - Phase 1 re-executes with failure context
# - Loop continues until max retries
# - Comprehensive failure summary appears
Test failure detection:
# Modify backend to fail compilation
# Run workflow
./workflow-script.sh --task TASK.md --phase 2
# Verify:
# - Detects compilation errors in logs
# - Fails with clear error message
# - Shows relevant log excerpts
Best for: Multi-agent implementation workflows
npx claude-flow@alpha swarm "$objective" \
--strategy development \ # Options: research, development, testing, optimization
--parallel \ # Enable parallel execution (2.8-4.4x speedup)
--max-agents 5 \ # Limit concurrent agents
--claude # Open Claude Code CLI (default: built-in executor)
Best for: Structured development phases (spec, architect, tdd)
npx claude-flow@alpha sparc spec "$task" # Requirements analysis
npx claude-flow@alpha sparc architect "$task" # System design
npx claude-flow@alpha sparc tdd "$task" # Test-driven implementation
Best for: Sequential workflows with context preservation
npx claude-flow@alpha stream-chain run \
"analyze requirements" \
"design architecture" \
"implement solution"
This skill includes comprehensive documentation in references/:
Use these references when building new workflows.
Start with the template:
workflow-script-template.sh from assets/--dry-run firstImplement patterns:
Optimize and extend:
Problem: Documentation may reference commands that don't exist in your version.
Solution: Always verify with --help:
npx claude-flow@alpha --help
npx claude-flow@alpha swarm --help
Problem: Process returns success but actually failed.
Solution: Never trust exit codes alone. Monitor logs for explicit success patterns.
Problem: Retries repeat identical failures.
Solution: Always inject failure context into retry attempts.
Problem: Users don't know what to do when workflow fails.
Solution: Provide specific next steps, log locations, and troubleshooting commands.
Problem: Can't preview workflow without executing.
Solution: Always implement --dry-run mode that shows commands without running them.
references/ - Detailed pattern documentationassets/ - Templates and examplesscripts/ - Helper utilities