# Scale this repo for coding agents, on plain git Adapt Anthropic's post "Redesigning source control at Anthropic" (https://www.anthropic.com/engineering/redesigning-source-control) to this repo, its agents and CI. Anthropic replaced git with Scion, which the post says "is by no means a suitable replacement for git for general use"; we stay on git. Tags: [POST] (the post says it), [OURS] (our adaptation; never present it as Anthropic's practice). (From the Ask It Something Hard explainer. Not produced or endorsed by Anthropic.) ## Rules - Work in your own worktree: `git fetch origin`, then `git worktree add --no-track -b source-control-audit ../source-control-audit origin/main`. "main" means the default branch (`git symbolic-ref --short refs/remotes/origin/HEAD`). - Measure read-only; create no tokens; redact credentials. - Ask me before anything destructive (deleting branches, worktrees, caches; gc, prune) or shared: CI, branch protection, merge settings, mirrors, servers, deploys, remotes, git config outside this repo, scheduled jobs. CI files and CODEOWNERS count as shared: propose them as diffs. - Never force-push, rewrite history or push. Stage only files you created. - Commands below are proposals; experiment only in a scratch directory. ## Steps 1. **Measure** [OURS]. Mark numbers measured, estimated or unknown. Merges per day: `git rev-list --count --first-parent --since="30 days ago" origin/main` รท 30 (under rebase-merge, count merged PRs on the host instead). From CI config and logs: checkouts per day, time and GB spent fetching. Repo size. Agents per machine. **Then stop, report and wait for my go-ahead.** Rough guide (ours): under ~50 merges/day, fetching under ~10% of job time and a few agents means steps 2 and 8 only. 2. **One store, a worktree per agent** [OURS, echoing Scion's per-machine daemon]. Script `git worktree add --no-track -b ../wt/ origin/main` on one shared clone; one process fetches and runs gc (set `gc.auto=0`). Cleanup: once landed (PR merged, or `git merge-base --is-ancestor origin/main`), `git worktree remove`, `git branch -d`. If `-d` refuses (squash merges), list the branch for me. Never `-D`. 3. **Fetch less, as a stopgap** [OURS, with git features the post names]. Build-only jobs: `git clone --depth=1`. Jobs reading a few folders: `git clone --filter=blob:none --sparse `, then in ``: `git sparse-checkout set `. The post's caveat: keeping diff and blame working on partial clones "took more and more care". 4. **Ask, don't clone** [POST: jobs query an API, often with no local repo; OURS: how on git]. For jobs cloning only to answer questions (blame, merge base, diff), propose the host's API or one warm-clone service. 5. **Cache in tiers** [OURS, adapting Scion's strict tiering]. Only if many machines fetch at real cost. Machine store, regional mirror, origin; each tier fills misses from the one above. Objects never go stale; refs move, so read them from the origin (`git ls-remote origin refs/heads/main`), then `git fetch `. 6. **Drop the global merge lock** [POST: post-merge and pre-deploy tests, agents fix conflicts; OURS: batched landing]. Only if merging is the bottleneck. Land a batch of reviewed changes, then test (merge queues test first). Main can briefly be red, so gate deploys on pre-deploy tests. On failure, in a throwaway worktree (`git worktree add --detach ../wt/bisect `): `git bisect start --first-parent `, `git bisect run `, `git bisect reset`. Revert the culprit, reviewed: `git revert -m 1 `, or `git revert ` if squashed. 7. **Record `landed_on`** [OURS, from the post's lesson: tools read the commit log instead of asking the review tool]. Store each change's merge or squash commit on main in its record (the host may already), and point tools scanning `git log` at it. 8. **Humans review intent** [POST]. People check a change's intent and stop agents breaking core constraints or over-engineering against hypothetical concerns. Propose approval rules separating comment-only changes from sensitive logic. 9. **Superfans** [POST; OURS: start with one]. Only for a component that failed recently. Write `docs/superfan-.md`: an agent whose only job is its health, reading its telemetry and logs. Grant no access. Keep normal alerts. ## Deliverable 1. `SOURCE-CONTROL-AUDIT.md`, under a page, summarised in your reply: step 1 numbers, each step fits / doesn't fit / needs my decision, with evidence. 2. Scripts and docs committed, one commit per step that changes a file. 3. Shared or destructive changes as exact commands or diffs for my yes.