re-init

A command that builds or updates AI guidance documents named CLAUDE.md at the repository root and inside detected modules. The documents describe the project structure, important files, interfaces, dependencies, entry points, tests, and project rules.

In plain words
What is it for?
Use it when starting work on a project, after major structural changes, or when you want root and module documentation that helps an agent navigate the codebase.
Why use it?
It gives an AI coding agent a reusable map of an unfamiliar repository instead of requiring the project context to be rediscovered every time. It can update the index incrementally and reports what it scanned or skipped.

Command

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/ysicing/code-pilot/re-init
Clone the repo
git clone --depth 1 https://github.com/ysicing/code-pilot
Per session 22 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 728 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 $0.00022 $0.00728
Opus 5 $0.00011 $0.00364
Sonnet 5 $0.00004 $0.00146
Haiku 4.5 $0.00002 $0.00073

Measured 2d ago against content hash b5a2c76e72ae, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

re-init 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 2d 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/re-init.md · 54 lines

What it actually says

用法

/re-init <项目摘要或名称>

目标

以"根级简明 + 模块级详尽"的混合策略初始化项目 AI 上下文:

  • 在仓库根生成/更新 CLAUDE.md(高层愿景、架构总览、模块索引、全局规范)。
  • 在识别的各模块目录生成/更新本地 CLAUDE.md(接口、依赖、入口、测试、关键文件等)。
  • 为了提升可读性,会在根 CLAUDE.md 中自动生成 Mermaid 结构图,并为每个模块 CLAUDE.md 添加导航面包屑

编排说明

步骤 1:调用 get-current-datetime 子智能体获取当前时间戳。

步骤 2:调用一次 init-architect 子智能体,输入:

  • project_summary: $ARGUMENTS
  • current_timestamp: (来自步骤1的时间戳)

执行策略(由 Agent 自适应决定,不需要用户传参)

  • 阶段 A:全仓清点(轻量) 快速统计文件与目录,识别模块根(package.json、pyproject.toml、go.mod、apps/、packages/、services/* 等)。
  • 阶段 B:模块优先扫描(中等) 对每个模块做"入口/接口/依赖/测试/数据模型/质量工具"的定点读取与样本抽取。
  • 阶段 C:深度补捞(按需) 若仓库较小或模块规模较小,则扩大读取面;若较大,则对高风险/高价值路径分批追加扫描。
  • 覆盖率度量与可续跑 输出"已扫描文件数 / 估算总文件数、已覆盖模块占比、被忽略/跳过原因",并列出"建议下一步深挖的子路径"。重复运行 /init-project 时按上次索引做增量更新断点续扫

安全与边界

  • 只读/写文档与索引,不改源代码。
  • 默认忽略常见生成物与二进制大文件。
  • 结果在主对话打印"摘要",全文写入仓库。

输出要求

  • 在主对话中打印"初始化结果摘要",包含:
    • 根级 CLAUDE.md 是否创建/更新、主要栏目概览。
    • 识别的模块数量及其路径列表。
    • 每个模块 CLAUDE.md 的生成/更新情况。
    • 明确提及"已生成 Mermaid 结构图"和"已为 N 个模块添加导航面包屑"
    • 覆盖率与主要缺口。
    • 若未读全:说明"为何到此为止",并列出推荐的下一步(例如"建议优先补扫:packages/auth/src/controllers")。
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. 2d ago First seen · 54 lines · 22 tokens per session scan A b5a2c76e72ae

Subscribe to this mod's changes

re-init is a command published in the GitHub repository ysicing/code-pilot (38 stars, last pushed 5mo ago), licensed Apache-2.0. It adds 22 tokens to every session and 728 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.