improve-claude-md
它能做什么
这项技能教智能体如何改进编码助手使用的 CLAUDE.md 指令文件。它把针对特定任务的指引放进带条件的代码块中,使助手能关注每项任务中真正重要的部分。
适用场景
- ✓当用户的 CLAUDE.md 文件似乎被助手忽略的时候。
- ✓当项目的指令文件变得很长,并混合了通用指引和特定任务指引的时候。
- ✓当用户希望改写助手指令,以提高其执行效果的时候。
技能链接
https://github.com/humanlayer/skills/blob/main/plugins/improve-claude-md/skills/improve-claude-md/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请改进我的 CLAUDE.md,让 Claude 在我编写测试时遵循测试规则。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会把核心项目背景保留为普通文本,并把针对特定任务的指引移入带有条件标记的代码块中。这样,助手就能清楚地知道每个代码块何时适用。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
When the user provides a CLAUDE.md file (or asks you to improve one), rewrite it following the principles and structure below.
Core Problem
Claude Code injects a system reminder with every CLAUDE.md that says:
"this context may or may not be relevant to your tasks. You should not respond to this context unless it is highly relevant to your task."
This means Claude will ignore parts of your CLAUDE.md it deems irrelevant. The more content that isn't applicable to the current task, the more likely Claude is to ignore everything — including the parts that matter.
Solution: <important if="condition"> Blocks
Wrap conditionally-relevant sections of the CLAUDE.md in <important if="condition"> XML tags. This exploits the same XML tag pattern used in Claude Code's own system prompt, giving the model an explicit relevance signal that cuts through the "may or may not be relevant" framing.
Principles
1. Foundational context stays bare, domain guidance gets wrapped
Not everything should be in an <important if> block. Context that is relevant to virtually every task — project identity, project map, tech stack — should be left as plain markdown at the top of the file. This is onboarding context the agent always needs.
Domain-specific guidance that only matters for certain tasks — testing patterns, API conventions, state management, i18n — gets wrapped in <important if> blocks with targeted conditions.
The rule of thumb: if it's relevant to 90%+ of tasks, leave it bare. If it's relevant to a specific kind of work, wrap it.
2. Conditions must be specific and targeted
Bad — overly broad conditions that match everything:
<important if="you are writing or modifying any code">
- Use absolute imports
- Use functional components
- Use camelCase filenames
</important>
Good — each rule has its own narrow trigger:
<important if="you are adding or modifying imports">
- Use `@/` absolute imports (see tsconfig.json for path aliases)
- Avoid default exports except in route files
</important>
<important if="you are creating new components">
- Use functional components with explicit prop interfaces
</important>
<important if="you are creating new files or directories">
- Use camelCase for file and directory names
</important>
3. Keep it short, use progressive disclosure sparingly
Do not shard into separate files that require the agent to make tool calls to discover, unless the extra context is incredibly verbose or complex.
The whole point of <important if> blocks is that everything is inline but conditionally weighted — the agent sees it all but only attends to what matches.
Prefer to keep the file concise.
4. Less is more
- Frontier models can reliably follow a few hundred. Claude Code's system prompt and tools already use ~50 of those. Your CLAUDE.md should be as lean as possible.
- Cut any instruction that a linter, formatter, or pre-commit hook can enforce
- Cut any instruction the agent can discover from existing code patterns. LLMs are in-context learners — if your codebase consistently uses a pattern, the agent will follow it after a few searches.
- Cut code snippets. They go stale and bloat the file. Use file path references instead (e.g., "see
src/utils/example.tsfor the pattern").
5. Keep all commands
Do not drop commands from the original file. The commands table is foundational reference — the agent needs to know what's available even if some commands are used less frequently.
Output Structure
When rewriting a CLAUDE.md, produce this structure:
# CLAUDE.md
[one-line project identity — what it is, what it's built with]
## Project map
[directory listing with brief descriptions]
<important if="you need to run commands to build, test, lint, or generate code">
[commands table — all commands from the original]
</important>
<important if="<specific trigger for rule 1>">
[rule 1]
</important>
<important if="<specific trigger for rule 2>">
[rule 2]
</important>
... more rules, each with their own block ...
<important if="<specific trigger for domain area 1>">
[guidance]
</important>
... more domain sections ...
How to Apply
When given an existing CLAUDE.md to improve:
- Identify the project identity — extract a single sentence describing what this is. Leave it bare at the top.
- Extract the directory map — keep it bare (no
<important if>wrapper). This is foundational context. - Extract the tech stack — if present, k
常见问题
什么是 important-if 代码块?
它是一种带条件的类 XML 标签,告诉助手何时适用其中的指引。
整个文件都要包裹吗?
不需要。这项技能说明,项目身份和技术栈等基础背景应保持为普通 Markdown。
为什么文件需要这样处理?
这项技能解释说,助手可能会忽略它认为不相关的上下文,因此大段无关文字可能会掩盖真正重要的内容。
详情
作者的原始描述
improve a CLAUDE.md file using <important if> blocks to improve instruction adherence
repo: humanlayer/skills
热度
- GitHub 星标
- 5.5k
- 排名
- #14776
- 许可证
- MIT
- 更新时间
- 2026/11/1
评论
- …
同一仓库的更多技能
build-iterated-agentic-loop
5.5k帮你的智能体把一项重复的编码任务,转换为仓库技能加上定时运行的 GitHub Actions 工作流,由编码智能体执行,并使用记忆文件,每个循环只保留一个打开的拉取请求。
design-control-loop
5.5k帮你的智能体通过访谈了解你的需求,设计一个控制循环,借助小而可审阅的改动让代码库逐步趋近目标,然后将其构建为定时工作流。
rpi
5.5k帮你的智能体研究一项改动,梳理其设计,并分阶段清晰地实施,每一步都会生成一份可供你审阅的文档。
visual-pr
5.5k帮你的智能体撰写或更新拉取请求说明,使用清晰的模板和简短的视觉大纲,解释改动为什么存在以及如何实现。