fix(sync): update landing sync script for new directory structure

- Change examples.html → examples/index.html
- Change quiz.html → quiz/index.html
- Add fresh-context-loop.sh script

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Florian BRUNIAUX 2026-01-17 15:42:03 +01:00
parent 4a79455c4d
commit 6f968dbfc5
2 changed files with 105 additions and 9 deletions

View file

@ -0,0 +1,96 @@
#!/usr/bin/env bash
# Fresh Context Loop - Ralph Wiggum pattern for Claude Code
#
# Solves context rot by spawning fresh Claude instances per task iteration.
# State persists via TASK.md, PROGRESS.md, and git commits.
#
# Usage: ./fresh-context-loop.sh [max_iterations] [task_file] [progress_file]
#
# Sources:
# - Pattern: https://block.github.io/goose/docs/tutorials/ralph-loop/
# - Research: https://research.trychroma.com/context-rot
set -euo pipefail
MAX_ITERATIONS=${1:-10}
TASK_FILE=${2:-"TASK.md"}
PROGRESS_FILE=${3:-"PROGRESS.md"}
# Validate prerequisites
if [[ ! -f "$TASK_FILE" ]]; then
echo "❌ Missing $TASK_FILE"
echo ""
echo "Create a TASK.md with:"
echo " ## Current Focus"
echo " [Single atomic task]"
echo ""
echo " ## Acceptance Criteria"
echo " - [ ] Tests pass"
echo " - [ ] Build succeeds"
exit 1
fi
# Create progress file if missing
[[ ! -f "$PROGRESS_FILE" ]] && touch "$PROGRESS_FILE"
echo "🔄 Fresh Context Loop"
echo " Max iterations: $MAX_ITERATIONS"
echo " Task file: $TASK_FILE"
echo " Progress file: $PROGRESS_FILE"
echo ""
for i in $(seq 1 "$MAX_ITERATIONS"); do
echo "═══════════════════════════════════════"
echo " Iteration $i/$MAX_ITERATIONS"
echo "═══════════════════════════════════════"
echo ""
# Fresh context each iteration (no -c flag = new session)
claude -p "$(cat "$TASK_FILE" "$PROGRESS_FILE")
---
INSTRUCTIONS FOR THIS ITERATION:
1. Read the task and progress above carefully
2. Complete the NEXT incomplete task only (one at a time)
3. Run tests/build to verify your changes work
4. Update $PROGRESS_FILE with:
- What you completed
- Any blockers encountered
- What should be done next
5. If ALL tasks are complete and verified, add this exact line to $PROGRESS_FILE:
LOOP_COMPLETE
IMPORTANT:
- Focus on ONE task per iteration
- Always verify before marking complete
- Commit your changes before the iteration ends"
echo ""
# Check completion marker
if grep -q "LOOP_COMPLETE" "$PROGRESS_FILE" 2>/dev/null; then
echo ""
echo "✅ All tasks completed in $i iterations"
exit 0
fi
# Auto-commit progress if changes exist
if ! git diff --quiet "$PROGRESS_FILE" 2>/dev/null; then
git add "$PROGRESS_FILE"
git commit -m "chore: update progress (iteration $i)" --no-verify 2>/dev/null || true
fi
# Auto-commit any other staged changes
if ! git diff --cached --quiet 2>/dev/null; then
git commit -m "feat: iteration $i progress" --no-verify 2>/dev/null || true
fi
echo ""
echo "─────────────────────────────────────────"
echo ""
done
echo "⚠️ Max iterations ($MAX_ITERATIONS) reached without completion"
echo " Check $PROGRESS_FILE for status"
exit 1

View file

