claude-md-templates

作者 abhishekray07已验证

CLAUDE.md best practices

309
Stars
36
Forks
2026/8/23
添加时间

⚠️ 第三方软件声明

本 Skill 为第三方开源软件,独立托管于 GitHub。SkillTip 仅为信息目录,不控制或维护底层仓库。所显示的安全检查为自动化且范围有限,安装前请自行审查源码。

阅读服务条款

安装

添加到你的 Claude Code skills 目录:

# Add to your Claude Code skills
git clone https://github.com/abhishekray07/claude-md-templates

快速入门

使用 claude-md-templates 等 Skills 的指南。

安全报告

已验证

上次扫描:—

{
  "status": "PASSED",
  "issues": []
}

README.md

The CLAUDE.md Starter Kit

Get better output from Claude Code in 5 minutes. No plugins, no MCP servers, no configuration — just markdown files in the right places.


The 3-Level Hierarchy

Claude Code reads instructions from three locations. Each has a different scope:

~/.claude/CLAUDE.md          -> Global: your personal preferences (every project)
.claude/CLAUDE.md            -> Project: shared with your team (committed to git)
./CLAUDE.local.md            -> Local: your personal overrides (gitignored)

Global = rules you'd repeat across every project ("always run tests," "prefer simple code"). Project = context your whole team benefits from (stack, structure, commands, conventions). Local = stuff only you need (your terminal, your MCP servers, your editor quirks).

Quick Start

1. Create your global file (~2 min)

mkdir -p ~/.claude
cp global/CLAUDE.md ~/.claude/CLAUDE.md

Edit it with your personal preferences. Keep it under 15 lines.

2. Create your project file (~3 min)

mkdir -p .claude
# Pick the template closest to your stack:
cp project/nextjs-typescript.md .claude/CLAUDE.md   # Next.js / React / TypeScript
cp project/python-fastapi.md .claude/CLAUDE.md      # Python / FastAPI
cp project/generic.md .claude/CLAUDE.md              # Anything else

Fill in the blanks. Commit it to git so your team gets the same behavior.

3. Create your local overrides (~1 min)

cp local/local.md ./CLAUDE.local.md
echo "CLAUDE.local.md" >> .gitignore

Add your personal setup. This file lives at the project root (not inside .claude/) and is never shared.

4. Add rules for your codebase (~2 min, optional)

mkdir -p .claude/rules
cp rules/code-style.md .claude/rules/code-style.md
cp rules/testing.md .claude/rules/testing.md
# Edit placeholders like [your test command]

Rules are modular instruction files. Path-scoped rules only load when Claude works with matching files. See principles.md for when and why to use rules vs CLAUDE.md.

Your final setup should look like this:

your-project/
├── .claude/
│   ├── CLAUDE.md              # Project instructions (committed)
│   └── rules/
│       ├── code-style.md      # Always loaded
│       └── testing.md         # Loaded when working with test files
├── CLAUDE.local.md            # Your personal overrides (gitignored)
└── ...

How It Works

Claude Code automatically reads these files at the start of every session. All discovered files are concatenated into context — they don't override each other. When instructions conflict, Claude sees the last one it read. Within each directory, CLAUDE.local.md loads after CLAUDE.md, so your personal notes get the final word at that level.

Important: Claude Code's system prompt already contains ~50 instructions. That's a third of the ~150-200 instruction limit frontier models can reliably follow. Your CLAUDE.md must be lean. Every line competes for attention.

Auto memory: Claude also maintains its own notes at ~/.claude/projects/<project>/memory/ — build commands it discovers, patterns from your corrections, debugging insights. These load at session start too. You don't need to put things in CLAUDE.md that Claude will learn on its own. Run /memory to see everything that's loaded. See principles.md for when to use CLAUDE.md vs auto memory.

The Self-Improvement Loop

This is the single most impactful habit you can build:

After every correction you give Claude, end with:

"Update CLAUDE.md so you don't make that mistake again."

Claude is good at writing rules for itself. Over time, your CLAUDE.md becomes a living document that gets smarter with every session.

What Goes Where (Decision Guide)

