claude-md
它能做什么
它指导你的智能体编写或审核 CLAUDE.md 文件,用来告诉 Claude 一个项目如何运作。适合希望 AI 助手每次会话都带着正确背景开始工作的开发者。
适用场景
- ✓当你开始一个新项目,想编写 CLAUDE.md 文件的时候。
- ✓当现有的 CLAUDE.md 文件太长或不够清楚,需要改进的时候。
- ✓当你想在与团队分享前,检查项目的 CLAUDE.md 质量的时候。
技能链接
https://github.com/luongnv89/claude-howto/blob/main/03-skills/claude-md/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请帮我审核 CLAUDE.md,并建议删掉哪些内容,让它保持简短又实用?”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会分析项目,检查是否已有 CLAUDE.md 文件,然后按一套原则创建、更新或审核它们。它只保留适用于每次会话的信息。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
User Input
$ARGUMENTS
You MUST consider the user input before proceeding (if not empty). User may specify:
create- Create new CLAUDE.md from scratchupdate- Improve existing CLAUDE.mdaudit- Analyze and report on current CLAUDE.md quality- A specific path to create/update (e.g.,
src/api/CLAUDE.mdfor directory-specific instructions)
Core Principles
LLMs are stateless: CLAUDE.md is the main project file loaded into every conversation (alongside auto memory and unscoped rules). It serves as the primary onboarding document for AI agents into your codebase.
The Golden Rules
Less is More: Frontier LLMs can follow ~150-200 instructions. Claude Code's system prompt already uses ~50. Keep your CLAUDE.md focused and concise.
Universal Applicability: Only include information relevant to EVERY session. Task-specific instructions belong in separate files.
Don't Use Claude as a Linter: Style guidelines bloat context and degrade instruction-following. Use deterministic tools (prettier, eslint, etc.) instead.
Never Auto-Generate: CLAUDE.md is the highest leverage point of the AI harness. Craft it manually with careful consideration.
Execution Flow
1. Project Analysis
First, analyze the current project state:
Check for existing CLAUDE.md files:
- Root level:
./CLAUDE.mdor.claude/CLAUDE.md - Directory-specific:
**/CLAUDE.md - Global user config:
~/.claude/CLAUDE.md
- Root level:
Identify the project structure:
- Technology stack (languages, frameworks)
- Project type (monorepo, single app, library)
- Development tools (package manager, build system, test runner)
Review existing documentation:
- README.md
- CONTRIBUTING.md
- package.json, pyproject.toml, Cargo.toml, etc.
2. Content Strategy (WHAT, WHY, HOW)
Structure CLAUDE.md around three dimensions:
WHAT - Technology & Structure
- Technology stack overview
- Project organization (especially important for monorepos)
- Key directories and their purposes
WHY - Purpose & Context
- What the project does
- Why certain architectural decisions were made
- What each major component is responsible for
HOW - Workflow & Conventions
- Development workflow (bun vs node, pip vs uv, etc.)
- Testing procedures and commands
- Verification and build methods
- Critical "gotchas" or non-obvious requirements
3. Progressive Disclosure Strategy
For larger projects, recommend creating an agent_docs/ folder:
agent_docs/
|- building_the_project.md
|- running_tests.md
|- code_conventions.md
|- architecture_decisions.md
In CLAUDE.md, reference these files with instructions like:
For detailed build instructions, refer to `agent_docs/building_the_project.md`
Important: Use file:line references instead of code snippets to avoid outdated context.
4. Quality Constraints
When creating or updating CLAUDE.md:
- Target Length: Keep it under 200 lines; shorter is better
- No Style Rules: Remove any linting/formatting instructions
- No Task-Specific Instructions: Move to separate files
- No Code Snippets: Use file references instead
- No Redundant Information: Don't repeat what's in package.json or README
5. Essential Sections
A well-structured CLAUDE.md should include:
# Project Name
Brief one-line description.
## Tech Stack
- Primary language and version
- Key frameworks/libraries
- Database/storage (if any)
## Project Structure
[Only for monorepos or complex structures]
- `apps/` - Application entry points
- `packages/` - Shared libraries
## Development Commands
- Install: `command`
- Test: `command`
- Build: `command`
## Critical Conventions
[Only non-obvious, high-impact conventions]
- Convention 1 with brief explanation
- Convention 2 with brief explanation
## Known Issues / Gotchas
[Things that consistently trip up developers]
- Issue 1
- Issue 2
6. Anti-Patterns to Avoid
DO NOT include:
- Code style guidelines (use linters)
- Documentation on how to use Claude
- Long explanations of obvious patterns
- Copy-pasted code examples
- Generic best practices ("write clean code")
- Instructions for specific tasks
- Auto-generated content
- Extensive TODO lists
7. Validation Checklist
Before finalizing, verify:
- Kept under 200 lines; shorter is better
- Every line applies to ALL sessions
- No style/formatting rules
- No code snipp
常见问题
为什么要让文件保持简短?
技能说明,前沿模型大约只能遵循 150 到 200 条指令,而系统提示词已经占用了其中一部分。
智能体会自动生成这个文件吗?
不会。技能要求不要自动生成,而应仔细手动编写。
它能处理子文件夹中的文件吗?
可以。你可以指定路径,例如某个子目录,用于只适用于该文件夹的说明。
详情
作者的原始描述
Create or update CLAUDE.md files following best practices for optimal AI agent onboarding
repo: luongnv89/claude-howto
热度
- GitHub 星标
- 46k
- 排名
- #6321
- 许可证
- MIT
- 更新时间
- 2026/11/2
评论
- …