Communitygithub.com

deepinit

深度代码库初始化,创建层次化的 AGENTS.md 文档

deepinit 是什么?

Deep Init 是一项专门用于自动创建和维护跨整个代码库的层次化 AGENTS.md 文档的技能。它通过在每个目录中生成 AI 可读的文档,帮助 AI 代理理解目录内容、组件关系、工作指令和依赖项。该技能支持递归目录映射、基于模板的内容生成、层次化标记系统(使用父引用标签)以及智能更新机制,同时保留手动添加的注释。它适用于任何代码库,并可与多种 AI 代理平台(如 Claude Code、Cursor 等)配合使用,通过将大型任务分解为探索、分析、生成和验证子任务来优化工作流程。

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/Yeachan-Heo/oh-my-claudecode/tree/main/skills/deepinit

在你喜欢的 AI 中提问

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

文档

Deep Init 技能

创建跨整个代码库的全面、层次化的 AGENTS.md 文档。

核心概念

AGENTS.md 文件作为AI 可读的文档,帮助代理理解:

  • 每个目录包含什么
  • 组件之间如何关联
  • 在该区域工作的特殊指令
  • 依赖关系和关联

层次化标签系统

每个 AGENTS.md(根目录除外)都包含一个父引用标签:

<!-- 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 模板

<!-- Parent: {relative_path_to_parent}/AGENTS.md -->
<!-- Generated: {timestamp} | Updated: {timestamp} -->

# {目录名称}

## 用途
{一段描述此目录内容及其作用的文字}

## 关键文件
{列出每个重要文件及其一行描述}

| 文件 | 描述 |
|------|------|
| `file.ts` | 简要描述用途 |

## 子目录
{列出每个子目录及其简要用途}

| 目录 | 用途 |
|------|------|
| `subdir/` | 包含内容(参见 `subdir/AGENTS.md`) |

## 针对 AI 代理

### 在此目录工作
{AI 代理修改此目录文件时的特殊说明}

### 测试要求
{如何测试此目录的更改}

### 常见模式
{此处使用的代码模式或约定}

## 依赖项

### 内部
{代码库中其他部分的引用,此目录依赖它们}

### 外部
{使用的主要外部包/库}

<!-- MANUAL: 在此行下方手动添加的注释将在重新生成时保留 -->

执行工作流

步骤 1:映射目录结构

Task(subagent_type="explore", model="haiku",
  prompt="递归列出所有目录。排除:node_modules, .git, dist, build, __pycache__, .venv, coverage, .next, .nuxt")

步骤 2:创建工作计划

为每个目录生成待办事项,按深度级别组织:

级别 0:/ (根目录)
级别 1:/src, /docs, /tests
级别 2:/src/components, /src/utils, /docs/api
...

步骤 3:逐级生成

重要:先生成父级目录,再生成子级目录,以确保父引用有效。

对于每个目录:

  1. 读取目录中的所有文件
  2. 分析用途和关系
  3. 生成 AGENTS.md 内容
  4. 写入带有正确父引用的文件

步骤 4:比较和更新(如果存在)

当 AGENTS.md 已存在时:

  1. 读取现有内容
  2. 识别部分:
    • 自动生成的部分(可更新)
    • 手动部分(<!-- MANUAL --> 保留)
  3. 比较:
    • 添加了新文件?
    • 删除了文件?
    • 结构发生变化?
  4. 合并:
    • 更新自动生成的内容
    • 保留手动注释
    • 更新时间戳

步骤 5:验证层次结构

生成后,运行验证检查:

检查项如何验证纠正措施
父引用可解析读取每个 AGENTS.md,检查 <!-- Parent: --> 路径是否存在修复路径或删除孤悬引用
无孤悬 AGENTS.md比较 AGENTS.md 位置与目录结构删除孤悬文件
完整性列出所有目录,检查是否有 AGENTS.md生成缺失的文件
时间戳最新检查 <!-- Generated: --> 日期重新生成过时的文件

验证脚本模式:

# 查找所有 AGENTS.md 文件
find . -name "AGENTS.md" -type f

# 检查父引用
grep -r "<!-- Parent:" --include="AGENTS.md" .

智能委派

任务代理
目录映射explore
文件分析architect
内容生成writer
AGENTS.md 写入writer

空目录处理

遇到空目录或接近空的目录时:

条件操作
无文件,无子目录跳过 - 不创建 AGENTS.md
无文件,有子目录创建仅包含子目录列表的最小 AGENTS.md
仅包含生成的文件(*.min.js, *.map)跳过或创建最小 AGENTS.md
仅包含配置文件创建描述配置用途的 AGENTS.md

仅作为目录容器的示例最小 AGENTS.md:

<!-- Parent: ../AGENTS.md -->
# {目录名称}

## 用途
用于组织相关模块的容器目录。

## 子目录
| 目录 | 用途 |
|------|------|
| `subdir/` | 描述(参见 `subdir/AGENTS.md`) |

并行化规则

  1. 同级目录:并行处理
  2. 不同层级:按顺序处理(先父级)
  3. 大型目录:为每个目录派发专用代理
  4. 小型目录:将多个目录合并到一个代理中处理

质量标准

必须包含

  • 准确的文件描述
  • 正确的父引用
  • 子目录链接
  • AI 代理指令

必须避免

  • 通用模板套话
  • 错误的文件名
  • 损坏的父引用
  • 遗漏重要文件

示例输出

根目录 AGENTS.md

<!-- Generated: 2024-01-15 | Updated: 2024-01-15 -->

# my-project

## 用途
一个用于用户任务管理并支持实时协作的 Web 应用程序。

## 关键文件
| 文件 | 描述 |
|------|------|
| `package.json` | 项目依赖和脚本 |
| `tsconfig.json` | TypeScript 配置 |
| `.env.example` | 环境变量模板 |

