init

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Generate CLAUDE.md and AGENTS.md

生成 CLAUDE.md 和 AGENTS.md

You are tasked with exploring the current codebase with the codebase-analyzer, codebase-locator, codebase-pattern-finder sub-agents, detecting the primary project languages, checking whether the corresponding language servers already exist on the user's machine, optionally installing any missing language servers after explicit user confirmation, and then generating populated
CLAUDE.md
and
AGENTS.md
files at the project root. These files provide coding agents with the context they need to work effectively in this repository.
你的任务是使用 codebase-analyzer、codebase-locator、codebase-pattern-finder 子 Agent 探索当前代码库,检测项目的主要开发语言,检查用户设备上是否已安装对应的语言服务器,在获得用户明确确认后可选安装缺失的语言服务器,随后在项目根目录生成填充好内容的
CLAUDE.md
AGENTS.md
文件。这些文件会为编码 Agent 提供在当前代码库中高效工作所需的上下文信息。

Steps

步骤

  1. Explore the codebase to discover project metadata:
    • Read
      package.json
      ,
      Cargo.toml
      ,
      go.mod
      ,
      pyproject.toml
      ,
      Gemfile
      ,
      pom.xml
      , or similar manifest files
    • Scan the top-level directory structure (
      src/
      ,
      lib/
      ,
      app/
      ,
      tests/
      ,
      docs/
      , etc.)
    • Check for existing config files:
      .eslintrc
      ,
      tsconfig.json
      ,
      biome.json
      ,
      oxlint.json
      ,
      .prettierrc
      , CI configs (
      .github/workflows/
      ,
      .gitlab-ci.yml
      ), etc.
    • Read
      README.md
      if it exists for project description and setup instructions
    • Check for
      .env.example
      ,
      .env.local
      , or similar environment files
    • Identify the package manager (bun, npm, yarn, pnpm, cargo, go, pip, etc.)
    • Identify the primary project languages from manifests, lockfiles, and source file extensions
    • Inspect editor/tooling config such as
      .vscode
      , language-specific config files, or existing LSP settings when present
  2. Identify key project attributes:
    • Project name: From manifest file or directory name
    • Project purpose: 1-2 sentence description from README or manifest
    • Project structure: Key directories and their purposes
    • Tech stack: Language, framework, runtime
    • Detected languages: The main implementation languages in the repo
    • Recommended LSPs: The language servers that best match those languages
    • Commands: dev, build, test, lint, typecheck, format (from scripts in manifest)
    • Environment setup: Required env vars, env example files
    • Verification command: The command to run before commits (usually lint + typecheck + test)
    • Existing documentation: Links to docs within the repo
  3. Detect installed language servers and prepare an installation plan:
    • For each detected language, choose the most standard LSP for that ecosystem and prefer already configured tooling when the repo clearly indicates a preference
    • Check whether each LSP is already available by using non-destructive discovery commands such as
      command -v
      ,
      --version
      , or equivalent read-only checks
    • Use this default mapping unless the repo clearly points to a different choice:
      • TypeScript / JavaScript ->
        typescript-language-server
        (and ensure
        typescript
        is available when required)
      • Python ->
        pyright
      • Go ->
        gopls
      • Rust ->
        rust-analyzer
      • Ruby ->
        ruby-lsp
      • PHP ->
        intelephense
      • Lua ->
        lua-language-server
      • Bash / shell ->
        bash-language-server
      • YAML ->
        yaml-language-server
      • Docker ->
        dockerfile-language-server-nodejs
      • Terraform ->
        terraform-ls
      • Java ->
        jdtls
      • Kotlin ->
        kotlin-language-server
      • C / C++ ->
        clangd
      • C# ->
        csharp-ls
    • If an LSP is missing, prepare the safest install command that fits the user's available tooling and platform; do not guess a package manager that is not installed
    • If the required runtime or package manager is missing, stop short of installation and report what is needed instead
  4. Ask for confirmation before installing anything:
    • Summarize the detected languages, the LSPs already present, the LSPs that are missing, and the exact install commands you plan to run
    • Ask the user for confirmation before running any install command
    • If the user declines, skip installation and continue with documentation generation
    • After installation, verify each newly installed LSP with a version check or binary lookup and mention any failures clearly
  5. Populate the template below with discovered values. Replace every
    {{placeholder}}
    with actual values from the repo. Delete sections that don't apply (e.g., Environment if there are no env files). Remove the "How to Fill This Template" meta-section entirely.
  6. Write the populated content to both
    CLAUDE.md
    and
    AGENTS.md
    at the project root with identical content.
  1. 探索代码库以获取项目元数据:
    • 读取
      package.json
      Cargo.toml
      go.mod
      pyproject.toml
      Gemfile
      pom.xml
      或同类清单文件
    • 扫描顶层目录结构(
      src/
      lib/
      app/
      tests/
      docs/
      等)
    • 检查现有配置文件:
      .eslintrc
      tsconfig.json
      biome.json
      oxlint.json
      .prettierrc
      、CI 配置(
      .github/workflows/
      .gitlab-ci.yml
      )等
    • 如果存在
      README.md
      则读取其内容,获取项目描述和环境搭建指引
    • 检查
      .env.example
      .env.local
      或同类环境配置文件
    • 识别项目使用的包管理器(bun、npm、yarn、pnpm、cargo、go、pip 等)
    • 通过清单文件、锁文件、源码文件扩展名识别项目的主要开发语言
    • 检查编辑器/工具配置,比如存在的
      .vscode
      配置、特定语言的配置文件、现有 LSP 设置
  2. 识别核心项目属性:
    • 项目名称:来自清单文件或目录名称
    • 项目用途:来自 README 或清单文件的1-2句描述
    • 项目结构:核心目录及其用途
    • 技术栈:语言、框架、运行时
    • 检测到的语言:代码库中主要的实现语言
    • 推荐 LSP:与这些语言最匹配的语言服务器
    • 命令:dev、build、test、lint、typecheck、format(来自清单文件的 scripts 配置)
    • 环境配置:所需的环境变量、环境示例文件
    • 校验命令:提交代码前需要运行的命令(通常是 lint + typecheck + test)
    • 现有文档:代码库内部的文档链接
  3. 检测已安装的语言服务器并制定安装计划:
    • 针对每个检测到的语言,选择对应生态中最标准的 LSP,如果代码库明确指定了偏好则优先使用已配置的工具
    • 使用非破坏性的探测命令比如
      command -v
      --version
      或同类只读检查,确认每个 LSP 是否已经可用
    • 除非代码库明确指定了其他选择,否则使用如下默认映射:
      • TypeScript / JavaScript ->
        typescript-language-server
        (需要时确保
        typescript
        可用)
      • Python ->
        pyright
      • Go ->
        gopls
      • Rust ->
        rust-analyzer
      • Ruby ->
        ruby-lsp
      • PHP ->
        intelephense
      • Lua ->
        lua-language-server
      • Bash / shell ->
        bash-language-server
      • YAML ->
        yaml-language-server
      • Docker ->
        dockerfile-language-server-nodejs
      • Terraform ->
        terraform-ls
      • Java ->
        jdtls
      • Kotlin ->
        kotlin-language-server
      • C / C++ ->
        clangd
      • C# ->
        csharp-ls
    • 如果缺失某个 LSP,准备适配用户现有工具和平台的最安全安装命令;不要猜测未安装的包管理器
    • 如果缺失所需的运行时或包管理器,暂停安装流程,告知用户需要的依赖即可
  4. 安装前需获取用户确认:
    • 汇总检测到的语言、已安装的 LSP、缺失的 LSP,以及你计划运行的具体安装命令
    • 运行任何安装命令前必须先获得用户确认
    • 如果用户拒绝安装,跳过安装步骤继续生成文档
    • 安装完成后,通过版本检查或二进制文件查找校验每个新安装的 LSP,明确告知用户任何安装失败的情况
  5. 用探测到的数值填充下方模板,将所有
    {{placeholder}}
    替换为代码库的实际值。删除不适用的章节(比如如果没有环境文件则删除环境章节),完全移除“如何填写该模板”的元章节。
  6. 将填充完成的内容写入项目根目录下的
    CLAUDE.md
    AGENTS.md
    两个文件,两份文件内容完全一致。

