Skip to content

Commit 5cbe1fc

Browse files
the-simianclaude
andcommitted
feat(skill-writer): Add scope-aware encapsulation depth gate
A skill's body should not exceed its registration scope. Global skills that hard-code project-specific identifiers ship them to every consumer, where the references resolve to nothing. - design-principles.md: new Scope-Aware Encapsulation section pairs registration locations with what the body may reference, and sets the rule for resolving scope before authoring. - mode-selection.md: scope mismatch on global registration is now a hard failure in the authoring path. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 0493d77 commit 5cbe1fc

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

skills/skill-writer/references/design-principles.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,22 @@ Use this guide to keep skill instructions dense, scannable, and worth their toke
6767
- Reuse established repo-specific path variables only when the repo already standardizes on them.
6868
- Label provider-specific mechanics explicitly and add portability notes when they matter.
6969

70+
## Scope-Aware Encapsulation
71+
72+
A skill must speak to the level of its authorship. Registration scope determines what content is in-scope.
73+
74+
| Registration | Scope | Body may reference |
75+
|--------------|-------|---------------------|
76+
| Global (`~/.claude/skills/`, `~/.claude/agents/`) | cross-project | generic patterns, public APIs, neutral placeholder names |
77+
| Project (`<project>/.claude/skills/`, `<project>/.claude/agents/`) | one codebase | project files, hooks, domain terms, internal helpers |
78+
79+
A global skill that bakes in identifiers from one project ships them to every consumer of the skill, where the references resolve to nothing.
80+
81+
- Resolve registration scope before authoring; ask the user once if ambiguous.
82+
- For global skills, abstract project-grounded patterns to placeholder names (`FollowToggle`, `useResourceActions`) before writing them into the body.
83+
- Source synthesis may consult a project's files for the canonical pattern; the resulting body must not.
84+
- Project skills may anchor freely on real codebase symbols; that's the value.
85+
7086
## Long Files
7187

7288
- Keep `SKILL.md` short enough to scan as a router.

skills/skill-writer/references/mode-selection.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,4 @@ Missing selected-profile requirements is also a hard failure.
6565
Missing required class dimensions is a hard failure.
6666
Missing an explicit execution-shape choice for a material skill change is a hard failure.
6767
Using advanced mechanics without justification or portability notes is a hard failure.
68+
Scope mismatch is a hard failure: a global-registered skill that hard-codes project-specific identifiers, file paths, hook names, or domain nouns must be fixed before completion. Project-registered skills are not constrained. See `references/design-principles.md` "Scope-Aware Encapsulation."

0 commit comments

Comments
 (0)