Skip to content

feat(claudecode): support user-defined hooks from settings.json#14823

Closed
xvweirong wants to merge 3 commits into
CherryHQ:mainfrom
xvweirong:feat/claudecode-user-hooks-v2
Closed

feat(claudecode): support user-defined hooks from settings.json#14823
xvweirong wants to merge 3 commits into
CherryHQ:mainfrom
xvweirong:feat/claudecode-user-hooks-v2

Conversation

@xvweirong
Copy link
Copy Markdown
Contributor

@xvweirong xvweirong commented May 4, 2026

Summary

This PR adds support for user-defined hooks in Cherry Studio's Claude Code integration, enabling skills like planning-with-files and other hook-dependent workflows to function correctly.

What changed

  1. New user-hooks.ts — loads and merges user-defined hooks from three settings.json sources (project-level → user-level → Cherry Studio-isolated). Supports all SDK HookEvent types (PreToolUse, PostToolUse, Stop, UserPromptSubmit, etc.).

  2. Hook merging in index.ts — replaces the hardcoded hooks: { PreToolUse: [...] } with mergeHooks(systemHooks, userHooks), so Cherry Studio's RTK rewrite and permission gate continue to run alongside user hooks.

Why this matters

Many community skills (e.g., planning-with-files) rely on hooks for:

  • Injecting context before/after tool use
  • Running validation or cleanup on Stop
  • Intercepting UserPromptSubmit for routing

Previously, Cherry Studio hardcoded hooks in Options, which silently overrode any user-defined hooks loaded via settingSources. This PR makes the two coexist.

Test plan

  • pnpm typecheck:node passes
  • transform.test.ts (8 tests) passes
  • No unrelated files modified

Related

🤖 Generated with Claude Code

David and others added 3 commits May 4, 2026 13:16
…kill files

- Add user-hooks.ts to load and merge user-defined hooks from project-level,
  user-level, and Cherry Studio-isolated settings.json files.
- Convert command-type hooks into SDK HookCallbacks with stdin/stdout protocol,
  timeout support, and abort signal handling.
- Merge system hooks (RTK rewrite, permission gate) with user hooks so both
  run together — system first, user second.
- Auto-allow Read/Write/Edit on planning files (task_plan.md, findings.md,
  progress.md) to prevent approval fatigue from skills.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- Remove planning file auto-allow (task_plan.md, findings.md, progress.md) —
  this was an inappropriate special-case for a specific skill; users should
  configure their own permissions.
- Remove changeset file (main app changes don't use changesets).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@xvweirong
Copy link
Copy Markdown
Contributor Author

Superseded by #14977 — cleaner branch with prompt-based hook support and no merge conflicts.

@xvweirong xvweirong closed this May 10, 2026
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.

1 participant