Template

模板

markdown
undefined
markdown
undefined

{{PROJECT_NAME}}

{{PROJECT_NAME}}

Overview

概述

{{1-2 sentences describing the project purpose}}
{{1-2 sentences describing the project purpose}}

Project Structure

项目结构

PathTypePurpose
`{{path}}`{{type}}{{purpose}}
PathTypePurpose
`{{path}}`{{type}}{{purpose}}

Quick Reference

快速参考

Languages and Tooling

语言与工具

  • Languages: {{comma-separated detected languages}}
  • LSPs: {{comma-separated installed or recommended language servers}}
  • Languages: {{comma-separated detected languages}}
  • LSPs: {{comma-separated installed or recommended language servers}}

Commands

命令

```bash {{dev_command}} # Start dev server / all services {{build_command}} # Build the project {{test_command}} # Run tests {{lint_command}} # Lint & format check {{typecheck_command}} # Type-check (if applicable) ```
```bash {{dev_command}} # Start dev server / all services {{build_command}} # Build the project {{test_command}} # Run tests {{lint_command}} # Lint & format check {{typecheck_command}} # Type-check (if applicable) ```

Environment

环境

  • Copy `{{env_example_file}}` → `{{env_local_file}}` for local development
  • Required vars: {{comma-separated list of required env vars}}
  • Copy `{{env_example_file}}` → `{{env_local_file}}` for local development
  • Required vars: {{comma-separated list of required env vars}}

