Skip to content

Skills part 1: what a skill is, and the file it round-trips through - #90

Open
shanforge wants to merge 3 commits into
shan/issue-83-mcp-settingsfrom
shan/issue-84-skill-model
Open

shanforge wants to merge 3 commits into
shan/issue-83-mcp-settingsfrom
shan/issue-84-skill-model

Conversation

@shanforge

Copy link
Copy Markdown
Collaborator

Part of #56. Closes #84 — the first two boxes of #64.

Stacked on #88 — review that first; this branch contains it.

There was no skills code in the tree, so this is the piece everything else stands on: what
a skill is, what it looks like on disk, and where the list lives. Nothing here draws,
and nothing here reaches a model yet — layering onto the system prompt and narrowing the
tool set are #85.

Two names, because one of them is an address

A skill is invoked by name from a composer, so the name is not decoration. Two skills
sharing an invocation means one of them can never be reached, and a name that is not one
typeable token is a skill that cannot be invoked at all.

So the title is the user's words — any text, any script, punctuation included — and the
invocation is derived from it: lowercased, folded to one word, bounded, trimmed of
leading and trailing hyphens so — Weekly Review — does not become -weekly-review-,
which reads as a typo rather than a name. Deriving rather than asking is the argument
MCPToolNaming already makes for namespaces: a supplied name can collide with something it
should not; a computed one cannot.

A title of nothing but punctuation is refused with its reason — it cleans to something
non-empty and derives to nothing, so it would be a skill that exists and can never be run.

The file is the sharing format

Frontmatter plus a body, the shape MarkdownDocumentFile and SpaceFile already use.
Rendering is stable, so an export is not a diff every time.

Import is the untrusted direction: forgiving about shape, strict about size. An unknown key
does not fail the read, a malformed file costs that skill rather than the import, and
nothing it carries is unbounded, because the body ends up in a prompt.

The identifier is deliberately not required, which is where this differs from
MarkdownDocumentFile. A document file without an id is a document Logue has lost track of;
a skill file without one is the normal case — somebody wrote it by hand or exported it
from another machine — so it becomes a new skill. Inventing an id is right here and wrong
there.

An absent tool list and an empty one mean different things, and the difference is
load-bearing: empty means no tools, which a skill may legitimately want, and reading
absent as empty would silently take every tool from every skill written before the field
existed.

A skill's text stays content

promptSection is the only way its instructions are meant to reach a prompt: wrapped,
bounded, stripped, and unable to close its own region. A skill file can be written by anyone
and passed around, so its body is third-party text in exactly the way an MCP server's reply
is — a body containing </skill_instructions> would otherwise end its own region and have
the rest read as something Logue said.

That neutralisation is now written once. MCPToolOutput had a copy and this needed the same
thing, so both go through DelimitedContent — a control that exists in two places is a
control that gets fixed in one. MCPToolOutput keeps what is genuinely its own: its tag and
its budget.

Editing a built-in copies it

The built-ins are documentation as much as features, so someone who overwrote the only
worked example must have a way back. An edit stores a copy carrying the built-in's id; that
copy stands in for the original wherever the original would have appeared; removing it
brings the original back. A stored skill can never claim to be a built-in — add and
update force the flag off — so an imported file cannot make itself unremovable or shadow
one of ours.

What the review rounds found

Round 1 — a built-in could disappear entirely (major). Which built-ins were overridden
was stored in its own defaults key, separate from the skills. Those are read separately, and
a corrupt skills blob reads as an empty list deliberately — a skill the user cannot see
must not steer a turn — while an intact override blob reads fine. The result: a built-in
filtered out with nothing standing in for it. Gone, with no way back short of editing
defaults. A user skill carrying a built-in's id is the override, so it is derived now, and
a pair that cannot disagree because there is no pair. Also: an edited built-in used to jump
to the bottom of the list; it now renders in the built-in's place.

Rounds 2 and 3 — an import that silently dropped a skill, and a first fix that did not
fix it.
Importing the same long-named skill twice dropped the second one without a word.
The rename appends a counter — but uniqueness is decided on the invocation, which is
bounded more tightly than the title
(40 against 60). A long title takes " 2", stays
comfortably inside the title limit, and has the counter truncated straight off when the
invocation is derived; every candidate folds to the name it was meant to differ from, the
loop runs out, and the skill is dropped.

The first fix shortened the base against the title limit — the obvious version, and it
does nothing, since 60 minus four is still far past 40. The case stayed red through that
attempt, which is the only reason the real bound got noticed: the reasoning had looked
convincing twice. A dropped import now also says which one and why.

Verification

  • xcodebuild build — succeeds
  • ./scripts/test-no-llm.sh — 1828 tests in 164 suites pass
  • SwiftFormat 0.62.1 --lint — 0/566 files require formatting
  • SwiftLint 0.65.0 --strict — 0 violations in 722 files

Mutation-checked: removing the delimiter neutralisation in DelimitedContent turns
six cases red, across both MCP and skills — which is also the evidence the extraction is
genuinely shared rather than a tidy-up.

Not in this PR

Nothing here is reachable from the UI yet, by design. #85 layers a skill onto the system
prompt and narrows the tool set; #86 puts it in both composers; #87 is the Settings editor
and closes #64. There is nothing to click through until #86 — the click-through for the
whole feature lands with #87.

🤖 Generated with Claude Code

https://claude.ai/code/session_01M3Wpnj9ZmWPKYdFPB1AVY3

shanforge and others added 3 commits September 4, 2026 12:43
Part of #56. Closes #84 — the first two boxes of #64.

There was no skills code in the tree, so this is the piece everything else stands on:
what a skill *is*, what it looks like on disk, and where the list lives. Nothing here
draws, and nothing here reaches a model yet — layering onto the system prompt and
narrowing the tool set are #85.

