Repository navigation
fix(skills): ship shared checklists as generated skill-local copies - #670
Conversation
Skills linked the repo-root references/ as ../../references/, which a single-skill or global npx skills install does not copy (addyosmani#597). Each skill now links references/<file>.md, a relative symlink to the root file; npx skills dereferences it on install, so the checklist stays in one place and ships with every skill that uses it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KepYXCwn74SMeQ8XcKPL31
…rences Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KepYXCwn74SMeQ8XcKPL31
…ctory A per-skill install copies only skills/<name>/, so a link that resolves outside it breaks after install even when the repo file exists. The check now fails such links and its hint names the skill-local symlink. Links from files inside a skill's references/ use ../references/<file>.md so their anchors stay checked. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KepYXCwn74SMeQ8XcKPL31
|
How the change works, shown for one skill and one shared checklist. The other ten skills and six checklists follow the same pattern. Before. The link leaves the skill directory. flowchart LR
subgraph repo1["Repository"]
A1["skills/code-review-and-quality/SKILL.md"] -- "../../references/security-checklist.md" --> R1["references/security-checklist.md"]
end
subgraph inst1["Installed with npx skills add --skill code-review-and-quality"]
B1["code-review-and-quality/SKILL.md"] -- "../../references/security-checklist.md" --> M1["missing: never copied"]
end
repo1 -- "copies skills/code-review-and-quality/ only" --> inst1
After. The skill links a copy of the checklist inside its own directory, in flowchart LR
subgraph repo2["Repository"]
R2["references/security-checklist.md (edited by hand)"] -- "sync-shared-references.js" --> C2["skills/code-review-and-quality/references/shared/security-checklist.md (generated)"]
A2["skills/code-review-and-quality/SKILL.md"] -- "references/shared/security-checklist.md" --> C2
end
subgraph inst2["Installed with npx skills add --skill code-review-and-quality"]
B2["code-review-and-quality/SKILL.md"] -- "references/shared/security-checklist.md" --> F2["code-review-and-quality/references/shared/security-checklist.md"]
end
repo2 -- "copies skills/code-review-and-quality/ only" --> inst2
Changing a checklist. A contributor edits only the root file and runs the script, which rewrites every copy of it. CI runs the same script with flowchart LR
E["edit references/security-checklist.md"] --> S["node scripts/sync-shared-references.js"]
S --> G["copies in every skill that links it are rewritten"]
G --> P["commit root file and copies"]
P --> CI["CI: sync-shared-references.js --check"]
CI -- "copies match" --> OK["pass"]
CI -- "missing, stale or unused copy" --> FAIL["fail: run the script"]
What flowchart TD
K["link to references/shared/file.md, root references/file.md exists"] --> C{"copy in the skill's shared/?"}
C -- "none" --> X1["missing"]
C -- "differs from root" --> X2["stale"]
C -- "matches" --> OK["in sync"]
U["file in shared/ that no link needs"] --> X3["unused"]
Validator. flowchart TD
L["references/ link in SKILL.md or in skills/name/references/*.md"] --> E{"target exists?"}
E -- "no" --> X1["error: does not exist"]
E -- "yes" --> O{"target inside skills/name/? (new)"}
O -- "no" --> X2["error: outside the skill (new)"]
O -- "yes" --> H{"anchor matches a heading?"}
H -- "no" --> X3["error: no heading"]
H -- "yes" --> P["pass"]
|
|
praise: this is the cleverest answer to #597 so far: one source of truth, no committed copies, and a validator rule that keeps links inside the skill. Thanks for being upfront about the Windows numbers. issue (blocking): those numbers are why I can't take symlinks. Git for Windows defaults to core.symlinks=false, so a full checkout, which is what the marketplace install is, turns 15 working links into one-line path stubs, and a Windows contributor can't pass validate-reference-links locally. We've spent a lot of this year fixing Windows breakage and I don't want to add a new one. suggestion (non-blocking): I'd take the alternative you offered: generated skill-local copies with a |
Git for Windows checks symlinks out as text files by default, so the skill-local symlinks broke a full checkout there. Each skill now holds a generated copy of the shared checklists it links, written from the root references/ by scripts/sync-shared-references.js. CI runs it with --check and fails when a copy is missing, stale, or no longer linked. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XTTwR4HS4sWgZ992ThEwmP
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XTTwR4HS4sWgZ992ThEwmP
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XTTwR4HS4sWgZ992ThEwmP
The copies sat next to each skill's own reference files and filled PR diffs. They now live in skills/<name>/references/shared/, which holds only generated files, and .gitattributes marks that directory linguist-generated so GitHub collapses it in diffs and language stats. The sync script refuses to overwrite or delete a hand-written file there. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XTTwR4HS4sWgZ992ThEwmP
shared/ holds only generated copies, so a run now deletes it and writes it again, and --check compares it with what a run would write. That drops the header-based checks that refused to overwrite or delete a hand-written file there, a case no one has hit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XTTwR4HS4sWgZ992ThEwmP
The generated header made every copy a separate blob. Without it a copy is byte for byte its root file, so git stores one blob for both, and a hand edit to a copy still fails --check as stale. The three --check tests become one table of drift cases. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XTTwR4HS4sWgZ992ThEwmP
|
@addyosmani thanks for the review. I took the generated-copies route you suggested, and the PR is ready for another look.
The diagrams in the first comment and the description match the current branch. Could you take another look when you have a moment? |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KepYXCwn74SMeQ8XcKPL31
|
@addyosmani I merged today's main (0.6.14) into the branch. Six of the PRs merged today (#688, #699, #719, #720, #725, #727) changed The workflow runs on this PR are still waiting for approval ( |
|
praise: this is the route I asked for, and it holds up. All 15 copies are byte-identical to Two things before it lands:
|
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@addyosmani I merged current main (0.6.15) and resynced the copies after #718 in 771a608. |
|
Thanks, I approved the CI run on 771a608. This still needs a second maintainer before it lands, so @federicobartoli @nucliweb it's yours when you get a minute. |
Reading the files as UTF-8 turned an invalid byte into U+FFFD on write, and two copies whose bytes differ but decode alike passed --check. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@addyosmani could you approve the CI run once more? I pushed 5690671 after you approved 771a608, and the run on it is waiting on a maintainer. The commit makes |
|
Thanks, CI is approved and green on 5690671, and the byte compare is a good fix. #785 just changed @federicobartoli @nucliweb this is the last call. If neither of you objects by Nov 20, I'll merge it after the resync. |
Converts accessibility-engineering's links to the skill-local references/shared/ form and resyncs the accessibility checklist copies. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@addyosmani the resync after #785 was already in db88949 on Nov 14. The branch now merges 0.6.17, and 3d78ead points the two checklist links in accessibility-engineering (added in #261) at a skill-local |
federicobartoli
left a comment
There was a problem hiding this comment.
Sorry for the delay on this. Addy first asked on Oct 31 and I am only getting to it now, a day past the last call. Thank you for your patience, and for keeping the branch in sync through five rounds of upstream changes in the meantime.
praise: this is the pack-wide answer I was hoping for when I asked to hold #400, one mechanism for every skill instead of a workaround per skill. I read the hand-written part (about 400 lines; the other 2,900 are the generated copies) and checked the head statically. All 16 copies have the same blob as their root file, all 26 links are converted and none sits inside a code fence, both anchors resolve, and no root checklist has a relative link that would break once it is copied three levels down. The routing evals only read names and descriptions, so the copies cannot shift them.
issue (blocking): one line, inline. The anchor-only test in validate-reference-links-test.js still looks for the wording of the symlink-era hint, so it can no longer fail. That fix, plus a green run on the head, is all I am asking for before this lands. CI has not run on 3d78ead yet (the last green run was on 5690671, four commits back), so I'll approve the run.
question: what should happen when main goes stale without any single PR being wrong? One PR edits a checklist and resyncs. Another, opened in parallel, adds a new link to that checklist and commits a copy of the old text. Both are green on their own, and after both merge the new copy is stale, so the next unrelated PR goes red. PRs that are already open and touch references/ will also need a resync once this lands. Not for this PR, but would a small job on push to main that reruns the sync be worth a follow-up?
suggestion (non-blocking): two link forms slip past both tools. From a file in skills/<name>/references/ the natural link is shared/<file>.md, and from SKILL.md someone may write ./references/shared/<file>.md. Neither matches the sync or the validator regex, so nothing generates the copy and nothing flags the link. The documented forms work, so this is only a thought for later: would a validator error for those two be useful?
suggestion (non-blocking): CLAUDE.md still says never to duplicate content between skills, which is the line Addy quoted against copies in #621, and it does not mention the sync command. One sentence there would keep an agent working on the repo from "fixing" the copies.
nitpick: the description still says eleven skills and 24 links; with accessibility-engineering it is twelve and 26. scripts/lib/skill-resources.js and the behavioral eval prompt still stage and describe the repo-root references/, which is follow-up material rather than something for this PR. For the record, skills/ grows from 437 KB to 585 KB on disk. Nothing loads until an agent opens a checklist, so that seems fine to me.
Two things on my side before I approve. I am requesting a Copilot review as a second pair of eyes on the script; please treat whatever it raises as non-blocking unless I pick it up here. And I want to try the per-skill and the global install from this branch myself a few times, since our CI only covers the full plugin install and the fork run is the only place those paths have been exercised. I'll do that in the next couple of days, and with the assertion fixed and CI green I'll approve.
| assert.match(result.stdout, /GitHub's heading slugs/); | ||
| // The path was right, so the path hint would only mislead. | ||
| assert.doesNotMatch(result.stdout, /use `\.\.\/\.\.\/references/); | ||
| assert.doesNotMatch(result.stdout, /Reach a shared checklist/); |
There was a problem hiding this comment.
issue (blocking): this can no longer fail. The validator's hint now starts with "Link a shared checklist as", and "Reach a shared checklist" does not appear anywhere in its output, so the test passes whether or not the path hint is printed on an anchor-only error. On main the same line matched the real hint.
| assert.doesNotMatch(result.stdout, /Reach a shared checklist/); | |
| assert.doesNotMatch(result.stdout, /Link a shared checklist/); |
| const target = path.resolve(baseDir, link); | ||
| if (!fs.existsSync(target)) { | ||
| violations.push({ line: i + 1, link, target }); | ||
| } else if (path.relative(skillDir, target).startsWith('..')) { |
There was a problem hiding this comment.
nitpick: startsWith('..') is the form our own security checklist warns about, since it would also reject a child named ..cache (the destructive-paths snippet in references/security-checklist.md, which this PR copies into three skills). It is unreachable here, because the link regex can only yield references/... or ../..., so feel free to leave it. rel === '..' || rel.startsWith('..' + path.sep) would match the checklist.
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved sync and validation issues can leave invalid skill layouts, delete needed checklist copies, and allow nonportable symlinked references to pass checks.
4 open issues
What changed in this PR
This PR packages shared checklists with each consuming skill, addressing the standalone-install gaps in #597 and #361 while keeping root checklists as the source of truth.
Changes:
- Redirects skill references to generated, byte-identical copies under
references/shared/. - Adds synchronization and drift checks, and rejects reference links outside the skill directory.
- Documents the convention, marks copies as generated, and adds cross-platform CI checks.
| File | Description |
|---|---|
skills/using-agent-skills/SKILL.md |
Uses the packaged Definition of Done. |
skills/using-agent-skills/references/shared/definition-of-done.md |
Generated Definition of Done copy. |
skills/test-driven-development/SKILL.md |
Uses packaged testing patterns. |
skills/test-driven-development/references/shared/testing-patterns.md |
Generated testing-patterns copy. |
skills/shipping-and-launch/SKILL.md |
Uses packaged launch checklists. |
skills/shipping-and-launch/references/shared/security-checklist.md |
Generated security checklist copy. |
skills/shipping-and-launch/references/shared/performance-checklist.md |
Generated performance checklist copy. |
skills/shipping-and-launch/references/shared/definition-of-done.md |
Generated Definition of Done copy. |
skills/shipping-and-launch/references/shared/accessibility-checklist.md |
Generated accessibility checklist copy. |
skills/security-and-hardening/SKILL.md |
Uses the packaged security checklist. |
skills/security-and-hardening/references/shared/security-checklist.md |
Generated security checklist copy. |
skills/security-and-hardening/references/hardening-patterns.md |
Redirects shared checklist links locally. |
skills/planning-and-task-breakdown/SKILL.md |
Uses the packaged Definition of Done. |
skills/planning-and-task-breakdown/references/shared/definition-of-done.md |
Generated Definition of Done copy. |
skills/performance-optimization/SKILL.md |
Uses the packaged performance checklist. |
skills/performance-optimization/references/shared/performance-checklist.md |
Generated performance checklist copy. |
skills/performance-optimization/references/optimization-patterns.md |
Redirects shared checklist links locally. |
skills/observability-and-instrumentation/SKILL.md |
Uses the packaged observability checklist. |
skills/observability-and-instrumentation/references/shared/observability-checklist.md |
Generated observability checklist copy. |
skills/incremental-implementation/SKILL.md |
Uses the packaged Definition of Done. |
skills/incremental-implementation/references/shared/definition-of-done.md |
Generated Definition of Done copy. |
skills/frontend-ui-engineering/SKILL.md |
Uses the packaged accessibility checklist. |
skills/frontend-ui-engineering/references/shared/accessibility-checklist.md |
Generated accessibility checklist copy. |
skills/doubt-driven-development/SKILL.md |
Uses packaged orchestration guidance. |
skills/doubt-driven-development/references/shared/orchestration-patterns.md |
Generated orchestration reference copy. |
skills/code-review-and-quality/SKILL.md |
Uses packaged review checklists. |
skills/code-review-and-quality/references/shared/security-checklist.md |
Generated security checklist copy. |
skills/code-review-and-quality/references/shared/performance-checklist.md |
Generated performance checklist copy. |
skills/accessibility-engineering/SKILL.md |
Uses the packaged accessibility checklist. |
skills/accessibility-engineering/references/shared/accessibility-checklist.md |
Generated accessibility checklist copy. |
scripts/validate-reference-links.js |
Enforces skill-local reference links. |
scripts/validate-reference-links-test.js |
Updates portability and anchor checks. |
scripts/sync-shared-references.js |
Generates copies and checks drift. |
scripts/sync-shared-references-test.js |
Covers copying, pruning, drift, and bytes. |
docs/skill-anatomy.md |
Documents generated shared-reference packaging. |
CONTRIBUTING.md |
Directs authors to synchronize shared references. |
.github/workflows/test-plugin-install.yml |
Adds synchronization checks and tests. |
.gitattributes |
Marks shared copies as generated. |
Review effort: Max
|
|
||
| for (const shared of new Set(names)) { | ||
| const source = path.join(SHARED_DIR, shared); | ||
| if (!fs.existsSync(source)) continue; |
| const problems = []; | ||
| for (const [file, content] of copies) { | ||
| if (!fs.existsSync(file)) problems.push(`missing ${toPosix(file)}`); | ||
| else if (!fs.readFileSync(file).equals(content)) problems.push(`stale ${toPosix(file)}`); |
|
|
||
| function sync(copies) { | ||
| for (const skillDir of skillDirs()) { | ||
| fs.rmSync(sharedDir(skillDir), { recursive: true, force: true }); |
| const target = path.resolve(baseDir, link); | ||
| if (!fs.existsSync(target)) { | ||
| violations.push({ line: i + 1, link, target }); | ||
| } else if (path.relative(skillDir, target).startsWith('..')) { | ||
| violations.push({ line: i + 1, link, target, outside: true }); | ||
| } else if (anchor && !headingAnchors(target).has(anchor)) { | ||
| violations.push({ line: i + 1, link, target, anchor }); | ||
| } |
- make the anchor-only test assert the current hint text so it can fail - sync removes an empty references/ after dropping the last shared copy - CLAUDE.md: the generated shared copies are the exception to no duplication Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
@federicobartoli thanks for the review. The fixes are in 25f972b:
On main going stale: yes, a job on push to main that reruns the sync and fails on drift is worth a follow-up PR once this one lands. I left Copilot's missing-source comment and its two symlink comments, the The CI run on 25f972b needs a maintainer's approval again. |
addyosmani
left a comment
There was a problem hiding this comment.
praise: thanks @drakulavich for six rounds of resyncs, and @federicobartoli for testing the per-skill and global installs yourself. That was the part CI couldn't cover. Merging. This fixes #597.
note: from now on, any PR that edits references/ needs node scripts/sync-shared-references.js, and open PRs touching those files will need a resync. Federico's idea of a sync check on push to main is worth a small follow-up PR if anyone wants it.
|
@addyosmani @federicobartoli thanks for the reviews and the merge. The follow-up is #816, could you take a look? The sync check on push to main already runs: |

Refs #597, #361
Problem
Twelve skills link the shared checklists in the repo-root
references/as../../references/<file>.md.npx skills addcopies onlyskills/<name>/, so after a single-skill install (#597, #361) or a global install of the pack, those 26 links point at a directory that was never created. Installingcode-review-and-qualityandshipping-and-launchfrommainwithnpx skills@1.7.2leaves all six of their checklist links broken, on macOS and on Windows.This change
Each skill gets a generated copy of every shared checklist it links, in
skills/<name>/references/shared/, and links it asreferences/shared/<file>.mdfromSKILL.mdor../references/shared/<file>.mdfrom a file already inskills/<name>/references/. That second form keeps the link and its anchors under the validator's check.scripts/sync-shared-references.jswrites the copies from the root files.shared/belongs to the script: each run deletes it and writes it again. A copy is byte for byte its root file, so git stores one blob for both..gitattributesmarks the directorylinguist-generated, so GitHub collapses the copies in diffs and leaves them out of language stats. With--checkit changes nothing and fails on a copy that is missing, stale or unused; CI runs that on Ubuntu, macOS and Windows. The rootreferences/stays the only place to edit a checklist, so the copies can't drift (the objection in #621).validate-reference-links.jsnow fails areferences/link that resolves outside the skill's directory, since a per-skill install leaves it behind, and its hint names the sync script. Run againstmain, it reports exactly the 26 links this PR changes.docs/skill-anatomy.mdandCONTRIBUTING.mddescribe the convention.An earlier version of this PR used symlinks instead of copies. Git for Windows checks symlinks out as text files by default, which broke a full checkout there, so this version has no symlinks.
#261 adds two
../../references/links. Whichever of the two lands second has to switch them toreferences/shared/<file>.mdand run the sync script.Other approaches
code-review-and-quality/SKILL.md, which fixes one skill of twelve.mainand to network access.code-review-and-qualityskill, but "references" not found #597 (sparse-clonereferences/and link it into the agent's directories) works, but every user has to set it up and refresh it.Testing
scripts/sync-shared-references-test.js: 7 tests pass, three of them one table of drift cases, one for a byte that is not valid UTF-8. Each of 9 one-line mutations of the script makes at least one of them fail: no fence stripping, no missing, stale or unused check, no pruning,--checkwriting, ignoring../references/shared/links, reading or comparing the files as UTF-8 text.validate-reference-links-test.js: 32 tests pass.test-plugin-install.ymlpass on the fork, Windows and macOS included (run);node --testover every script test: 223 pass.maininto this branch changedreferences/performance-checklist.md, and--checkcaught the three copies it left stale before the resync.🤖 Generated with Claude Code
https://claude.ai/code/session_01XTTwR4HS4sWgZ992ThEwmP