Skip to content

feat(claude): メモリ更新時にNotion反映リマインダーを注入するhookを追加 - #950

Merged
keito4 merged 7 commits into
mainfrom
feat/claude-memory-update-hook
Jul 8, 2026
Merged

feat(claude): メモリ更新時にNotion反映リマインダーを注入するhookを追加#950
keito4 merged 7 commits into
mainfrom
feat/claude-memory-update-hook

Conversation

@keito4

@keito4 keito4 commented Jul 7, 2026

Copy link
Copy Markdown
Owner

Why

ローカルのClaude自動メモリ(~/.claude/projects/*/memory/)を更新した際に、Notion側(コンテキストDocの🔄・デイリーログ)への反映を忘れるケースがあったため。

What

  • PostToolUse(matcher: Write|Edit)にフックを追加
  • メモリディレクトリ配下への書き込みを検知したら、additionalContextで反映確認のリマインダーをClaudeに注入
  • 対象パスはjqのtestでフィルタ(それ以外のWrite/Editでは何も出力しない)

How

  • jqのみに依存(config-baseに同梱済み)
  • 動作確認済み:マッチ/非マッチ/file_pathなしの3ケースのパイプテスト+実セッションでの発火確認

Risk

  • 低。マッチしない場合は出力なし・exit 0。既存フックへの影響なし

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added support guidance for additional services in the credentials setup docs, including Sentry, Gemini API, Notion, and GitHub Packages.
    • Expanded macOS app availability to include Duet, Linear, Spark, and a new menu-bar utility.
  • Bug Fixes

    • Improved desktop configuration checks to keep dock, menu bar, input, and terminal shortcuts aligned with expected behavior.
    • Added a reminder flow when memory-related updates are detected.

keito and others added 5 commits June 30, 2026 01:28
~/.claude/projects/*/memory/ 配下へのWrite/Edit後に、NotionコンテキストDoc(🔄)とデイリーログへの反映確認をClaudeに自動注入する。反映漏れの再発防止。
@cursor

cursor Bot commented Jul 7, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 79e16482-6cd6-4881-802b-a64f76f4fe11

📥 Commits

Reviewing files that changed from the base of the PR and between a93c945 and 17db3ef.

📒 Files selected for processing (1)
  • .claude/settings.json
🚧 Files skipped from review as they are similar to previous changes (1)
  • .claude/settings.json

📝 Walkthrough

Walkthrough

This PR documents new MCP server/credential support (Sentry, Gemini, Notion, GitHub Packages) in the credentials README, adds a Claude Code PostToolUse hook detecting memory file edits, updates Homebrew casks/brews, and extends the nix-darwin config test suite with new assertions.

Changes

Credential Documentation

Layer / File(s) Summary
Credential README updates
credentials/README.md
Adds Sentry, Gemini API, Notion, and GitHub Packages rows to the MCP server table, expands the 1Password setup example, and documents token derivation and template scope notes.

Estimated code review effort: 2 (Simple) | ~10 minutes

Claude Code Memory Hook

Layer / File(s) Summary
Memory hook configuration
.claude/settings.json
Adds a PostToolUse hook matching Write|Edit|MultiEdit that detects edits to Claude project memory paths and emits a Japanese reminder to update README and Notion logs.

macOS System Configuration

Layer / File(s) Summary
Homebrew cask changes
nix/modules/homebrew.nix, test/nix-darwin-config.test.js
Removes yabai brew and alfred cask, adds duet, linear, readdle-spark, jordanbaird-ice casks, and updates test assertions accordingly.
Darwin defaults and home-manager tests
test/nix-darwin-config.test.js
Adds tests for Dock running-apps display, menu bar visibility, and home-manager cmux imports excluding tmux.
Input source and dotfiles tests
test/nix-darwin-config.test.js
Adds input-source helper assertions excluding Karabiner references, removes two required dotfile paths, and asserts privateConfig/mkOutOfStoreSymlink usage.

Estimated code review effort: 2 (Simple) | ~15 minutes

Possibly related PRs

  • keito4/config#610: Both PRs add new hooks.PostToolUse entries to .claude/settings.json triggering custom hook outputs.
  • keito4/config#854: Both PRs modify credentials/README.md for MCP server/credential documentation coverage.
  • keito4/config#897: Both PRs modify nix/modules/homebrew.nix cask/tap configuration and corresponding test/nix-darwin-config.test.js assertions.

Suggested labels: size/M

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately describes the main change: adding a memory-update hook with a Notion reminder.
Description check ✅ Passed The description covers Why, What, How, and Risk with concrete testing details, so it is mostly complete despite missing some template sections.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/claude-memory-update-hook

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3df1eb1778

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread .zsh/configs/pre/devcontainer-env.zsh Outdated
# NOTE: This list is duplicated in nix/home/zsh.nix (home.file). Keep both in sync.
# Clear previously exported tokens so removed entries in ~/.devcontainer.env don't linger.
unset SUPABASE_ACCESS_TOKEN VERCEL_TOKEN LINEAR_API_KEY DOPPLER_TOKEN
unset SUPABASE_ACCESS_TOKEN VERCEL_TOKEN LINEAR_API_KEY DOPPLER_TOKEN ELU_SENTRY_TOKEN GEMINI_API_KEY ELU_NOTION_API_KEY OYKOT_NOTION_API_KEY GITHUB_TOKEN NODE_AUTH_TOKEN

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve inherited GitHub/npm tokens

When a devcontainer, Codespace, or parent shell already injects GITHUB_TOKEN or NODE_AUTH_TOKEN, this startup file now unsets them before it even checks whether ~/.devcontainer.env exists or contains replacements. Because nix/home/zsh.nix sources this loader during zsh startup, shells without those keys in ~/.devcontainer.env lose otherwise-valid GitHub/npm credentials and gh, npm package installs, or package publishing can fail; the home-manager copy of this list needs the same treatment.

Useful? React with 👍 / 👎.

Comment thread .claude/settings.json Outdated
]
},
{
"matcher": "Write|Edit",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Match MultiEdit for memory updates

If a Claude Code version exposes MultiEdit (as the adjacent post-edit hook already accounts for), memory files changed via that tool skip this reminder entirely because the Claude Code hooks reference treats Write|Edit as an exact list of tool names, not a substring regex. Batched updates under ~/.claude/projects/*/memory/ therefore won't inject the Notion sync context even though they are the same memory-update scenario.

Useful? React with 👍 / 👎.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.claude/settings.json:
- Line 277: The hook matcher currently only covers Write and Edit, so MultiEdit
changes will bypass the Notion-sync reminder. Update the matcher in the relevant
settings entry to include MultiEdit as well, matching the pattern used by the
neighboring hooks in the same configuration.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9e3577f0-a3bb-4fce-8e8a-b4e716f50583

📥 Commits

Reviewing files that changed from the base of the PR and between 54ca48a and 3df1eb1.

📒 Files selected for processing (8)
  • .claude/settings.json
  • .zsh/configs/pre/devcontainer-env.zsh
  • credentials/README.md
  • credentials/templates/mcp.env.template
  • nix/home/zsh.nix
  • nix/modules/homebrew.nix
  • test/integration/credentials_templates.bats
  • test/nix-darwin-config.test.js

Comment thread .claude/settings.json Outdated
@keito4

keito4 commented Jul 7, 2026

Copy link
Copy Markdown
Owner Author

(aside)
@claude PRがbaseにマージする際にコンフリクトが発生しています。最新のbaseからpullし、修正してください。

@claude

claude Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Claude finished @keito4's task in 11m 7s —— View job


コンフリクト解決完了 ✅

  • 現在のブランチ状態確認
  • mainブランチの最新変更を取得(共通祖先: a085ca8
  • コンフリクトファイルを特定
  • 各コンフリクトを解決
  • マージコミット作成 & プッシュ(a93c945

解決内容

git read-tree による3wayマージを実施。コンフリクトの解決方針は以下の通りです:

ファイル 解決方針
credentials/templates/mcp.env.template mainによる削除を採用(private-config分離に伴う整理)
credentials/templates/devcontainer.env.template mainによる削除を採用
.zsh/functions/op, dot/config/agent-deck/config.toml, dot/config/codespaces-secrets/repos.txt mainによる削除を採用
.zsh/configs/pre/devcontainer-env.zsh mainの4キー構成を採用(org固有キーはprivate-configへ)
nix/home/zsh.nix mainの外部allowlistファイル方式(~/.config/devcontainer-env-keys.txt)を採用
nix/modules/homebrew.nix 両方の変更をマージ: duet/linear/readdle-spark(feature)+ jordanbaird-ice(main)を保持、alfred/yabaiはmainの削除を採用
test/integration/credentials_templates.bats mainのprivate-config未存在時スキップ方式を採用
test/nix-darwin-config.test.js 両方の変更をマージ: mainの新テスト群 + duet/linear/readdle-sparkの検証を追加
Branch

mainブランチの最新変更をマージ。コンフリクト解決方針:
- credentials/templates/mcp.env.template: mainによる削除を採用(private-config分離)
- .zsh/configs/pre/devcontainer-env.zsh: mainのキーセット(4キー)を採用
- nix/home/zsh.nix: mainの外部allowlistファイル方式を採用
- nix/modules/homebrew.nix: duet/linear/readdle-spark(feature)+ jordanbaird-ice(main)をマージ
- test/nix-darwin-config.test.js: mainの新テスト群 + duet/linear/readdle-spark の確認を追加
- test/integration/credentials_templates.bats: private-config未存在時はスキップする方式に更新

Co-authored-by: keito4 <keito4@users.noreply.github.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
nix/home/dotfiles.nix (1)

10-13: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Hardcoded absolute path reduces portability.

privateConfig hardcodes /Users/keito/develop/github.com/keito4/private-config/.... Since config is already passed into this module, prefer building the path from config.home.homeDirectory to avoid breakage if the username or home path differs.

♻️ Proposed fix
   privateConfig = path: {
-    source = config.lib.file.mkOutOfStoreSymlink "/Users/keito/develop/github.com/keito4/private-config/${path}";
+    source = config.lib.file.mkOutOfStoreSymlink "${config.home.homeDirectory}/develop/github.com/keito4/private-config/${path}";
     force = true;
   };
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@nix/home/dotfiles.nix` around lines 10 - 13, The privateConfig helper
currently hardcodes an absolute
/Users/keito/develop/github.com/keito4/private-config path, which makes the
module non-portable. Update the privateConfig function in dotfiles.nix to build
the symlink target from config.home.homeDirectory instead of a fixed
username-specific path, while keeping the existing mkOutOfStoreSymlink and force
behavior unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@test/settings-hooks.test.js`:
- Around line 174-187: The drift check in referencedHookScripts only extracts
hooks/*.py matches from hook.command, so it misses inline or non-Python hooks
like the jq memory hook and can let mismatched settings pass. Update
referencedHookScripts in the settings-hooks parity test to collect and compare
normalized matcher + command pairs, or whole hook entries, from
settingsObject.hooks instead of scanning only .py script references, so the
comparison covers every hook command consistently.

---

Nitpick comments:
In `@nix/home/dotfiles.nix`:
- Around line 10-13: The privateConfig helper currently hardcodes an absolute
/Users/keito/develop/github.com/keito4/private-config path, which makes the
module non-portable. Update the privateConfig function in dotfiles.nix to build
the symlink target from config.home.homeDirectory instead of a fixed
username-specific path, while keeping the existing mkOutOfStoreSymlink and force
behavior unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e2f984c8-eedd-49f5-b15e-bb734ab53100

📥 Commits

Reviewing files that changed from the base of the PR and between 3df1eb1 and a93c945.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (58)
  • .claude/commands/sync-settings.md
  • .claude/hooks/README.md
  • .claude/hooks/stop_test_verification.py
  • .context/code-complexity-baseline.json
  • .context/complexity-report.md
  • .devcontainer/Dockerfile
  • .devcontainer/claude-settings.json
  • .filelengthignore
  • .github/workflows/claude-code-review.yml
  • .github/workflows/claude.yml
  • .github/workflows/scheduled-maintenance.yml
  • .gitignore
  • .zsh/configs/virtual/node.zsh
  • .zsh/functions/op
  • AGENTS.md
  • commitlint.config.js
  • credentials/templates/devcontainer.env.template
  • credentials/templates/mcp.env.template
  • docs/adr/0016-use-kanary-for-keyboard-remapping.md
  • docs/adr/0017-manage-bettertouchtool-gestures.md
  • docs/adr/README.md
  • docs/mcp-servers-guide.md
  • docs/tool-catalog.md
  • dot/aerospace.toml
  • dot/config/agent-deck/config.toml
  • dot/config/codespaces-secrets/repos.txt
  • nix/home/default.nix
  • nix/home/dotfiles.nix
  • nix/home/input-source.nix
  • nix/home/zsh.nix
  • nix/hosts/darwin/default.nix
  • nix/modules/homebrew.nix
  • package.json
  • script/README.md
  • script/check-workflow-template-sync.js
  • script/credentials.sh
  • script/macos/agent-select-input-source.sh
  • script/macos/select-input-source.swift
  • script/macos/setup-bettertouchtool.js
  • script/repo-maintenance.sh
  • script/update-agents-md.sh
  • templates/workflows/claude.yml
  • templates/workflows/scheduled-maintenance.yml
  • test/brew-categories.test.js
  • test/claude-workflow-contract.test.js
  • test/eslint-complexity-rules.test.js
  • test/eslint-main-config.test.js
  • test/hooks-integrity.test.js
  • test/hooks-lifecycle.test.js
  • test/hooks-post-pr-tools.test.js
  • test/hooks-post-tools.test.js
  • test/integration/core-scripts.bats
  • test/integration/credentials_templates.bats
  • test/integration/lib_functions.bats
  • test/issue-resolver-agents.test.js
  • test/nix-darwin-config.test.js
  • test/required-workflow-trigger.test.js
  • test/settings-hooks.test.js
💤 Files with no reviewable changes (6)
  • dot/config/agent-deck/config.toml
  • dot/config/codespaces-secrets/repos.txt
  • credentials/templates/devcontainer.env.template
  • credentials/templates/mcp.env.template
  • script/macos/select-input-source.swift
  • test/claude-workflow-contract.test.js
✅ Files skipped from review due to trivial changes (13)
  • .github/workflows/scheduled-maintenance.yml
  • script/macos/agent-select-input-source.sh
  • .filelengthignore
  • nix/home/input-source.nix
  • test/hooks-integrity.test.js
  • .gitignore
  • .zsh/configs/virtual/node.zsh
  • .context/code-complexity-baseline.json
  • docs/adr/README.md
  • docs/adr/0016-use-kanary-for-keyboard-remapping.md
  • .claude/hooks/README.md
  • .context/complexity-report.md
  • AGENTS.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • test/integration/credentials_templates.bats

Comment on lines +174 to +187
function referencedHookScripts(settingsObject) {
const scripts = new Set();
const events = Object.values(settingsObject.hooks || {});
for (const entries of events) {
for (const entry of entries) {
for (const hook of entry.hooks) {
for (const match of hook.command.matchAll(/hooks\/(\w+\.py)/g)) {
scripts.add(match[1]);
}
}
}
}
return scripts;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

sed -n '1,260p' test/settings-hooks.test.js

Repository: keito4/config

Length of output: 10685


🏁 Script executed:

python3 - <<'PY'
import json, pathlib

for p in [pathlib.Path('.claude/settings.json'), pathlib.Path('.devcontainer/claude-settings.json')]:
    data = json.loads(p.read_text())
    print(f'FILE: {p}')
    for event, entries in data.get('hooks', {}).items():
        print(f'  EVENT: {event}')
        for entry in entries:
            print(f'    matcher: {entry.get("matcher")}')
            for hook in entry.get('hooks', []):
                print(f'      type={hook.get("type")} command={hook.get("command")}')
    print()
PY

Repository: keito4/config

Length of output: 6131


Parity test should compare full hook commands, not just .py scripts test/settings-hooks.test.js:174-187 The jq memory hook in .claude/settings.json is skipped by referencedHookScripts(), so an inline hook added to only one settings file can still pass this drift check. Compare normalized matcher + command pairs (or full hook entries) instead.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/settings-hooks.test.js` around lines 174 - 187, The drift check in
referencedHookScripts only extracts hooks/*.py matches from hook.command, so it
misses inline or non-Python hooks like the jq memory hook and can let mismatched
settings pass. Update referencedHookScripts in the settings-hooks parity test to
collect and compare normalized matcher + command pairs, or whole hook entries,
from settingsObject.hooks instead of scanning only .py script references, so the
comparison covers every hook command consistently.

@keito4

keito4 commented Jul 7, 2026

Copy link
Copy Markdown
Owner Author

(aside)
@claude PRがbaseにマージする際にコンフリクトが発生しています。最新のbaseからpullし、修正してください。

@claude

claude Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Claude finished @keito4's task in 10m 53s —— View job


コンフリクト解決完了 ✅

  • 現在のブランチ状態確認
  • mainブランチの最新変更を取得(origin/main @ 54ca48a
  • コンフリクトファイルを特定・解決
  • コミット & プッシュ(17db3ef

解決内容

前回のClaudeがgit read-treeを使用したため単一親コミットになっていた問題を修正し、正しい2親マージコミットを作成しました。

git merge --allow-unrelated-histories FETCH_HEAD で衝突を検出し、以下の方針で解決:

ファイル コンフリクト内容 解決方針
.claude/settings.json main側にメモリhookなし HEADのメモリhookを保持、さらにCodeRabbitのレビュー提案を適用してmatcherをWrite|EditWrite|Edit|MultiEditに修正
credentials/README.md main側にSentry/Gemini/Notion/GitHub Packages参照なし HEADの追加を保持
nix/modules/homebrew.nix main側にduet/linear/readdle-spark追加なし HEADの追加を保持
test/nix-darwin-config.test.js main側にduet/linear/readdle-sparkテストなし HEADのテストを保持

補足

  • メモリhookのmatcher修正(Write|EditWrite|Edit|MultiEdit)はCodeRabbitのレビューコメントに基づく改善です
  • マージコミット17db3efにはa93c945(feature branch)と54ca48a(main)の2つの親が含まれ、GitHub上でのコンフリクト検出が解消されます
    | Branch

…ommit)

mainブランチの最新変更(PR#949: 型安全性改善)をマージ。
前回のgit read-treeによる単一親コミットを置き換え、正しいマージコミットを作成。

コンフリクト解決方針:
- .claude/settings.json: HEADのメモリhookを保持 + matcherをWrite|Edit|MultiEditに修正
- credentials/README.md: HEADのSentry/Gemini/Notion/GitHub Packages参照を保持
- nix/modules/homebrew.nix: HEADのduet/linear/readdle-spark追加を保持
- test/nix-darwin-config.test.js: HEADのduet/linear/readdle-sparkテストを保持

Co-authored-by: keito4 <keito4@users.noreply.github.com>
@keito4
keito4 merged commit bc4f6d7 into main Jul 8, 2026
2 checks passed
@keito4
keito4 deleted the feat/claude-memory-update-hook branch July 8, 2026 11:13
@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 1.121.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@github-actions github-actions Bot added the released リリース済み label Jul 9, 2026
github-actions Bot added a commit that referenced this pull request Jul 9, 2026
…952,#954)

- templates/workflows/label-sync.yml: accept main's reusable workflow caller
  (PR#921: feat/920-reusable-label-sync)
- package-lock.json: regenerate to include takt@0.47.0 + latest deps

Co-authored-by: keito4 <keito4@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released リリース済み

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant