init-index

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

A project command named init-index that creates or rebuilds a code index for the current project. An index is a searchable map of code files and their contents or structure.

In plain words
What is it for?
Use it when first setting up the project index or rebuilding it. It confirms the project directory, scans supported source files, excludes common generated or dependency folders, and reports file counts by language.
Why use it?
It helps an AI assistant or developer find relevant files in a large codebase without scanning everything manually. It also applies configured language, directory, and file-type rules during the scan.

Command for Claude Code

Written for Claude Code: a Claude Code plugin manifest.

Not installable: its command points at a path on the author’s own machine, so it runs nowhere else. The line is /home/user/my-project,.

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

Install

Getting it into your agent

This one installs as part of its plugin. Adding the marketplace and installing the plugin brings it with everything else the plugin ships.

Claude Code
/plugin marketplace add Claudate/project-multilevel-index
Claude Code
/plugin install 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 init-index

README.md
[![agentmods](https://agentmods.dev/badge/commands/claudate/project-multilevel-index/init-index.svg)](https://agentmods.dev/commands/claudate/project-multilevel-index/init-index)
Your own site
<a href="https://agentmods.dev/commands/claudate/project-multilevel-index/init-index"><img src="https://agentmods.dev/badge/commands/claudate/project-multilevel-index/init-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 2,833 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.00000 $0.02833
Opus 5 $0.00000 $0.01417
Sonnet 5 $0.00000 $0.00567
Haiku 4.5 $0.00000 $0.00283

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

Security

Grade A, and why

init-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 6d 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/init-index.md · 400 lines

How it starts

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

命令: /init-index - 初始化索引系统

🎯 使用场景

用户首次在项目中运行,或想要重建整个索引系统。


📋 执行步骤

步骤 0: 加载语言配置

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

  1. 读取 .claude/locale-config.json
  2. 加载语言文件到 LANG 对象
  3. 如果失败,使用默认语言 zh-CN

步骤 1: 确认项目根目录

询问用户:

{{LANG.messages.commands.initIndex.confirmDirectory}}

{directory} 替换为当前工作目录(使用 pwd 或等效命令获取)。

示例输出:

  • zh-CN: "当前目录是 /home/user/my-project, 确认这是项目根目录吗?"
  • en-US: "Current directory is /home/user/my-project, confirm this is the project root?"

如果用户确认,继续;否则要求用户 cd 到正确目录后重试。


步骤 2: 扫描项目结构

输出: {{LANG.messages.commands.initIndex.scanning}}

使用 Glob 工具扫描所有代码文件:

排除目录 (从 LANG.skill.excludePatterns.directories):

node_modules, .git, dist, build, .next, target, vendor, __pycache__, .cache

支持的文件类型 (从 LANG.skill.excludePatterns.fileTypes):

.js, .jsx, .ts, .tsx, .py, .java, .kt, .rs, .go, .cpp, .c, .h, .php, .rb, .swift, .cs

Glob 模式示例:

**/*.{js,jsx,ts,tsx,py,java,kt,rs,go,cpp,c,h,php,rb,swift,cs}

报告扫描结果:

输出: {{LANG.messages.commands.initIndex.found}}

按语言分组统计:

{{LANG.messages.commands.initIndex.fileCount}}  # 替换 {language} 和 {count}

输出总计:

{{LANG.messages.commands.initIndex.totalFiles}}  # 替换 {count} 和 {folders}

示例输出(zh-CN):

发现:
- JavaScript/TypeScript: 45 文件
- Python: 12 文件
- 总计 57 个代码文件,分布在 8 个文件夹

示例输出(en-US):

Found:
- JavaScript/TypeScript: 45 files
- Python: 12 files
- Total 57 code files across 8 folders

步骤 3: 生成文件头注释

输出: {{LANG.messages.commands.initIndex.generating}}

对每个代码文件执行以下操作:

3.1 读取文件内容

使用 Read 工具读取文件。

3.2 分析依赖 (Input)

根据文件扩展名识别依赖语句:

语言 依赖关键字 示例
JavaScript/TypeScript import, require import { foo } from './bar'
Python import, from from models import User
Java/Kotlin import import java.util.List;
Rust use use std::collections::HashMap;
Go import import "fmt"
C/C++ #include #include <vector>
C# using using System.Collections.Generic;
PHP use, require use Illuminate\Support\Facades\DB;
Ruby require require 'active_record'
Swift import import Foundation

Read the full file on GitHub · 400 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. 6d ago First seen · 400 lines · 0 tokens per session scan A 3ab43ef0edd5

Subscribe to this mod's changes

init-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 2,833 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.