RuleWhere it goesWhy
"Run tests after changes"GlobalYou want this everywhere
"Use shadcn/ui components"ProjectTeam convention
"I use Ghostty terminal"LocalOnly you need this
"Never use any in TypeScript"ProjectTeam standard
"Ask before committing"GlobalPersonal preference
"I have Context7 MCP configured"LocalYour setup, not theirs
"Prices are in src/lib/config"ProjectDomain knowledge
"Keep code simple"GlobalUniversal preference

Common Mistakes

Too long. If your project CLAUDE.md is over 80 lines, Claude starts ignoring parts of it. HumanLayer keeps theirs under 60 lines. That's a good benchmark.

Personality instructions. "Be a senior engineer" or "Think step by step" wastes tokens. Claude Code already has strong system-level instructions.

@-mentioning docs. Writing @docs/api-guide.md embeds the entire file into context every single session. Instead, pitch Claude on when to read it: "For Stripe integration issues, see docs/stripe-guide.md."

Formatting rules without a formatter. If you have a linter/formatter configured, use a hook to run it — don't burn CLAUDE.md lines on what a tool enforces. But if you don't have a formatter, concrete style rules like "Use 2-space indentation" are exactly the kind of specific instruction Anthropic recommends.

Duplicate rules. If your global file says "run tests" and your project file also says "run tests," you've wasted tokens saying the same thing twice.

Scaling Up: Module-Specific Files

For larger codebases, you can place CLAUDE.md files in subdirectories:

.claude/CLAUDE.md              -> Project root (always loaded)
src/auth/CLAUDE.md             -> Auth module (loaded when working in src/auth/)
src/api/CLAUDE.md              -> API module (loaded when working in src/api/)

Claude Code loads these on demand — only when working in that directory. This keeps your root file lean while giving Claude deep context where it matters.

Use this when your root CLAUDE.md pushes past 80 lines, or when different parts of the codebase have different conventions.

Scaling Up: Rules

For rules that only apply to specific parts of your codebase, use .claude/rules/:

.claude/rules/
  testing.md          -> Only activates for test files
  api-design.md       -> Only activates for API route handlers
  code-style.md       -> No path restriction = applies everywhere

Rules use YAML frontmatter with paths globs to scope when they activate. See rules/ in this repo for annotated guides you can adapt to your stack, and principles.md for the full guide on writing effective rules.

CLAUDE.md vs rules: Use CLAUDE.md for project-wide context (stack, commands, structure). Use rules for focused standards that apply to specific file types or directories.

Included Files

FileWhat it isWhen to use it
global/CLAUDE.mdPersonal preferences templateCopy to ~/.claude/CLAUDE.md
project/nextjs-typescript.mdNext.js/React/TS project templateCopy to .claude/CLAUDE.md
project/python-fastapi.mdPython/FastAPI project templateCopy to .claude/CLAUDE.md
project/generic.mdFill-in-the-blank for any stackCopy to .claude/CLAUDE.md
local/local.mdPersonal overrides templateCopy to .claude/local.md
rules/testing.mdTesting standards (path-scoped)Copy to .claude/rules/testing.md, edit placeholders
rules/api-design.mdAPI design standards (path-scoped)Copy to .claude/rules/api-design.md, adjust paths
rules/code-style.mdUniversal code style standardsCopy to .claude/rules/code-style.md
workflows/self-improvement-rules.mdStructured rules for planning, verification, self-correctionPaste sections into your CLAUDE.md
workflows/prompting-patterns.md11 copy-paste prompts from the Claude Code teamUse directly in your sessions
cheatsheet.mdOne-page reference cardBookmark or print
principles.mdThe full research — why these patterns workRead when you want to go deeper

The Principles (Go Deeper)

