Skip to content

fix(claude-code): preserve permissions when removing hooks - #1948

Open
MuskanPaliwal wants to merge 5 commits into
entireio:mainfrom
MuskanPaliwal:fix-claude-settings-removal
Open

fix(claude-code): preserve permissions when removing hooks#1948
MuskanPaliwal wants to merge 5 commits into
entireio:mainfrom
MuskanPaliwal:fix-claude-settings-removal

Conversation

@MuskanPaliwal

Copy link
Copy Markdown
Contributor

Fixes #1924

entire agent remove claude-code is documented as uninstalling Claude Code hooks, but it also removed Read(./.entire/metadata/**) from permissions.deny. When that was the only permission and the file contained only Entire hooks, both top-level objects were deleted and .claude/settings.json became {}.

This PR removes the permissions cleanup from UninstallHooks. Agent removal now filters Entire-managed entries under hooks and leaves the rest of the shared Claude settings file alone. Permissions, user-defined hooks, unknown hook types, and unrelated top-level settings are preserved. A file containing only Entire hooks and no other settings still correctly becomes {}.

Windows amd64 in the issue records the reporter's environment; the issue does not identify this as an OS-specific bug. The affected code path is platform-independent JSON parsing and rewriting.

Testing

  • Added regression coverage for permissions containing Entire and user rules, additional permission fields, and unknown nested fields
  • Covered settings containing only Entire hooks, mixed Entire and user hooks, and unrelated top-level settings
  • Ran mise run lint
  • Ran mise run test
  • Ran mise run test:ci
  • Ran the Claude Code package with the race detector
  • Cross-compiled the Claude Code test package for Windows amd64
  • Manually built the CLI and verified that agent add claude-code followed by agent remove claude-code removes all seven hooks while preserving the complete permissions object

@MuskanPaliwal
MuskanPaliwal marked this pull request as ready for review August 11, 2026 12:11
@MuskanPaliwal
MuskanPaliwal requested a review from a team as a code owner August 11, 2026 12:11
@MuskanPaliwal

Copy link
Copy Markdown
Contributor Author

I took another look, and I think I interpreted the issue too broadly. Entire installs Read(./.entire/metadata/**), so removing it along with the hooks is reasonable cleanup. The existing code already preserves other permissions and settings.

I鈥檓 going to pause this PR until we know whether the reporter already had that rule before enabling Entire, or whether they want to remove Claude hooks while keeping Entire active for another agent. Depending on the answer, I鈥檒l either narrow the fix or close the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

agent remove claude-code deletes unrelated .claude/settings.json keys

1 participant