home / skills / howell5 / willhong-skills / check-claude-md

check-claude-md skill

/skills/check-claude-md

This skill analyzes code changes and guides updating CLAUDE.md to capture new patterns, decisions, and best practices for future development.

npx playbooks add skill howell5/willhong-skills --skill check-claude-md

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
3.8 KB
---
name: check-claude-md
description: 检查本次对话的改动是否需要更新项目 CLAUDE.md。分析代码变更,识别新模式和约定,建议更新内容。
---

# CLAUDE.md 更新检查器

检查本次对话中的代码改动,判断是否需要更新项目的 CLAUDE.md。

## 概述

这个 skill 帮助你在完成一次开发任务后,检查是否有值得记录到 CLAUDE.md 的新模式、约定或项目知识。

## 使用方法

```
/check-claude-md
```

在完成一个功能开发、bug 修复或重构后调用。

## 工作流程

### Phase 1: 收集本次改动

1. **回顾对话历史** - 识别本次对话中修改或创建了哪些文件
2. **分类改动类型**:
   - 新功能代码
   - Bug 修复
   - 重构
   - 配置变更
   - 依赖更新

### Phase 2: 分析是否有可记录内容

检查以下几类值得记录的内容:

#### 2.1 项目约定和模式

- 新建立的命名约定
- 新的目录结构规则
- 新的代码组织模式
- 新的错误处理方式

#### 2.2 技术决策

- 选择了某个库/框架的原因
- 架构决策及其理由
- 性能优化策略
- 安全考虑

#### 2.3 开发流程

- 新的测试策略
- 新的构建/部署步骤
- 新的环境配置要求

#### 2.4 避坑指南

- 遇到的问题及解决方案
- 需要注意的边界情况
- 依赖的版本兼容性问题

### Phase 3: 读取现有 CLAUDE.md

1. 查找项目根目录的 CLAUDE.md
2. 如果不存在,提示是否需要创建
3. 分析现有内容,避免重复

### Phase 4: 生成更新建议

**输出格式:**

```
## 本次改动摘要

- [改动 1]
- [改动 2]
- ...

## 建议更新 CLAUDE.md

### 需要新增的内容

#### [章节名称]

[具体内容]

### 需要修改的内容

[原内容] → [新内容]

## 不需要更新的原因(如适用)

[说明为什么本次改动不需要记录]
```

### Phase 5: 确认并执行

1. **展示建议** - 显示具体的更新内容
2. **询问确认** - 使用 AskUserQuestion 询问用户是否同意更新
3. **执行更新** - 用户确认后,使用 Edit 工具更新 CLAUDE.md

## 关键指令

### 判断原则

**值得记录的:**
- 对未来开发有指导意义的决策
- 不明显但重要的约定
- 踩过的坑和解决方案
- 项目特有的模式

**不值得记录的:**
- 显而易见的代码(如简单的 CRUD)
- 一次性的修复(无普遍意义)
- 通用的最佳实践(已在全局 CLAUDE.md 中)
- 具体的业务逻辑细节

### 必须遵守

1. **不要过度记录** - CLAUDE.md 应精简,只记录真正重要的内容
2. **避免重复** - 检查现有内容,不要重复已有的规则
3. **保持一致性** - 新内容要与现有 CLAUDE.md 风格一致
4. **必须确认** - 更新前必须获得用户确认

### 禁止事项

1. **不要记录临时代码** - 如 debug 代码、实验性代码
2. **不要记录具体实现** - CLAUDE.md 是指导原则,不是代码文档
3. **不要未经确认就修改** - 必须先展示建议,等用户确认

## 输出示例

**场景:用户完成了一个 API 错误处理的重构**

```
## 本次改动摘要

- 重构了 API 错误处理,统一使用 `AppError` 类
- 新增了 `src/errors/index.ts` 错误定义文件
- 所有 API 路由统一返回 `{ error: string, code: string }` 格式

## 建议更新 CLAUDE.md

### 需要新增的内容

#### 错误处理

- 所有 API 错误使用 `AppError` 类(位于 `src/errors/index.ts`)
- 错误响应格式:`{ error: string, code: string }`
- 不要在路由中直接 throw Error,使用 `throw new AppError()`

---

是否要将以上内容添加到 CLAUDE.md?
```

## 与其他工具的配合

- 通常在完成一个 feature 或 fix 后手动调用
- 可以在 commit 前调用,确保重要决策被记录
- 建议形成习惯:改完代码 → `/check-claude-md` → commit

Overview

This skill checks whether the changes made in the current conversation should be recorded in the project CLAUDE.md. It summarizes code edits, identifies new patterns, conventions, or decisions, and proposes concise updates. The goal is to keep CLAUDE.md focused, useful, and free of transient implementation details.

How this skill works

The tool scans the conversation and the list of modified or created files, classifies changes (feature, bugfix, refactor, config, dependency), and extracts candidate items worth documenting. It compares candidates against existing CLAUDE.md content to avoid duplication, then formats a clear suggested update with sections for additions, edits, and reasons not to update. Finally it prompts for confirmation before applying any edits.

When to use it

  • After finishing a feature implementation
  • After a cross-cutting refactor or API change
  • When introducing new conventions, directories, or error-handling patterns
  • After choosing or upgrading a library that affects developer workflows
  • Before committing large or non-obvious configuration changes

Best practices

  • Run the check after each non-trivial change but before final commit
  • Record only project-specific conventions and recurring lessons, not one-off fixes
  • Keep entries short: intent, location, and succinct guidance
  • Avoid documenting low-level implementation details or temporary experiments
  • Confirm suggested edits before applying them to maintain team alignment

Example use cases

  • Refactoring API error handling to a shared AppError class and standard response shape
  • Introducing a new directory layout or naming convention for services
  • Adding a required environment variable or build step that developers must know
  • Upgrading to a new major library version with migration notes and compatibility caveats
  • Documenting a discovered pitfall and its workaround for future contributors

FAQ

What types of changes should never go into CLAUDE.md?

Transient debug code, one-off fixes without broader impact, and low-level implementation details should not be recorded.

How does the skill avoid duplicate content?

It reads the existing CLAUDE.md and compares proposed items; suggestions exclude entries that closely match existing content and flag potential redundancy for review.