| description | 创建或更新 CLAUDE.md — 首次生成,或跟随项目演进检测漂移并优化 |
|---|---|
| argument-hint | [附加说明] |
Analyze this codebase and create or update CLAUDE.md, which will be given to future instances of pi to operate in this repository. The goal: the file must accurately describe the codebase as it is today.
Check whether CLAUDE.md (or AGENTS.md) already exists in the repository root.
Analyze the codebase and create CLAUDE.md with:
- Commands that will be commonly used — build, lint, test (including how to run a single test), dev servers, code generation.
- High-level architecture: the "big picture" that requires reading multiple files to understand — entry points, core services, data flow, key abstractions.
- Project-specific constraints and pitfalls (e.g. "errors return HTTP 200 with an error body", "multipart requests bypass X").
An existing CLAUDE.md may describe a codebase that no longer exists. Do NOT rewrite from scratch — audit it:
- Extract every factual claim in the current file: commands, file/directory paths, architecture descriptions, configuration mechanisms, env var names.
- Verify each claim against reality:
- Commands actually exist (
package.jsonscripts, Makefile, CLI entry points) — run--helpif cheap - Referenced files/directories still exist
- Architecture description matches the code (entry point, request flow, core services) — spot-check the imports and entry files
- Configuration mechanism unchanged (e.g.
.envvsconfig.yaml, renamed options)
- Commands actually exist (
- Hunt for drift since the doc was written:
git log --onelinerecent feature/BREAKING commits;git log --diff-filter=A --name-onlyfor added dirs/tools- New top-level directories, tools/, scripts, CI workflows, new CLI subcommands
- Deleted or renamed modules the doc still references
- Edit surgically: keep what's still accurate, fix what's stale, add what's missing and high-value. Preserve the file's voice and structure where possible.
- Update cross-references: sub-package doc lists, docs/ indexes, pointers from a parent workspace CLAUDE.md — new docs must be discoverable.
- Report the diff in plain terms: list what was stale (and what the code actually does now), what was added, and what was verified unchanged. This report is the primary deliverable — the user wants to know what drifted.
Optional hygiene checks (do them when relevant, mention in the report):
- Generated artifacts or large exported data files tracked in git that should be ignored (or vice versa: hand-maintained config that is accidentally untracked)
- Missing index/README when a docs directory accumulates many files
- Do not repeat yourself; do not include obvious instructions ("provide helpful error messages", "write unit tests", "never commit secrets").
- Do not list every file or component — only what is not discoverable by
lsor a quick grep. - No generic development practices.
- If there is a README.md, distill its important parts rather than duplicating them.
- Never invent content ("Common Development Tasks", "Tips", "Support") that you did not verify in the code or other files. If a claim cannot be verified cheaply, leave it out or mark it explicitly as unverified.
- Keep it short. A CLAUDE.md that is twice as long is half as useful.
- When creating the file, prefix it with:
This file provides guidance to pi when working with code in this repository.
Additional instructions: $ARGUMENTS