## 子目录
| 目录 | 用途 |
|------|------|
| `src/` | 应用程序源代码(参见 `src/AGENTS.md`) |
| `docs/` | 文档(参见 `docs/AGENTS.md`) |
| `tests/` | 测试套件(参见 `tests/AGENTS.md`) |

## 针对 AI 代理

### 在此目录工作
- 修改项目清单后始终安装依赖
- 使用 TypeScript 严格模式
- 遵循 ESLint 规则

### 测试要求
- 提交前运行测试
- 确保覆盖率 >80%

### 常见模式
- 使用 Barrel 导出(index.ts)
- 优先使用函数式组件

## 依赖项

### 外部
- React 18.x - UI 框架
- TypeScript 5.x - 类型安全
- Vite - 构建工具

<!-- MANUAL: 可在此行下方添加自定义项目注释 -->

嵌套 AGENTS.md

<!-- Parent: ../AGENTS.md -->
<!-- Generated: 2024-01-15 | Updated: 2024-01-15 -->

# components

## 用途
按功能和复杂度组织的可复用 React 组件。

## 关键文件
| 文件 | 描述 |
|------|------|
| `index.ts` | 所有组件的 Barrel 导出 |
| `Button.tsx` | 主要按钮组件 |
| `Modal.tsx` | 模态对话框组件 |

## 子目录
| 目录 | 用途 |
|------|------|
| `forms/` | 表单相关组件(参见 `forms/AGENTS.md`) |
| `layout/` | 布局组件(参见 `layout/AGENTS.md`) |

## 针对 AI 代理

### 在此目录工作
- 每个组件都有自己的文件
- 使用 CSS Modules 进行样式管理
- 通过 index.ts 导出

### 测试要求
- 单元测试位于 `__tests__/` 子目录
- 使用 React Testing Library

### 常见模式
- Props 接口定义在组件之上
- 对需要暴露 DOM 的组件使用 forwardRef

## 依赖项

### 内部
- `src/hooks/` - 组件使用的自定义 hooks
- `src/utils/` - 工具函数

### 外部
- `clsx` - 条件类名
- `lucide-react` - 图标

<!-- MANUAL: -->

触发更新模式

在已有 AGENTS.md 文件的代码库上运行时:

  1. 首先检测现有文件
  2. 读取并解析现有内容
  3. 分析当前目录状态
  4. 生成现有内容与当前内容之间的差异
  5. 应用更新,同时保留手动部分

性能考虑

  • 缓存目录列表 - 不要重新扫描相同的目录
  • 批量处理小型目录 - 一次处理多个
  • 跳过未更改的目录 - 如果目录未更改,跳过重新生成
  • 并行写入 - 多个代理同时写入不同的文件

Individual skills in this repo

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

agent-doc-discipline

Writing-time discipline for documents agents consume (the five surfaces, specs, tickets, .omc/skills/) — every rule checkable and carrying a why, steps before reference, one meaning in one home, no restating what the environment already says. Mandatory at drydock seed generation and the launch C5 sediment pass; opt-in for any other agent-facing doc edit. The companion of minimal-code-discipline: that one disciplines code, this one disciplines papers.

ai-slop-cleaner

Clean AI-generated code slop with a regression-safe, deletion-first workflow and optional reviewer-only mode

ask

Process-first advisor routing for Claude, Codex, Gemini, Antigravity, Grok, or Cursor via `omc ask`, with artifact capture and no raw CLI assembly

ask-navigator

Shipyard

autopilot

Full autonomous execution from idea to working code

autoresearch

Stateful single-mission improvement loop with strict evaluator contract, markdown decision logs, and max-runtime stop behavior

cancel

Cancel any active OMC mode (autopilot, ralph, ultragoal, swarm, ultrapilot, pipeline, team) and clean up retired legacy state

configure-notifications

Configure notification integrations (Telegram, Discord, Slack) via natural language

debug

Diagnose the current OMC session or repo state using logs, traces, state, and focused reproduction

deep-interview

Socratic deep interview with mathematical ambiguity gating before explicit execution approval

drydock

Lay the keel of the shipyard harness in any repo — the 4-pillar shared environment (Context, Rules, Tools, Standards) across 5 surfaces (CLAUDE.md, skills, design-system, mcp/cli, shared context) so that every human and agent inherits the same design language and anyone can ship. Run once per repo; re-run with --check to audit drift.

execute

Carry an approved task through to working, verified code

external-context

Invoke parallel document-specialist agents for external web searches and documentation lookup

graph

Deterministic orchestration graph runtime - declarative DAG pipelines with journal-based crash recovery

harbor

Harbor intake for external work — the captain only handles unresolved decisions. Sweeps incoming issues and PRs, verifies every claim before disposition, reuses every decision already made, and hands the maintainer a docket whose pending items each carry one question with options, recommendation, impact and evidence. Agent-autonomous for facts and for actions covered by standing authorization; signed for every new judgment. Never merges.

hud

Configure HUD display options (layout, presets, display elements)

launch

Shipyard

loft

Loft the shape before cutting steel — answer a design question that prose cannot settle by building a throwaway artifact: a pure logic module in a clickable shell, or structurally different UI variants behind one route. The captain reacts to the artifact; the answer folds into the decision; the artifact never docks. Use when a design question stalls in words, when a navigator map carries a loft ticket, or when a spec discussion reaches

minimal-code-discipline

YAGNI-ladder coding discipline for writing changes — existence-first, reuse before writing, dependency ladder, shortest correct diff, with non-negotiables that must never be minimized away

omc-doctor

Diagnose and fix oh-my-claudecode installation issues

相关技能