update-index

update-index is a command for Claude Code from Claudate/project-multilevel-index. It costs 0 tokens per session (1,218 once invoked), scanned A, original, MIT.

A command that updates a project's generated documentation indexes after code changes. It checks whether a change affects dependencies or public definitions, then updates the relevant index files when needed.

In plain words
What is it for?
Use it to refresh project and folder indexes, dependency diagrams, and file header information after adding or removing imports, exports, classes, or other public code.
Why use it?
It prevents project maps and dependency documentation from becoming outdated while avoiding unnecessary work for changes inside a function. It can run manually or after file-edit hooks.

Command for Claude Code

Written for Claude Code: PostToolUse hook event.

Part of the project-multilevel-index plugin — 1 skill, 4 commands shipped together

Good fit Use it to refresh project and folder indexes, dependency diagrams, and file header information after adding or removing imports, exports, classes, or other public code.

Compare 6 commands from other repositories ↓
Install with agentmods
npx agentmods add commands/claudate/project-multilevel-index/update-index
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.

Clone the repo
git clone --depth 1 https://github.com/Claudate/project-multilevel-index

Made for: Claude Code.

Or install project-multilevel-index, the plugin that ships this one along with the rest of its 1 skill, 4 commands.

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-index

README.md
[![agentmods](https://agentmods.dev/badge/commands/claudate/project-multilevel-index/update-index.svg)](https://agentmods.dev/commands/claudate/project-multilevel-index/update-index)
Your own site
<a href="https://agentmods.dev/commands/claudate/project-multilevel-index/update-index"><img src="https://agentmods.dev/badge/commands/claudate/project-multilevel-index/update-index.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,218 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.00000 $0.01218
Opus 5 $0.00000 $0.00609
Sonnet 5 $0.00000 $0.00244
Haiku 4.5 $0.00000 $0.00122

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

Security

Grade A, and why

update-index 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 8d 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.

.claude-plugin/commands/update-index.md · 169 lines

How it starts

The opening of the file, as written. The whole thing — 169 lines — stays where its author put it; the contents beside it link to each section on GitHub.

命令: /update-index - 更新索引

🎯 使用场景

  • 用户手动触发索引更新
  • PostToolUse Hook 自动调用(文件修改后)

📋 执行步骤

步骤 0: 加载语言配置

必须首先执行,详见 ../core/i18n.md


步骤 1: 检测变更范围

输出: {{LANG.messages.commands.updateIndex.analyzing}}

如果是 Hook 触发,分析被修改的文件:

过滤规则:

  • 是否为索引文件自身(PROJECT_INDEX.md, FOLDER_INDEX.md)? → 跳过
  • 是否为代码文件? → 继续
  • 文件大小 > 500KB? → 跳过(性能保护)

变更类型判断:

变更内容 类型 更新范围
新增/删除 import/require/use {{LANG.skill.changeTypes.structural}} {{LANG.skill.updateRanges.full}}
修改 export/public/class 声明 {{LANG.skill.changeTypes.structural}} {{LANG.skill.updateRanges.full}}
修改 Input/Output/Pos 注释 {{LANG.skill.changeTypes.header}} {{LANG.skill.updateRanges.header}}
修改函数内部实现 {{LANG.skill.changeTypes.implementation}} {{LANG.skill.updateRanges.none}}

判断方法:

  1. 读取文件内容
  2. 搜索关键字:
    • 依赖: import, require, use, from, #include, using
    • 导出: export, public, class, interface, function, def, fn, async, struct
  3. 如果发现变更 → Structural
  4. 否则检查文件头是否修改 → Header
  5. 都不是 → Implementation(跳过)

步骤 2: 执行增量更新

根据变更类型执行不同更新策略:

Structural 变更
  1. 重新分析文件:

    • 分析 Input(依赖)
    • 分析 Output(导出)
    • 推断 Pos(定位)
  2. 更新文件头注释:

    • 使用 Edit 工具更新
    • 保留用户自定义内容
  3. 更新 FOLDER_INDEX.md:

    • 只更新该文件的条目
    • 不重新生成整个索引
  4. 更新 PROJECT_INDEX.md:

    • 重新生成依赖关系图
    • 更新受影响的目录结构描述
Header 变更
  1. 仅更新文件头注释
  2. 不触及 FOLDER_INDEX 或 PROJECT_INDEX

步骤 3: 智能合并(批量更新优化)

如果短时间内(< 5秒)检测到多个文件变更:

  1. 收集所有变更
  2. 去重文件夹(每个文件夹只更新一次)
  3. 最后统一更新根索引

这样可以避免频繁写入同一文件。


步骤 4: 报告更新

静默模式(小改动):

{{LANG.messages.notifications.skipped}}

通知模式(结构性变更):

{{LANG.messages.commands.updateIndex.updated}}
- {{LANG.messages.commands.updateIndex.updatedItems}}

替换占位符:

  • {file}: 文件名
  • {folder}: 文件夹名

示例输出(zh-CN):

[索引系统] 检测到结构性变更,已自动更新索引
已更新:
- 文件头注释、services/FOLDER_INDEX.md、PROJECT_INDEX.md

示例输出(en-US):

[Index System] Detected structural change, automatically updated index
Updated:
- File header, services/FOLDER_INDEX.md, PROJECT_INDEX.md

Read the full file on GitHub · 169 lines

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. 8d ago First seen · 169 lines · 0 tokens per session scan A c6a80db56738

Subscribe to this mod's changes

update-index is a command published in the GitHub repository Claudate/project-multilevel-index (139 stars, last pushed 7mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,218 tokens. 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.