Mastermind repeat

From monoes/monomind · View interactive version

Mastermind repeat is an AI agent skill from the GitHub repository monoes/monomind. Repeat postamble: continues --repeat/--tillend loops after a mastermind command finishes, scheduling a wakeup while work remains.

How to use this skill

Skill file

REPEAT POSTAMBLE

<EXTREMELY-IMPORTANT>

MANDATORY EXECUTION — READ THIS FIRST

This postamble is not optional. You MUST execute every step below. You MUST call ScheduleWakeup unless a legitimate stop condition is met (stop file, empty round confirmed by git, or count reached).

Anti-rationalization rules:

If you are about to end your response without calling ScheduleWakeup and you have not hit a legitimate stop condition, YOU ARE MAKING AN ERROR. Go back and call ScheduleWakeup.

</EXTREMELY-IMPORTANT>

If neither tillend_mode = true nor repeat_count ≥ 2 was active in this invocation, stop immediately — this skill is a no-op.

Otherwise execute all steps below before ending the response.


Step 1 — Stop check

[ -f ".monomind/loops/${LOOP_ID}.stop" ] && echo "STOP_REQUESTED"

If the stop file exists:


Step 2 — Tillend termination check (tillend mode only — skip for fixed-count)

LOOP_ASYNC_PENDING escape hatch: If the calling skill set LOOP_ASYNC_PENDING=true before invoking this postamble (because it spawned background agents whose results have not yet arrived), skip the empty-round check and go directly to Step 4 to schedule the next run. Output: [tillend] Async work in flight — deferring empty-round check to run <next_rep>.

Step 2a — Machine verification (REQUIRED before any self-assessment):

Run this command to get an objective signal of whether files changed during this run:

GIT_CHANGES=$(git diff --stat HEAD 2>/dev/null; git diff --cached --stat 2>/dev/null; git status --porcelain 2>/dev/null | grep -v '^\?\?' | head -20)
echo "GIT_CHANGES_DURING_RUN: ${GIT_CHANGES:-NONE}"

If GIT_CHANGES is non-empty, files were modified — TILLEND_EMPTY=false regardless of your self-assessment. Skip to "Otherwise" below.

Step 2b — Self-assessment (only if git shows no changes):

Only if GIT_CHANGES was empty, evaluate whether this run produced findings (issues identified, problems flagged) or actions (tasks created, content written, configs changed — anything not captured by git diff).

Set TILLEND_EMPTY=true only if git shows no changes AND your self-assessment confirms zero findings and zero actions.

Important: If this round found things AND fixed them, TILLEND_EMPTY=false — the loop must continue to verify the fixes didn't introduce new issues.

If TILLEND_EMPTY=true:

```

[tillend] Empty round — nothing found, nothing changed in run <current_rep>.

/<command> tillend loop complete (ran <current_rep> run(s)).

```

If current_rep >= tillend_maxruns (safety cap reached):

```

[tillend] Safety cap reached (<tillend_maxruns> runs). Stopping loop.

If work is still incomplete, re-run: /<command> --tillend --maxruns <N> <prompt>

```

Otherwise (TILLEND_EMPTY=false, cap not reached):


Step 3 — Fixed-count completion check (fixed-count mode only — skip for tillend)

If current_rep >= repeat_count:


Step 4 — Schedule next run (REQUIRED tool call — cannot be skipped)

Compute next_rep = current_rep + 1.

Update state file:

NOW_MS=$(python3 -c 'import time;print(int(time.time()*1000))' 2>/dev/null || echo "$(date +%s)000")
NEXT_AT=$(( NOW_MS + <wait_seconds> * 1000 ))
INTERVAL_MIN=$(( (<wait_seconds> + 30) / 60 ))
LOOP_TYPE=$( [ "<tillend_mode>" = "true" ] && echo "tillend" || echo "repeat" )
MAX_REPS=$( [ "<tillend_mode>" = "true" ] && echo "<tillend_maxruns>" || echo "<repeat_count>" )
PROMPT_JSON=$(jq '.prompt' ".monomind/loops/${LOOP_ID}.json" 2>/dev/null \
  || python3 -c "import json; print(json.dumps(json.load(open('.monomind/loops/${LOOP_ID}.json'))['prompt']))" 2>/dev/null \
  || echo '"<prompt>"')
STARTED_AT=$(jq '.startedAt' ".monomind/loops/${LOOP_ID}.json" 2>/dev/null || echo "${NOW_MS}")
cat > ".monomind/loops/${LOOP_ID}.json" << EOF
{
  "id": "${LOOP_ID}",
  "sessionId": "${LOOP_ID}",
  "type": "${LOOP_TYPE}",
  "command": "/<command>",
  "prompt": ${PROMPT_JSON},
  "maxReps": ${MAX_REPS},
  "interval": ${INTERVAL_MIN},
  "wait": <wait_seconds>,
  "currentRep": <next_rep>,
  "startedAt": ${STARTED_AT},
  "lastRunAt": ${NOW_MS},
  "nextRunAt": ${NEXT_AT},
  "status": "running",
  "source": "mastermind-repeat/SKILL.md"
}
EOF

Call ScheduleWakeup now — this is a mandatory tool call:

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.