Prompt #156

Back to prompts
Write glug bin wf-* Script
Code Β· openai/gpt-4.1
4/5
Variables
operation_name, operation_description, endpoint
Tags
stack-aware,glug,workflow,bin,scripting,cron,idempotent
Source
research-2026-05-01-stack-aware
Use count
0
Created
2026-05-01T18:30:48.776731+00:00
Updated
2026-05-01T18:30:48.776731+00:00

Content

Write a workflow script bin/wf-{operation_name}.sh for a recurring glug-server operation.

Pattern: all wf-*.sh scripts in glug/bin/ follow this structure:
1. Shebang + set -euo pipefail
2. Source bin/agent-prelude.sh (sets GLUG_TOKEN, BASE_URL, LOG_DIR)
3. Idempotent: check if already run today (touch /tmp/wf-{operation_name}.lock)
4. HTTP call using $GLUG_TOKEN for auth:
   `curl -sS -X POST "$BASE_URL/api/v1/glug/{endpoint}"      -H "Authorization: Bearer $GLUG_TOKEN"      -d '{{...}}'`
5. Log output to $LOG_DIR/wf-{operation_name}-$(date +%Y%m%d).log
6. Exit 0 on success, non-zero on failure (triggers agent-cron alert)

For operation: {operation_description}
Endpoint: /api/v1/glug/{endpoint}
Schedule: add to /etc/cron.d/glug-cron or as systemd timer