## Two names, because one of them is an address

A skill is invoked **by name** from a composer, so the name is not decoration. Two skills
sharing an invocation means one can never be reached, and a name that is not one typeable
token is a skill that cannot be invoked at all.

So the **title** is the user's words — any text, any script, punctuation included — and the
**invocation** is derived from it: lowercased, folded to one word, bounded, and trimmed of
leading and trailing hyphens so `— Weekly Review —` does not become `-weekly-review-`,
which reads as a typo rather than a name. Deriving rather than asking is the argument
`MCPToolNaming` already makes for namespaces: a supplied name can collide with something it
should not, a computed one cannot.

A title of nothing but punctuation is refused *with its reason*, because it cleans to
something non-empty and derives to nothing — a skill that exists and can never be run.

## The file is the sharing format

Frontmatter plus a body, the shape `MarkdownDocumentFile` and `SpaceFile` already use.
Rendering is stable, so an export is not a diff every time it is written.

Import is the untrusted direction and is forgiving about shape, strict about size: an
unknown key does not fail the read, a malformed file costs that skill rather than the
import, and nothing it carries is unbounded, because the body ends up in a prompt.

**The identifier is deliberately not required**, which is where this differs from
`MarkdownDocumentFile`. A document file without an id is a document Logue has lost track
of; a skill file without one is the *normal* case — somebody wrote it by hand or exported
it elsewhere — so it becomes a new skill. Inventing an id is right here and wrong there.

**An absent tool list and an empty one mean different things**, and the difference is
load-bearing: empty means *no tools*, which a skill may legitimately ask for, and reading
absent as empty would silently take every tool from every skill written before the field
existed. So `decodeIfPresent` without a default, and an unnarrowed skill renders no `tools`
key rather than `tools: []`.

## A skill's text stays content

`promptSection` is the only way its instructions are meant to reach a prompt: wrapped,
bounded, stripped, and unable to close its own region. A skill file can be written by
anyone and passed around, so its body is third-party text in exactly the way an MCP
server's reply is — and a body containing `</skill_instructions>` would otherwise end its
own region and have the rest read as something Logue said.

That neutralisation is now written once. `MCPToolOutput` had a copy and this needed the
same thing, so both go through `DelimitedContent` — a control that exists in two places is
a control that gets fixed in one. `MCPToolOutput` keeps what is actually its own: its tag,
and its budget.

Mutation-checked: removing the neutralisation turns **six** cases red, across both MCP and
skills.

## Editing a built-in copies it

The built-ins are documentation as much as features — #64 asks that they be readable as
examples — so someone who overwrote the only worked example must have a way back. An edit
hides the original and stores the edit; `restore` brings it back; removing an edited
built-in restores it too, which is what makes trying an edit safe.

A stored skill can never claim to be a built-in: `add` and `update` force `isBuiltIn` to
false, so an imported file cannot make itself unremovable or shadow one of ours.

A colliding import is **renamed rather than dropped** — someone importing six skills should
not have to find the clash, fix it and start over, and silently discarding one is worse
than either.

## Verification

- `xcodebuild build` — succeeds
- `./scripts/test-no-llm.sh` — 1825 tests in 164 suites pass
- SwiftFormat 0.62.1 `--lint` — 0/566 files require formatting
- SwiftLint 0.65.0 `--strict` — 0 violations in 722 files

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01M3Wpnj9ZmWPKYdFPB1AVY3
**A built-in could be hidden with nothing standing in for it (major).** The set of edited
built-ins was stored in its own defaults key, separate from the skills themselves — a
state pair, and the two are read separately. A corrupt skills blob reads as an empty list
(deliberately: a skill the user cannot see must not steer a turn) while an intact override
blob reads fine, and the result is a built-in filtered out of the list with no replacement.
The skill is simply gone, and nothing short of editing defaults brings it back.

A user skill carrying a built-in's id *is* the override, so this is a question about
`userSkills` rather than a second thing to keep in step with it. Derived, the pair cannot
disagree, because there is no pair. The extra key goes with it.

**An edited built-in jumped to the end of the list (minor).** It was filtered out of the
built-ins and appended to the user's own, so changing a summary moved the skill to the
bottom of the picker. An override is now rendered in the built-in's place.

Two cases added: one pinning the order, and one that plants a corrupt skills blob and
asserts every built-in is still invocable.

Verified: build succeeds, 1827 tests in 164 suites pass, SwiftFormat --lint clean over 566
files, SwiftLint --strict 0 violations in 722 files.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01M3Wpnj9ZmWPKYdFPB1AVY3
…applies

Round two found that importing the same long-named skill twice dropped the second one
silently, and round three found the first fix for it was wrong.

**The bound that decides uniqueness is the invocation, not the title.** Titles are capped
at 60 characters and invocations at 40, and it is the invocation that has to differ — so a
long title takes `" 2"`, stays comfortably inside the title limit, and has the counter
truncated straight off again when the invocation is derived. Every candidate then folds to
exactly the name it was supposed to differ from, the loop runs out of suffixes, and the
skill is dropped.

The first fix shortened the base against the title limit, which is the obvious version and
does nothing: 60 minus four is still far past 40. It is shortened against the tighter of
the two now. The case stayed red through that first attempt, which is the only reason the
real bound got noticed — the reasoning alone had looked convincing twice.

**A dropped import now says which one and why.** It was counted and skipped in silence; a
skill that does not arrive and does not explain itself is worse than one refused loudly.

Verified: build succeeds, 1828 tests in 164 suites pass, SwiftFormat --lint clean over 566
files, SwiftLint --strict 0 violations in 722 files.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01M3Wpnj9ZmWPKYdFPB1AVY3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant