musubi-cli 0.0.0-stage → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,261 @@
1
+ # musubiの定義
2
+
3
+ 定義のバージョンは`2026-11-20`。
4
+
5
+ musubiは、文書の書式や書き方のルールのように、エージェントのスキルが提供するコンテンツと、そのコンテンツに準拠するスキルを結び付ける。
6
+ あるスキルがコンテンツを名前とバージョン付きで宣言し、別のスキルがそのコンテンツに準拠すると宣言する。
7
+ `SKILL.md`を読むエージェントはどれも同じ方法でコンテンツを読み込み、コンテンツが変わると、準拠するスキルが再チェックされる。
8
+ 正式な定義は英語の[musubi.md](musubi.md)で、この文書はその日本語訳である。
9
+
10
+ ## 概要
11
+
12
+ musubiに参加するスキルは、Agent Skillsが定める`SKILL.md`をそのまま持ち、その隣に`musubi.json`というファイルを1つ追加する。
13
+
14
+ | ファイル | 書く人 | 持つもの |
15
+ |---|---|---|
16
+ | `SKILL.md` | スキルの作者 | Agent Skillsのフロントマターと本文で、変更しない。本文がエージェントに、どのコンテンツを読むかを伝える |
17
+ | `musubi.json` | 作者か`musubi add` | スキルが提供するコンテンツと、準拠するコンテンツ |
18
+ | コンテンツのファイル | provider | 書式や書き方のルールなど、consumerが準拠する文書 |
19
+ | チェックのファイル | provider | `musubi check`がconsumerの例に適用する、JSONのルール |
20
+
21
+ ```text
22
+ skills/
23
+ ├── design-doc/ providerのスキル
24
+ │ ├── SKILL.md 提供するコンテンツごとにファイルを指定する
25
+ │ ├── musubi.json "provides": design 1.0.0
26
+ │ ├── formats/design.md コンテンツ
27
+ │ └── checks/design.json チェックのルール
28
+ └── api-design/ consumerのスキル
29
+ ├── SKILL.md design-doc/design を指す3行
30
+ ├── musubi.json "follows": design-doc/design ^1.0.0 とフィンガープリント
31
+ └── examples/orders-api.md チェックを適用する例
32
+ ```
33
+
34
+ ここで使う用語は[GLOSSARY.ja.md](../GLOSSARY.ja.md)で定義する。
35
+
36
+ ## providerの宣言
37
+
38
+ providerのスキルは、提供するコンテンツを`musubi.json`の`provides`に並べる。
39
+
40
+ ```json
41
+ {
42
+ "$schema": "../../../schema/2026-11-19/musubi.schema.json",
43
+ "musubi": "2026-11-19",
44
+ "provides": {
45
+ "design": { "version": "1.0.0", "file": "formats/design.md", "check": "checks/design.json" }
46
+ }
47
+ }
48
+ ```
49
+
50
+ | フィールド | 必須 | 意味 |
51
+ |---|---|---|
52
+ | `$schema` | いいえ | エディタがJSON Schemaを見つける場所。`schema/<日付>/musubi.schema.json`を指す |
53
+ | `musubi` | はい | このファイルが準拠する定義のバージョン |
54
+ | `provides.<名前>` | コンテンツごとに1つ | コンテンツの名前。小文字の単語を`-`でつなぐ |
55
+ | `provides.<名前>.version` | はい | コンテンツのバージョン。`MAJOR.MINOR.PATCH`の形で書く |
56
+ | `provides.<名前>.file` | はい | コンテンツのファイル。スキルのフォルダからの相対パスで書く |
57
+ | `provides.<名前>.check` | いいえ | JSONのルールのファイル。スキルのフォルダからの相対パスで書き、形はチェックのルールの節で定める |
58
+
59
+ コンテンツは1つのファイルと、最大1つのチェックからなり、`design-doc/design`のように`<スキル名>/<名前>`で呼ぶ。
60
+ コンテンツごとにバージョンを持つので、1つを変えても、ほかのコンテンツのバージョンは変わらない。
61
+ パスはスキルのフォルダの中に限り、`musubi check`は絶対パスとフォルダの外へ出るパスを拒否する。
62
+ エージェントはproviderの`SKILL.md`の本文を読んでファイルを見つけるので、providerの本文はコンテンツごとにファイルを指定する (判断の記録[0002](../docs/adr/0002-agents-open-the-provider-by-name.ja.md))。
63
+
64
+ 宣言をフロントマターの項目でなく別の`musubi.json`に書くのは、`SKILL.md`がAgent Skillsのチェックを通り続けるようにするためである (判断の記録[0001](../docs/adr/0001-declarations-in-musubi-json.ja.md))。
65
+
66
+ ## consumerの宣言
67
+
68
+ consumerのスキルは、準拠するコンテンツを`musubi.json`の`follows`に並べる。
69
+
70
+ ```json
71
+ {
72
+ "musubi": "2026-11-19",
73
+ "follows": {
74
+ "design-doc/design": {
75
+ "version": "^1.0.0",
76
+ "integrity": "sha256-yNSwpBT+xXEV5bGBqedpHmjWIHVi+JaAnRATAJ0s7wM=",
77
+ "examples": ["examples/orders-api.md"]
78
+ }
79
+ }
80
+ }
81
+ ```
82
+
83
+ | フィールド | 必須 | 意味 |
84
+ |---|---|---|
85
+ | `follows.<スキル名>/<名前>` | コンテンツごとに1つ | 準拠するコンテンツ |
86
+ | `follows.<参照>.version` | はい | consumerが受け入れるバージョン。形はバージョンとフィンガープリントの節で定める |
87
+ | `follows.<参照>.integrity` | はい | 最後にチェックした時のコンテンツのフィンガープリント |
88
+ | `follows.<参照>.examples` | いいえ | providerのチェックを適用する、consumerのファイル |
89
+ | `follows.<参照>.optional` | いいえ | providerが無くてもconsumerが動く時に`true`を書く。下で定める |
90
+
91
+ consumerの`SKILL.md`の本文には、準拠するコンテンツごとに次の3行を書く。
92
+ この3行は`musubi add`が出力する。
93
+
94
+ ```text
95
+ Write in the `design` format of the `design-doc` skill: open the `design-doc` skill by name and read the file it names for `design`.
96
+ If the `musubi` command is available, run `musubi check` before reading, and stop if it fails.
97
+ If the `design-doc` skill is not installed, do not start: tell the user that `design-doc` is missing and how to install it, then stop.
98
+ ```
99
+
100
+ コンテンツのファイルがスクリプトの時は、1行目が、書式として読む代わりに実行するようエージェントに伝える。
101
+ スクリプトかどうかは拡張子`.py`、`.sh`、`.bash`、`.js`、`.mjs`、`.cjs`、`.ts`で判定し、大文字と小文字は区別しない。
102
+
103
+ ```text
104
+ Run the `verify` of the `design-doc` skill: open the `design-doc` skill by name and run the file it names for `verify`.
105
+ ```
106
+
107
+ providerのスキルがインストールされていなくても動くconsumerは、その準拠に`optional: true`を書く。
108
+ この準拠を任意の準拠と呼ぶ (判断の記録[0007](../docs/adr/0007-optional-follows.ja.md))。
109
+ 任意の準拠では、`musubi add --optional`が代わりに次の3行を出力する。
110
+
111
+ ```text
112
+ When the `design-doc` skill is installed, write in the `design` format of the `design-doc` skill: open the `design-doc` skill by name and read the file it names for `design`.
113
+ If the `musubi` command is available, run `musubi check` before reading, and stop if it fails.
114
+ If the `design-doc` skill is not installed, go on without the `design` of `design-doc`.
115
+ ```
116
+
117
+ consumerは、準拠するコンテンツに自分の節を追加できる。
118
+ ただし、providerのチェックが求めるものを削除したり、名前を変えたりはできない。
119
+ 1つのスキルが、コンテンツを提供しながら別のコンテンツに準拠してもよい。
120
+ たとえば、providerの書式が、共通の書き方のルールに準拠することがある。
121
+
122
+ ## 見つけ方と読み込み方
123
+
124
+ エージェントは`SKILL.md`の本文を読んでコンテンツを読み込み、スキルを使っている間に`musubi.json`を読むことはない。
125
+ そのため、musubiを知らないエージェントも、`musubi`コマンドを使えるエージェントと同じ方法でコンテンツを読み込む。
126
+
127
+ 1. エージェントは、ほかのスキルと同じように、consumerの`SKILL.md`を読む。
128
+ 2. 本文は、providerのスキルとコンテンツを名前で示す。エージェントはインストール済みのスキルからproviderのスキルを名前で開き、providerの本文がそのコンテンツについて指定するファイルを読む。
129
+ 3. エージェントはそのファイルだけを全文読む。providerのほかのコンテンツは読まない。
130
+ 4. providerのスキルがインストールされていない時、エージェントは作業を始めない。足りないスキルとそのインストール方法をユーザーに伝えて止まる。任意の準拠の時は止まらず、そのコンテンツ無しで作業を続ける。
131
+
132
+ Claude Code、Codex、GitHub Copilot CLI、Gemini CLIはどれもインストール済みのスキルを名前で一覧にするので、スキルがどこにインストールされていても名前で開ける。
133
+ 別々のプラグインからインストールした2つのスキルは同じ場所に並ぶとは限らないので、スキルのフォルダどうしの相対パスは使わない。
134
+
135
+ `musubi check`と`musubi graph`は、コマンドラインで指定したフォルダからスキルを読む。
136
+ フォルダを指定しない時は、カレントフォルダとホームフォルダにある`.claude/skills`、`.agents/skills`、`.github/skills`、`.gemini/skills`を読む。
137
+ そのいずれかの直下にあり、`SKILL.md`を持つフォルダがスキルで、スキルの名前はフォルダの名前である。
138
+ 同じ名前のスキルが2つのフォルダにある時は、上の順で先のフォルダのスキルを使い、`musubi check`がもう一方について警告する。
139
+
140
+ エージェントはコンテンツのファイルを全文読むので、`musubi check`は500行を超えるコンテンツを警告する。
141
+ 500行は、Agent Skillsが`SKILL.md`に勧める長さである。
142
+ そのようなコンテンツも拒否はしない。
143
+ 長いコンテンツは、providerが複数のコンテンツに分ける。
144
+
145
+ ## バージョンとフィンガープリント
146
+
147
+ コンテンツのバージョンは`MAJOR.MINOR.PATCH`の形で書く。
148
+
149
+ | コンテンツかチェックの変更 | 上げる番号 |
150
+ |---|---|
151
+ | consumerがチェックを通らなくなりうる変更。必須の節や列を削除するか名前を変える、チェックを厳しくする | `MAJOR` |
152
+ | consumerが使えるものを追加する変更。任意の節を追加するなど | `MINOR` |
153
+ | 全てのconsumerが通ったままになる、言い回しの変更 | `PATCH` |
154
+
155
+ consumerは、受け入れるバージョンを次の3つの形のいずれかで書く。
156
+ 読み方はnpmと同じである。
157
+
158
+ | 形 | 受け入れるバージョン | 例 |
159
+ |---|---|---|
160
+ | `^X.Y.Z` | `X.Y.Z`から次の`MAJOR`の手前まで。`0.Y.Z`の時は次の`MINOR`の手前まで | `^1.2.0`は`1.9.4`を受け入れ、`2.0.0`は受け入れない |
161
+ | `~X.Y.Z` | `X.Y.Z`から次の`MINOR`の手前まで | `~1.2.0`は`1.2.7`を受け入れ、`1.3.0`は受け入れない |
162
+ | `X.Y.Z` | `X.Y.Z`だけ | `1.2.0` |
163
+
164
+ フィンガープリントは、consumerが最後にどの内容に対してチェックされたかを正確に記録する。
165
+ エージェントはproviderの`SKILL.md`とコンテンツのファイルを読み、チェックはconsumerが通るかを決めるので、フィンガープリントはこの3つのファイルを対象にする。
166
+
167
+ ```text
168
+ for each path in [SKILL.md, <file>, <check, when present>]:
169
+ hash.update(path + "\n" + byte length in decimal + "\n")
170
+ hash.update(the file's bytes)
171
+ hash.update("\n")
172
+ integrity = "sha256-" + base64(sha256 digest)
173
+ ```
174
+
175
+ パスはproviderのスキルのフォルダからの相対パスで、区切りに`/`を使う。
176
+ バージョンの範囲とフィンガープリントは`musubi.json`に並べて書き、ロックファイルは持たない (判断の記録[0003](../docs/adr/0003-range-and-fingerprint-without-a-lockfile.ja.md))。
177
+
178
+ 定義そのもののバージョンは日付で表す。
179
+ `musubi.json`とチェックのファイルは、準拠する日付を`musubi`のフィールドに書く。
180
+ `musubi check`は知っている日付を全て読み、それ以外の日付を拒否する。
181
+ 知っている日付は、`schema/`の下にあるフォルダの名前である。
182
+ 定義のバージョン`2026-11-20`で`follows.<参照>.optional`を加えた。
183
+ `2026-11-19`を書いた`musubi.json`は今も通り、`optional`は書けない。
184
+
185
+ ## 再チェック
186
+
187
+ consumerは、スキルをインストールした後と、スキルを更新した後に再チェックされる。
188
+ `musubi`コマンドが使える時は、エージェントがコンテンツを読む前にも再チェックされる。
189
+
190
+ `musubi check`は次の場合に、ファイルと行を示して拒否する。
191
+
192
+ - `musubi.json`がJSONとして正しくない、定義にないフィールドを持つ、知らない定義のバージョンを指定している
193
+ - バージョンが`MAJOR.MINOR.PATCH`の形でない、範囲が3つの形のどれでもない
194
+ - ファイル、チェック、例のパスがスキルのフォルダの外へ出るか、存在しないファイルを指している
195
+ - チェックがJSONのルールのファイルでない
196
+ - consumerが、インストールされていないスキル (任意の準拠を除く) か、そのスキルが提供していないコンテンツに準拠している
197
+ - providerのバージョンがconsumerの範囲の外にある
198
+ - フィンガープリントが一致しない。最後のチェックの後にコンテンツが変わったことを表す
199
+ - 例がproviderのチェックのルールに違反している
200
+ - スキルどうしが循環して準拠している (`alpha -> beta -> alpha`など)
201
+
202
+ 任意の準拠のスキルがインストールされていない時、`musubi check`は警告を出してその準拠を飛ばす。
203
+ インストールされている時は、ほかの準拠と同じようにチェックする。
204
+ 循環しない限り、準拠の連鎖はどれだけ深くてもよい。
205
+ フィンガープリントが一致しない時、そのコンテンツはまだ受け入れられていないので、`musubi check`はそのproviderのチェックを適用しない。
206
+ `musubi check --update`は変わったコンテンツにチェックを適用し、全ての例が通った時だけフィンガープリントを書き換える。
207
+
208
+ 1つでも通らなかった時は、フィンガープリントを元のまま残す。
209
+ `--update`を付けない`musubi check`は、ファイルを書き込まない。
210
+
211
+ | 終了コード | 意味 |
212
+ |---|---|
213
+ | `0` | 全ての宣言と例が通った。警告を出力することがある |
214
+ | `1` | 1つ以上の問題があり、`<ファイル>:<行>: <メッセージ>`の形で出力した |
215
+ | `2` | コマンドの呼び出し方が間違っている |
216
+
217
+ ## チェックのルール
218
+
219
+ チェックのファイルは、定義のバージョンとルールの一覧を持つJSONである。
220
+ `musubi check`はルールを読み、consumerが指定した例それぞれに適用する。
221
+ providerのコードは実行しない (判断の記録[0004](../docs/adr/0004-checks-are-json-rules.ja.md))。
222
+
223
+ ```json
224
+ {
225
+ "musubi": "2026-11-19",
226
+ "rules": [
227
+ { "kind": "headings", "headings": ["## Purpose and scope", "## Decisions", "## Open decisions"] },
228
+ { "kind": "forbid", "text": ["Fill in:"] },
229
+ { "kind": "table-columns", "heading": "## Decisions", "columns": ["Option", "Chosen", "Why"] }
230
+ ]
231
+ }
232
+ ```
233
+
234
+ | 種類 | フィールド | 例が通る条件 |
235
+ |---|---|---|
236
+ | `headings` | `headings`に見出しの行を並べる | 全ての見出しの行がこの順番で現れる。間にほかの見出しがあってもよい |
237
+ | `forbid` | `text`に文字列を並べる | どの行も、並べた文字列のいずれも含まない |
238
+ | `table-columns` | `heading`と`columns` | 見出しの下の最初の表が全ての列を持つ。ほかの列があってもよい |
239
+
240
+ ルールは、コードブロックの中の行を読み飛ばす。
241
+ 各ルールは求めるものだけを探すので、consumerが追加した節は通る。
242
+ 新しい種類のルールは、新しい定義のバージョンで追加する。
243
+
244
+ ## 既存の仕組みとの関係
245
+
246
+ | 仕組み | すること | musubiとの関係 |
247
+ |---|---|---|
248
+ | スキルのインストーラー (APM、npx skills、skillpmなど) | スキルとその依存をインストールし、バージョンを固定する | スキルの入手先はインストーラーが管理する。`musubi.json`はスキルとコンテンツとバージョンだけを書くので、入手先を書くのは1か所で済む |
249
+ | Claude Codeのプラグインの`dependencies` | プラグインが依存するプラグインをインストールする | インストーラーと同じ。このようなフィールドを持たないエージェントでは、consumerの本文にある作業を止める1行に頼る |
250
+ | Agent Skills | `SKILL.md`とスキルのフォルダを定める | `SKILL.md`は変えず、フォルダの中に`musubi.json`が1つ増えるだけである。musubiは実際のスキルで動くようになった後に、Agent Skillsへ提案する |
251
+ | Agent Skillsの依存ファイルとロックファイルの提案 | スキルが必要とするスキルを宣言する | これらはどのスキルをインストールするかを書く。musubiは、そのスキルのどのコンテンツにどのバージョンで準拠するかを書き、再チェックする |
252
+
253
+ ## musubiコマンド
254
+
255
+ コマンドはNode.js 22.18以降で動き、実行時の依存を持たない。
256
+
257
+ | コマンド | すること |
258
+ |---|---|
259
+ | `musubi check [<フォルダ>...] [--update]` | フォルダの中の全ての`musubi.json`を、再チェックの節のとおりにチェックする |
260
+ | `musubi add <スキル名>/<名前> [<フォルダ>...] [--optional]` | consumerのフォルダで実行する。`musubi.json`に範囲`^<今のバージョン>`とフィンガープリントを書き込み、既にあるフィールドは残し、`SKILL.md`に置く3行を出力する。`--optional`を付けると`optional: true`も書き、`musubi`が`optional`を持たない定義のバージョンなら最新の定義のバージョンに上げ、任意の準拠の3行を出力する |
261
+ | `musubi graph [<フォルダ>...] [--out <ファイル>]` | 各スキルと、準拠するコンテンツへの矢印を描いたHTMLのページを1つ書き出す |
package/spec/musubi.md ADDED
@@ -0,0 +1,245 @@
1
+ # The musubi definition
2
+
3
+ Definition version `2026-11-20`.
4
+
5
+ musubi binds the content one agent skill provides, such as a document format or writing rules, to the skills that follow it.
6
+ A skill declares that content under a name and a version, another skill declares that it follows it, agents load it the same way in every agent that reads `SKILL.md`, and the skills that follow it are checked again when it changes.
7
+ This English text is the normative definition; [musubi.ja.md](musubi.ja.md) is its Japanese translation.
8
+
9
+ ## Overview
10
+
11
+ A skill that takes part keeps its `SKILL.md` as Agent Skills defines it and adds one file, `musubi.json`, next to it.
12
+
13
+ | File | Written by | Holds |
14
+ |---|---|---|
15
+ | `SKILL.md` | The skill's author | The Agent Skills frontmatter and body, unchanged. The body tells agents which content to read |
16
+ | `musubi.json` | The author, or `musubi add` | The content the skill provides and the content it follows |
17
+ | A content file | The provider | A format, writing rules, or any other text that consumers follow |
18
+ | A check file | The provider | JSON rules that `musubi check` applies to the consumers' examples |
19
+
20
+ ```text
21
+ skills/
22
+ ├── design-doc/ provider skill
23
+ │ ├── SKILL.md names the file of each content it provides
24
+ │ ├── musubi.json "provides": design 1.0.0
25
+ │ ├── formats/design.md the content
26
+ │ └── checks/design.json the check rules
27
+ └── api-design/ consumer skill
28
+ ├── SKILL.md three lines that point at design-doc/design
29
+ ├── musubi.json "follows": design-doc/design ^1.0.0 and its fingerprint
30
+ └── examples/orders-api.md an example the check is applied to
31
+ ```
32
+
33
+ [GLOSSARY.md](../GLOSSARY.md) defines the terms used here.
34
+
35
+ ## Provider declaration
36
+
37
+ A provider skill lists its content under `provides` in `musubi.json`.
38
+
39
+ ```json
40
+ {
41
+ "$schema": "../../../schema/2026-11-19/musubi.schema.json",
42
+ "musubi": "2026-11-19",
43
+ "provides": {
44
+ "design": { "version": "1.0.0", "file": "formats/design.md", "check": "checks/design.json" }
45
+ }
46
+ }
47
+ ```
48
+
49
+ | Field | Required | Meaning |
50
+ |---|---|---|
51
+ | `$schema` | No | Where editors find the JSON Schema, `schema/<date>/musubi.schema.json` |
52
+ | `musubi` | Yes | The definition version the file follows |
53
+ | `provides.<name>` | Yes, one per content | The content name: lowercase words joined by `-` |
54
+ | `provides.<name>.version` | Yes | The content's version, `MAJOR.MINOR.PATCH` |
55
+ | `provides.<name>.file` | Yes | The content file, relative to the skill folder |
56
+ | `provides.<name>.check` | No | A JSON rules file, relative to the skill folder, described in Check rules |
57
+
58
+ Each content is one file with at most one check, and it is named `<skill>/<name>`, such as `design-doc/design`.
59
+ Each content has its own version, so changing one does not change the version of the others.
60
+ Paths stay inside the skill folder; `musubi check` refuses absolute paths and paths that leave it.
61
+ The provider's `SKILL.md` body names the file of each content, because agents find the file by reading that body (decision record [0002](../docs/adr/0002-agents-open-the-provider-by-name.md)).
62
+ `musubi.json` is a separate file, not a frontmatter field, so that `SKILL.md` keeps passing the Agent Skills checks (decision record [0001](../docs/adr/0001-declarations-in-musubi-json.md)).
63
+
64
+ ## Consumer declaration
65
+
66
+ A consumer skill lists the content it follows under `follows` in `musubi.json`.
67
+
68
+ ```json
69
+ {
70
+ "musubi": "2026-11-19",
71
+ "follows": {
72
+ "design-doc/design": {
73
+ "version": "^1.0.0",
74
+ "integrity": "sha256-yNSwpBT+xXEV5bGBqedpHmjWIHVi+JaAnRATAJ0s7wM=",
75
+ "examples": ["examples/orders-api.md"]
76
+ }
77
+ }
78
+ }
79
+ ```
80
+
81
+ | Field | Required | Meaning |
82
+ |---|---|---|
83
+ | `follows.<skill>/<content>` | Yes, one per content | The content followed |
84
+ | `follows.<ref>.version` | Yes | The versions the consumer accepts, described in Versions and fingerprints |
85
+ | `follows.<ref>.integrity` | Yes | The fingerprint of the content at the last check |
86
+ | `follows.<ref>.examples` | No | Files of the consumer that the provider's check is applied to |
87
+ | `follows.<ref>.optional` | No | `true` when the consumer also works without the provider, described below |
88
+
89
+ The consumer's `SKILL.md` body carries three lines for each content it follows, which `musubi add` prints.
90
+
91
+ ```text
92
+ Write in the `design` format of the `design-doc` skill: open the `design-doc` skill by name and read the file it names for `design`.
93
+ If the `musubi` command is available, run `musubi check` before reading, and stop if it fails.
94
+ If the `design-doc` skill is not installed, do not start: tell the user that `design-doc` is missing and how to install it, then stop.
95
+ ```
96
+
97
+ When the content's file is a script, told apart by the extensions `.py`, `.sh`, `.bash`, `.js`, `.mjs`, `.cjs`, and `.ts` in any case, the first line tells the agent to run it instead of reading it as a format.
98
+
99
+ ```text
100
+ Run the `verify` of the `design-doc` skill: open the `design-doc` skill by name and run the file it names for `verify`.
101
+ ```
102
+
103
+ A consumer that also works without the provider writes `optional: true` in that follow, which makes it an optional follow (decision record [0007](../docs/adr/0007-optional-follows.md)).
104
+ For an optional follow, `musubi add --optional` prints these three lines instead.
105
+
106
+ ```text
107
+ When the `design-doc` skill is installed, write in the `design` format of the `design-doc` skill: open the `design-doc` skill by name and read the file it names for `design`.
108
+ If the `musubi` command is available, run `musubi check` before reading, and stop if it fails.
109
+ If the `design-doc` skill is not installed, go on without the `design` of `design-doc`.
110
+ ```
111
+
112
+ A consumer may add its own sections to the content it follows.
113
+ It may not remove or rename what the provider's check requires.
114
+ A skill may both provide content and follow content; a provider's format may follow shared writing rules, for example.
115
+
116
+ ## Discovery and loading
117
+
118
+ Agents load content by reading `SKILL.md` bodies, and never read `musubi.json` while they use a skill.
119
+ An agent that knows nothing of musubi therefore loads content the same way as one that has the command.
120
+
121
+ 1. The agent reads the consumer's `SKILL.md`, as it does for any skill.
122
+ 2. The body names the provider skill and the content. The agent opens the provider skill by name from the skills it has installed and reads the file that the provider's body names for that content.
123
+ 3. The agent reads only that file, whole. It does not read the provider's other content.
124
+ 4. When the provider skill is not installed, the agent does not start; it tells the user which skill is missing and how to install it, and stops. When the follow is optional, the agent goes on without that content instead.
125
+
126
+ Claude Code, Codex, GitHub Copilot CLI, and Gemini CLI each list installed skills by name, so opening a skill by name works wherever the skill is installed.
127
+ Relative paths between skill folders are not used, because two skills from different plugins are not installed side by side.
128
+
129
+ `musubi check` and `musubi graph` read skills from the folders named on the command line.
130
+ Without folders they read `.claude/skills`, `.agents/skills`, `.github/skills`, and `.gemini/skills` in the current folder and in the home folder.
131
+ A skill is a folder directly inside one of them that holds `SKILL.md`, and its name is the folder name.
132
+ When two folders hold a skill of the same name, the first folder in that order wins and `musubi check` warns about the other.
133
+
134
+ Agents read a content file whole, so `musubi check` warns when one is over 500 lines, the length Agent Skills suggests for `SKILL.md`.
135
+ It does not refuse such content; a provider splits a long content into several.
136
+
137
+ ## Versions and fingerprints
138
+
139
+ A content version is `MAJOR.MINOR.PATCH`.
140
+
141
+ | Change to the content or its check | Raise |
142
+ |---|---|
143
+ | A consumer can break: a required section or column is removed or renamed, or the check becomes stricter | `MAJOR` |
144
+ | Something is added that consumers may use, such as an optional section | `MINOR` |
145
+ | Wording changes that keep every consumer valid | `PATCH` |
146
+
147
+ A consumer writes the versions it accepts in one of three forms, read the way npm reads them.
148
+
149
+ | Form | Accepts | Example |
150
+ |---|---|---|
151
+ | `^X.Y.Z` | From `X.Y.Z` up to the next `MAJOR`; for `0.Y.Z`, up to the next `MINOR` | `^1.2.0` accepts `1.9.4`, not `2.0.0` |
152
+ | `~X.Y.Z` | From `X.Y.Z` up to the next `MINOR` | `~1.2.0` accepts `1.2.7`, not `1.3.0` |
153
+ | `X.Y.Z` | Only `X.Y.Z` | `1.2.0` |
154
+
155
+ The fingerprint records exactly what the consumer was last checked against.
156
+ It covers the provider's `SKILL.md`, the content file, and the check file, because an agent reads the first two and the check decides whether the consumer passes.
157
+
158
+ ```text
159
+ for each path in [SKILL.md, <file>, <check, when present>]:
160
+ hash.update(path + "\n" + byte length in decimal + "\n")
161
+ hash.update(the file's bytes)
162
+ hash.update("\n")
163
+ integrity = "sha256-" + base64(sha256 digest)
164
+ ```
165
+
166
+ Paths are relative to the provider's skill folder and use `/`.
167
+ The range and the fingerprint sit together in `musubi.json`; there is no lockfile (decision record [0003](../docs/adr/0003-range-and-fingerprint-without-a-lockfile.md)).
168
+
169
+ The definition itself is versioned by date.
170
+ Each `musubi.json` and each check file names the date it follows in `musubi`, and `musubi check` reads every date it knows and refuses the others.
171
+ The dates it knows are the folders under `schema/`.
172
+ Definition version `2026-11-20` added `follows.<ref>.optional`; a `musubi.json` that names `2026-11-19` still passes and may not use it.
173
+
174
+ ## Re-checking
175
+
176
+ A consumer is checked again after a skill is installed, after a skill is updated, and, when the `musubi` command is available, before an agent reads the content.
177
+
178
+ `musubi check` refuses, naming the file and the line, when:
179
+
180
+ - `musubi.json` is not valid JSON, has a field the definition does not know, or names a definition version it does not know
181
+ - a version is not `MAJOR.MINOR.PATCH`, or a range is not one of the three forms
182
+ - a file, check, or example path leaves the skill folder or names a missing file
183
+ - a check is not a JSON rules file
184
+ - a consumer follows a skill that is not installed (except in an optional follow), or a content that skill does not provide
185
+ - the provider's version is outside the consumer's range
186
+ - the fingerprint does not match, which means the content changed after the last check
187
+ - an example breaks a rule of the provider's check
188
+ - skills follow each other in a cycle, such as `alpha -> beta -> alpha`
189
+
190
+ When the skill of an optional follow is not installed, `musubi check` warns and skips that follow; when it is installed, the follow is checked like any other.
191
+ Chains of any depth are allowed as long as they do not form a cycle.
192
+ When a fingerprint does not match, `musubi check` does not apply that provider's check, because its content has not been accepted.
193
+ `musubi check --update` applies the check to the changed content and rewrites the fingerprint only when every example passes; when one fails, the fingerprint stays as it was.
194
+ `musubi check` without `--update` never writes a file.
195
+
196
+ | Exit status | Meaning |
197
+ |---|---|
198
+ | `0` | Every declaration and example passed; warnings may be printed |
199
+ | `1` | At least one problem, printed as `<file>:<line>: <message>` |
200
+ | `2` | The command was called the wrong way |
201
+
202
+ ## Check rules
203
+
204
+ A check file is JSON with the definition version and a list of rules.
205
+ `musubi check` reads the rules and applies them to each example the consumer names; it never runs provider code (decision record [0004](../docs/adr/0004-checks-are-json-rules.md)).
206
+
207
+ ```json
208
+ {
209
+ "musubi": "2026-11-19",
210
+ "rules": [
211
+ { "kind": "headings", "headings": ["## Purpose and scope", "## Decisions", "## Open decisions"] },
212
+ { "kind": "forbid", "text": ["Fill in:"] },
213
+ { "kind": "table-columns", "heading": "## Decisions", "columns": ["Option", "Chosen", "Why"] }
214
+ ]
215
+ }
216
+ ```
217
+
218
+ | Kind | Fields | An example passes when |
219
+ |---|---|---|
220
+ | `headings` | `headings`: heading lines | Every heading line appears, in this order. Other headings may come between them |
221
+ | `forbid` | `text`: pieces of text | No line contains any of the text |
222
+ | `table-columns` | `heading`, `columns` | The first table under the heading has every column. It may have more |
223
+
224
+ Rules skip lines inside fenced code blocks.
225
+ A consumer's added sections pass, because each rule looks only for what it requires.
226
+ A new kind of rule is added by a new definition version.
227
+
228
+ ## Relation to existing systems
229
+
230
+ | System | What it does | How musubi relates |
231
+ |---|---|---|
232
+ | Skill installers (APM, npx skills, skillpm, and others) | Install skills and their dependencies, and lock versions | They own where a skill comes from. `musubi.json` names only the skill, the content, and the version, so the source is written once |
233
+ | Claude Code plugin `dependencies` | Install the plugins a plugin depends on | Same as installers. Agents without such a field rely on the stop line in the consumer's body |
234
+ | Agent Skills | Defines `SKILL.md` and the skill folder | `SKILL.md` is unchanged and `musubi.json` is one more file in the folder. musubi is to be proposed to Agent Skills once it runs on real skills |
235
+ | Agent Skills proposals for dependency files and lockfiles | Declare which skills a skill needs | They say which skill to install. musubi says which content of it a skill follows, at which version, and checks it again |
236
+
237
+ ## The musubi command
238
+
239
+ The command needs Node.js 22.18 or later and has no runtime dependencies.
240
+
241
+ | Command | Does |
242
+ |---|---|
243
+ | `musubi check [<folder>...] [--update]` | Checks every `musubi.json` in the folders, as described in Re-checking |
244
+ | `musubi add <skill>/<content> [<folder>...] [--optional]` | Run in a consumer's folder: writes the range `^<current version>` and the fingerprint into its `musubi.json`, keeps the fields already there, and prints the three lines for its `SKILL.md`. With `--optional` it also writes `optional: true`, moves `musubi` to the latest definition version when the file names one without `optional`, and prints the three lines for an optional follow |
245
+ | `musubi graph [<folder>...] [--out <file>]` | Writes one HTML page that draws each skill and an arrow to each content it follows |