用Claude Code写代码,一个好用的CLAUDE.md文件能直接提效、保质量,这点不用多说。
网上讲写法的文章不少,但大多是纯方法论,说要简洁、少写多余指令,看再多不如直接看实战范例。
下面分享2个GitHub高星、有代表性的CLAUDE.md真实范例,一个适合个人用,一个适合团队用,可直接复制、改写,省去自己摸索的时间。
一、andrej-karpathy-skills(18.3K星)
该项目是作者基于AI界传奇人物Andrej Karpathy(曾担任特斯拉AI高级总监)的核心观点,总结出的利用LLM写代码的高频坑点,风格极简、纪律性极强,特别适合个人项目。
核心亮点:
极简严要求,完全贴合Karpathy的工程风格;
只写必守规则,没有一句废话;
明确禁止行为,精准规避LLM坑点;
适用场景:个人项目
CLAUDE.md原文(可直接复制使用):
CLAUDE.md
Behavioral guidelines to reduce common LLM coding mistakes. Merge with project-specific instructions as needed.
Tradeoff: These guidelines bias toward caution over speed. For trivial tasks, use judgment.
- Think Before Coding
Don't assume. Don't hide confusion. Surface tradeoffs.
Before implementing:
•State your assumptions explicitly. If uncertain, ask.
•If multiple interpretations exist, present them - don't pick silently.
•If a simpler approach exists, say so. Push back when warranted.
•If something is unclear, stop. Name what's confusing. Ask.
- Simplicity First
Minimum code that solves the problem. Nothing speculative.
•No features beyond what was asked.
•No abstractions for single-use code.
•No "flexibility" or "configurability" that wasn't requested.
•No error handling for impossible scenarios.
•If you write 200 lines and it could be 50, rewrite it.
Ask yourself: "Would a senior engineer say this is overcomplicated?" If yes, simplify.
- Surgical Changes
Touch only what you must. Clean up only your own mess.
When editing existing code:
•Don't "improve" adjacent code, comments, or formatting.
•Don't refactor things that aren't broken.
•Match existing style, even if you'd do it differently.
•If you notice unrelated dead code, mention it - don't delete it.
When your changes create orphans:
•Remove imports/variables/functions that YOUR changes made unused.
•Don't remove pre-existing dead code unless asked.
The test: Every changed line should trace directly to the user's request.
- Goal-Driven Execution
Define success criteria. Loop until verified.
Transform tasks into verifiable goals:
•"Add validation" → "Write tests for invalid inputs, then make them pass"
•"Fix the bug" → "Write a test that reproduces it, then make it pass"
•"Refactor X" → "Ensure tests pass before and after"
For multi-step tasks, state a brief plan:
- [Step] → verify: [check]
- [Step] → verify: [check]
- [Step] → verify: [check]
Strong success criteria let you loop independently. Weak criteria ("make it work") require constant clarification.
These guidelines are working if: fewer unnecessary changes in diffs, fewer rewrites due to overcomplication, and clarifying questions come before implementation rather than after mistakes.
二、Everything Claude Code(153K星)
该项目是来自Anthropic黑客马拉松获胜者的实战配置集合,项目是一整套可直接用于生产环境的系统,经过10个多月实战打磨,支持多AI智能体框架,适合团队/企业项目。
核心亮点:
企业级标准,全流程覆盖,可直接用于团队协作;
分模块清晰:包括测试、架构、关键指令、开发、技能多个模块;
可作为团队协作项目的手册,只需微调即可。
适用场景:团队/企业项目
CLAUDE.md原文(可根据项目情况修改后使用):
Cloud.md原文
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Project Overview
This is a Claude Code plugin - a collection of production-ready agents, skills, hooks, commands, rules, and MCP configurations. The project provides battle-tested workflows for software development using Claude Code.
Running Tests
*Run all tests node tests/run-all.js
*Run individual test files node
tests/lib/utils.test.js node
tests/lib/package-manager.test.js node
tests/hooks/hooks.test.js
Architecture
The project is organized into several core components:
•agents/ - Specialized subagents for delegation (planner, code-reviewer, tdd-guide, etc.)
•skills/ - Workflow definitions and domain knowledge (coding standards, patterns, testing)
•commands/ - Slash commands invoked by users (/tdd, /plan, /e2e, etc.)
•hooks/ - Trigger-based automations (session persistence, pre/post-tool hooks)
•rules/ - Always-follow guidelines (security, coding style, testing requirements)
•mcp-configs/ - MCP server configurations for external integrations
•scripts/ - Cross-platform Node.js utilities for hooks and setup
•tests/ - Test suite for scripts and utilities
Key Commands
•/tdd - Test-driven development workflow
•/plan - Implementation planning
•/e2e - Generate and run E2E tests
•/code-review - Quality review
•/build-fix - Fix build errors
•/learn - Extract patterns from sessions
•/skill-create - Generate skills from git history
Development Notes
•Package manager detection: npm, pnpm, yarn, bun (configurable via CLAUDE_PACKAGE_MANAGER env var or project config)
•Cross-platform: Windows, macOS, Linux support via Node.js scripts
•Agent format: Markdown with YAML frontmatter (name, description, tools, model)
•Skill format: Markdown with clear sections for when to use, how it works, examples
•Skill placement: Curated in skills/; generated/imported under ~/.claude/skills/. See docs/SKILL-PLACEMENT-POLICY.md
•Hook format: JSON with matcher conditions and command/notification hooks
Contributing
Follow the formats in CONTRIBUTING.md:
•Agents: Markdown with frontmatter (name, description, tools, model)
•Skills: Clear sections (When to Use, How It Works, Examples)
•Commands: Markdown with description frontmatter
•Hooks: JSON with matcher and hooks array File naming: lowercase with hyphens (e.g., python-reviewer.md, tdd-workflow.md)
Skills
Use the following skills when working on related files:
File(s) |Skill
README.md |readme
.github/workflows/*.yml | ci-workflow
When spawning subagents, always pass conventions from the respective skill into the agent's prompt.
最后补充一句:个人用选第一个,极简高效避坑;团队用选第二个,规范全面可直接落地。复制过去根据自己的项目微调,比自己从零写省心太多。
