Communitygithub.com

CLAUDE.md 生成器

当用户要求从代码库扫描生成或更新项目的 CLAUDE 或 AGENTS 上下文文件时使用。专注于编写一个不超过 100 行、仅包含非显而易见的构建命令、约定和常见陷阱的文件,供 Claude Code 使用。

CLAUDE.md 生成器 是什么?

该技能是一个用于自动生成和审计 CLAUDE.md 文件的工具。它通过扫描项目的代码库结构,提取非显而易见的构建命令、代码约定、测试设置和常见陷阱(Gotchas),并利用 Gemini AI 模型生成一个简洁(不超过 100 行)的上下文文件。它支持“创建”、“更新”和“审计”三种模式:创建模式从头编写文件,更新模式改进现有文件而不丢弃自定义内容,审计模式则根据一套评分标准(如命令完整性、架构说明、简洁性等)对所有 CLAUDE.md 文件进行评分(A-F 等级)并生成详细报告。该技能适用于 Claude Code、Cursor 等 AI 编程助手,帮助开发者快速为项目提供精准的 AI 上下文,避免在 CLAUDE.md 中包含冗余或显而易见的信息,从而提高 AI 助手的效率和准确性。

兼容平台✓Claude Code~Codex CLI~Cursor✓Gemini CLI
npx skills add https://github.com/Varnan-Tech/opendirectory/tree/main/skills/claude-md-generator

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

CLAUDE.md 生成器 是做什么的?

读取代码库。编写一个只包含 Claude 所需信息的 CLAUDE.md:不多不少。


关键规则: 一份好的 CLAUDE.md 不超过 100 行。它只包含 Claude 无法从阅读代码本身推导出的信息。不要自动写入文件:始终先展示草稿并等待用户批准。

代码片段规则: 不要在 CLAUDE.md 中包含内联代码示例。应改用 file.ts:42 引用。CLAUDE.md 中的代码会浪费令牌且容易过时。


步骤 1:检测模式

确定要运行的三种模式:

create:不存在 CLAUDE.md。从头编写。 update:存在 CLAUDE.md。在不丢弃自定义内容的前提下进行改进。 audit:对项目中所有 CLAUDE.md 文件进行 A-F 评分并输出质量报告。如果用户说“审计”、“检查”、“审查”或“评分”我的 CLAUDE.md,则运行审计模式。

# 发现所有 CLAUDE.md 的位置
find . -name "CLAUDE.md" -not -path "*/node_modules/*" -not -path "*/.git/*" 2>/dev/null
ls ~/.claude/CLAUDE.md 2>/dev/null && echo "找到全局 CLAUDE.md"
ls .claude.local.md 2>/dev/null && echo "找到 .claude.local.md"

如果找到多个 CLAUDE.md 文件:列出它们。询问:“在 [位置] 找到了 CLAUDE.md。我应该全部更新还是只更新 [根目录]?”


步骤 2:审计模式(如果是 create/update 则跳过此步骤)

对于找到的每个 CLAUDE.md,使用以下评分标准进行 A-F 评分:

标准检查内容
命令构建/测试/lint 命令是否存在且可运行?
架构是否解释了非显而易见的项目结构?
非显而易见模式是否记录了常见陷阱、生成文件、环境变量顺序?
简洁性是否在 100 行以内?没有明显的填充内容?
时效性命令是否与当前的 package.json/Makefile 匹配?
可操作性新贡献者能否在不提问的情况下遵循此文件?

评分:90-100 = A,70-89 = B,50-69 = C,30-49 = D,0-29 = F

以表格形式呈现:

## CLAUDE.md 审计报告

| 文件 | 评分 | 等级 | 主要问题 |
|------|-------|-------|-----------|
| ./CLAUDE.md | 72 | B | 缺少常见陷阱部分,测试命令已过时 |
| ./packages/api/CLAUDE.md | 45 | D | 无命令,340 行(太长了),架构说明已过时 |

**总体评分:B (72/100)**

发现的问题:
- ./packages/api/CLAUDE.md:340 行:远超 100 行的目标
- ./packages/api/CLAUDE.md:测试命令引用的是 `jest`,但 package.json 中使用的是 `vitest`
- ./CLAUDE.md:缺少常见陷阱部分:最有价值的部分缺失了

