You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor(claude): make ctm pure-overlay; never mutate Claude config files
ctm previously wrote three Claude-owned config files at install /
first-run time:
- ~/.claude.json: remoteControlAtStartup=true
- ~/.claude/settings.json: tui="fullscreen", viewMode="focus"
- ~/.config/ctm/env.sh: sourced by the launching shell
This commit reduces the surface to zero. ctm now never writes to any
Claude-owned config. All ctm-side defaults are delivered via
~/.config/ctm/claude-overlay.json (passed via 'claude --settings') and
~/.config/ctm/claude-env.json (read by ctm and exported into the
launch shell as a Go-built export prelude). Direct 'claude' invocations
outside ctm are now completely unaffected.
(1) Move tui, viewMode, remoteControlAtStartup into the overlay
template (cmd/overlay.go: buildSampleOverlay). Delete:
- claude.EnsureTUIFullscreen + EnsureViewModeFocus
- claude.EnsureRemoteControlAtStartup + ClaudeJSONPath
- claude.patchJSONFile (no remaining callers)
plus their tests. Drop the matching ensureClaude*Default helpers
and call sites in cmd/bootstrap.go + cmd/install.go.
(2) Replace bash-script env.sh with JSON-shaped claude-env.json.
New internal/config/claude_env.go provides:
- LoadClaudeEnv(path) — strict JSON load, key-name validation
- (ClaudeEnvFile).ShellExports() — alphabetised, single-quote-
escaped 'export K1=V1 K2=V2' string
- ClaudeEnvExports() — one-call convenience for the launch path
BuildCommand's last param changes from envFilePath to envExports
(a pre-built shell prelude); EnvFilePathIfExists removed. Sample
file pre-seeds CLAUDE_CODE_NO_FLICKER and CTM_STATUSLINE_DUMP
(the same two vars the old env.sh shipped).
claude.SettingsJSONPath + ReadEffortLevel are kept — read-only, used
by the statusline renderer.
Existing users: ctm auto-creates claude-env.json on next launch via
ensureOverlaySidecars; their stale env.sh becomes inert (per the
hard-cutover plan; not auto-deleted).
Verified: go vet -tags sqlite_fts5 ./..., go build, and
go test -tags sqlite_fts5 -race ./... — all 27 packages green.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
// - CTM_STATUSLINE_DUMP: where `ctm statusline` writes per-session
141
+
// quota dumps; `{uuid}` is substituted by
142
+
// the statusline subcommand at render time.
143
+
constsampleClaudeEnvJSON=`{
144
+
"_comment": "ctm-managed env vars exported into the shell that spawns claude. Only affects claude processes launched via ctm; direct 'claude' calls outside ctm are unaffected. Use this for vars claude reads too early in startup for claude-overlay.json's 'env' block to take effect. For anything else, prefer the overlay's 'env' block.",
0 commit comments