返回 CodeWhale
SKILLS.md
根目录 / docs / SKILLS.md
1 # Skills Manager
2
3 In the terminal, `/skills` opens **Plugins → Skills**. Enter on a skill opens the dedicated manager, also available directly through `/skills manage`, for existing install, update, remove, and trust operations. `/skill <name>` still activates a skill, and the explicit inspection, remote, sync, and suggestion subcommands remain available.
4
5
6 > 阅读简体中文版:[zh_hans/SKILLS.md](zh_hans/SKILLS.md)
7
8 Everything you add to Codewhale is a plugin: a skill you set up by hand is a
9 plugin of the kind **Skill**, and a skill inside a plugin bundle belongs to that
10 plugin. Skills are managed under Plugins → Skills and Customize ›
11 Skills. This page keeps the word "skill" for the kind; files, trust
12 and the `/skills` commands are unchanged.
13
14 Skills are reusable `SKILL.md` instruction packs. Codewhale discovers them from
15 several roots, but **only Codewhale-owned directories are writable**. The unified
16 `/skills manage` manager is the interactive surface for audit and mutation; slash
17 aliases share the same write path.
18
19 For Claude Code plugin boundaries, see [CLAUDE_PLUGIN_COMPAT.md](CLAUDE_PLUGIN_COMPAT.md).
20 For `skills_dir` and `[skills]` config keys, see [CONFIGURATION.md](CONFIGURATION.md).
21
22 ## Architecture (four layers)
23
24 | Layer | Role |
25 | --- | --- |
26 | **Root catalog** | Single source of precedence and ownership (`SkillRootCatalog`). |
27 | **Audit** | Read-only, unmerged on-disk inventory (status, digest, actions). |
28 | **Mutation controller** | Only writer for install / import / update / remove / trust. |
29 | **Skills manager view** | TUI: emits events only; never writes files itself. |
30
31 Runtime discovery (`SkillRegistry`) still merges skills for the model. Audit
32 intentionally does **not** merge — it shows every on-disk copy so conflicts and
33 shadowing stay visible.
34
35 ## Ownership and roots
36
37 **Writable (Codewhale-owned)**
38
39 | Scope | Path |
40 | --- | --- |
41 | Project | `<workspace>/.codewhale/skills/` |
42 | Global | `~/.codewhale/skills/` |
43
44 **Read-only compatible** (discover / import source only — never mutated in place)
45
46 Examples: `<workspace>/.agents/skills`, `./skills`, `.claude/skills`,
47 `.cursor/skills`, `.opencode/skills`, `~/.agents/skills`, `~/.claude/skills`,
48 and similar harness layouts.
49
50 **Audit-only (not runtime-active)**
51
52 - Flat `<workspace>/skills` is an audit candidate until `[skills] flat_workspace_root = true`; an explicit `skills_dir` can also select it.
53 - `.codex/skills` appears in **compatible** audit scans so operators can see it.
54 It does **not** join the runtime discovery set.
55
56 Configured `skills_dir` that is not one of the owned Codewhale roots stays
57 read-only. Discovery and the manager can list it; mutations still target owned
58 project/global roots only.
59
60 Within each scope, the owned `.codewhale/skills` root wins name collisions.
61 Project order is `.codewhale`, `.agents`, `.claude`, `.opencode`, `.cursor`, then
62 an opted-in flat `skills` root. Global order is `.codewhale`, `.agents`, `.claude`,
63 then legacy `.deepseek`. Project roots precede global roots. Shadowing warnings
64 name both copies, so install and update select the owned copy in that scope.
65
66 Every root inside the workspace — owned, compatible, or a configured
67 `skills_dir` that resolves there — loads only once the workspace is trusted
68 (`/trust on --save`). Until then discovery names the skipped directories in its
69 warning, and the session's skills directory falls back to the global one.
70
71 ## Slash commands
72
73 | Command | Behavior |
74 | --- | --- |
75 | `/skills` | Opens Plugins → Skills (owned-only scan, **no network**). |
76 | `/skills manage` | Opens the dedicated Skills Manager for audit and mutation. |
77 | `/skills <prefix>` | Text list filtered by name prefix. |
78 | `/skills inspect` | Text discovery mode, searched directories, and source paths. |
79 | `/skills --remote` | Explicit registry listing (network). |
80 | `/skills suggest <task>` | Rank up to three remote skills for a task, with matching evidence and an explicit install command (network; no install). |
81 | `/skills sync` | Explicit registry → local cache sync (network). |
82 | `/skill <name>` | Activate a skill for the next turn. |
83 | `/skill install [--project\|--global] <spec>` | Install via mutation controller. |
84 | `/skill update [--project\|--global] <name>` | Update a managed skill from its registry provenance. |
85 | `/skill uninstall [--project\|--global] <name>` | Remove a managed skill. |
86 | `/skill trust [--project\|--global] <name>` | Write digest-bound advisory trust. |
87
88 Notes:
89
90 - There is **no** `/skills audit` subcommand. Use the manager (and `c` to toggle
91 compatible roots) or `/skills inspect` for discovery details.
92 - Bare `/skill install <spec>` (no scope flag) installs into the Codewhale
93 **global** owned root.
94 - `/skills suggest` only reads the curated registry through the existing
95 network policy. It never downloads, trusts, enables, or activates a skill;
96 each result gives a separate `/skill install <name>` command for the user to
97 choose.
98 - If the same name exists in both project and global owned roots, update /
99 uninstall / trust require `--project` or `--global`.
100 - If a name exists only under a compatible external root, writes are refused;
101 import it through `/skills manage` instead of editing harness directories.
102
103 ## Skills Manager (TUI)
104
105 Direct manager path: type `/skills manage` and confirm. The surface is zero-network on
106 open (owned-only audit).
107
108 | Key | Action |
109 | --- | --- |
110 | `↑`/`↓` or `j`/`k` | Move selection |
111 | `Enter` | Primary available action / confirm pending prompt |
112 | `i` | Import (external → owned) |
113 | `u` | Update (managed + registry provenance) |
114 | `r` | Remove (managed; confirms first) |
115 | `t` | Trust (managed; digest-bound) |
116 | `s` | Toggle import target: project ↔ global |
117 | `c` | Toggle scan: owned-only ↔ compatible (still local disk only) |
118 | `Esc` | Cancel confirm, or close the manager |
119
120 The view never calls install helpers or touches the filesystem. It emits a
121 mutation request; the host runs the controller, shows a receipt, and rebuilds
122 the inventory.
123
124 ## System starter skills
125
126 A fresh installation writes six skills under `$CODEWHALE_HOME/skills/.system/`. Use `skill-creator`, `skill-installer`, and `plugin-creator` to extend Codewhale, `help` to find a command, `forget` to manage memory, and `review` to review changes. Workflow, Office, consumer, and Cordis packs can be installed separately. User and trusted project skills with the same name take precedence.
127
128 The repository keeps guides for [contributor onboarding and feedback](skills/README.md).
129 The maintainer and release-operator skills have been retired.
130
131 Discovery keeps a separate snapshot for each skill directory. Worktrees can reuse a shared user directory. Editing a skill, changing its ownership marker or changing the applicable workspace boundary causes discovery to check that directory again.
132
133 ### Invocation and alias metadata
134
135 Bundled and user skills may declare two runtime-routing fields in frontmatter:
136
137 | Field | Meaning |
138 | --- | --- |
139 | `invocation: model+user` | The default; the skill appears in the model's compact catalogue and can be loaded by the model or user. |
140 | `invocation: explicit-only` | The skill remains loadable by an explicit name, but is omitted from the model catalogue so opt-in instructions do not become ambient context. |
141 | `aliases-for: name, other-name` | Additional lookup names for the same canonical skill. Aliases are not separate catalogue entries and do not duplicate prompt content. |
142
143 `disable-model-invocation: true` makes a skill explicit-only. `user-invocable:
144 false` hides it from user menus and refuses explicit activation while preserving
145 model selection. Setting both disables both paths. Boolean spellings `true/false`,
146 `yes/no`, `on/off`, and `1/0` are accepted; invalid policy booleans fail closed.
147 The model's catalog, list/query, and `load_skill` enforce model eligibility; the
148 user's slash and command palettes enforce user eligibility. `argument-hint` is
149 shown beside user-facing descriptions. `when_to_use` joins the routing description
150 as `Use when:`.
151
152 The runtime and installer share one frontmatter validator. Runtime accepts missing
153 descriptions and heading-only Markdown with warnings; installation requires a
154 frontmatter block, a nonempty description, and a path-safe name. A name/directory
155 mismatch warns without renaming the file. Nested `metadata` stays nested; flow
156 and block lists share the same interpretation. `license`, `compatibility`,
157 `metadata`, localized descriptions, and `x-*` extension keys are accepted silently.
158 Unknown keys warn once. `allowed-tools` / `disallowed-tools`, `model`, `context`,
159 and `agent` warn because they grant no tool, approval, provider, or fork authority.
160 The existing workspace-trust and reviewed-plugin byte/hash gates still apply.
161
162 Missing or unknown invocation values retain the historical `model+user`
163 behavior. Canonical names win over aliases when a collision exists. Loading a
164 skill reports its canonical invocation and aliases so receipts remain
165 inspectable.
166
167 Mention `$review` in a user message to load an enabled skill for that turn. If names collide, link the discovered skill file. Skills marked `allow_implicit_invocation: false` or `explicit_only: true` require explicit user invocation. The same policy can be declared as `policy.allow_implicit_invocation` in `agents/openai.yaml`. The regular Turn-1 skill index and `always_load` settings are applied independently and are restored after compaction.
168
169 When `read` returns lines from the active native copy of a model-invocable `SKILL.md`, the tool result records the skill and the implicit access. File reads retain normal workspace permissions. The invocation policy controls skill discovery and activation.
170
171 ```text
172 [review](.codewhale/skills/review/SKILL.md)
173 ```
174
175 Use `agents/openai.yaml` to declare dependencies by name.
176
177 ```yaml
178 dependencies:
179 tools:
180 - type: mcp
181 value: local-docs
182 - type: tool
183 value: read
184 ```
185
186 When a user mentions the skill, Codewhale can start an enabled, approved lazy
187 MCP server with that exact name. The turn’s tool restrictions still apply.
188 Tool names are shown as guidance. Configure and approve new servers through
189 the normal MCP setup flow.
190
191 ### Non-ASCII names and saved activation
192
193 ASCII names keep their existing command spelling. A name containing non-ASCII
194 characters gets a stable ASCII ID: a shortened old slug plus 32 hexadecimal
195 SHA-256 digits, at most 64 characters per skill-name segment. The hash uses
196 trimmed UTF-8 with ASCII case folding; it does not transliterate or merge Unicode
197 normalization forms. Unqualified raw names and those IDs select the same body.
198 Package directories stay in place. Qualified lookup requires the declared canonical
199 namespace, with ASCII case folding and no punctuation folding: `Team.Plugin:技能`
200 cannot select a skill in `team-plugin`.
201
202 Previously disabled lossy names such as `skill` or `pdf` continue to suppress
203 every corresponding renamed skill. Enabling one exact catalog ID enables only
204 that identity, including a literal ASCII skill named `skill`; it does not enable
205 its formerly colliding siblings. Toggle requests use the exact ID returned by
206 `GET /v1/skills`. Plugin bundle trust remains a separate gate.
207
208 Activation still uses one `skills_state.toml` file and its `disabled` array.
209 Reserved `!codewhale-skill-state:1:*` entries preserve legacy veto history and
210 exact enable choices through older writers, using the same lock and atomic
211 write. Listing/discovery do not rewrite the file. Unknown versions or malformed
212 reserved entries are errors and are left untouched; existing recovery behavior
213 keeps native skills available but hides reviewed plugin skills when policy
214 cannot be read.
215
216 This is **not simultaneous-version activation compatibility**. v0.10.0 readers
217 cannot enforce new per-identity disables, and their lossy or no-op toggles cannot
218 express every new choice. Upgrade every runtime sharing the state directory
219 before relying on consistent controls. Retaining marker strings through an old
220 write does not give that old binary the new identity semantics.
221
222 ### Starter names and aliases
223
224 `create-skill` selects `skill-creator`. `code-review` selects `review`. Invoke `help` explicitly for directions to commands and settings. Optional packs declare their own names and aliases.
225
226 ### Catalog fixture matrix (provider-free)
227
228 [`crates/skills/assets/skills-catalog-matrix.json`](../crates/skills/assets/skills-catalog-matrix.json)
229 is an **authored** expectation table covering every bundled skill: canonical
230 name, tier, invocation, aliases, whether it renders as an ambient catalogue
231 entry, and which of its aliases are shadowed by another canonical name. The
232 tests in `crates/skills/src/catalog_matrix.rs` assert a bijection between
233 that fixture and `BUNDLED_SKILLS`, so the shipped pack cannot change without an
234 explicit fixture update.
235
236 What those tests do and do not claim:
237
238 - They validate **deterministic registry / catalog / resolver behavior**:
239 install, parse, eligibility, explicit load, non-activation, alias resolution,
240 explicit-only exclusion, collision precedence, and prompt budget.
241 - They validate **nothing about semantic LLM routing**. Whether a model chooses
242 `debug` for a stack trace is a live-provider question; see
243 [LIVE_SMOKE.md](LIVE_SMOKE.md).
244
245 Collision and prompt-budget invariants asserted today:
246
247 | Invariant | Meaning |
248 | --- | --- |
249 | Canonical wins | A canonical bundled name always beats another skill's alias when both names match. |
250 | Single alias owner | No two bundled skills may claim the same alias. |
251 | No duplicate entries | Each canonical name renders at most one catalogue line; aliases render zero. |
252 | Budget headroom | The shipped pack alone renders under the window-scaled skills budget (2,400 characters at the default 128k window, the index floor) with **no** "additional skills omitted" line, so user skills are never silently displaced. |
253 | Bounded preview | Descriptions stay single-line and respect `[skills] listing_max_description_chars` (default 120) in the catalog preview. |
254
255 ### Locale-aware routing metadata
256
257 `description_<tag>` frontmatter is supported (exact tag, then primary subtag,
258 then the canonical description — with Traditional Chinese excluded from the
259 Simplified `zh` fallback). **No bundled skill ships a localized routing
260 description**, and none is fabricated. The shipped contract is therefore an
261 explicit, tested fallback:
262
263 - For every skill in the bundle × every locale in `Locale::shipped()` — all 15
264 of `en`, `ja`, `zh-Hans`, `zh-Hant`, `pt-BR`, `es-419`, `vi`, `ko`, `ca`,
265 `de`, `fr`, `id`, `hi`, `ru`, `uk` (`crates/localization/src/lib.rs:70-88`) —
266 `description_for_locale` returns the canonical English description.
267 - The rendered catalogue block is byte-identical across all shipped locales.
268 - Exact-tag match, primary-subtag fallback (`pt-BR` → `description_pt`), and
269 English fallback are covered against a synthetic authored fixture, so the
270 resolution paths stay tested even while the bundle itself is English-only.
271
272 If a bundled skill later ships localized routing metadata, the parity test
273 fails until source-backed coverage is added for it — the fallback contract
274 cannot silently absorb a translation.
275
276 ## Audit statuses
277
278 Each audited row carries precedence and relationship flags:
279
280 | Status | Meaning |
281 | --- | --- |
282 | **Active** | Highest-precedence copy for that canonical name in the scan. |
283 | **Shadowed** | Same name exists at a higher-precedence root. |
284 | **Duplicate** | Same canonical name and same package digest as another copy. |
285 | **Conflict** | Same canonical name, different package digest. |
286
287 External skills with no owned peer (and a valid digest) are **import
288 candidates**. Externals that conflict with or exactly duplicate an owned copy
289 can still offer Import — duplicate → already present; conflict → confirm replace
290 in the selected import scope.
291
292 ## Provenance and markers
293
294 Managed installs write schema **v2** metadata under the skill directory:
295
296 **`.installed-from` (v2)** — written last on successful install/import:
297
298 ```json
299 {
300 "schema_version": 2,
301 "spec": "github:owner/repo",
302 "url": "https://…",
303 "source_checksum": "…",
304 "content_digest": "…",
305 "installed_name": "my-skill",
306 "registry_version": null
307 }
308 ```
309
310 - `content_digest` is a bounded package tree hash (not SKILL.md alone).
311 - Display of URLs strips userinfo, query, and fragment.
312 - Imports use a local `import:…` provenance and **cannot** be updated from a
313 registry; re-import or remove them instead.
314 - Legacy v1 markers are recognized as managed with
315 `LegacyMetadataUnknown` integrity until refreshed.
316
317 **`.trusted` (v2)** — advisory, digest-bound:
318
319 ```json
320 {
321 "schema_version": 2,
322 "content_digest": "…"
323 }
324 ```
325
326 Trust records review intent. It does **not** sandbox the skill or auto-approve
327 tools. Content updates clear trust so a stale marker cannot outlive the bytes.
328
329 Manual skills (owned root, no managed marker) are visible but not
330 update/remove/trust through the managed actions.
331
332 ## Package digest and safety
333
334 Audit and mutation share a bounded package digest:
335
336 - Regular files only; symlinks that escape the skill root or cycle → fail closed.
337 - Caps on total size, file count, and depth.
338 - Mutations re-check an expected digest before write (TOCTOU).
339 - Import/replace keeps a `.bak` until digest + marker finalize succeed; failure
340 restores the previous owned package.
341
342 ## Readiness
343
344 The audit model has a readiness field and optional provider hook for a future
345 readiness cache ([#4407](https://github.com/codewhale-hq/CodeWhale/issues/4407)).
346 Today, when no cache is wired, readiness is always **`Unknown`**. The manager
347 does not run readiness probes and does not block mutations on readiness.
348
349 ## Config knobs
350
351 Installed skills from trusted project roots, `~/.codewhale/skills`, enabled plugins with descriptions, and compatible roots (excluding Cursor/Claude vendor defaults under `/.cursor/` and `/.claude/`) are surfaced once per parent session in a bounded 3-tier `<codewhale:runtime_event kind="skills_context">` history message. Putting the index in a session history event keeps the static system prompt cache-stable and re-injects automatically after `/compact`. Sub-agents continue loading skills on demand through `load_skill`. `[skills] listing_max_description_chars` sets the per-entry description ceiling (1–40,000, default 120), and `listing_budget_fraction` sets the listing's share of the resolved route window (greater than 0 and at most 1, default 0.002), estimated at four characters per token with a 2,400-character floor and 40,000-character ceiling. `/context` and `codewhale doctor --context-json` use the same preview settings and record zero static-prompt tokens for it. Explicit profile values override inherited values independently.
352
353 `[skills] always_load = ["<skill-name>"]` (default `[]`, mirroring `[tools] always_load`) preloads the full body of each named skill into the session's `skills_context` message at session start. An entry that cannot be preloaded is reported rather than dropped silently, and the warning names the cause: a name `[skills.bundled]` policy excludes, a skill whose `invocation` forbids model loading, or one that matches nothing at all. Warnings are status events — visible in the TUI but not on `exec` stdout — and the model also sees them in its skills block.
354
355 Bundled policy governs installed copies only: discovery applies `disabled` and `selected` to a shipped copy, identified by its path and a byte-for-byte body match, so a skill you wrote yourself survives them. `always_load` sees the result rather than re-deciding it — a name the registry carries is preloaded as-is, and only a name the registry does not carry is reported against the bundled list that excludes it. Naming your own skill in both `always_load` and `disabled` is therefore not a configuration error; the entry loads. Preloaded bodies are capped at 64 KiB per skill and 128 KiB total with a warning if truncated.
356
357 The preview favors trigger clauses (`Use when:` and localized markers such as `Триггеры:` or `触发条件:`) and shortens descriptions before falling back to names; the names-only tier keeps a skill's path when it fits. When descriptions are shortened, the context report includes a count in the preview detail. Descriptions exceeding the configured cap without a recognized trigger produce a load warning. `/skills inspect` shows a localized note with the same effective cap.
358
359 `load_skill name="list"` shows concise descriptions for project and Codewhale skills and counts global compatible skills by source. Use `name="list-all"` or `include_external=true` to list those skills individually. A multi-word `query` searches names, aliases, and full descriptions across both groups. Loading an exact name returns the full skill body. `listing_max_description_chars` also caps the descriptions in this list, keeping a recognized trigger clause when it shortens one. For filesystem skills, the companion list includes regular files beside `SKILL.md` and in subdirectories up to 4 levels deep, at most 128 files (32 per directory), keeping shallower files first when it is cut off. It skips hidden entries, symlinks, `__pycache__` and `node_modules`, says how many more files exist when it is cut off, and is empty for plugin skills. Companions of a global skill outside the workspace are opened with a shell read, because `read` is workspace-scoped.
360
361 ```toml
362 # Optional override for discovery preference (not automatically a write target
363 # unless it is the Codewhale project/global owned path).
364 skills_dir = "/path/to/skills"
365
366 [skills]
367 # When true, runtime discovery skips cross-tool roots (.claude, .agents, …).
368 # Owned Codewhale roots and an explicit skills_dir override still apply.
369 scan_codewhale_only = false
370 listing_max_description_chars = 120
371 listing_budget_fraction = 0.002
372 always_load = []
373
374 # Optional registry / install size overrides used by --remote, sync, and install.
375 # registry_url = "https://…"
376 # max_install_size_bytes = 5242880
377 ```
378
379 See [CONFIGURATION.md](CONFIGURATION.md) for the full config surface.
380
381
382 ### Bundled skills
383
384 Configure the system pack independently of your discovery directories.
385
386 ```toml
387 [skills.bundled]
388 install = "auto"
389 disabled = ["forget"]
390 explicit_only = ["review"]
391 ```
392
393 The installer records its content fingerprint and selected names in `.system/.fingerprint`. With `auto`, deleting an installed starter opts out of that copy. Setting `skills_dir` skips automatic installation. Use `all` to repair missing enabled starters, or `none` to skip installation. Discovery continues in all three modes.
394
395 An empty `selected` list enables the entire pack. A nonempty list selects specific starters. `disabled` excludes a starter, and `explicit_only` reserves it for user invocation. These settings apply to recognized shipped copies. User-authored skills and managed installs keep their own invocation policy.
396
397 When upgrading a generation-marked flat pack, Codewhale checks the body and companion files against shipped hashes before retiring a copy. Edited files and directories with additional material stay available. Use `/skills inspect` for paths and selection reasons, or `codewhale doctor --full` for the installation status.
398
399 ## Operator checklist
400
401 1. Prefer `/skills manage` for day-to-day management; keep `--remote` / `sync` explicit.
402 2. Never hand-edit `.claude` / `.agents` / `.cursor` trees to “install” for
403 Codewhale — import into `.codewhale/skills` instead.
404 3. Treat `.trusted` as advisory documentation of review, not a security boundary.
405 4. After registry updates that change content, re-trust if you still want the
406 advisory marker.
407 5. Dual project+global copies of the same name need an explicit scope flag on
408 CLI mutations.
409
409 lines MARKDOWN