克劳德医学博士

人工智能 社区

技能解读

当前原文的自动摘译,尚未人工审校。

用户输入

在继续之前您必须考虑用户输入(如果不为空)。用户可以指定: create - 从头开始创建新的 CLAUDE.md update - 改进现有的 CLAUDE.md audit - 分析并报告当前 CLAUDE.md 的质量 创建/更新的特定路径(例如,src/api/CLAUDE.md 用于特定于目录的指令)

核心原则

LLM 是无状态的:CLAUDE.md 是唯一一个自动包含在每个对话中的文件。它是人工智能代理进入代码库的主要入门文档。

黄金法则

少即是多:前沿法学硕士可以遵循约 150-200 条指令。克劳德·科德的系统提示符已经使用了~50。让您的 CLAUDE.md 保持重点和简洁。普遍适用性:仅包含与每个会话相关的信息。特定于任务的指令位于单独的文件中。不要使用 Claude 作为 Linter:样式指南会使上下文变得臃肿并降低指令遵循性。请改用确定性工具(prettier、eslint 等)。

一、项目分析

首先,分析当前项目状态: 检查现有的 CLAUDE.md 文件: 根级别:./CLAUDE.md 或 .claude/CLAUDE.md 目录特定:/CLAUDE.md 全局用户配置:~/.claude/CLAUDE.md

2. 内容策略(什么、为什么、如何)

围绕三个维度构建 CLAUDE.md: 内容 - 技术与结构 技术堆栈概述 项目组织(对于 monorepos 尤其重要) 关键目录及其用途

流狐档案 运行与权限由流狐静态检查推断,不代表作者声明或实际测试结果。
领域
人工智能
作者声明的智能体
未找到明确声明;不据此推断已兼容或已测试
静态检查
88 / 100 · 启发式扫描,不代表运行安全
运行环境证据
未执行;当前没有隔离运行测试证据
作者 / 版本 / 许可证
@luongnv89 · 未声明许可证
上下文用量评级
低消耗
接入复杂程度
需简单配置
是否需要外部接口密钥
不需要
兼容的系统
macOS · Linux · Windows
运行环境要求
Node.js · Bun
检测到的文件与系统行为
  • 只读
  • 允许写入 / 修改
  • 命令执行
网络行为
仅限本地
安装命令数
无(仅作为资料)

需要注意: 未声明工具权限范围;实际权限由运行环境决定。

作者说明文件(原文) SKILL.md

## User Input

```text
$ARGUMENTS
```

You **MUST** consider the user input before proceeding (if not empty). User may specify:
- `create` - Create new CLAUDE.md from scratch
- `update` - Improve existing CLAUDE.md
- `audit` - Analyze and report on current CLAUDE.md quality
- A specific path to create/update (e.g., `src/api/CLAUDE.md` for directory-specific instructions)

## Core Principles

**LLMs are stateless**: CLAUDE.md is the only file automatically included in every conversation. It serves as the primary onboarding document for AI agents into your codebase.

### The Golden Rules

1. **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.

2. **Universal Applicability**: Only include information relevant to EVERY session. Task-specific instructions belong in separate files.

3. **Don't Use Claude as a Linter**: Style guidelines bloat context and degrade instruction-following. Use deterministic tools (prettier, eslint, etc.) instead.

4. **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:

1. Check for existing CLAUDE.md files:
   - Root level: `./CLAUDE.md` or `.claude/CLAUDE.md`
   - Directory-specific: `**/CLAUDE.md`
   - Global user config: `~/.claude/CLAUDE.md`

2. Identify the project structure:
   - Technology stack (languages, frameworks)
   - Project type (monorepo, single app, library)
   - Development tools (package manager, build system, test runner)

3. 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:
```markdown
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:

1. **Target Length**: Under 300 lines (ideally under 100)
2. **No Style Rules**: Remove any linting/formatting instructions
3. **No Task-Specific Instructions**: Move to separate files
4. **No Code Snippets**: Use file references instead
5. **No Redundant Information**: Don't repeat what's in package.json or README

### 5. Essential Sections

A well-structured CLAUDE.md should include:

```markdown
# 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:

- [ ] Under 300 lines (preferably under 100)
- [ ] Every line applies to ALL sessions
- [ ] No style/formatting rules
- [ ] No code snippets (use file references)
- [ ] Commands are verified to work
- [ ] Progressive disclosure used for complex projects
- [ ] Critical gotchas are documented
- [ ] No redundancy with README.md

## Output Format

### For `create` or default:

1. Analyze the project
2. Draft a CLAUDE.md following the structure above
3. Present the draft for review
4. Write to the appropriate location after approval

### For `update`:

1. Read existing CLAUDE.md
2. Audit against best practices
3. Identify:
   - Content to remove (style rules, code snippets, task-specific)
   - Content to condense
   - Missing essential information
4. Present changes for review
5. Apply changes after approval

### For `audit`:

1. Read existing CLAUDE.md
2. Generate a report with:
   - Current line count vs target
   - Percentage of universally-applicable content
   - List of anti-patterns found
   - Recommendations for improvement
3. Do NOT modify the file, only report

## AGENTS.md Handling

If the user requests AGENTS.md creation/update:

AGENTS.md is used for defining specialized agent behaviors. Unlike CLAUDE.md (which is for project context), AGENTS.md defines:
- Custom agent roles and capabilities
- Agent-specific instructions and constraints
- Workflow definitions for multi-agent scenarios

Apply similar principles:
- Keep focused and concise
- Use progressive disclosure
- Reference external docs instead of embedding content

## Notes

- Always verify commands work before including them
- When in doubt, leave it out - less is more
- The system reminder tells Claude that CLAUDE.md "may or may not be relevant" - the more noise, the more it gets ignored
- Monorepos benefit most from clear WHAT/WHY/HOW structure
- Directory-specific CLAUDE.md files should be even more focused

讨论

基于 GitHub Discussions。登录 GitHub 即可参与讨论、点赞、订阅更新。