Keep the account's claude.ai skills, plugins and connectors out of the loop's Claude home and its clone
CI / tests (pull_request) Successful in 4m34s

This commit is contained in:
2026-12-06 17:28:07 +01:00
parent e7831d2c1e
commit e64666d206
9 changed files with 89 additions and 10 deletions
+4
View File
@@ -8,3 +8,7 @@ reviewer-merge-trials/results/
reviewer-merge-trials/runs.pkl
workflow-bench/*-[0-9]*.md
workflow-bench/*/
# What Claude Code writes under skills/, should the loop's Claude home ever link the folder whole again: the signed-in account's skills.
skills/.trash/
skills/synced/
+4 -2
View File
@@ -77,13 +77,15 @@ Run `build-release` by its path, `~/build-release/bin/build-release`: no step in
build-release and build-epic run every claude in the loop's Claude home, `~/.local/share/build-release/claude-home`, which each of the two builds when it starts. Neither reads or writes your own `~/.claude`, and nothing in it loads in the loop's home. `task-bench gather` builds the home too, and runs its claude there. The loop's home holds:
- links to the clone's `agents/`, `bin/`, `CLAUDE.md`, `principles/`, `rules/` and `skills/`, so a claude opens there each file of the setup that the rules name, and the rules name each as the setup's, as in the setup's `rules/todo-items.md`;
- links to the clone's `agents/`, `bin/`, `CLAUDE.md`, `principles/` and `rules/`, and a `skills/` folder of its own with a link to each of the clone's skills, so a claude opens there each file of the setup that the rules name, and the rules name each as the setup's, as in the setup's `rules/todo-items.md`;
- a `settings.json` generated from the clone's, whose hooks run the clone's tools;
- every plugin the clone's `settings.json` enables, which build-release or build-epic installs;
- what Claude Code keeps in its home: your sign-in there, the sessions and the memory files.
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, `task-bench gather` or `claude-release` ran last, so run only the release clone's, never the development clone's: that one would point every running loop at unreleased rules.
From the account you sign in with, the loop's home keeps only the sign-in and the account's profile. It keeps out what a claude.ai account brings: its connectors, such as mail, calendar and files, its skills and its plugins. The generated `settings.json` turns each of these off, and every claude the loop starts also runs with `ENABLE_CLAUDEAI_MCP_SERVERS=false`. `claude-release` uses the same home, so the account's connectors don't load there either. Signing in can copy the account's skills into the home's `skills/synced/` before the home is built; the next claude there moves them to `skills/.trash/` and loads none. The home shares two things with your own Claude Code that it can't avoid. It signs in as an account, usually yours, so the loop's usage counts against that account's limits. And the account lists the home as one more signed-in session.
To work 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 or refreshes the home first, as above, then runs claude there and passes every argument on, so `--resume`, `-p` and `--model` work as with plain claude. Where nobody has signed in to the home yet, type `/login` in the claude it opens. The home's `settings.json` bypasses permissions, and Claude Code may still ask you to trust the folder. The setup's hooks, such as `rule-hook`, which refuses a tool call that breaks a rule a program can check, run in every claude in the loop's home: the loop's sessions and `claude-release`. The claude you start from your own `~/.claude` loads neither the setup nor 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:
@@ -208,7 +210,7 @@ Move `~/build-release` to the newest release:
It prints `CHANGELOG.md`'s section for each version it moved past: do what each asks, such as a new step under Install. `self-update` moves the clone it ships in, whatever the directory it is run from, and names that clone in each line that says what it did or why it refused. So run `~/build-release`'s copy, never the development clone's. The next build-release or build-epic builds the loop's Claude home again from the new release. `self-update --help` says what else it checks.
It refuses while a file the clone tracks has an uncommitted change. Claude Code keeps its own files in the loop's home, not in the clone. The home's six links lead into the clone, though, so a rule, an agent, a skill, a principle or a tool changed in that home changes the clone's file. Carry such a change into `~/code/dev-factory` on a branch of its own, merge it through a PR, and cut a release.
It refuses while a file the clone tracks has an uncommitted change. Claude Code keeps its own files in the loop's home, not in the clone. The home's links lead into the clone, though, so a rule, an agent, a skill, a principle or a tool changed in that home changes the clone's file. Carry such a change into `~/code/dev-factory` on a branch of its own, merge it through a PR, and cut a release.
A release up to 0.17.0 was a checkout in `~/.claude`, and `self-update` doesn't move one out of there. Finish each open chunk first: its session stays in `~/.claude`, where the new release doesn't look for it. Then clone the newest release as Install says, and sign in to the loop's home. In each project's config, write `setup:` in place of `~/.claude/` in `principles` and `standards`, as in `setup:principles`, and write the new clone in place of `~/.claude` in the crontab line. build-release and build-epic don't read `~/.claude` after that, so the checkout there is yours to keep or remove. Keep it on 0.17.0 if you keep it: a later `settings.json` names its hooks by a placeholder that only the loop's home fills in, so in `~/.claude` the hooks would not run. A later release's `.gitignore` doesn't ignore Claude Code's credentials, transcripts and memory files, so in `~/.claude` a `git add .` would stage them. Where that checkout has moved past 0.17.0, run `echo '*' >> .git/info/exclude` in it.
+16 -2
View File
@@ -1,6 +1,6 @@
"""Builds the loop's Claude home: the folder every claude the loop starts reads in place of the person's own `~/.claude`.
The home lies outside the clone, so the clone stays a clean checkout. It holds links to the clone's LINKED files, a `settings.json` generated from the clone's, and what Claude Code itself keeps in its home: the plugins, the sign-in and the transcripts. docs/decisions.md → `Claude Code in a home of its own` says what loads from such a home.
The home lies outside the clone, so the clone stays a clean checkout. It holds links to the clone's LINKED files, a SKILLS folder of its own with a link to each of the clone's skills, a `settings.json` generated from the clone's, and what Claude Code itself keeps in its home: the plugins, the sign-in and the transcripts. docs/decisions.md → `Claude Code in a home of its own` says what loads from such a home.
"""
import collections.abc
import fcntl
@@ -14,7 +14,9 @@ from failure import Failure
from text_files.file_writes import replace_file
# What the home links to in the clone: the instruction files Claude Code reads from its home, and the two folders those files name beside them. So a claude opens each file of the setup that they name in its own home: the setup's CLAUDE.md → "Vocabulary", "setup".
LINKED = ("CLAUDE.md", "agents", "bin", "principles", "rules", "skills")
LINKED = ("CLAUDE.md", "agents", "bin", "principles", "rules")
# The folder of skills, a folder of the home's own that holds a link to each of the clone's skills: Claude Code writes in it, such as the signed-in account's skills at sign-in, and a whole link would carry those writes into the clone.
SKILLS = "skills"
# Stands for the clone's folder in the clone's settings.json. Every value that holds it is a shell command, such as a hook's.
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.
@@ -96,6 +98,18 @@ def linked(home: pathlib.Path, clone: pathlib.Path) -> Failure | None:
if link.is_symlink():
link.unlink()
link.symlink_to(clone / name)
skills = home / SKILLS
# A release before 0.18.1 linked the whole folder.
if skills.is_symlink():
skills.unlink()
skills.mkdir(exist_ok=True)
# Only links are replaced, so a skill the clone dropped loses its own, and what Claude Code wrote here stays.
for entry in skills.iterdir():
if entry.is_symlink():
entry.unlink()
# A clone without skills, as a test's may be, links none, as a whole link to a missing folder linked none.
for skill in sorted((clone / SKILLS).iterdir()) if (clone / SKILLS).is_dir() else []:
(skills / skill.name).symlink_to(skill)
return None
+48 -2
View File
@@ -26,7 +26,7 @@ class Home(unittest.TestCase):
self.temp = pathlib.Path(tempfile.mkdtemp())
self.addCleanup(subprocess.run, ["rm", "-rf", str(self.temp)])
self.clone = self.temp / "the clone"
for folder in ("agents", "bin", "principles", "rules", "skills"):
for folder in ("agents", "bin", "principles", "rules", "skills/larv-review", "skills/comprehension-panel"):
(self.clone / folder).mkdir(parents=True)
(self.clone / "CLAUDE.md").write_text("# The setup's rules\n", encoding="utf-8")
(self.clone / "settings.json").write_text(json.dumps(SETTINGS), encoding="utf-8")
@@ -55,11 +55,57 @@ class Home(unittest.TestCase):
def test_a_new_home_links_each_folder_of_the_setup_that_an_instruction_file_names(self) -> None:
self.assertIsNone(self.unready())
for name in ("CLAUDE.md", "agents", "bin", "principles", "rules", "skills"):
for name in ("CLAUDE.md", "agents", "bin", "principles", "rules", "skills/larv-review", "skills/comprehension-panel"):
self.assertTrue((self.home / name).is_symlink(), name)
self.assertEqual((self.home / name).resolve(), (self.clone / name).resolve())
self.assertEqual((self.home / "CLAUDE.md").read_text(encoding="utf-8"), "# The setup's rules\n")
def test_the_skills_folder_stands_in_the_home_so_what_claude_code_writes_there_stays_out_of_the_clone(self) -> None:
self.assertIsNone(self.unready())
self.assertTrue((self.home / "skills").is_dir())
self.assertFalse((self.home / "skills").is_symlink())
def test_a_skills_folder_claude_code_made_at_sign_in_is_kept_with_its_files(self) -> None:
synced = self.home / "skills" / "synced" / "account" / "docx" / "SKILL.md"
trashed = self.home / "skills" / ".trash" / "1-docx"
synced.parent.mkdir(parents=True)
synced.write_text("an account's skill\n", encoding="utf-8")
trashed.mkdir(parents=True)
self.assertIsNone(self.unready())
self.assertEqual(synced.read_text(encoding="utf-8"), "an account's skill\n")
self.assertTrue(trashed.is_dir())
self.assertEqual((self.home / "skills" / "larv-review").resolve(), (self.clone / "skills" / "larv-review").resolve())
self.assertEqual(sorted(path.name for path in (self.clone / "skills").iterdir()), ["comprehension-panel", "larv-review"])
def test_a_skills_link_an_older_release_made_becomes_a_folder(self) -> None:
self.home.mkdir(parents=True)
(self.home / "skills").symlink_to(self.clone / "skills")
self.assertIsNone(self.unready())
self.assertFalse((self.home / "skills").is_symlink())
self.assertEqual((self.home / "skills" / "comprehension-panel").resolve(), (self.clone / "skills" / "comprehension-panel").resolve())
def test_a_clone_without_skills_builds_a_home_with_an_empty_skills_folder(self) -> None:
subprocess.run(["rm", "-r", str(self.clone / "skills")], check=True)
self.assertIsNone(self.unready())
self.assertEqual(list((self.home / "skills").iterdir()), [])
def test_a_skill_the_clone_dropped_loses_its_link_at_the_next_refresh(self) -> None:
self.assertIsNone(self.unready())
(self.clone / "skills" / "comprehension-panel").rmdir()
self.commit = "4d5e6f\n"
self.assertIsNone(self.unready())
self.assertFalse((self.home / "skills" / "comprehension-panel").is_symlink())
self.assertTrue((self.home / "skills" / "larv-review").is_symlink())
def test_the_generated_settings_name_the_clone_quoted_for_a_shell_and_leave_the_tracked_file_alone(self) -> None:
self.unready()
+4 -2
View File
@@ -25,6 +25,8 @@ DATA_HOME = ".local/share"
XDG_DATA_HOME = "XDG_DATA_HOME"
# The variable that names the home a claude runs in, in place of the person's own.
CLAUDE_CONFIG_DIR = "CLAUDE_CONFIG_DIR"
# Set to "false", the variable keeps the signed-in claude.ai account's connectors, such as its mail, out of a session: a second lock beside the home's disableClaudeAiConnectors, docs/decisions.md → `Claude Code in a home of its own`.
CLAUDE_AI_CONNECTORS = "ENABLE_CLAUDEAI_MCP_SERVERS"
# Only a claude started through this has the tools on PATH. One a person starts by hand lacks them, as their shell does: the plan keeps short names such as `wait-for` out of a person's shell. README.md → Tools says how to call a tool there.
@@ -55,8 +57,8 @@ def claude_home(env: Mapping[str, str], home: pathlib.Path) -> pathlib.Path:
def in_claude_home(env: Mapping[str, str], home: pathlib.Path) -> dict[str, str]:
"""env with the loop's Claude home as the home a claude started in it runs in."""
return {**env, CLAUDE_CONFIG_DIR: str(claude_home(env, home))}
"""env with the loop's Claude home as the home a claude started in it runs in, and no claude.ai connector."""
return {**env, CLAUDE_CONFIG_DIR: str(claude_home(env, home)), CLAUDE_AI_CONNECTORS: "false"}
# The XDG Base Directory Specification calls a relative path in one of its variables invalid, to be ignored: https://specifications.freedesktop.org/basedir-spec/latest/
+4 -1
View File
@@ -60,7 +60,10 @@ class ClaudeHome(unittest.TestCase):
self.assertEqual((found.claude_dir, found.claude_code_transcripts, found.model_catalog), (home, home / "projects", home / "cache" / "model-catalog"))
def test_a_claude_started_in_the_loops_home_is_told_so_and_keeps_every_other_variable(self):
self.assertEqual(in_claude_home({"PATH": "/bin", "CLAUDE_CONFIG_DIR": "/elsewhere"}, HOME), {"PATH": "/bin", "CLAUDE_CONFIG_DIR": "/home/me/.local/share/build-release/claude-home"})
self.assertEqual(in_claude_home({"PATH": "/bin", "CLAUDE_CONFIG_DIR": "/elsewhere"}, HOME), {"PATH": "/bin", "CLAUDE_CONFIG_DIR": "/home/me/.local/share/build-release/claude-home", "ENABLE_CLAUDEAI_MCP_SERVERS": "false"})
def test_a_claude_started_in_the_loops_home_loads_no_claude_ai_connector_whatever_the_environment_asked(self):
self.assertEqual(in_claude_home({"ENABLE_CLAUDEAI_MCP_SERVERS": "true"}, HOME)["ENABLE_CLAUDEAI_MCP_SERVERS"], "false")
if __name__ == "__main__":
+3
View File
@@ -27,6 +27,9 @@ class Settings(unittest.TestCase):
self.assertTrue(command.startswith(f"{CLONE}/bin/"), command)
self.assertTrue((ROOT / "bin" / command.split()[0].removeprefix(f"{CLONE}/bin/")).is_file(), command)
def test_the_signed_in_accounts_connectors_skills_and_plugins_stay_out_of_the_home(self) -> None:
self.assertEqual((self.settings.get("disableClaudeAiConnectors"), self.settings.get("syncClaudeAiSkills"), self.settings.get("syncClaudeAiPlugins")), (True, False, False))
def test_the_persons_theme_and_status_line_are_not_set(self) -> None:
self.assertNotIn("theme", self.settings)
self.assertNotIn("statusLine", self.settings)
+4 -1
View File
@@ -136,12 +136,15 @@ The cap is 5, `bin/plan/todo_table.py`'s `BUNDLE_MAX_R`, from the same chunks: b
- **The loop's home signs in by `/login`.** 2026-12-03, lilleman, planning 0.18.0: the human signs in once, in a claude started with `CLAUDE_CONFIG_DIR` naming the loop's home, and makes and keeps no long-lived token file. `bin/claude_home` asks `claude auth status` before a command starts a chunk. Probed on Claude Code 2.1.336 in a throwaway home: signed out, it prints JSON with `loggedIn: false` and exits 1. Not tested: where the home keeps the sign-in. The token below stays the way a container signs in, as task-bench does.
- **Signs in by `CLAUDE_CODE_OAUTH_TOKEN`:** the request carried `Authorization: Bearer <token>` with the `oauth-2025-04-20` beta, and `claude auth status` said `loggedIn: true, authMethod: oauth_token`. The home didn't hold a credentials file. Without the variable the home is `loggedIn: false`. Not tested: that Anthropic accepts a real token, since `claude setup-token` needs the human's browser sign-in. The authentication docs say the token lasts one year and can only make model requests; neither is tested, and the first real run shows whether it signs in.
- **`--bare` can't use that token.** With `CLAUDE_CODE_OAUTH_TOKEN`, it says `Not logged in · Please run /login` and doesn't send a request. With `ANTHROPIC_API_KEY` it signs in, but doesn't load anything from the home (`CLAUDE.md`, rules, agents or skills) and offers only Bash, Edit and Read. So a container that signs in by a long-lived token runs without `--bare`; its fresh home is empty, so nothing of the human's loads there either. The project's `CLAUDE.md` loads from the working folder, and its `AGENTS.md` only where the project has no `CLAUDE.md`.
- **A claude.ai account signed in there brings its connectors, skills and plugins, unless the home's settings turn them off.** 2026-12-06, item 605, on the owner's machine with Claude Code 2.1.337: after `/login` in the loop's home, before any build, `claude mcp list` there listed the account's Gmail, Google Drive, Google Calendar and Claude Docs connectors, each connected, and the account's skills sat in `<home>/skills/synced/`. With `disableClaudeAiConnectors: true`, `syncClaudeAiSkills: false` and `syncClaudeAiPlugins: false` in the home's `settings.json`, `claude mcp list` listed no server, the next `claude -p` moved the synced skills to `<home>/skills/.trash/` and loaded only Claude Code's built-in skills, and no `<home>/plugins/synced/` appeared. So the clone's `settings.json` holds all three, and `in_claude_home` sets `ENABLE_CLAUDEAI_MCP_SERVERS=false` as a second lock. Claude Code's docs name the keys (settings-reference, skills and plugins/loading at code.claude.com/docs/en) and the variable (env-vars); they don't say `--strict-mcp-config` keeps connectors out, so the loop doesn't rely on it. A long-lived token from `claude setup-token` can't fetch connectors at all, per the authentication docs; not tested.
- **Transcripts** land in `<home>/projects/<working folder's path, with each / as ->/<session id>.jsonl`. `--no-session-persistence` doesn't write one, only an empty `memory` folder, so a bench that uses it reads the run from `--output-format stream-json`.
- **The model catalog** sits in `<home>/cache/model-catalog/` on the human's machine, as `bin/loop_state/paths.py` expects. The throwaway homes didn't write one, since the mock was the only server they reached. Not tested: whether a long-lived-token session writes it. Where it doesn't, `bin/chunk_driver/project/model_choice.py` prints `no model catalog cached` and takes a typed model name.
## loop's Claude home: `bin/claude_home` generates it in the data folder from the clone it ships in, with links to the clone's instruction files and a `settings.json` whose `{clone}` it fills in
2026-12-04, lilleman's plan for 0.18.0. Serves goal 3. `bin/claude_home` builds the home in the data folder, `~/.local/share/build-release/claude-home`, so the clone stays a clean checkout: the files Claude Code keeps in its home never reach a commit. Only a change made through one of the six links below reaches the clone. `bin/claude_home` links `agents/`, `bin/`, `CLAUDE.md`, `principles/`, `rules/` and `skills/` to the clone's, `bin/` and `principles/` since `setup files: …` below, and writes `settings.json` from the clone's with the clone's path in place of `{clone}`, since the clone may lie anywhere and the tracked file can't hold its path. It builds the home again when the clone's commit or path changes, which covers a release's tag and a development clone alike. Probed on 2.1.336, once, while the home was built: `claude plugin install` finds a plugin only after `claude plugin marketplace add` of its marketplace; each exits 0 where its work is already done; and an install rewrites the home's `settings.json` in Claude Code's key order. Not tested: that a session loads `agents/`, `CLAUDE.md`, `rules/` and `skills/` through links, which needs a model request.
2026-12-04, lilleman's plan for 0.18.0. Serves goal 3. `bin/claude_home` builds the home in the data folder, `~/.local/share/build-release/claude-home`, so the clone stays a clean checkout: the files Claude Code keeps in its home never reach a commit. Only a change made through one of the links below reaches the clone. `bin/claude_home` links `agents/`, `bin/`, `CLAUDE.md`, `principles/` and `rules/` to the clone's, `bin/` and `principles/` since `setup files: …` below, and each of the clone's skills inside a `skills/` folder of the home's own, and writes `settings.json` from the clone's with the clone's path in place of `{clone}`, since the clone may lie anywhere and the tracked file can't hold its path. It builds the home again when the clone's commit or path changes, which covers a release's tag and a development clone alike. Probed on 2.1.336, once, while the home was built: `claude plugin install` finds a plugin only after `claude plugin marketplace add` of its marketplace; each exits 0 where its work is already done; and an install rewrites the home's `settings.json` in Claude Code's key order. Not tested: that a session loads `agents/`, `CLAUDE.md`, `rules/` and `skills/` through links, which needs a model request.
2026-12-06, item 605, for patch release 0.18.1. Claude Code writes the signed-in account's skills into `<home>/skills/synced/` at sign-in, which README → Install has the person do before the first build. A whole `skills` link then stopped that build at the folder in its place, and once made it would have carried Claude Code's writes into the clone. So `skills/` is a folder of the home's own, and each build replaces only the links in it: a skill the clone dropped loses its link, and what Claude Code wrote there stays in the home. The clone's `.gitignore` also ignores `skills/synced/` and `skills/.trash/`.
2026-12-04, the release review of 0.18.0, declining the architect's finding that two clones can rebuild one home. Only the README keeps the development clone's build-release, build-epic, `task-bench gather` and `claude-release` from repointing a running loop's home. Serves goal 2. One home per machine is what lets the person sign in once. A program-held guard would have to know which clone is the development one and whether a loop is running, and pass both into `claude_home`. The cost of the README's rule is a chunk that runs on unreleased rules after someone ran the development clone's tool. Valid while one person runs the setup on a machine; two clones that run loops at once would each need a home.
+2
View File
@@ -63,5 +63,7 @@
},
"skipDangerousModePermissionPrompt": true,
"skipWorkflowUsageWarning": true,
"syncClaudeAiPlugins": false,
"syncClaudeAiSkills": false,
"tui": "fullscreen"
}