checkpoint-workflow-builder
Build resumable state-machine workflows with checkpoint patterns, progress preservation, and automatic recovery for complex multi-phase operations that need to survive interruptions, timeouts, and failures.
What this skill does
# Checkpoint Workflow Builder
Design and implement fault-tolerant workflows that can resume from any point of failure.
## Overview
Complex workflows often fail mid-execution due to:
- Network timeouts
- System crashes
- Resource exhaustion
- External service failures
- User interruptions
This skill teaches you to build workflows that:
- Save progress at key checkpoints
- Resume from last successful state
- Handle partial failures gracefully
- Provide clear progress visibility
- Enable manual intervention points
## When to Use
Use this skill when:
- Building multi-phase data pipelines
- Implementing long-running migration scripts
- Creating deployment workflows
- Processing large batches of items
- Orchestrating multi-system operations
- Building ETL (Extract, Transform, Load) workflows
- Implementing saga patterns for distributed systems
- Creating user-facing wizards with save/resume
## Core Concepts
### State Machine Pattern
```
┌─────────┐
│ INIT │
└────┬────┘
│
▼
┌────────────┐
│ DOWNLOAD │
└─────┬──────┘
│
▼
┌────────────┐
│ PROCESS │
└─────┬──────┘
│
▼
┌────────────┐
│ VALIDATE │
└─────┬──────┘
│
▼
┌────────────┐
│ FINALIZE │
└─────┬──────┘
│
▼
┌────────────┐
│ COMPLETE │
└────────────┘
```
Each state:
- Has clear entry conditions
- Performs specific operations
- Saves checkpoint before transition
- Can be resumed independently
## Basic Implementation
### Simple State Machine
```bash
#!/bin/bash
# state-machine.sh - Basic resumable workflow
STATE_FILE=".workflow_state"
# Read current state (default: INIT)
CURRENT_STATE=$(cat "$STATE_FILE" 2>/dev/null || echo "INIT")
echo "Current state: $CURRENT_STATE"
case "$CURRENT_STATE" in
INIT)
echo "=== Phase 1: Initialization ==="
# Initialize workspace
mkdir -p workspace
mkdir -p results
# Download dependencies
echo "Setting up environment..."
# Save next state
echo "DOWNLOAD" > "$STATE_FILE"
echo "✓ Initialization complete"
echo "Run again to continue"
;;
DOWNLOAD)
echo "=== Phase 2: Download Data ==="
# Download data files
echo "Downloading data..."
# curl -o workspace/data.zip https://example.com/data.zip
# Verify download
if [ -f "workspace/data.zip" ]; then
echo "EXTRACT" > "$STATE_FILE"
echo "✓ Download complete"
echo "Run again to continue"
else
echo "✗ Download failed - fix and run again"
exit 1
fi
;;
EXTRACT)
echo "=== Phase 3: Extract Data ==="
# Extract files
echo "Extracting data..."
# unzip workspace/data.zip -d workspace/
echo "PROCESS" > "$STATE_FILE"
echo "✓ Extraction complete"
echo "Run again to continue"
;;
PROCESS)
echo "=== Phase 4: Process Data ==="
# Process data
echo "Processing data..."
# ./process_data.sh workspace/ results/
echo "VALIDATE" > "$STATE_FILE"
echo "✓ Processing complete"
echo "Run again to continue"
;;
VALIDATE)
echo "=== Phase 5: Validate Results ==="
# Validate results
echo "Validating results..."
# ./validate.sh results/
if [ $? -eq 0 ]; then
echo "FINALIZE" > "$STATE_FILE"
echo "✓ Validation passed"
echo "Run again to finalize"
else
echo "✗ Validation failed"
echo "Fix issues and change state to PROCESS to reprocess"
exit 1
fi
;;
FINALIZE)
echo "=== Phase 6: Finalize ==="
# Cleanup and finalize
echo "Finalizing workflow..."
# mv results/ final/
# rm -rf workspace/
echo "COMPLETE" > "$STATE_FILE"
echo "✓ Workflow complete!"
;;
COMPLETE)
echo "=== Workflow Already Complete ==="
echo "Results available in: final/"
;;
*)
echo "✗ Unknown state: $CURRENT_STATE"
echo "Reset with: echo 'INIT' > $STATE_FILE"
exit 1
;;
esac
```
### Enhanced with Progress Tracking
```bash
#!/bin/bash
# enhanced-state-machine.sh - With detailed progress
STATE_FILE=".workflow_state"
PROGRESS_FILE=".workflow_progress.json"
# Initialize progress tracking
init_progress() {
cat > "$PROGRESS_FILE" << EOF
{
"current_state": "INIT",
"started_at": "$(date -Iseconds)",
"updated_at": "$(date -Iseconds)",
"phases": {
"INIT": {"status": "pending", "started": null, "completed": null},
"DOWNLOAD": {"status": "pending", "started": null, "completed": null},
"PROCESS": {"status": "pending", "started": null, "completed": null},
"VALIDATE": {"status": "pending", "started": null, "completed": null},
"FINALIZE": {"status": "pending", "started": null, "completed": null}
}
}
EOF
}
# Update progress
update_progress() {
local state="$1"
local status="$2" # "running", "completed", "failed"
local timestamp="$(date -Iseconds)"
if [ ! -f "$PROGRESS_FILE" ]; then
init_progress
fi
jq --arg state "$state" \
--arg status "$status" \
--arg timestamp "$timestamp" \
'.current_state = $state |
.updated_at = $timestamp |
.phases[$state].status = $status |
(.phases[$state].started //= $timestamp) |
(if $status == "completed" then .phases[$state].completed = $timestamp else . end)' \
"$PROGRESS_FILE" > "$PROGRESS_FILE.tmp"
mv "$PROGRESS_FILE.tmp" "$PROGRESS_FILE"
}
# Show progress
show_progress() {
if [ ! -f "$PROGRESS_FILE" ]; then
echo "No progress file found"
return
fi
echo "=== Workflow Progress ==="
echo ""
jq -r '.phases | to_entries | .[] |
"[\(.value.status | ascii_upcase)] \(.key)" +
(if .value.started then " (started: " + .value.started + ")" else "" end)' \
"$PROGRESS_FILE"
echo ""
echo "Current: $(jq -r '.current_state' $PROGRESS_FILE)"
echo "Updated: $(jq -r '.updated_at' $PROGRESS_FILE)"
}
# Workflow implementation
run_workflow() {
CURRENT_STATE=$(cat "$STATE_FILE" 2>/dev/null || echo "INIT")
# Show progress before executing
show_progress
case "$CURRENT_STATE" in
INIT)
update_progress "INIT" "running"
echo "Initializing..."
# ... initialization logic ...
update_progress "INIT" "completed"
echo "DOWNLOAD" > "$STATE_FILE"
;;
DOWNLOAD)
update_progress "DOWNLOAD" "running"
echo "Downloading..."
# ... download logic ...
update_progress "DOWNLOAD" "completed"
echo "PROCESS" > "$STATE_FILE"
;;
# ... other states ...
esac
}
run_workflow
```
## Advanced Patterns
### Pattern 1: Batched Checkpoint
```bash
#!/bin/bash
# batched-checkpoint.sh - Process items with batch checkpoints
ITEMS_FILE="items.txt"
CHECKPOINT_FILE=".batch_checkpoint"
BATCH_SIZE=10
# Load checkpoint
if [ -f "$CHECKPOINT_FILE" ]; then
LAST_COMPLETED=$(cat "$CHECKPOINT_FILE")
echo "Resuming from item $LAST_COMPLETED"
else
LAST_COMPLETED=0
fi
TOTAL_ITEMS=$(wc -l < "$ITEMS_FILE")
ITEMS_PROCESSED=0
# Process in batches
tail -n +$((LAST_COMPLETED + 1)) "$ITEMS_FILE" | while read -r item; do
# Process item
echo "Processing: $item"
process_item "$item"
ITEMS_PROCESSED=$((ITEMS_PROCESSED + 1))
# Checkpoint every batch
if [ $((ITEMS_PROCESSED % BATCH_SIZE)) -eq 0 ]; then
CURRENT_POSITION=$((LAST_COMPLETED + ITEMS_PROCESSED))
echo "$CURRENT_POSITION" > "$CHECKPOINT_FILE"
echo "Checkpoint: $CURRENT_POSITION/$TOTAL_ITEMS"
# Optional: Break for timeout management
if [ $((ITEMS_PROCESSED)) -ge $((BATCH_SIZE * 5)) ]; then
echo "Processed 5 baRelated in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.