报告完成后,询问:“要我修复其中任何一个吗?(全部 / 仅根目录 / 指定)”

如果用户回答是,则针对他们想要修复的每个文件继续执行步骤 3。


步骤 3:扫描项目结构

# 项目类型和包管理器
ls package.json yarn.lock pnpm-lock.yaml bun.lockb requirements.txt pyproject.toml Cargo.toml go.mod 2>/dev/null

# 顶层目录结构
find . -maxdepth 2 -type d \
  | grep -v node_modules | grep -v .git | grep -v __pycache__ \
  | grep -v ".next" | grep -v dist | grep -v build | sort

步骤 4:提取构建和测试命令

# npm/yarn/pnpm/bun 脚本
cat package.json 2>/dev/null \
  | python3 -c "
import sys, json
d = json.load(sys.stdin)
for name, cmd in d.get('scripts', {}).items():
    print(f'{name}: {cmd}')
"

# Python、Go、Rust Makefiles
cat Makefile 2>/dev/null | grep -E "^[a-z].*:" | head -20

# Go
cat go.mod 2>/dev/null | head -5

# Rust
cat Cargo.toml 2>/dev/null | grep -E "^\[" | head -10

确定以下内容的精确命令:build、test(全部)、test(单个文件/名称)、dev server、lint/typecheck。注意运行它们所需的任何环境变量。


步骤 5:查找代码风格和常见陷阱

# 导入别名(最常被遗漏)
python3 -c "
import json, sys
try:
    d = json.load(open('tsconfig.json'))
    paths = d.get('compilerOptions', {}).get('paths', {})
    if paths: print('导入别名:', json.dumps(paths, indent=2))
except: pass
" 2>/dev/null

# 所需的环境变量
cat .env.example 2>/dev/null | grep -v "^#" | grep -v "^$" | head -20

# 自动生成的文件(不可编辑)
find . -path "*/node_modules" -prune -o -name "*.ts" -print \
  | xargs grep -l "DO NOT EDIT\|@generated\|Generated by" 2>/dev/null | head -5

# 测试设置要求
cat jest.config.js jest.config.ts vitest.config.ts 2>/dev/null | head -30

# 数据库/迁移设置
ls migrations/ prisma/ drizzle/ db/ 2>/dev/null

什么算作常见陷阱(包含这些,跳过其他所有内容):

  • 自动生成的文件(不可编辑)
  • 运行测试之前所需的环境变量
  • 非默认的导入别名映射
  • 需要运行服务的测试命令
  • 已知的故意怪癖(变通方法,而非错误)

步骤 6:使用 Gemini 生成 CLAUDE.md 草稿

编译所有发现并生成草稿:

cat > /tmp/claude-md-request.json << 'ENDJSON'
{
  "system_instruction": {
    "parts": [{
      "text": "为一个软件项目编写 CLAUDE.md 文件。规则:(1) 总共不超过 100 行。(2) 只包含 Claude 无法从阅读代码中推导出的信息。(3) 无内联代码示例:改用 file.ts:42 引用。(4) 章节:Commands(命令)、Code Style(代码风格,仅非默认项)、Testing(测试,仅在需要设置时)、Gotchas(常见陷阱,必需:容易出错的地方)。跳过任何没有非显而易见内容的章节。(5) 所有命令放在代码块中。(6) 推荐顺序:简短的项目概述(1-2 句话,仅当非显而易见时)、Commands、Architecture(架构,仅非显而易见结构)、Code Style、Testing、Gotchas。(7) 不要使用 em dash(长破折号)。(8) 只输出 CLAUDE.md 内容,不加注释。"
    }]
  },
  "contents": [{
    "parts": [{
      "text": "PROJECT_ANALYSIS_HERE"
    }]
  }],
  "generationConfig": {
    "temperature": 0.3,
    "maxOutputTokens": 2048
  }
}
ENDJSON

curl -s -X POST \
  "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent?key=$GEMINI_API_KEY" \
  -H "Content-Type: application/json" \
  -d @/tmp/claude-md-request.json \
  | python3 -c "import sys,json; d=json.load(sys.stdin); print(d['candidates'][0]['content']['parts'][0]['text'])"

将 PROJECT_ANALYSIS_HERE 替换为步骤 3-5 的发现。

对于大型项目(50+ 个文件): 在 CLAUDE.md 底部添加一个 @path 指针,而不是内联细节:

