/initis not a one-time scaffolding command — it's a CLAUDE.md lifecycle tool. 首次运行生成 CLAUDE.md,之后每次运行检测文档与代码的漂移并精准更新。
A prompt template for pi (coding agent) that keeps your CLAUDE.md in sync with the code as it actually is today.
Stock /init templates only help on day one. But codebases evolve:
- the config system moved from
.envtoconfig.yaml - a
tools/directory appeared three months ago - the architecture section describes services that were since refactored away
The CLAUDE.md written at project birth quietly becomes a lie — and every future agent session starts by being misled by it.
| Run | Mode | Behavior |
|---|---|---|
| First run (no CLAUDE.md) | Generate | Commands (incl. single-test), big-picture architecture, project-specific pitfalls |
| Every run after | Drift audit | Extracts every factual claim in the existing file → verifies each against the code (commands exist? paths alive? config mechanism unchanged?) → hunts drift via git history → edits surgically instead of rewriting → reports what went stale and why |
Optional hygiene checks when relevant: generated artifacts that shouldn't be git-tracked, missing docs indexes, stale cross-references between parent/sub-package docs.
# global (all projects)
cp init.md ~/.pi/agent/prompts/
# or per-project (takes precedence, requires project trust)
cp init.md your-project/.pi/prompts//init # audit or generate
/init 重点关注计费相关文档 # with extra instructions
- STALE: "configure via LEONARDO_CREDENTIAL env var" — the project moved to
config.yaml (multi-account) in 8f3a21c; rewritten to match server/config.js
- STALE: "docs/API.md is the only integration doc" — docs/ now has 6 files
including pricing.md and SOP.md; added index reference
- VERIFIED OK: test commands, request flow description
- ADDED: tools/pricing.mjs subcommands (added last month, undocumented)
- Verify, don't assume — claims that can't be verified cheaply are left out or marked unverified
- Edit, don't rewrite — your hand-tuned sections survive the update
- The report is the deliverable — you learn what drifted, not just get a new file
- Short > complete — "a CLAUDE.md twice as long is half as useful"
MIT