@ -51,13 +51,13 @@ TEMPLATE_COUNT=$(find "$GUIDE_DIR/examples" -type f \( -name "*.md" -o -name "*.
# Check index.html
LANDING_TEMPLATES_INDEX=$(grep -oE '[0-9]+ Templates' "$LANDING_DIR/index.html" | head -1 | grep -oE '[0-9]+')
# Check examples.html
LANDING_TEMPLATES_EXAMPLES=$(grep -oE '[0-9]+ Templates' "$LANDING_DIR/examples.html" | head -1 | grep -oE '[0-9]+')
# Check examples/index.html
LANDING_TEMPLATES_EXAMPLES=$(grep -oE '[0-9]+ Templates' "$LANDING_DIR/examples/index.html" | head -1 | grep -oE '[0-9]+')
echo -e "${BLUE}2. Templates Count${NC}"
echo " Guide: $TEMPLATE_COUNT files"
echo " index.html: $LANDING_TEMPLATES_INDEX"
echo " examples.html: $LANDING_TEMPLATES_EXAMPLES"
echo " examples/index.html: $LANDING_TEMPLATES_EXAMPLES"
TEMPLATES_OK=true
if [ "$TEMPLATE_COUNT" != "$LANDING_TEMPLATES_INDEX" ]; then
@ -65,7 +65,7 @@ if [ "$TEMPLATE_COUNT" != "$LANDING_TEMPLATES_INDEX" ]; then
TEMPLATES_OK=false
fi
if [ "$TEMPLATE_COUNT" != "$LANDING_TEMPLATES_EXAMPLES" ]; then
echo -e " ${YELLOW}MISMATCH in examples.html${NC}"
echo -e " ${YELLOW}MISMATCH in examples/index.html${NC}"
TEMPLATES_OK=false
fi
if [ "$TEMPLATES_OK" = true ]; then
@ -85,12 +85,12 @@ QUESTIONS_COUNT=$(grep -cE '"id": "[0-9]+-[0-9]+"' "$LANDING_DIR/questions.json"
# Check what landing pages say
LANDING_QUESTIONS_INDEX=$(grep -oE '[0-9]+ quiz questions' "$LANDING_DIR/index.html" | head -1 | grep -oE '[0-9]+')
LANDING_QUESTIONS_QUIZ=$(grep -oE '[0-9]+ Questions' "$LANDING_DIR/quiz.html" | head -1 | grep -oE '[0-9]+')
LANDING_QUESTIONS_QUIZ=$(grep -oE '[0-9]+ Questions' "$LANDING_DIR/quiz/index.html" | head -1 | grep -oE '[0-9]+')
echo -e "${BLUE}3. Quiz Questions${NC}"
echo " questions.json: $QUESTIONS_COUNT"
echo " index.html: $LANDING_QUESTIONS_INDEX"
echo " quiz.html: $LANDING_QUESTIONS_QUIZ"
echo " quiz/index.html: $LANDING_QUESTIONS_QUIZ"
QUESTIONS_OK=true
if [ "$QUESTIONS_COUNT" != "$LANDING_QUESTIONS_INDEX" ]; then
@ -98,7 +98,7 @@ if [ "$QUESTIONS_COUNT" != "$LANDING_QUESTIONS_INDEX" ]; then
QUESTIONS_OK=false
fi
if [ "$QUESTIONS_COUNT" != "$LANDING_QUESTIONS_QUIZ" ]; then
echo -e " ${YELLOW}MISMATCH in quiz.html${NC}"
echo -e " ${YELLOW}MISMATCH in quiz/index.html${NC}"
QUESTIONS_OK=false
fi
if [ "$QUESTIONS_OK" = true ]; then
@ -141,8 +141,8 @@ else
echo ""
echo "To fix:"
echo " 1. Edit: $LANDING_DIR/index.html"
echo " 2. Edit: $LANDING_DIR/examples.html (if templates changed)"
echo " 3. Edit: $LANDING_DIR/quiz.html (if questions changed)"
echo " 2. Edit: $LANDING_DIR/examples/index.html (if templates changed)"
echo " 3. Edit: $LANDING_DIR/quiz/index.html (if questions changed)"
echo ""
echo "See: $LANDING_DIR/CLAUDE.md for exact line numbers"
fi