From 13f0aae899cdca6757909a10d365882bd92ff17a Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Fri, 25 Sep 2026 08:39:37 +0200 Subject: [PATCH 1/7] Run loop-claude from the checkout root wherever inside it is started --- CHANGELOG.md | 1 + bin/loop-claude | 17 ++++++++++++----- bin/test_loop_claude.py | 11 +++++++++++ todo.md | 1 - 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c33de2ec..7f45ae72 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - `loop-claude` exits 1 when the judge fails three times running; a verdict missing a field or quoting nothing in the transcript is a failure. - `loop-claude` exits 2 when an interrupt gets no answer, saying why: stdin or stdout is not a terminal, or nothing was typed. Rerunning resumes the session. - `loop-claude` archives each session's transcript under `~/.claude/loop-claude-transcripts/`, one folder per project; `LOOP_CLAUDE_TRANSCRIPTS` overrides the root. +- `loop-claude` works from the checkout root wherever inside the checkout it is started. - `loop-claude --help` names the Claude Code version its transcript, session and trust handling were observed on; check it first when an upgrade breaks a cycle. - `loop-claude` runs the model each project's settings pick; `LOOP_CLAUDE_WORKER_MODEL` and `LOOP_CLAUDE_JUDGE_MODEL` override it. This repo runs on Fable 5.1. - Reviewers share one protocol for verdicts, severities, rounds and declines: `agents/review-protocol.md`. diff --git a/bin/loop-claude b/bin/loop-claude index 6e371597..3118457c 100755 --- a/bin/loop-claude +++ b/bin/loop-claude @@ -3,11 +3,12 @@ usage: loop-claude -Run it in a project checkout whose README.md has ## Goals and ## Audience, the premises. Each cycle -a worker runs the task; a judge then reads the transcript against them. A question only the human -can answer, or a release ready to cut, is an interrupt: `claude --resume` on the terminal. An -unfinished chunk resumes the same session next cycle; a finished one starts a fresh session. Cycles -continue until that interrupt or Ctrl-C. Words: ~/.claude/CLAUDE.md → "Vocabulary". +Run it anywhere inside a project checkout whose README.md has ## Goals and ## Audience, the +premises; it works from the checkout root. Each cycle a worker runs the task; a judge then reads the +transcript against them. A question only the human can answer, or a release ready to cut, is an +interrupt: `claude --resume` on the terminal. An unfinished chunk resumes the same session next +cycle; a finished one starts a fresh session. Cycles continue until that interrupt or Ctrl-C. Words: +~/.claude/CLAUDE.md → "Vocabulary". Exit 1: no task, no premises, claude leaves no transcript, or the worker or the judge fails three times running, a verdict missing a field or quoting nothing in the transcript being a judge failure. @@ -112,6 +113,11 @@ def read_premises(): return f"## Goals\n{found['Goals'][0]}\n\n## Audience\n{found['Audience'][0]}" +def checkout_root(): + found = subprocess.run(["git", "rev-parse", "--show-toplevel"], capture_output=True, text=True) + return found.stdout.strip() if found.returncode == 0 else os.getcwd() + + def project(): return os.getcwd().removeprefix(os.path.expanduser("~/code/")).lstrip("/") @@ -359,6 +365,7 @@ def main(): if task in ("", "-h", "--help"): print(__doc__.strip()) sys.exit(0 if task else 1) + os.chdir(checkout_root()) cycle_number = int(os.environ.pop(RELOAD_CYCLE, 0)) failures = int(os.environ.pop(RELOAD_FAILURES, 0)) while True: diff --git a/bin/test_loop_claude.py b/bin/test_loop_claude.py index 030010cd..09501fc1 100644 --- a/bin/test_loop_claude.py +++ b/bin/test_loop_claude.py @@ -5,6 +5,7 @@ import json import os import pathlib import stat +import subprocess import tempfile import unittest import unittest.mock @@ -84,6 +85,16 @@ class HumanTurns(unittest.TestCase): ]), 2) +class CheckoutRoot(unittest.TestCase): + def test_is_the_checkout_from_any_directory_inside_it_and_the_directory_itself_outside_one(self): + with tempfile.TemporaryDirectory() as root, contextlib.chdir(root): + self.assertEqual(loop.checkout_root(), os.getcwd()) + subprocess.run(["git", "init", "-q"], check=True) + os.makedirs("a/b") + with contextlib.chdir("a/b"): + self.assertEqual(loop.checkout_root(), root) + + class Project(unittest.TestCase): def test_names_a_checkout_relative_to_code_and_any_other_relative_to_root(self): with unittest.mock.patch.dict(os.environ, {"HOME": "/h"}): diff --git a/todo.md b/todo.md index 1bce87f0..73653587 100644 --- a/todo.md +++ b/todo.md @@ -4,7 +4,6 @@ Ordered by how many seats of the 2026-09-24 scoring panel (`docs/decisions.md`) named the place; each is one chunk. -- Derive `project()` from the checkout root, today `os.getcwd()`, so `loop-claude` run from a subdirectory joins the root's session. - Settle whether the "Expect the codebase to get smaller" bullet under `CLAUDE.md` → "One spelling per goal" names an action, and cut it if it is a forecast. - Re-run the four-seat scoring panel and record the score in `docs/decisions.md`; the target is every dimension at 7.0 or above. - Exit `loop-claude` with a message, today a traceback, when `README.md` is not UTF-8. -- 2.52.0 From 76d1b218bf33d5194b7f33244bcae48ced9b89b5 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Fri, 25 Sep 2026 08:44:37 +0200 Subject: [PATCH 2/7] Compare the checkout root to the resolved temp dir --- bin/test_loop_claude.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bin/test_loop_claude.py b/bin/test_loop_claude.py index 09501fc1..582ba86c 100644 --- a/bin/test_loop_claude.py +++ b/bin/test_loop_claude.py @@ -87,8 +87,9 @@ class HumanTurns(unittest.TestCase): class CheckoutRoot(unittest.TestCase): def test_is_the_checkout_from_any_directory_inside_it_and_the_directory_itself_outside_one(self): - with tempfile.TemporaryDirectory() as root, contextlib.chdir(root): - self.assertEqual(loop.checkout_root(), os.getcwd()) + with tempfile.TemporaryDirectory() as tmp, contextlib.chdir(tmp): + root = os.getcwd() + self.assertEqual(loop.checkout_root(), root) subprocess.run(["git", "init", "-q"], check=True) os.makedirs("a/b") with contextlib.chdir("a/b"): -- 2.52.0 From 4d46d369d38d0a881121d8a0224c75a19286e16b Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Fri, 25 Sep 2026 08:44:48 +0200 Subject: [PATCH 3/7] Exit when loop-claude is started outside a checkout --- bin/loop-claude | 6 ++++-- bin/test_loop_claude.py | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/bin/loop-claude b/bin/loop-claude index 3118457c..ce41b82e 100755 --- a/bin/loop-claude +++ b/bin/loop-claude @@ -10,7 +10,7 @@ interrupt: `claude --resume` on the terminal. An unfinished chunk resumes the sa cycle; a finished one starts a fresh session. Cycles continue until that interrupt or Ctrl-C. Words: ~/.claude/CLAUDE.md → "Vocabulary". -Exit 1: no task, no premises, claude leaves no transcript, or the worker or the judge fails three +Exit 1: no task, not inside a checkout, no premises, claude leaves no transcript, or the worker or the judge fails three times running, a verdict missing a field or quoting nothing in the transcript being a judge failure. Exit 2: the human is needed and stdin or stdout is not a terminal, or the interrupt ended without them typing anything. Rerunning resumes the session after either exit. Before an interrupt every @@ -115,7 +115,9 @@ def read_premises(): def checkout_root(): found = subprocess.run(["git", "rev-parse", "--show-toplevel"], capture_output=True, text=True) - return found.stdout.strip() if found.returncode == 0 else os.getcwd() + if found.returncode != 0: + sys.exit(found.stderr.strip()) + return found.stdout.strip() def project(): diff --git a/bin/test_loop_claude.py b/bin/test_loop_claude.py index 582ba86c..39659ed0 100644 --- a/bin/test_loop_claude.py +++ b/bin/test_loop_claude.py @@ -86,10 +86,12 @@ class HumanTurns(unittest.TestCase): class CheckoutRoot(unittest.TestCase): - def test_is_the_checkout_from_any_directory_inside_it_and_the_directory_itself_outside_one(self): + def test_is_the_checkout_from_any_directory_inside_it_and_exits_outside_one(self): with tempfile.TemporaryDirectory() as tmp, contextlib.chdir(tmp): root = os.getcwd() - self.assertEqual(loop.checkout_root(), root) + with self.assertRaises(SystemExit) as stopped: + loop.checkout_root() + self.assertIn("not a git repository", stopped.exception.code) subprocess.run(["git", "init", "-q"], check=True) os.makedirs("a/b") with contextlib.chdir("a/b"): -- 2.52.0 From 4e1efc78eeb707c11c59e91fec4eeca14ba8e23b Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Fri, 25 Sep 2026 08:44:57 +0200 Subject: [PATCH 4/7] Reflow the exit paragraph --- bin/loop-claude | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bin/loop-claude b/bin/loop-claude index ce41b82e..99539d27 100755 --- a/bin/loop-claude +++ b/bin/loop-claude @@ -10,11 +10,11 @@ interrupt: `claude --resume` on the terminal. An unfinished chunk resumes the sa cycle; a finished one starts a fresh session. Cycles continue until that interrupt or Ctrl-C. Words: ~/.claude/CLAUDE.md → "Vocabulary". -Exit 1: no task, not inside a checkout, no premises, claude leaves no transcript, or the worker or the judge fails three -times running, a verdict missing a field or quoting nothing in the transcript being a judge failure. -Exit 2: the human is needed and stdin or stdout is not a terminal, or the interrupt ended without -them typing anything. Rerunning resumes the session after either exit. Before an interrupt every -worktree is marked trusted in ~/.claude.json. +Exit 1: no task, not inside a checkout, no premises, claude leaves no transcript, or the worker or +the judge fails three times running, a verdict missing a field or quoting nothing in the transcript +being a judge failure. Exit 2: the human is needed and stdin or stdout is not a terminal, or the +interrupt ended without them typing anything. Rerunning resumes the session after either exit. +Before an interrupt every worktree is marked trusted in ~/.claude.json. Each project has one session, "A loop-claude", being the checkout relative to ~/code, or to / outside it, deleted when the chunk finishes. Its transcript is archived under -- 2.52.0 From 41aff3b568d04bdb82a596aa0ea93845c75d0470 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Fri, 25 Sep 2026 08:46:40 +0200 Subject: [PATCH 5/7] Assert git's reason is passed on, not its wording --- bin/test_loop_claude.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/test_loop_claude.py b/bin/test_loop_claude.py index 39659ed0..94a0c723 100644 --- a/bin/test_loop_claude.py +++ b/bin/test_loop_claude.py @@ -91,7 +91,7 @@ class CheckoutRoot(unittest.TestCase): root = os.getcwd() with self.assertRaises(SystemExit) as stopped: loop.checkout_root() - self.assertIn("not a git repository", stopped.exception.code) + self.assertTrue(stopped.exception.code) subprocess.run(["git", "init", "-q"], check=True) os.makedirs("a/b") with contextlib.chdir("a/b"): -- 2.52.0 From 0f77045837467ec86a6f5b41106ededf7ef3f9d9 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Fri, 25 Sep 2026 08:48:44 +0200 Subject: [PATCH 6/7] Say the task runs at the checkout root --- bin/loop-claude | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/loop-claude b/bin/loop-claude index 99539d27..0b5ae089 100755 --- a/bin/loop-claude +++ b/bin/loop-claude @@ -4,8 +4,8 @@ usage: loop-claude Run it anywhere inside a project checkout whose README.md has ## Goals and ## Audience, the -premises; it works from the checkout root. Each cycle a worker runs the task; a judge then reads the -transcript against them. A question only the human can answer, or a release ready to cut, is an +premises; the task runs at the checkout root. Each cycle a worker runs the task; a judge then reads +the transcript against them. A question only the human can answer, or a release ready to cut, is an interrupt: `claude --resume` on the terminal. An unfinished chunk resumes the same session next cycle; a finished one starts a fresh session. Cycles continue until that interrupt or Ctrl-C. Words: ~/.claude/CLAUDE.md → "Vocabulary". -- 2.52.0 From 3a6ea7e6cac39dce0103670e3b66c55caacf29ee Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Fri, 25 Sep 2026 08:50:11 +0200 Subject: [PATCH 7/7] Keep the exit paragraph to exits and drop the rerun overclaim --- CHANGELOG.md | 2 +- bin/loop-claude | 13 ++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f45ae72..68cbb253 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ - `loop-claude` exits 1 when the judge fails three times running; a verdict missing a field or quoting nothing in the transcript is a failure. - `loop-claude` exits 2 when an interrupt gets no answer, saying why: stdin or stdout is not a terminal, or nothing was typed. Rerunning resumes the session. - `loop-claude` archives each session's transcript under `~/.claude/loop-claude-transcripts/`, one folder per project; `LOOP_CLAUDE_TRANSCRIPTS` overrides the root. -- `loop-claude` works from the checkout root wherever inside the checkout it is started. +- `loop-claude` runs at the checkout root wherever inside the checkout it is started. - `loop-claude --help` names the Claude Code version its transcript, session and trust handling were observed on; check it first when an upgrade breaks a cycle. - `loop-claude` runs the model each project's settings pick; `LOOP_CLAUDE_WORKER_MODEL` and `LOOP_CLAUDE_JUDGE_MODEL` override it. This repo runs on Fable 5.1. - Reviewers share one protocol for verdicts, severities, rounds and declines: `agents/review-protocol.md`. diff --git a/bin/loop-claude b/bin/loop-claude index 0b5ae089..9fac06f2 100755 --- a/bin/loop-claude +++ b/bin/loop-claude @@ -6,15 +6,14 @@ usage: loop-claude Run it anywhere inside a project checkout whose README.md has ## Goals and ## Audience, the premises; the task runs at the checkout root. Each cycle a worker runs the task; a judge then reads the transcript against them. A question only the human can answer, or a release ready to cut, is an -interrupt: `claude --resume` on the terminal. An unfinished chunk resumes the same session next -cycle; a finished one starts a fresh session. Cycles continue until that interrupt or Ctrl-C. Words: -~/.claude/CLAUDE.md → "Vocabulary". +interrupt: `claude --resume` on the terminal, every worktree first marked trusted in ~/.claude.json. +An unfinished chunk resumes the same session next cycle; a finished one starts a fresh session. +Cycles continue until that interrupt or Ctrl-C. Words: ~/.claude/CLAUDE.md → "Vocabulary". Exit 1: no task, not inside a checkout, no premises, claude leaves no transcript, or the worker or -the judge fails three times running, a verdict missing a field or quoting nothing in the transcript -being a judge failure. Exit 2: the human is needed and stdin or stdout is not a terminal, or the -interrupt ended without them typing anything. Rerunning resumes the session after either exit. -Before an interrupt every worktree is marked trusted in ~/.claude.json. +the judge fails three times running. A judge fails when its verdict misses a field or quotes nothing +in the transcript. Exit 2: the human is needed and stdin or stdout is not a terminal, or the +interrupt ended without them typing anything. Rerunning resumes any open session. Each project has one session, "A loop-claude", being the checkout relative to ~/code, or to / outside it, deleted when the chunk finishes. Its transcript is archived under -- 2.52.0