"""Create the real-Git and real-Claude starting state; pass a fresh scratch directory.
Run with a configured CLAUDE_CONFIG_DIR, and inherit that same name in scenarios.
No transcript or provider response is invented.
"""
from pathlib import Path
import os, subprocess, sys
root = Path(sys.argv[1]).resolve()
repo = root / 'repo'
repo.mkdir(parents=True)
def git(*args):
    subprocess.run(['git', '-C', str(repo), *args], check=True)
git('init', '-b', 'main')
git('-c', 'user.name=Proof', '-c', 'user.email=proof@example.invalid',
    'commit', '--allow-empty', '-m', 'Initial')
git('worktree', 'add', '-b', 'feat\u00a0', str(root / 'repo-wt'))
env = dict(os.environ)
env.pop('CLAUDECODE', None)
for cwd, prompt in [(repo, 'Reply exactly Root-hello'),
                    (root / 'repo-wt', 'Reply exactly Worktree-hello')]:
    subprocess.run(['claude', '-p', '--model', 'haiku', prompt],
                   cwd=cwd, env=env, check=True, timeout=120)
print('Worktree HEAD bytes:', (repo / '.git/worktrees/repo-wt/HEAD').read_bytes().hex())
