Open claude in the loop's home with the setup loaded through claude-release #811

Merged
lilleman merged 12 commits from item-486 into main 2026-12-04 06:37:30 +01:00
8 changed files with 125 additions and 2 deletions
Showing only changes of commit 0eb726939c - Show all commits
+4 -1
View File
@@ -70,6 +70,8 @@ build-release and build-epic run every claude in the loop's Claude home, `~/.loc
Sign in to the loop's home once. Until you have, build-release and build-epic stop and print the line to run, `CLAUDE_CONFIG_DIR=~/.local/share/build-release/claude-home claude`: type `/login` in the claude it opens. A model you pick there with `/model` stays in the generated `settings.json`. The loop's home has no theme or status line of yours: those stay in your own `~/.claude`, for the claude you start yourself. build-release or build-epic builds the home again once the clone holds another commit, as after `self-update`, and keeps the sign-in, the model and the sessions. It builds the home again when you change `XDG_STATE_HOME`, too. The home follows the clone whose build-release, build-epic or `task-bench gather` ran last, so run only the release clone's, never the development clone's: that one would point every running loop at unreleased rules.
To open claude in the loop's home yourself, for a manual `/larv-review` or a planning talk, run `~/build-release/bin/claude-release` in the project's checkout. It builds the home as above where that is due, then passes every argument on to claude, so `--resume`, `-p` and `--model` work as with plain claude. It signs in as the home does, so type `/login` in it where you haven't yet. Permissions come from the setup's `settings.json`, which skips every prompt, as for the loop's claudes. Only the loop's sessions and `claude-release` get rule-hook's guards: the claude you start from your own `~/.claude` doesn't load the setup or its hooks.
The setup keeps each project's config, and what you choose for a project, in the config folder, `~/.config/build-release/`. Its tools keep their own state, such as transcripts, review reports and locks, in the state folder, `~/.local/state/build-release/`. The loop's Claude home is in the data folder, `~/.local/share/build-release/`, which holds what build-release builds again and what Claude Code writes. Where `XDG_CONFIG_HOME` holds an absolute path, the config folder is `build-release/` under that path instead, and likewise the state folder under `XDG_STATE_HOME` and the data folder under `XDG_DATA_HOME`; this README spells the defaults. Set such a variable in the environment Claude Code starts in, since rule-hook reads it there. Back up these four folders:
- `~/.config/build-release/`: each project's config, a client project's plan and records, and `models.json`, the model of each project, which build-release and build-epic write. A project's `env-file`, if you keep it here as below, puts credentials in the backup, so keep the backup private.
@@ -216,13 +218,14 @@ It applies only those commits on the newest tag, tests them with `ci.sh`, tags a
## Tools
build-release, build-epic and `task-bench gather` put the release's tools first on the `PATH` of every claude they start, so this README and the rules name each tool bare, as in `metric-bench`. Install puts no tool on your shell's `PATH`: there, and in a claude you start from it yourself, call each by its path, `~/build-release/bin/<tool>`, from the project's checkout. Run `cut-release` from the development clone instead, as Release says. The tools under `~/build-release` are the release's; test a change to one from `~/code/claude-config/bin`. The tools are listed in alphabetical order, and the packages under `bin/` follow under their own heading.
build-release, build-epic, `task-bench gather` and `claude-release` put the release's tools first on the `PATH` of every claude they start, so this README and the rules name each tool bare, as in `metric-bench`. Install puts no tool on your shell's `PATH`: there, and in a claude you start without them, call each by its path, `~/build-release/bin/<tool>`, from the project's checkout. Run `cut-release` from the development clone instead, as Release says. The tools under `~/build-release` are the release's; test a change to one from `~/code/claude-config/bin`. The tools are listed in alphabetical order, and the packages under `bin/` follow under their own heading.
- `build-epic <EPIC-KEY>` runs the chunks of one Jira epic whose items span repos, or have none, each in its own window of the tmux session `epic-<EPIC-KEY>`, on the same cycle, judge and interrupt as build-release. The epic's description is its record: goals, audience, scoring and decisions. Before it starts chunks, build-epic plans each open issue that no label places yet, as "Set up a project" says. It files a sub-task per repo where the issue changes several repos. Otherwise it labels the issue with where it is worked, and asks you where that is unclear. It plans no issue your team filed a sub-task under: those sub-tasks run instead, each under a label of its own, and your team closes the issue. Then, where two or more issues may start, it scores each of them that holds no scores, and moves the issues that build-epic itself filed into order of score on the board. An open issue runs once a label names its repo or marks it as Claude's, in order of score, as many at once as a line such as `**Max parallel chunks:** 2` in the epic's description allows, 1 without it, and as each repo's `parallel-chunks` allows. A chunk whose pull request waits on a gate parks. An open task of yours that blocks another issue gets a window that DMs you once and reads the epic every minute; once you close the task, the issues it blocked may start. `build-epic <EPIC-KEY> --dry-run` prints what `build-epic <EPIC-KEY>` would write to Jira and which chunks it would start, and does neither; run it before the first real run on a team's epic. `--help` lists what it prints and leaves out. build-epic closes the epic only once you confirm every goal. Install → "Set up a project" says how to set it up; `build-epic --help` states the flags and the contract.
- `build-epic-e2e` runs `build-epic` against a sandbox epic on a real Jira site, as Test says.
- `build-release <task>` runs a project's next chunks, each in its own tmux window, cycle after cycle; `build-release --help` states its contract.
- `chunk-pr open|sync|ready|push|merge|clean|open-epic` opens a chunk's pull request as a draft, brings its branch level with origin's default branch, marks it ready and merges it once its checks pass, with `gh` on a GitHub origin and `tea` elsewhere. Where the project's config sets `epic-branch`, the pull request goes into the epic's working branch instead, `push` pushes later commits and asks the auto-reviewer for a review, and `open-epic` opens the pull request from that branch into the default branch. The chunks of one project merge one at a time: in its turn, `merge` brings the branch level again, finishes the plan items its `--finish` flags name, and waits for the checks. Under `merge = "human"` it then marks the pull request ready and leaves the merge to a person. Once the pull request is merged, `clean` removes the chunk's worktree and branch and fast-forwards the main checkout. `chunk-pr --help` states the steps.
- `chunk-preflight` finds the mechanical facts a chunk starts from, and with `--worktree` makes its worktree; `build-release` runs it with `--worktree` before it routes each chunk, and `chunk-preflight --help` lists the facts.
- `claude-release [<claude argument>…]` opens an interactive claude in the loop's Claude home, with the setup loaded, in the folder you run it in, and passes every argument on to claude; Install says why you'd want that.
- `command-patterns [<version>] [--calls <file>]` prints a table of the shell command patterns a release's archived chunks ran, such as `tea pr create`, for an audit of the release, and with `--calls <file>` saves each call as a JSON line; `command-patterns --help` states the columns and the line's keys.
- `compress-archives` gzips each transcript in build-release's archive and each file in the review folders 30 days after it last changed, keeping all of them; Install's crontab line runs it daily.
- `cut-release [--patch <commits>]` cuts the next release of the development clone it ships in, and with `--patch` a patch release of only the commits named, as Release says.
+1
View File
@@ -31,6 +31,7 @@ build-release runs every claude in the loop's Claude home, ~/.local/share/build-
which it builds from the clone it ships in before it starts anything. Until someone has signed in
there, it stops and prints the command to sign in with. README.md → Install says what the
home holds.
`claude-release [<claude argument>…]` opens an interactive claude in that home.
build-release needs tmux 3.2 or later, and checks that too before it starts anything. Each chunk
runs in its own window of one tmux session per project, named loop-<key>, such as
+15
View File
@@ -0,0 +1,15 @@
#!/usr/bin/env python3
import os
import pathlib
import sys
# Said before the first import of the setup's code, which an older Python cannot read.
if sys.version_info < (3, 14):
sys.exit(f"claude-release needs Python 3.14 or later as python3 on PATH; it found Python {sys.version.split()[0]}")
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parent))
from claude_release import main
from loop_effects import effects
sys.exit(main.main(sys.argv[1:], pathlib.Path.cwd(), effects.system_effects(pathlib.Path.home(), os.environ)))
+3 -1
View File
@@ -19,6 +19,8 @@ LINKED = ("CLAUDE.md", "agents", "bin", "principles", "rules", "skills")
CLONE = "{clone}"
# Stands for the reports folder, which holds every chunk's review folder, in the clone's settings.json. Every value that holds it is a path, so unlike CLONE it isn't shell-quoted.
REPORTS = "{reports}"
# What `unready` says first where nobody has signed in to the home yet; `claude-release` runs there anyway, since /login is typed in that claude.
SIGNED_OUT = "nobody is signed in to the loop's Claude home"
# The file in the home that names the clone, its commit and the reports folder the home was built from.
BUILT_FROM = "built-from"
@@ -45,7 +47,7 @@ def unready(home: pathlib.Path, clone: pathlib.Path, reports: pathlib.Path, clau
if signed:
return None
# /login is typed in a claude that runs in the home: docs/decisions.md → `Claude Code in a home of its own`.
return f"nobody is signed in to the loop's Claude home; run `CLAUDE_CONFIG_DIR={shlex.quote(str(home))} claude` and type /login there, once"
return f"{SIGNED_OUT}; run `CLAUDE_CONFIG_DIR={shlex.quote(str(home))} claude` and type /login there, once"
def signed_in(status: str) -> bool | None:
View File
+16
View File
@@ -0,0 +1,16 @@
import pathlib
import sys
from claude_home.home import SIGNED_OUT
from loop_effects.effects import Effects
# The spelling, a command of its own beside build-release: a panel of readers seated as the README's audience rejected `build-release claude`, since build-release reads every word after its name as a task, so a task that starts with "claude" would mean something else. They picked the name that opens with the word they look for.
def main(argv: list[str], cwd: pathlib.Path, effects: Effects) -> int:
"""Runs claude on the terminal in cwd with argv as its arguments, in the loop's Claude home with the release's tools first on `PATH`, which the effect sets for every claude it starts. Returns claude's exit code, or 1 where the home cannot be built."""
not_ready = effects.claude_home()
# Where nobody has signed in yet, the login is typed in this claude.
if not_ready and not not_ready.startswith(SIGNED_OUT):
print(not_ready, file=sys.stderr)
return 1
return effects.claude_on_terminal(argv, str(cwd), {})
+41
View File
@@ -0,0 +1,41 @@
import contextlib
import io
import pathlib
import sys
import unittest
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
from claude_home.home import SIGNED_OUT
from claude_release import main
from loop_effects.doubles import FakeEffects
class ClaudeRelease(unittest.TestCase):
def run_main(self, args: list[str], fake: FakeEffects) -> tuple[int, str]:
err = io.StringIO()
with contextlib.redirect_stderr(err):
return main.main(args, pathlib.Path("/project"), fake.effects()), err.getvalue()
def test_passes_every_argument_on_to_claude_in_the_folder_it_runs_in(self):
fake = FakeEffects(on_terminal_claude=[0])
code, err = self.run_main(["--resume", "abc", "--model", "opus", "-p", "hi"], fake)
self.assertEqual((code, err, fake.made("claude_on_terminal"), fake.terminal_folders), (0, "", [["--resume", "abc", "--model", "opus", "-p", "hi"]], ["/project"]))
def test_exits_with_the_code_of_claude(self):
self.assertEqual(self.run_main([], FakeEffects(on_terminal_claude=[3]))[0], 3)
def test_opens_claude_where_nobody_is_signed_in_yet_for_the_login_typed_there(self):
fake = FakeEffects(on_terminal_claude=[0])
fake.home_unready = f"{SIGNED_OUT}; run `CLAUDE_CONFIG_DIR=/h claude` and type /login there, once"
self.assertEqual((self.run_main([], fake)[0], len(fake.made("claude_on_terminal"))), (0, 1))
def test_stops_where_the_home_cannot_be_built(self):
fake = FakeEffects()
fake.home_unready = "could not build the loop's Claude home, /h: disk full"
code, err = self.run_main(["--resume"], fake)
self.assertEqual((code, err, fake.made("claude_on_terminal")), (1, "could not build the loop's Claude home, /h: disk full\n", []))
if __name__ == "__main__":
unittest.main()
+45
View File
@@ -4095,3 +4095,48 @@ Read most (opens and searches):
- `bin/review_replay/replay.py` 6
- `todo.md` 6
- `bin/build-release` 5
## Reading cost, chunk 338e966493fc, finished 2026-12-04T03:26:52Z
62696 new input tokens before the first commit.
Read most (opens and searches):
- `README.md` 7
- `.gitignore` 3
- `bin/build_epic/test_main.py` 3
- `bin/rule_hook/rules.py` 2
- `ci.sh` 2
- `CHANGELOG.md` 1
- `bin/mutate_changes/tool_process.py` 1
- `bin/repo_checks/test_gitignore.py` 1
- `bin/rule_hook/main.py` 1
- `bin/run-tests` 1
## Reading cost, chunk dedf3d6e1aca, finished 2026-12-04T03:51:53Z
71912 new input tokens before the first commit.
Read most (opens and searches):
- `README.md` 4
- `bin/loop_effects/effects.py` 4
- `bin/loop_state/paths.py` 4
- `CHANGELOG.md` 3
- `bin/claude_home/test_home.py` 2
- `bin/claude_home/home.py` 1
- `bin/review_rules/review_folder.py` 1
- `settings.json` 1
## Reading cost, chunk a7593c957df7, finished 2026-12-04T04:31:15Z
87399 new input tokens before the first commit.
Read most (opens and searches):
- `README.md` 3
- `rules/todo-items.md` 3
- `CLAUDE.md` 1
- `bin/claude_home/home.py` 1
- `skills/larv-review/review-findings.md` 1
- `todo.md` 1