Progressive Disclosure

渐进式披露

Read relevant docs before starting:
TopicLocation
{{topic}}`{{path_to_doc}}`
开始操作前请阅读相关文档:
TopicLocation
{{topic}}`{{path_to_doc}}`

Universal Rules

通用规则

  1. Run `{{verify_command}}` before commits
  2. Keep PRs focused on a single concern
  3. {{Add any project-specific universal rules}}
  1. 提交代码前运行 `{{verify_command}}`
  2. 保持 PR 聚焦单一需求
  3. {{Add any project-specific universal rules}}

Code Quality

代码质量

Formatting and linting are handled by automated tools:
  • `{{lint_command}}` — {{linter/formatter names}}
  • `{{format_command}}` — Auto-fix formatting (if separate from lint)
Run before committing. Don't manually check style—let tools do it.
undefined
格式化和代码检查由自动化工具处理:
  • `{{lint_command}}` — {{linter/formatter names}}
  • `{{format_command}}` — Auto-fix formatting (if separate from lint)
提交代码前运行上述命令。无需手动检查代码风格,交给工具处理即可。
undefined

Important Notes

重要说明

  • Keep it under 100 lines (ideally under 60) after populating
  • Every instruction must be universally applicable to all tasks in the repo
  • No code style rules — delegate to linters/formatters
  • No task-specific instructions — use the progressive disclosure table
  • No code snippets — use
    file:line
    pointers instead
  • Include verification commands the agent can run to validate work
  • Never install tooling without an explicit user confirmation first
  • Prefer read-only discovery before installation and verify any installed LSP afterward
  • Delete any section from the template that doesn't apply to this project
  • Do NOT include the "How to Fill This Template" section in the output
  • Write identical content to both
    CLAUDE.md
    and
    AGENTS.md
    at the project root
  • 填充后的内容控制在100行以内(理想情况下少于60行)
  • 所有指引必须适用于代码库内的所有任务
  • 不要添加代码风格规则 — 交给 linter/格式化工具处理
  • 不要添加特定任务的指引 — 放到渐进式披露表格中
  • 不要添加代码片段 — 改用
    文件:行号
    形式指向对应位置
  • 包含校验命令,可供 Agent 运行验证工作成果
  • 未获得用户明确确认前绝对不要安装任何工具
  • 安装前优先使用只读探测,安装后校验所有已安装的 LSP
  • 删除模板中所有不适用当前项目的章节
  • 输出中不要包含“如何填写该模板”章节
  • 向项目根目录的
    CLAUDE.md
    AGENTS.md
    写入完全相同的内容