update-memory

update-memory is a command for Claude Code from Galaxy-Dawn/claude-scholar. It costs 21 tokens per session (905 once invoked), scanned A, original, MIT.

A command that checks whether CLAUDE.md, a shared instruction and memory file, is out of date with skills, commands, agents, and hooks.

In plain words
What is it for?
Use it to check, preview, or update memory after changing those source files, with optional forced or non-interactive modes.
Why use it?
It helps keep the summary file synchronized with its source configuration while preserving manual sections.

Command for Claude Code

Written for Claude Code: PostToolUse hook event. Also seen: reads .claude/ paths; mentions CLAUDE.md.

Part of the claude-scholar plugin — 45 skills, 34 commands, 6 agents, 5 hooks shipped together

About the project

Claude Scholar is a semi-automated research assistant for academic research and software development, supporting literature review, coding, experiments, reporting, writing, and project knowledge management. Computer science and AI researchers use it across the research workflow with several coding-agent platforms; the catalogue contains its skills, commands, agents, hooks, plugin, and instruction.

Galaxy-Dawn/claude-scholar · 5,336 stars · on GitHub

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/galaxy-dawn/claude-scholar/update-memory
Clone the repo
git clone --depth 1 https://github.com/Galaxy-Dawn/claude-scholar

Made for: Claude Code.

Or install claude-scholar, the plugin that ships this one along with the rest of its 45 skills, 34 commands, 6 agents, 5 hooks.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for update-memory

README.md
[![agentmods](https://agentmods.dev/badge/commands/galaxy-dawn/claude-scholar/update-memory.svg)](https://agentmods.dev/commands/galaxy-dawn/claude-scholar/update-memory)
Your own site
<a href="https://agentmods.dev/commands/galaxy-dawn/claude-scholar/update-memory"><img src="https://agentmods.dev/badge/commands/galaxy-dawn/claude-scholar/update-memory.svg" alt="Measured on agentmods" height="20"></a>
Per session 21 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 905 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00021 $0.00905
Opus 5 $0.00010 $0.00452
Sonnet 5 $0.00004 $0.00181
Haiku 4.5 $0.00002 $0.00090

Measured 7d ago against content hash 7a8ef6f29c9a, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

update-memory scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 7d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

commands/update-memory.md · 127 lines

What it actually says

Update Memory

检查并更新 CLAUDE.md 全局记忆文件,确保其内容与 skills、commands、agents、hooks 的源文件保持同步。

功能概述

CLAUDE.md 是一个汇总记忆文件,包含:

  • 技能目录结构(来自 skills/
  • 命令列表(来自 commands/
  • 代理配置(来自 agents/
  • 钩子定义(来自 hooks/

当这些源文件发生变化时,CLAUDE.md 需要同步更新。

检测逻辑

  1. 扫描源文件修改时间

    • ~/.claude/skills/**/skill.md
    • ~/.claude/commands/**/*.md
    • ~/.claude/agents/**/*.md
    • ~/.claude/hooks/**/*.{js,json}
  2. 对比 CLAUDE.md 最后修改时间

    • 如果任意源文件比 CLAUDE.md 新 → 需要更新
    • 记录上次同步时间戳(~/.claude/.last-memory-sync
  3. 生成报告

    • 列出所有变更的源文件
    • 显示需要更新的 CLAUDE.md 章节

更新流程

1. 扫描阶段

扫描 Skills: X 个
扫描 Commands: Y 个
扫描 Agents: Z 个
扫描 Hooks: W 个

2. 对比阶段

需要更新的章节:
- [ ] 技能目录结构 (3 个技能变更)
- [ ] 命令列表 (1 个命令新增)
- [ ] 代理配置 (无变更)
- [ ] 钩子定义 (2 个钩子修改)

3. 确认更新

询问用户是否执行更新:

是否更新 CLAUDE.md? (yes/no/diff)
- yes: 执行更新
- no: 取消
- diff: 显示详细差异

4. 执行更新

  • 保留用户手动编辑的内容(如"用户背景"、"技术栈偏好")
  • 仅更新 AUTO-GENERATED 标记的章节
  • 更新时间戳

使用方式

/update-memory          # 检查并提示更新
/update-memory --check  # 仅检查,不更新
/update-memory --force  # 强制更新,不询问
/update-memory --diff   # 显示差异对比

输出示例

检查结果

📋 CLAUDE.md 记忆状态检查

源文件状态:
✅ Skills: 24 个 (最近修改: ml-paper-writing)
✅ Commands: 14 个 (最近修改: update-readme)
✅ Agents: 7 个 (无变更)
✅ Hooks: 5 个 (最近修改: session-summary)

时间对比:
- CLAUDE.md 最后更新: 2024-01-15 10:30
- 源文件最后修改: 2024-01-16 14:22

⚠️ 检测到变更,建议更新 CLAUDE.md

变更详情:
1. skills/ml-paper-writing/skill.md (修改于 14:22)
2. commands/update-readme.md (修改于 13:15)
3. hooks/session-summary.js (修改于 11:45)

是否执行更新? (yes/no/diff)

更新完成

✅ CLAUDE.md 已更新

更新内容:
- 技能目录: 同步 24 个技能
- 命令列表: 同步 14 个命令
- 代理配置: 无变更
- 钩子定义: 同步 5 个钩子

下次同步时间戳已更新。

集成建议

  • session-summary.js 中集成检查提醒
  • 在 PostToolUse 钩子中实时检测
  • 建议定期执行(如每次会话结束时)
Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 7d ago First seen · 127 lines · 21 tokens per session scan A 7a8ef6f29c9a

Subscribe to this mod's changes

update-memory is a command published in the GitHub repository Galaxy-Dawn/claude-scholar (5,336 stars, last pushed 10d ago), licensed MIT. It adds 21 tokens to every session and 905 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.