Skip to content

feat: add settings.local.json support for Claude Code integration#309

Open
CorticalCode wants to merge 10 commits intosirmalloc:mainfrom
CorticalCode:feat/settings-local-json
Open

feat: add settings.local.json support for Claude Code integration#309
CorticalCode wants to merge 10 commits intosirmalloc:mainfrom
CorticalCode:feat/settings-local-json

Conversation

@CorticalCode
Copy link
Copy Markdown
Contributor

Summary

Adds settings.local.json support to the Claude Code integration layer. Fixes #276.

  • When settings.local.json exists, the TUI install flow lets users choose which file to target
  • Detection functions check both files, matching Claude Code's merge precedence (local wins)
  • Uninstall cleans both files but only removes entries ccstatusline owns (isKnownCommand guard)
  • Hook sync targets the file where the statusLine lives, cleans stale hooks from the other

Design decisions

  1. Auto-detect: If settings.local.json exists on disk, prompt the user to choose a target. If it doesn't exist, default behavior is unchanged — zero friction for the common case.
  2. Local wins: settings.local.json takes precedence when checking installation status, matching Claude Code's own merge semantics.
  3. Ownership guard: Uninstall only removes statusLine entries identified by isKnownCommand(). A company-managed or user-custom statusLine in either file is never touched.
  4. Accurate display: Confirmation dialogs show the actual file being targeted. A warning appears if installing to settings.json while settings.local.json already has a statusLine that would take precedence.

Files changed

  • src/utils/claude-settings.tsfilePath param on load/save, private resolveStatusLine() for dual-file precedence, ownership-guarded uninstall
  • src/utils/hooks.ts — file-aware hook sync targeting active file, stale hook cleanup from non-active file
  • src/tui/components/FileTargetSelect.tsx — new component for install target selection
  • src/tui/App.tsx — install flow integration, fileTarget screen, confirmation warnings
  • src/tui/components/InstallMenu.tsxlocalSettingsDetected prop for contextual help text
  • Tests for all new behavior including path traversal, malformed files, ownership preservation

Known limitations

  • If settings.json is read-only (e.g., company-managed with restrictive permissions), write operations that target it will error. The settings.local.json support provides a workaround.
  • Related but not in scope: PR feat(settings): Add support for local/project settings #58 by @jackall3n (project-level ccstatusline settings) addresses a different settings layer.

Test plan

  • Install to settings.json (default, no settings.local.json present) — unchanged behavior
  • Install when settings.local.json exists — FileTargetSelect screen appears
  • Install to settings.local.json — writes only to local file
  • Uninstall with entries in both files — removes ccstatusline entries, preserves non-ccstatusline entries
  • Hook sync after install to local file — hooks written to local, cleaned from global

🤖 Generated with Claude Code

CorticalCode and others added 9 commits April 12, 2026 16:02
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Adds optional `targetPath` parameter to `installStatusLine` so it can
write to settings.local.json (or any path) instead of the default
settings.json. Hook sync is skipped for targeted writes pending Task 6.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow claude.local.settings file to configure ccstatusline

1 participant