返回 FEED
CLAUDE2026-05-29

Karpathy 的 CLAUDE.md:GitHub 82000 星背后的 7 条规则

82,000 stars。7,800 forks。

这一切始于 Andrej Karpathy。特斯拉前 AI 总监,OpenAI 创始成员。他发现了 4 个让 Claude Code 失败的行为,写在了一个文件里。

一个开发者把这 4 条规则扩展,发布了出去。然后就炸了。

原因很简单:一份 CLAUDE.md 让编码准确率从 65% 升到 94%。

大多数每天用 Claude Code 的开发者从来没配置过这个。他们每次 session 都从零开始,重新解释上下文,重新说明不要做什么,重新撤销没人要求做的重构。

CLAUDE.md 是什么

CLAUDE.md 是放在项目根目录的纯文本文件。Claude Code 每次 session 开始时自动读取。

一次配置,零重复解释,三类昂贵错误永久修复。

数字告诉你为什么重要

每天重复解释上下文的成本:

每位开发者每天 30 分钟。$150/小时。

  • 每天:$75
  • 每周:$375
  • 5 人团队每周:$1,875

无授权重构的成本:

你让 Claude 修一个函数。它重构了三个文件,改了变量名,重组了 import,删了你花了时间的注释。

全部没问。

  • 一小时审查和撤销:$150
  • 每周三次:$450/开发者
  • 5 人团队每周:$2,250

一份 CLAUDE.md 用 45 分钟永久消除这两笔账。

CLAUDE.md 核心规则

规则 1:Kill the filler

Never open responses with filler phrases like "Great question!", "Of course!", "Certainly!", or similar warmups. Start every response with the actual answer. No preamble, no acknowledgment of the question.

规则 2:Match length to the task

Match response length to task complexity. Simple questions get direct, short answers. Complex tasks get full, detailed responses. Never pad responses with restatements of the question or closing sentences that repeat what you just said.

规则 3:Show options before acting

Before any significant task, show me 2-3 ways you could approach this work. Wait for me to choose before proceeding.

规则 4:Admit uncertainty before it costs me

If you are uncertain about any fact, statistic, date, or piece of technical information: say so explicitly before including it. Never fill gaps in your knowledge with plausible-sounding information. When in doubt, say so.

规则 5:Who I am and what I know

About me: [Name] / Role: [your role] / Background in: [areas]. Strong in: [what you know well]. Still learning: [gaps]. Adjust the depth of every response to match this. Never over-explain what I already know. Never skip context I need.

规则 6:Current project context

What I'm working on: [project name] / Goal: [specific outcome] / Audience: [who uses this] / Stack context: [any relevant constraints] / What to avoid: [list]. Apply this context to every task. When something doesn't fit, flag it before proceeding.

规则 7:Lock your voice

My writing style — always match this: [describe your voice] / Sentence length: [preference] / Words I use: [examples] / Words I never use: [examples] / Format: [prose or structured]. When writing anything on my behalf, match this exactly. Do not default to your own patterns.

行为规范部分

Stay in scope

Only modify files, functions, and lines of code directly related to the current task. Do not refactor, rename, reorganize, reformat, or "improve" anything I did not explicitly ask you to change. If you notice something worth fixing elsewhere, mention it in a note at the end. Do not touch it. Ever.

Ask before big changes

Before making any change that significantly alters content I've already created (rewriting sections, removing paragraphs, restructuring flow, changing tone): stop. Describe exactly what you're about to change and why. Wait for my confirmation before proceeding.

Confirm before anything destructive

Before deleting any file, overwriting existing code, dropping database records, or removing dependencies: stop. List exactly what will be affected. Ask for explicit confirmation. Only proceed after I say yes in the current message. "You mentioned this earlier" is not confirmation.

不要从零写 CLAUDE.md

用这个 prompt 让 Claude 帮你写初稿:

Based on what I've told you about myself, my project, and how I want to work: write me a complete CLAUDE.md file. Include: who I am, my tech context, my communication preferences, and default behaviors for every session. Be specific. Plain text. Under 500 words.

团队价值

对于 5 人开发团队:

  • 每周节省 $1,875 上下文重解释成本
  • 每周节省 $2,250 无授权重构恢复成本
  • 合计:每周 $4,125

CLAUDE.md 是投入产出比最高的开发工具配置,没有之一。