agentsmd-generator

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Agent Context Generator

Agent 上下文生成器

What You'll Do

你需要完成的工作

  • 🔍 Inventory the repository's structure, capture a
    .gitignore
    -aware
    tree
    output, and record automation entry points (preferring
    just
    /
    make
    tasks when available)
  • 🧭 Capture coding conventions, directory ownership, testing expectations, and review workflows so future agents can navigate confidently
  • 🧩 Produce an
    AGENTS.md
    file following the opinionated section order below, honoring scope rules for nested directories
  • ✅ Embed universal wrap-up tasks: ensure the README is updated after significant code changes and summarize changes per conventional commits while resolving any open questions with the developer

  • 🔍 盘点代码仓库结构,生成支持
    .gitignore
    tree
    命令输出,并记录自动化入口点(优先使用
    just
    /
    make
    任务)
  • 🧭 记录编码规范、目录归属、测试要求及评审流程,以便后续Agent能顺利开展工作
  • 🧩 按照以下指定的章节顺序生成
    AGENTS.md
    文件,遵循嵌套目录的范围规则
  • ✅ 嵌入通用收尾任务:重大代码变更后更新README,按照规范提交格式总结变更,并与开发者解决所有未决问题

Phase 1 · Understand the Repository

第一阶段 · 了解代码仓库

  1. Check for existing AGENTS.md
    • Use
      find
      alternative (
      glob
      or repo tree) to discover current files. Determine scope inheritance so you can update or extend instead of duplicating.
  2. Read Core Docs
    • Skim
      README.md
      ,
      CONTRIBUTING.md
      , and other onboarding docs for project philosophy, setup, and workflows.
    • If
      docs/
      or
      documentation/
      exists, scan for architectural or process references worth surfacing.
  3. Survey Project Layout
    • Note primary directories, languages, build targets, and ownership (e.g., "
      src/ui
      maintained by Frontend team").
    • Check for
      plans/
      ,
      docs/
      , or other knowledge directories. Flag must-read files (ADR indexes, architecture overviews, runbooks) to reference later in AGENTS.md.
  4. Build a Git-aware Tree
    • Use the
      tree
      command with the
      --gitignore
      flag (tree ≥ 2.0) so ignored paths stay hidden:
      tree --gitignore -a -L 3 > tmp/tree.txt
      .
    • If your
      tree
      build lacks
      --gitignore
      , run
      tree -a -L 3 --prune
      and manually prune any ignored directories noted in
      .gitignore
      , or install an updated version via your package manager.
    • Capture or trim the output before placing it in AGENTS.md (focus on the top 2–3 levels, and note when you omitted details for brevity).
  5. Identify Automation Runners
    • If
      Justfile
      exists, run
      just --list
      (or
      just --list --unsorted
      for extra notes).
    • If
      Makefile
      exists (and
      just
      does not), run
      make help
      or inspect phony targets for canonical tasks.
    • Record which commands are recommended for linting, testing, building, syncing data, etc. Link the definitive task names you surface in your notes for inclusion later.
  6. Catalog Tooling & Environment
    • List required runtimes, package managers, env vars, secrets handling, and local services.
    • Note down any
      .env.example
      ,
      config/
      , or secrets documentation that agents must review.
  7. Clarify Testing & Quality Gates
    • Identify test suites, coverage expectations, linting, formatting, and CI workflows.
  8. Resolve Ambiguities Early
    • Whenever conventions, ownership, or workflows seem unclear, prompt the developer with focused questions before drafting the guide.
    • Ask explicitly whether existing
      plans/
      or documentation directories are authoritative or stale, and clarify what canon to reference.
Outcome: A structured notes list describing layout, tooling, commands, testing, release process, documentation references, pending questions, and update expectations.

  1. 检查现有AGENTS.md文件
    • 使用
      find
      的替代工具(
      glob
      或仓库树)查找当前文件。确定范围继承关系,以便进行更新或扩展,而非重复创建。
  2. 阅读核心文档
    • 浏览
      README.md
      CONTRIBUTING.md
      及其他入职文档,了解项目理念、搭建步骤及工作流程。
    • 若存在
      docs/
      documentation/
      目录,扫描其中是否有值得纳入的架构或流程参考内容。
  3. 调研项目布局
    • 记录主要目录、开发语言、构建目标及归属方(例如:“
      src/ui
      由前端团队维护”)。
    • 检查是否存在
      plans/
      docs/
      或其他知识目录。标记必须阅读的文件(ADR索引、架构概述、运行手册),以便后续在AGENTS.md中引用。
  4. 生成Git感知的目录树
    • 使用带有
      --gitignore
      参数的
      tree
      命令(tree ≥ 2.0版本),隐藏被忽略的路径:
      tree --gitignore -a -L 3 > tmp/tree.txt
    • 若你的
      tree
      版本不支持
      --gitignore
      ,运行
      tree -a -L 3 --prune
      并手动剔除
      .gitignore
      中记录的忽略目录,或通过包管理器安装更新版本。
    • 在将输出放入AGENTS.md之前,先整理或裁剪内容(重点展示前2-3级目录,并注明为简洁起见省略了部分细节)。
  5. 识别自动化运行器
    • 若存在
      Justfile
      ,运行
      just --list
      (或
      just --list --unsorted
      查看额外说明)。
    • 若存在
      Makefile
      (且无
      just
      ),运行
      make help
      或检查伪目标以获取标准任务。
    • 记录推荐的代码检查、测试、构建、数据同步等命令。记录你发现的确定任务名称,以便后续纳入指南。
  6. 整理工具与环境信息
    • 列出所需的运行时、包管理器、环境变量、密钥处理方式及本地服务。
    • 记录Agent必须查看的
      .env.example
      config/
      或密钥相关文档。
  7. 明确测试与质量门禁
    • 识别测试套件、覆盖率要求、代码检查、格式化及CI工作流程。
  8. 尽早解决歧义
    • 每当遇到规范、归属或工作流程不明确的情况,在起草指南前向开发者提出针对性问题。
    • 明确询问现有
      plans/
      或文档目录是否为权威内容或已过时,并确定需引用的标准内容。
成果: 一份结构化的笔记列表,描述目录布局、工具、命令、测试、发布流程、文档参考、未决问题及更新要求。

Phase 2 · Plan the AGENTS.md Structure

第二阶段 · 规划AGENTS.md结构

Follow this opinionated order to keep files consistent and scannable:
  1. Header — Title + short purpose statement.
  2. Quick Facts — Table or bullet summary (languages, package manager, key scripts, CI).
  3. Repository Tour — High-level directory map with responsibilities and ownership hints.
  4. Tooling & Setup — Required runtimes, package managers, environment variables, secrets.
  5. Common Tasks — Lint/test/build/deploy commands. Prefer listing
    just
    recipes first, then
    make
    targets, then raw commands.
  6. Testing & Quality — When and how to run tests, linting, formatting, coverage, and CI expectations.
  7. Workflow Expectations — Branching model, review norms, feature flagging, deployment cadence.
  8. Documentation Duties — When to update
    README.md
    , architecture diagrams, or other docs.
  9. Finish the Task — Mandatory wrap-up checklist for every agent task.
For deeper directories (e.g.,
services/api/
), include a "Scope" note at the top clarifying inheritance from parent AGENTS instructions. Always confirm with the developer before drafting new per-directory AGENTS files so you do not duplicate existing guidance or create unnecessary overhead.

遵循以下指定的顺序,保持文件一致性和易读性:
  1. 标题栏 — 标题 + 简短用途说明。
  2. 快速概览 — 表格或项目符号摘要(开发语言、包管理器、关键脚本、CI)。
  3. 仓库导览 — 高级别目录映射,包含职责和归属提示。
  4. 工具与搭建 — 所需的运行时、包管理器、环境变量、密钥。
  5. 常见任务 — 代码检查/测试/构建/部署命令。优先列出
    just
    任务,其次是
    make
    目标,最后是原生命令。
  6. 测试与质量 — 何时及如何运行测试、代码检查、格式化、覆盖率检查,以及CI要求。
  7. 工作流程要求 — 分支模型、评审规范、功能标记、发布节奏。
  8. 文档职责 — 何时更新
    README.md
    、架构图或其他文档。
  9. 任务收尾 — 每个Agent任务的强制收尾检查清单。
对于深层目录(如
services/api/
),在顶部添加“范围”说明,明确继承自父级AGENTS指令的内容。在起草新的目录级AGENTS文件前,务必与开发者确认,避免重复现有指南或造成不必要的负担。

Phase 3 · Compose AGENTS.md

第三阶段 · 编写AGENTS.md

Use the template below and adapt each section to the project:
markdown
undefined
使用以下模板,根据项目情况调整各章节:
markdown
undefined

Project Agent Guide

Project Agent Guide

Scope: Root project (applies to all subdirectories unless overridden)
Scope: Root project (applies to all subdirectories unless overridden)

Quick Facts

Quick Facts

  • Primary language:
  • Package manager:
  • Entrypoints:
  • CI/CD:
  • Primary language:
  • Package manager:
  • Entrypoints:
  • CI/CD:

Repository Tour

Repository Tour

  • path/
    — description & owner
  • path/
    — description & owner

Tooling & Setup

Tooling & Setup

  • Install instructions (per OS)
  • Required environment variables (with purpose)
  • Secrets management notes
  • Install instructions (per OS)
  • Required environment variables (with purpose)
  • Secrets management notes

Common Tasks

Common Tasks

  • just <task>
    — what it does (preferred)
  • make <target>
    — what it does
  • Raw command fallback when automation missing
  • just <task>
    — what it does (preferred)
  • make <target>
    — what it does
  • Raw command fallback when automation missing

Testing & Quality Gates

Testing & Quality Gates

  • Unit/integration test commands
  • Lint/format commands
  • Coverage expectations & thresholds
  • CI status command or dashboard link
  • Unit/integration test commands
  • Lint/format commands
  • Coverage expectations & thresholds
  • CI status command or dashboard link

Workflow Expectations

Workflow Expectations

  • Branch naming and review rules
  • Feature toggles or release cadence
  • Any approval or ticket linkage requirements
  • Branch naming and review rules
  • Feature toggles or release cadence
  • Any approval or ticket linkage requirements

Documentation Duties

Documentation Duties

  • Update
    README.md
    when features, setup steps, or developer ergonomics change materially
  • List other docs to refresh (architecture, ADRs, etc.)
  • Update
    README.md
    when features, setup steps, or developer ergonomics change materially
  • List other docs to refresh (architecture, ADRs, etc.)

Finish the Task Checklist

Finish the Task Checklist

  • Update relevant docs (&
    README.md
    if significant changes landed)
  • Summarize changes in conventional commit format (e.g.,
    feat: ...
    ,
    fix: ...
    )
undefined
  • Update relevant docs (&
    README.md
    if significant changes landed)
  • Summarize changes in conventional commit format (e.g.,
    feat: ...
    ,
    fix: ...
    )
undefined

Subdirectory Template (Use Only with Developer Approval)

子目录模板(仅在开发者批准后使用)

markdown
undefined
markdown
undefined

<Directory Name> Agent Guide

<Directory Name> Agent Guide

Scope: ./path/to/directory (inherits root AGENTS.md unless noted)
Scope: ./path/to/directory (inherits root AGENTS.md unless noted)

Purpose

Purpose

  • What lives here
  • Who owns it (team/contact)
  • What lives here
  • Who owns it (team/contact)

Key Files

Key Files

  • file_or_folder/
    — why it matters
  • file_or_folder/
    — why it matters

Common Tasks

Common Tasks

  • just <task>
    /
    make <target>
    / command snippets scoped to this directory
  • just <task>
    /
    make <target>
    / command snippets scoped to this directory

Testing & Quality

Testing & Quality

  • Specific tests, linters, or data fixtures for this directory
  • Specific tests, linters, or data fixtures for this directory

Hand-off Notes

Hand-off Notes

  • Docs or runbooks to reference
  • Open questions captured during discovery
Only create these per-directory guides after confirming with the developer which areas need dedicated context and what information should be emphasized.

**Writing Notes:**
- Keep language direct and actionable. Agents should follow commands verbatim.
- Mention the preferred order of operations (e.g., "Always run `just format` before opening a PR").
- When referencing scripts, include relative paths so agents can jump quickly (e.g., ``scripts/bootstrap.sh``).
- Incorporate a trimmed `tree --gitignore` snapshot (or link to the saved artifact) so readers grasp layout quickly.
- In the Repository Tour, highlight where `plans/`, `docs/`, design docs, or ADRs live if present.
- Call out any unanswered questions as action items, and confirm with the developer before creating any per-directory AGENTS overlays.
- If the project mixes languages/platforms, add subsections per component but keep global guidance first.

---
  • Docs or runbooks to reference
  • Open questions captured during discovery
仅在与开发者确认哪些区域需要专属上下文以及需要强调哪些信息后,再创建这些目录级指南。

**编写注意事项:**
- 语言直接且可执行。Agent应严格遵循命令操作。
- 提及操作的优先顺序(例如:“提交PR前务必运行`just format`”)。
- 引用脚本时,包含相对路径以便Agent快速跳转(例如:``scripts/bootstrap.sh``)。
- 加入裁剪后的`tree --gitignore`快照(或链接到保存的工件),以便读者快速了解布局。
- 在仓库导览部分,若存在`plans/`、`docs/`、设计文档或ADR,突出显示其位置。
- 将未解决的问题列为行动项,并在创建任何目录级AGENTS覆盖文件前与开发者确认。
- 若项目混合多种语言/平台,按组件添加子章节,但先保留全局指南。

---

Phase 4 · Validate & Wrap Up

第四阶段 · 验证与收尾

  1. Self-review
    • Does the file respect AGENTS scope rules? (Mention inheritance or overrides.)
    • Are all critical commands documented, especially automation entry points?
    • Is the README update expectation explicit?
    • Did you obtain developer approval before adding any per-directory AGENTS files, and is that approval reflected in the write-up?
    • Does the "Finish the Task" checklist include the conventional commit summary reminder?
  2. Formatting
    • Ensure headings use Title Case, commands are wrapped in backticks, and lists are concise.
    • Keep sections under ~8 bullets unless a table is clearer.
  3. Handoff Summary
    • When delivering the AGENTS.md to the user, include:
      • A short summary of major sections added/updated.
      • Confirmation that README and conventional commit reminders are present.
      • Any follow-up suggestions (e.g., missing tests or outdated scripts).
Use this skill whenever a repo lacks AGENTS context or when existing instructions are incomplete or outdated. The goal is to leave future agents with a single, trustworthy map of the project, its tooling, and the expectations for finishing tasks responsibly.
  1. 自我审查
    • 文件是否遵循AGENTS范围规则?(提及继承或覆盖关系。)
    • 所有关键命令是否已记录,尤其是自动化入口点?
    • README更新要求是否明确?
    • 添加任何目录级AGENTS文件前是否已获得开发者批准,且该批准是否已在文档中体现?
    • “任务收尾”检查清单是否包含规范提交格式的提醒?
  2. 格式调整
    • 确保标题使用标题大小写,命令用反引号包裹,列表简洁。
    • 除非表格更清晰,否则每个章节的项目符号不超过8个。
  3. 交付总结
    • 向用户交付AGENTS.md时,需包含:
      • 新增/更新主要章节的简短总结。
      • 确认已包含README和规范提交的提醒。
      • 任何后续建议(例如:缺失的测试或过时的脚本)。
当仓库缺少AGENTS上下文,或现有指南不完整、过时,即可使用本工具。目标是为后续Agent提供一份单一、可靠的项目地图,涵盖项目工具及负责任完成任务的要求。