domain-init
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseDomain Registry Initializer
域注册表初始化工具
Initialize or refresh the Domain Registry in this project's .
CLAUDE.md初始化或更新本项目中的Domain Registry。
CLAUDE.mdWhat This Does
功能说明
- Scans the project for library/domain directories
- Reads each library's metadata (,
project.json, orpackage.json)ng-package.json - Writes (or updates) a section in
## Domain RegistryCLAUDE.md - Adds the auto-load instruction if it's not already present
- 扫描项目中的库/域目录
- 读取每个库的元数据(、
project.json或package.json)ng-package.json - 在中写入(或更新)
CLAUDE.md章节## Domain Registry - 如果自动加载说明不存在,则添加该说明
Instructions
使用说明
Step 1 — Detect Project Structure
步骤1 — 检测项目结构
Run the detection script to find all library directories:
bash
bash .claude/skills/domain-init/scripts/scan_domains.sh 2>/dev/null \
|| node .claude/skills/domain-init/scripts/scan_domains.js 2>/dev/nullIf neither script is available, scan manually:
- Look for directories under that contain
libs/orproject.jsonpackage.json - For Nx workspaces: read →
project.jsonandnametargets.build.options.project - For plain npm: read →
package.jsonname - For Angular libraries: read → check parent
ng-package.jsonfor namepackage.json
运行检测脚本查找所有库目录:
bash
bash .claude/skills/domain-init/scripts/scan_domains.sh 2>/dev/null \
|| node .claude/skills/domain-init/scripts/scan_domains.js 2>/dev/null如果两个脚本都不可用,请手动扫描:
- 查找目录下包含
libs/或project.json的目录package.json - 对于Nx工作区:读取→
project.json和name字段targets.build.options.project - 对于普通npm项目:读取→
package.json字段name - 对于Angular库:读取→ 检查上级
ng-package.json获取名称package.json
Step 2 — Build the Registry Table
步骤2 — 构建注册表表格
For each found library, collect:
| Field | Source |
|---|---|
| Relative directory path from workspace root |
| |
| First line of existing |
Generate description heuristics if no README exists:
- → "Widget: [name] feature module"
widget-* - or
*-domain→ "Domain layer: business logic and state"domain - or
*-feature→ "Feature layer: container components"feature - or
*-ui→ "UI layer: presentational components"ui - or
*-util→ "Utilities and helpers"util - → "Shared: [name]"
shared/*
针对每个找到的库,收集以下信息:
| 字段 | 来源 |
|---|---|
| 工作区根目录下的相对目录路径 |
| |
| 现有 |
如果没有README文件,可通过启发式规则生成描述:
- → "Widget: [name] 功能模块"
widget-* - 或
*-domain→ "域层:业务逻辑与状态"domain - 或
*-feature→ "功能层:容器组件"feature - 或
*-ui→ "UI层:展示组件"ui - 或
*-util→ "工具函数与辅助方法"util - → "共享:[name]"
shared/*
Step 3 — Write to CLAUDE.md
步骤3 — 写入CLAUDE.md
Read the current . Then:
CLAUDE.mdIf already exists: Replace everything between the start and end markers with the new table.
<!-- domain-registry-start -->If it does not exist: Append the following block to :
CLAUDE.mdmarkdown
undefined读取当前的,然后按以下规则处理:
CLAUDE.md如果已存在: 替换起止标记之间的所有内容为新生成的表格。
<!-- domain-registry-start -->如果不存在: 将以下代码块追加到末尾:
CLAUDE.mdmarkdown
undefinedDomain Registry
Domain Registry
<!-- domain-registry-start -->Auto-maintained by domain-init skill. Runto regenerate./domain-init
| Path | Import Path | Description |
|---|---|---|
| <path> | <import-path> | <description> |
undefined<!-- domain-registry-start -->Auto-maintained by domain-init skill. Runto regenerate./domain-init
| Path | Import Path | Description |
|---|---|---|
| <path> | <import-path> | <description> |
undefinedStep 4 — Add Auto-Load Instruction (if missing)
步骤4 — 添加自动加载说明(如缺失)
Check if already contains the phrase or . If it does NOT, also append:
CLAUDE.mddomain-init skillDomain Registrymarkdown
undefined检查中是否已包含或字样。如果没有,同时追加以下内容:
CLAUDE.mddomain-init skillDomain Registrymarkdown
undefinedDomain Context Loading
Domain Context Loading
The skill is active. Before working on any library listed in the
Domain Registry above, silently read its for architecture context.
domain-initREADME.mdundefinedThe skill is active. Before working on any library listed in the
Domain Registry above, silently read its for architecture context.
domain-initREADME.mdundefinedStep 5 — Report
步骤5 — 结果报告
After writing, output a summary:
✓ Domain Registry updated in CLAUDE.md
Found N domains:
- libs/widget-chat → @scope/widget-chat
- libs/shared/... → @scope/shared/...
...
Domains without README.md (consider running /domain-readme <path>):
- libs/dashboards-manager
- libs/widget-map写入完成后,输出汇总信息:
✓ Domain Registry updated in CLAUDE.md
Found N domains:
- libs/widget-chat → @scope/widget-chat
- libs/shared/... → @scope/shared/...
...
Domains without README.md (consider running /domain-readme <path>):
- libs/dashboards-manager
- libs/widget-mapArguments
参数说明
$ARGUMENTSlibs/Examples:
- — scans
/domain-initlibs/ - — scans only
/domain-init libs/sharedlibs/shared/ - — scans a
/domain-init packagesmonorepo structurepackages/
$ARGUMENTSlibs/示例:
- — 扫描
/domain-init目录libs/ - — 仅扫描
/domain-init libs/shared目录libs/shared/ - — 扫描monorepo结构的
/domain-init packages目录packages/
Re-running
重复运行
This skill is idempotent. Running it multiple times only updates the registry table, preserving all other content in .
CLAUDE.md本skill是幂等的。多次运行只会更新注册表表格,不会修改中的其他内容。
CLAUDE.md