## Extended Reference
See @docs/ai-context/architecture.md for full module map.
See @docs/ai-context/testing.md for integration test setup details.

将无法放入 100 行以内的细节写入 docs/ai-context/ 下的引用文件。


步骤 7:自我质量检查

在展示草稿前,检查:

  • 不超过 100 行(计数:echo "$CONTENT" | wc -l)
  • 无内联代码示例(仅 file.ts:42 引用或 shell 命令)
  • 所有命令放在代码块中,且可直接运行
  • 常见陷阱部分存在,且至少包含一个真实条目
  • 没有只说明文件中显而易见内容的章节
  • 没有 em dash
  • 没有营销用语或填充短语(“该项目使用 React 来...”)
  • 如果存在导入别名,已记录
  • 如果存在自动生成的文件,已标记“不可编辑”

如果任何检查失败,在展示前进行修改。


步骤 8:展示草稿并等待批准

未经用户批准,切勿写入文件。

在代码块中展示草稿:

## CLAUDE.md 草稿([N] 行)

[完整草稿内容]

---
将此写入 CLAUDE.md?(yes / edit first / cancel)

如果用户回答 yes:写入文件,然后确认:“CLAUDE.md 已写入([N] 行)。章节:[所有 ## 标题列表]。”

如果用户回答 edit first:应用他们的编辑,重新展示草稿。

如果用户回答 cancel:停止。


不包含的内容

  • 语言/框架版本(“这是一个 TypeScript 项目”)
  • 框架工作原理(Claude 已经了解 React、FastAPI 等)
  • 所有依赖项列表
  • lint 器已经强制执行的风格规则(缩进大小、引号风格)
  • 与 README.md 重复的内容
  • 内联代码示例或多行代码片段
  • 任何使用相同技术栈的任何项目都会完全相同的内容

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

Varnan-Tech/opendirectory

Use when the user asks to generate a blog cover image, thumbnail, or article header. Automatically uses modern typography, brand logos, and Google Search grounding to create beautiful 16:9 images with Gemini 3.1 Flash Image Preview.

Varnan-Tech/opendirectory

World-class brand strategist and naming expert. Uses an interrogation-led discovery phase to extract your brand's DNA, then applies scientific naming frameworks (Phonosemantics) and automated multi-TLD domain checking.

Varnan-Tech/opendirectory

Use when the user wants to verify cold emails, enrich a lead list, or autonomously guess email addresses from a CSV using ValidEmail.co or the open-source Reacher engine.

Varnan-Tech/opendirectory

Competitive intelligence orchestrator tracking companies across 8+ platforms (GitHub, Twitter, Reddit, HN, PH, YC Jobs) with heat scores and AI briefings.

Varnan-Tech/opendirectory

Give it your product URL or description. It finds your top 5 competitors, runs three-track PR research across all of them (editorial, podcasts, communities), identifies which channels appear most frequently, looks up the journalist or host for each, and returns a tiered outreach list with story angles and ready-to-send cold pitch drafts tailored to your product. Use when asked to find PR opportunities, discover where competitors got featured, build a media outreach list, find which journalists cover my space, or get pitch templates for press coverage.

Varnan-Tech/opendirectory

Generate high-converting, deep-dive growth case studies in MDX format. Use this skill when asked to write a case study or blog post about a company's growth, tech stack, or product-led strategy. It handles the full pipeline (researching the company via Tavily, generating a 16:9 cover image, quality checking the draft, uploading assets to cloud storage, and pushing directly to the target repository).

Varnan-Tech/opendirectory

Scans your project for outdated npm, pip, Cargo, Go, or Ruby packages. Runs a CVE security audit. Fetches changelogs, summarizes breaking changes with Gemini, and opens one PR per risk group (patch, minor, major). Includes Diagnosis Mode for install conflicts. Use when asked to update dependencies, check for outdated packages, open dependency PRs, scan for package updates, audit for CVEs, or flag breaking changes in upgrades. Trigger when a user says "check for outdated packages", "update my dependencies", "open PRs for dependency updates", "scan for CVEs", or "which packages need upgrading".

Varnan-Tech/opendirectory

Generates and updates README.md and API reference docs by reading your codebase's functions, routes, types, schemas, and architecture. Uses graphify to build a knowledge graph first, then writes accurate docs from it. Use when asked to write docs, generate a README, document an API, update stale docs, create an API reference from code, add an architecture section, or document a project in any language. Trigger when a user says their docs are missing, outdated, or wants to document their codebase without writing it manually.

Varnan-Tech/opendirectory

Evaluates expired domain candidates against a target niche, scores them by topical relevance, historical activity level, and history cleanliness, then outputs a ranked shortlist with explainable reasoning and risk flags.

Varnan-Tech/opendirectory

Brutally honest developer-experience audit for a GitHub repo. Scores 10 DX dimensions (time-to-first-success, README clarity, visual proof, install, quick-start, docs, examples, community, trust, marketing), writes a shareable roast in the requested tone (brutal/honest/kind), produces a prioritized action plan ranked by impact × effort, and sketches an ideal README. Trigger when user says "roast my repo", "audit my README", "dx audit", "developer experience review", "score my GitHub project", "before launch checklist", or "make my repo shareable".

Varnan-Tech/opendirectory

Drafts and designs a complete HTML email newsletter from a topic or content brief. Outputs paste-ready HTML for Loops, Mailchimp, Beehiiv, Resend, or any standard email platform. Includes subject line options and plain-text fallback. Trigger when a user says "write a newsletter", "draft an email newsletter", "create an HTML email", "design an email for my subscribers", or "write a newsletter about [topic]".

Varnan-Tech/opendirectory

Takes a GitHub PR URL or the current branch and writes a plain-English explanation of what it does and why, then posts it as a PR comment. Use when asked to explain a PR, summarize a pull request, write a plain-English description of a PR, add a summary comment to a PR, or understand what a PR changes. Trigger when a user says "explain this PR", "summarize this pull request", "what does this PR do", "add a comment explaining the PR", or shares a GitHub PR URL and asks what it does.

Varnan-Tech/opendirectory

Audit how often LLMs recommend your brand vs competitors and generate a GEO action plan.

Varnan-Tech/opendirectory

Takes a competitor's public GitHub repo URL, fetches their open issues via the GitHub REST API, filters noise locally, clusters issues into 6 demand categories, computes a demand score per issue and per cluster, and outputs a ranked demand gap report with a GTM messaging brief. Use when asked to scan a competitor's GitHub issues, find what their users are begging for, turn GitHub complaints into product positioning, identify competitor feature gaps, or generate messaging from real user demand. Trigger when a user says "scan competitor issues", "what are users asking for on X repo", "find demand gaps in Y", "turn GitHub issues into messaging", or "what should I build based on competitor complaints".

Varnan-Tech/opendirectory

Find recurring confusion in your repo's GitHub Discussions, rank it by urgency, and draft the actual docs fixes and content angles — with verbatim community quotes and source links as evidence.

Varnan-Tech/opendirectory

SEO keyword research workflow for blog generation using Google Trends data. Use when writing blog posts, planning content calendars, or optimizing articles for search engines. Finds breakout keywords, builds content structure, and generates SEO-optimized blog outlines targeting tech and developer audiences.

Varnan-Tech/opendirectory

Generates a professionally designed case study PDF for B2B SaaS sales and marketing. Supports 7 page layouts, 9 style presets, 1-4 page output. Trigger when user says "create a case study", "write a customer story", "make a case study PDF", "design a success story", "turn this customer win into a PDF".

Varnan-Tech/opendirectory

Generates data visualization charts (bar, line, area, pie, doughnut, scatter, radar, treemap) as PNG using Apache ECharts v6. 1080×1080px default, 5 style presets, highlight annotations. Trigger when user says "create a chart", "visualize data", "make a bar chart", "line graph", "pie chart", "data visualization", "chart this data", "plot", "graph", or "visualize these numbers".

Varnan-Tech/opendirectory

Creates professionally designed B2B SaaS e-books in HTML + CSS, exported as print-ready PDF. 3–10 pages, 9 style presets, 11 page layout types. Trigger when user says "create an ebook", "design a lead magnet", "make a PDF guide", "build a gated content piece", "write a B2B ebook", "design a white paper", "create a nurture asset", or "make a PDF report".

Varnan-Tech/opendirectory

Fetches low-star App Store and Google Play reviews, clusters them into broken-promise patterns, and generates a ranked copy brief with positioning opportunities.

相关技能