domain-init

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Domain Registry Initializer

域注册表初始化工具

Initialize or refresh the Domain Registry in this project's
CLAUDE.md
.
初始化或更新本项目
CLAUDE.md
中的Domain Registry

What This Does

功能说明

  1. Scans the project for library/domain directories
  2. Reads each library's metadata (
    project.json
    ,
    package.json
    , or
    ng-package.json
    )
  3. Writes (or updates) a
    ## Domain Registry
    section in
    CLAUDE.md
  4. Adds the auto-load instruction if it's not already present
  1. 扫描项目中的库/域目录
  2. 读取每个库的元数据(
    project.json
    package.json
    ng-package.json
  3. CLAUDE.md
    中写入(或更新)
    ## Domain Registry
    章节
  4. 如果自动加载说明不存在,则添加该说明

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/null
If neither script is available, scan manually:
  • Look for directories under
    libs/
    that contain
    project.json
    or
    package.json
  • For Nx workspaces: read
    project.json
    name
    and
    targets.build.options.project
  • For plain npm: read
    package.json
    name
  • For Angular libraries: read
    ng-package.json
    → check parent
    package.json
    for name
运行检测脚本查找所有库目录:
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:
FieldSource
Path
Relative directory path from workspace root
Import Path
importPath
from
project.json
, or
name
from
package.json
Description
First line of existing
README.md
(skip
#
heading), or generate from library name
Generate description heuristics if no README exists:
  • widget-*
    → "Widget: [name] feature module"
  • *-domain
    or
    domain
    → "Domain layer: business logic and state"
  • *-feature
    or
    feature
    → "Feature layer: container components"
  • *-ui
    or
    ui
    → "UI layer: presentational components"
  • *-util
    or
    util
    → "Utilities and helpers"
  • shared/*
    → "Shared: [name]"
针对每个找到的库,收集以下信息:
字段来源
Path
工作区根目录下的相对目录路径
Import Path
project.json
中的
importPath
,或
package.json
中的
name
Description
现有
README.md
的第一行(跳过
#
标题),或根据库名生成
如果没有README文件,可通过启发式规则生成描述:
  • widget-*
    → "Widget: [name] 功能模块"
  • *-domain
    domain
    → "域层:业务逻辑与状态"
  • *-feature
    feature
    → "功能层:容器组件"
  • *-ui
    ui
    → "UI层:展示组件"
  • *-util
    util
    → "工具函数与辅助方法"
  • shared/*
    → "共享:[name]"

Step 3 — Write to CLAUDE.md

步骤3 — 写入CLAUDE.md

Read the current
CLAUDE.md
. Then:
If
<!-- domain-registry-start -->
already exists:
Replace everything between the start and end markers with the new table.
If it does not exist: Append the following block to
CLAUDE.md
:
markdown
undefined
读取当前的
CLAUDE.md
,然后按以下规则处理:
如果
<!-- domain-registry-start -->
已存在:
替换起止标记之间的所有内容为新生成的表格。
如果不存在: 将以下代码块追加到
CLAUDE.md
末尾:
markdown
undefined

Domain Registry

Domain Registry

Auto-maintained by domain-init skill. Run
/domain-init
to regenerate.
<!-- domain-registry-start -->
PathImport PathDescription
<path><import-path><description>
<!-- domain-registry-end -->
undefined
Auto-maintained by domain-init skill. Run
/domain-init
to regenerate.
<!-- domain-registry-start -->
PathImport PathDescription
<path><import-path><description>
<!-- domain-registry-end -->
undefined

Step 4 — Add Auto-Load Instruction (if missing)

步骤4 — 添加自动加载说明(如缺失)

Check if
CLAUDE.md
already contains the phrase
domain-init skill
or
Domain Registry
. If it does NOT, also append:
markdown
undefined
检查
CLAUDE.md
中是否已包含
domain-init skill
Domain Registry
字样。如果没有,同时追加以下内容:
markdown
undefined

Domain Context Loading

Domain Context Loading

The
domain-init
skill is active. Before working on any library listed in the Domain Registry above, silently read its
README.md
for architecture context.
undefined
The
domain-init
skill is active. Before working on any library listed in the Domain Registry above, silently read its
README.md
for architecture context.
undefined

Step 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-map

Arguments

参数说明

$ARGUMENTS
— optional scan root path. Defaults to
libs/
if empty.
Examples:
  • /domain-init
    — scans
    libs/
  • /domain-init libs/shared
    — scans only
    libs/shared/
  • /domain-init packages
    — scans a
    packages/
    monorepo structure
$ARGUMENTS
— 可选的扫描根路径。如果为空默认是
libs/
示例:
  • /domain-init
    — 扫描
    libs/
    目录
  • /domain-init libs/shared
    — 仅扫描
    libs/shared/
    目录
  • /domain-init packages
    — 扫描monorepo结构的
    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
中的其他内容。