domain-init
Initializes or refreshes the Domain Registry in CLAUDE.md by scanning the project for library directories. Run this once per project, or after adding new libraries. Creates the registry table that domain-context skill uses for auto-loading.
安装与使用
请根据来源仓库和你的 AI 工具说明安装此技能。先阅读技能文件和依赖要求,再添加到工作流。
查看来源 ↗使用指南技能说明
Domain Registry Initializer
Initialize or refresh the Domain Registry in this project's CLAUDE.md.
What This Does
- Scans the project for library/domain directories
- Reads each library's metadata (
project.json,package.json, orng-package.json) - Writes (or updates) a
## Domain Registrysection inCLAUDE.md - Adds the auto-load instruction if it's not already present
Instructions
Step 1 — Detect Project Structure
Run the detection script to find all library directories:
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 containproject.jsonorpackage.json - For Nx workspaces: read
project.json→nameandtargets.build.options.project - For plain npm: read
package.json→name - For Angular libraries: read
ng-package.json→ check parentpackage.jsonfor name
Step 2 — Build the Registry Table
For each found library, collect:
| Field | Source |
|---|---|
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" -
*-domainordomain→ "Domain layer: business logic and state" -
*-featureorfeature→ "Feature layer: container components" -
*-uiorui→ "UI layer: presentational components" -
*-utilorutil→ "Utilities and helpers" -
shared/*→ "Shared: [name]"
Step 3 — Write to 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:
## Domain Registry
> Auto-maintained by domain-init skill. Run `/domain-init` to regenerate.
<!-- domain-registry-start -->
| Path | Import Path | Description |
|------|-------------|-------------|
| <path> | <import-path> | <description> |
<!-- domain-registry-end -->
Step 4 — Add Auto-Load Instruction (if missing)
Check if CLAUDE.md already contains the phrase domain-init skill or Domain Registry. If it does NOT, also append:
## 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.
Step 5 — Report
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
Arguments
$ARGUMENTS — optional scan root path. Defaults to libs/ if empty.
Examples:
-
/domain-init— scanslibs/ -
/domain-init libs/shared— scans onlylibs/shared/ -
/domain-init packages— scans apackages/monorepo structure
Re-running
This skill is idempotent. Running it multiple times only updates the registry table, preserving all other content in CLAUDE.md.
使用示例
查看来源仓库中的使用示例与配置说明。
查看来源 ↗来源历史
- 收录时间
- 2026-03-11
- 索引更新时间
- 2026-03-11
- Branch
- main
收录与同步日期属于本站记录。源码修改历史请查看来源仓库。
GitHub ↗chat Comments (0)
Sign in to join the discussion and leave a comment.
No comments yet. Be the first to share your thoughts!