deepinit
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseDeep Init Skill
Deep Init Skill
Creates comprehensive, hierarchical AGENTS.md documentation across the entire codebase.
Read references/scope-and-preservation.md before running on a repository with existing AGENTS.md files or runtime directories. Validate results with .
scripts/validate_agents_hierarchy.py在整个代码库中创建全面的层级化AGENTS.md文档。
运行前请阅读references/scope-and-preservation.md,如果仓库中已有AGENTS.md文件或运行时目录。使用验证结果。
scripts/validate_agents_hierarchy.pyCore Concept
核心概念
AGENTS.md files serve as AI-readable documentation that helps agents understand:
- What each directory contains
- How components relate to each other
- Special instructions for working in that area
- Dependencies and relationships
AGENTS.md文件作为AI可读文档,帮助Agent理解:
- 每个目录包含的内容
- 组件之间的关联方式
- 在该区域工作的特殊说明
- 依赖关系
Hierarchical Tagging System
层级标签系统
Every AGENTS.md (except root) includes a parent reference tag:
markdown
<!-- Parent: ../AGENTS.md -->This creates a navigable hierarchy:
/AGENTS.md ← Root (no parent tag)
├── src/AGENTS.md ← <!-- Parent: ../AGENTS.md -->
│ ├── src/components/AGENTS.md ← <!-- Parent: ../AGENTS.md -->
│ └── src/utils/AGENTS.md ← <!-- Parent: ../AGENTS.md -->
└── docs/AGENTS.md ← <!-- Parent: ../AGENTS.md -->除根目录外,每个AGENTS.md都包含父引用标签:
markdown
<!-- Parent: ../AGENTS.md -->这会创建一个可导航的层级结构:
/AGENTS.md ← 根目录(无父标签)
├── src/AGENTS.md ← <!-- Parent: ../AGENTS.md -->
│ ├── src/components/AGENTS.md ← <!-- Parent: ../AGENTS.md -->
│ └── src/utils/AGENTS.md ← <!-- Parent: ../AGENTS.md -->
└── docs/AGENTS.md ← <!-- Parent: ../AGENTS.md -->AGENTS.md Template
AGENTS.md模板
markdown
<!-- Parent: {relative_path_to_parent}/AGENTS.md -->
<!-- Generated: {timestamp} | Updated: {timestamp} -->markdown
<!-- Parent: {relative_path_to_parent}/AGENTS.md -->
<!-- Generated: {timestamp} | Updated: {timestamp} -->{Directory Name}
{Directory Name}
Purpose
用途
{One-paragraph description of what this directory contains and its role}
{一段描述该目录包含内容及其作用的文字}
Key Files
关键文件
{List each significant file with a one-line description}
| File | Description |
|---|---|
| Brief description of purpose |
{列出每个重要文件并附带一行描述}
| 文件 | 描述 |
|---|---|
| 用途的简要描述 |
Subdirectories
子目录
{List each subdirectory with brief purpose}
| Directory | Purpose |
|---|---|
| What it contains (see |
{列出每个子目录并简要说明用途}
| 目录 | 用途 |
|---|---|
| 包含内容(详见 |
For AI Agents
面向AI Agent
Working In This Directory
在此目录中工作
{Special instructions for AI agents modifying files here}
{针对AI Agent修改此目录文件的特殊说明}
Testing Requirements
测试要求
{How to test changes in this directory}
{如何测试此目录中的更改}
Common Patterns
常见模式
{Code patterns or conventions used here}
{此处使用的代码模式或约定}
Dependencies
依赖
Internal
内部
{References to other parts of the codebase this depends on}
{此目录依赖的代码库其他部分的引用}
External
外部
{Key external packages/libraries used}
<!-- MANUAL: Any manually added notes below this line are preserved on regeneration -->
undefined{使用的关键外部包/库}
<!-- MANUAL: 此行以下的手动添加注释在重新生成时会被保留 -->
undefinedExecution Workflow
执行流程
Step 1: Map Directory Structure
步骤1:映射目录结构
Task(subagent_type="explore", model="haiku",
prompt="List all directories recursively. Exclude runtime/build/cache directories from references/scope-and-preservation.md.")Default excludes:
- ,
.git/,node_modules/,dist/,build/,coverage/,.next/,.nuxt/,__pycache__/,.venv/venv/ - Root runtime state: ,
.omc/,.omx/,.survey/,.codex/,.claude/,.gemini/,.agents/,.opencode/.ouroboros/
Keep in scope because it is repository source, not runtime state.
.agent-skills/Task(subagent_type="explore", model="haiku",
prompt="List all directories recursively. Exclude runtime/build/cache directories from references/scope-and-preservation.md.")默认排除目录:
- ,
.git/,node_modules/,dist/,build/,coverage/,.next/,.nuxt/,__pycache__/,.venv/venv/ - 根目录运行时状态:,
.omc/,.omx/,.survey/,.codex/,.claude/,.gemini/,.agents/,.opencode/.ouroboros/
将纳入范围,因为它是仓库源码,而非运行时状态。
.agent-skills/Step 2: Create Work Plan
步骤2:创建工作计划
Generate todo items for each directory, organized by depth level:
Level 0: / (root)
Level 1: /src, /docs, /tests
Level 2: /src/components, /src/utils, /docs/api
...生成按深度级别组织的每个目录的待办事项:
Level 0: / (根目录)
Level 1: /src, /docs, /tests
Level 2: /src/components, /src/utils, /docs/api
...Step 3: Generate Level by Level
步骤3:按层级生成
IMPORTANT: Generate parent levels before child levels to ensure parent references are valid.
For each directory:
- Read all files in the directory
- Analyze purpose and relationships
- Generate AGENTS.md content
- Write file with proper parent reference
重要提示:先生成父层级,再生成子层级,确保父引用有效。
针对每个目录:
- 读取目录中的所有文件
- 分析用途和关联关系
- 生成AGENTS.md内容
- 写入带有正确父引用的文件
Step 4: Compare and Update (if exists)
步骤4:对比与更新(若已存在)
When AGENTS.md already exists:
- Read existing content
- Identify sections:
- Auto-generated sections (can be updated)
- Manual sections (preserved)
<!-- MANUAL -->
- Compare:
- New files added?
- Files removed?
- Structure changed?
- Merge:
- Update auto-generated content
- Preserve manual annotations
- Update timestamp
- Keep existing instructions that are still true; flag stale instructions instead of deleting them silently
当AGENTS.md已存在时:
- 读取现有内容
- 识别区块:
- 自动生成区块(可更新)
- 手动区块(会被保留)
<!-- MANUAL -->
- 对比:
- 是否新增文件?
- 是否删除文件?
- 结构是否变化?
- 合并:
- 更新自动生成的内容
- 保留手动注释
- 更新时间戳
- 保留仍然有效的现有说明;标记过时说明而非静默删除
Step 5: Validate Hierarchy
步骤5:验证层级结构
After generation, run validation checks:
| Check | How to Verify | Corrective Action |
|---|---|---|
| Parent references resolve | Read each AGENTS.md, check | Fix path or remove orphan |
| No orphaned AGENTS.md | Compare AGENTS.md locations to directory structure | Delete orphaned files |
| Completeness | List all directories, check for AGENTS.md | Generate missing files |
| Timestamps current | Check | Regenerate outdated files |
Validation script pattern:
bash
python3 .agent-skills/deepinit/scripts/validate_agents_hierarchy.py .生成完成后,运行验证检查:
| 检查项 | 验证方式 | 纠正措施 |
|---|---|---|
| 父引用可解析 | 读取每个AGENTS.md,检查 | 修复路径或移除孤立文件 |
| 无孤立AGENTS.md | 对比AGENTS.md位置与目录结构 | 删除孤立文件 |
| 完整性 | 列出所有目录,检查是否存在AGENTS.md | 生成缺失文件 |
| 时间戳最新 | 检查 | 重新生成过时文件 |
验证脚本示例:
bash
python3 .agent-skills/deepinit/scripts/validate_agents_hierarchy.py .Smart Delegation
智能委派
| Task | Agent |
|---|---|
| Directory mapping | |
| File analysis | |
| Content generation | |
| AGENTS.md writes | |
| 任务 | Agent |
|---|---|
| 目录映射 | |
| 文件分析 | |
| 内容生成 | |
| AGENTS.md写入 | |
Empty Directory Handling
空目录处理
When encountering empty or near-empty directories:
| Condition | Action |
|---|---|
| No files, no subdirectories | Skip - do not create AGENTS.md |
| No files, has subdirectories | Create minimal AGENTS.md with subdirectory listing only |
| Has only generated files (*.min.js, *.map) | Skip or minimal AGENTS.md |
| Has only config files | Create AGENTS.md describing configuration purpose |
Example minimal AGENTS.md for directory-only containers:
markdown
<!-- Parent: ../AGENTS.md -->遇到空目录或近乎空的目录时:
| 条件 | 操作 |
|---|---|
| 无文件且无子目录 | 跳过 - 不创建AGENTS.md |
| 无文件但有子目录 | 创建仅包含子目录列表的极简AGENTS.md |
| 仅包含生成文件(*.min.js, *.map) | 跳过或创建极简AGENTS.md |
| 仅包含配置文件 | 创建描述配置用途的AGENTS.md |
仅包含目录的容器的极简AGENTS.md示例:
markdown
<!-- Parent: ../AGENTS.md -->{Directory Name}
{Directory Name}
Purpose
用途
Container directory for organizing related modules.
用于组织相关模块的容器目录。
Subdirectories
子目录
| Directory | Purpose |
|---|---|
| Description (see |
undefined| 目录 | 用途 |
|---|---|
| 描述(详见 |
undefinedParallelization Rules
并行化规则
- Same-level directories: Process in parallel
- Different levels: Sequential (parent first)
- Large directories: Spawn dedicated agent per directory
- Small directories: Batch multiple into one agent
- 同级目录:并行处理
- 不同层级:顺序处理(先父后子)
- 大型目录:为每个目录分配专属Agent
- 小型目录:批量分配给单个Agent
Quality Standards
质量标准
Must Include
必须包含
- Accurate file descriptions
- Correct parent references
- Subdirectory links
- AI agent instructions
- 准确的文件描述
- 正确的父引用
- 子目录链接
- AI Agent操作说明
Must Avoid
必须避免
- Generic boilerplate
- Incorrect file names
- Broken parent references
- Missing important files
- Documenting ignored runtime state as source architecture
- Replacing user-authored manual notes
- 通用模板内容
- 错误的文件名
- 无效的父引用
- 遗漏重要文件
- 将被忽略的运行时状态记录为源码架构
- 替换用户编写的手动注释
Runtime-Specific Notes
运行时特定说明
| Runtime | Documentation rule |
|---|---|
| Claude Code / OMC | Root |
| Codex / OMX | Root |
| Gemini / Antigravity / OMA | Document |
| Always allowed as source; document skill folders, scripts, references, evals, and validation commands |
| 运行环境 | 文档规则 |
|---|---|
| Claude Code / OMC | 根目录 |
| Codex / OMX | 根目录 |
| Gemini / Antigravity / OMA | 仅当 |
| 始终视为源码;记录技能文件夹、脚本、参考文献、评估和验证命令 |
Example Output
示例输出
Root AGENTS.md
根目录AGENTS.md
markdown
<!-- Generated: 2024-01-15 | Updated: 2024-01-15 -->markdown
<!-- Generated: 2024-01-15 | Updated: 2024-01-15 -->my-project
my-project
Purpose
用途
A web application for managing user tasks with real-time collaboration features.
一款具备实时协作功能的用户任务管理Web应用。
Key Files
关键文件
| File | Description |
|---|---|
| Project dependencies and scripts |
| TypeScript configuration |
| Environment variable template |
| 文件 | 描述 |
|---|---|
| 项目依赖和脚本 |
| TypeScript配置 |
| 环境变量模板 |
Subdirectories
子目录
| Directory | Purpose |
|---|---|
| Application source code (see |
| Documentation (see |
| Test suites (see |
| 目录 | 用途 |
|---|---|
| 应用源码(详见 |
| 文档(详见 |
| 测试套件(详见 |
For AI Agents
面向AI Agent
Working In This Directory
在此目录中工作
- Always install dependencies after modifying the project manifest
- Use TypeScript strict mode
- Follow ESLint rules
- 修改项目清单后务必安装依赖
- 使用TypeScript严格模式
- 遵循ESLint规则
Testing Requirements
测试要求
- Run tests before committing
- Ensure >80% coverage
- 提交前运行测试
- 确保覆盖率>80%
Common Patterns
常见模式
- Use barrel exports (index.ts)
- Prefer functional components
- 使用桶导出(index.ts)
- 优先使用函数式组件
Dependencies
依赖
External
外部
- React 18.x - UI framework
- TypeScript 5.x - Type safety
- Vite - Build tool
undefined- React 18.x - UI框架
- TypeScript 5.x - 类型安全
- Vite - 构建工具
undefinedNested AGENTS.md
嵌套AGENTS.md
markdown
<!-- Parent: ../AGENTS.md -->
<!-- Generated: 2024-01-15 | Updated: 2024-01-15 -->markdown
<!-- Parent: ../AGENTS.md -->
<!-- Generated: 2024-01-15 | Updated: 2024-01-15 -->components
components
Purpose
用途
Reusable React components organized by feature and complexity.
按功能和复杂度组织的可复用React组件。
Key Files
关键文件
| File | Description |
|---|---|
| Barrel export for all components |
| Primary button component |
| Modal dialog component |
| 文件 | 描述 |
|---|---|
| 所有组件的桶导出 |
| 主按钮组件 |
| 模态对话框组件 |
Subdirectories
子目录
| Directory | Purpose |
|---|---|
| Form-related components (see |
| Layout components (see |
| 目录 | 用途 |
|---|---|
| 表单相关组件(详见 |
| 布局组件(详见 |
For AI Agents
面向AI Agent
Working In This Directory
在此目录中工作
- Each component has its own file
- Use CSS modules for styling
- Export via index.ts
- 每个组件单独存放在一个文件中
- 使用CSS模块进行样式管理
- 通过index.ts导出
Testing Requirements
测试要求
- Unit tests in subdirectory
__tests__/ - Use React Testing Library
- 单元测试位于子目录
__tests__/ - 使用React Testing Library
Common Patterns
常见模式
- Props interfaces defined above component
- Use forwardRef for DOM-exposing components
- 组件上方定义Props接口
- 对暴露DOM的组件使用forwardRef
Dependencies
依赖
Internal
内部
- - Custom hooks used by components
src/hooks/ - - Utility functions
src/utils/
- - 组件使用的自定义hooks
src/hooks/ - - 工具函数
src/utils/
External
外部
- - Conditional class names
clsx - - Icons
lucide-react
undefined- - 条件类名
clsx - - 图标库
lucide-react
undefinedTriggering Update Mode
触发更新模式
When running on an existing codebase with AGENTS.md files:
- Detect existing files first
- Read and parse existing content
- Analyze current directory state
- Generate diff between existing and current
- Apply updates while preserving manual sections
在已有AGENTS.md文件的现有代码库上运行时:
- 先检测现有文件
- 读取并解析现有内容
- 分析当前目录状态
- 生成现有内容与当前状态的差异
- 应用更新同时保留手动区块
Performance Considerations
性能考量
- Cache directory listings - Don't re-scan same directories
- Batch small directories - Process multiple at once
- Skip unchanged - If directory hasn't changed, skip regeneration
- Parallel writes - Multiple agents writing different files simultaneously
- 缓存目录列表 - 不要重复扫描相同目录
- 批量处理小型目录 - 同时处理多个目录
- 跳过未更改内容 - 如果目录未发生变化,跳过重新生成
- 并行写入 - 多个Agent同时写入不同文件
References
参考资料
- Scope and preservation
scripts/validate_agents_hierarchy.py
- 范围与保留规则
scripts/validate_agents_hierarchy.py