principles.md contains everything we know about writing effective CLAUDE.md files:

  • The attention budget (why less is more)
  • Advisory vs deterministic: CLAUDE.md vs hooks
  • Anthropic's official include/exclude table
  • .claude/rules/ — path-scoped modular rules with YAML frontmatter
  • Writing rules Claude actually follows (with bad/good examples)
  • Emphasis keywords that actually work (IMPORTANT, YOU MUST)
  • Module-specific CLAUDE.md files for scaling
  • Progressive disclosure patterns and @import syntax
  • Architecture diagrams (HumanLayer's pattern)
  • The "Don't X, Do Y" rule
  • Troubleshooting: "Claude isn't following my rules" diagnostic checklist
  • Matt Pocock's plan loop
  • Real-world benchmarks from HumanLayer, Boris Cherny, Cloudflare, ChrisWiles
  • Skill activation mapping
  • TODO priority systems
  • Every anti-pattern and what to do instead

If you only read one file in this kit besides the templates, read that one.

Sources

This starter kit is based on:

Future Work

  • Before/after examples showing real CLAUDE.md files improved with these principles
  • Stack-specific rule templates (Go, Rust, Ruby on Rails, Django)
  • Migration guide: "You have a 200-line CLAUDE.md — here's how to split it into rules"
  • Hooks cookbook: common lifecycle hooks paired with CLAUDE.md patterns
  • Video walkthrough of setting up the full hierarchy from scratch

Built by Claude Code Camp — a weekly newsletter teaching developers how to get 10x more from Claude Code.

常见问题

What is claude-md-templates?

claude-md-templates is an open-source ai agents skill for AI coding assistants such as Claude Code, Codex CLI, and ChatGPT, built by abhishekray07. CLAUDE.md best practices. It has 309 GitHub stars.

Is claude-md-templates safe to use?

Yes. claude-md-templates passed SkillsLLM's automated security scan — a dependency vulnerability audit plus prompt-injection heuristics — with no high-severity issues. You can read the full report in the Security Report section on this page.

How do I install claude-md-templates?

Clone the repository with "git clone https://github.com/abhishekray07/claude-md-templates" and add it to your Claude Code skills directory (see the Installation section above).

Are there alternatives to claude-md-templates?

Yes. SkillsLLM lists many other AI Agents skills you can browse and compare side by side. Open the AI Agents category from the badge at the top of this page, or use the Related Skills and comparison links further down to weigh claude-md-templates against similar tools.

评论 (0)

暂无评论,成为第一个分享想法的人!

ECC

by affaan-m

10

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

242,21936,702JavaScript
AI 智能体ai-agentsanthropicclaude-code
查看详情
15

An agentic skills framework & software development methodology that works.

234,96620,863Shell
AI 智能体ai-agentsbrainstorming
查看详情

hermes-agent

by NousResearch

10

The agent that grows with you

234,43747,175Python
AI 智能体ai-agentsagent-orchestration
查看详情

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

185,94028,768JavaScript
AI 智能体ai-agentsanthropicclaude-code
查看详情

cc-switch

by farion1231

3

A cross-platform desktop All-in-One assistant for Claude Code, Codex, OpenCode, OpenClaw, Grok Build & Hermes Agent. Only official website: ccswitch.io

128,8688,826Rust
AI 智能体claude-codeai-tools
查看详情

claude-code

by anthropics

Claude Code is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explaining complex code, and handling git workflows - all through natural language commands.

120,03119,897Shell
AI 智能体
查看详情

开发者还喜欢

基于喜欢此 Skill 的开发者投票和收藏

ECC

by affaan-m

10

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

242,21936,702JavaScript
AI 智能体ai-agentsanthropicclaude-code
查看详情
15

An agentic skills framework & software development methodology that works.

234,96620,863Shell
AI 智能体ai-agentsbrainstorming
查看详情

hermes-agent

by NousResearch

10

The agent that grows with you

234,43747,175Python
AI 智能体ai-agentsagent-orchestration
查看详情

n8n

by n8n-io

12

Fair-code workflow automation platform with native AI capabilities. Combine visual building with custom code, self-host or cloud, 400+ integrations.

201,88160,308TypeScript
MCP 服务器apisai-tools
查看详情

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

185,94028,768JavaScript
AI 智能体ai-agentsanthropicclaude-code
查看详情

cc-switch

by farion1231

3

A cross-platform desktop All-in-One assistant for Claude Code, Codex, OpenCode, OpenClaw, Grok Build & Hermes Agent. Only official website: ccswitch.io

128,8688,826Rust
AI 智能体claude-codeai-tools
查看详情