Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 

Repository files navigation

pi-init-lifecycle

/init is 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.

The problem

Stock /init templates only help on day one. But codebases evolve:

  • the config system moved from .env to config.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.

What this template does

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.

Install

# global (all projects)
cp init.md ~/.pi/agent/prompts/

# or per-project (takes precedence, requires project trust)
cp init.md your-project/.pi/prompts/

Usage

/init                          # audit or generate
/init 重点关注计费相关文档        # with extra instructions

Example drift report (Mode B)

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

Design principles baked into the template

  • 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"

License

MIT

About

A pi prompt template that keeps CLAUDE.md in sync with your codebase — generates it on first run, then audits drift and updates it surgically as your project evolves

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors