Skip to content

docs(skills): hook 示例改用 defineHook(),不再教裸 : Hook 字面量 (#4274) - #4283

Merged
os-zhuang merged 2 commits into
mainfrom
claude/skills-definehook-4274
Jul 31, 2026
Merged

docs(skills): hook 示例改用 defineHook(),不再教裸 : Hook 字面量 (#4274)#4283
os-zhuang merged 2 commits into
mainfrom
claude/skills-definehook-4274

Conversation

@os-zhuang

Copy link
Copy Markdown
Contributor

Closes #4274(#4269 / #4273 的后续)。

#4273 落地了 defineHook(),schema.mdxobject.zod.ts 的处方均已指向工厂,但 skills(AI 作者的第一入口)还在 18 处教旧姿势 —— AI 照 skill 写出的 hook 拿到 tsc 绿就报告完成,「import 即校验」闭环在最主要受众上落空。

改动(纯文档,机械替换)

  • const x: Hook = {…}const x = defineHook({…}) ×18,涉及:
    • SKILL.md(os:check 打标块 + CRM 蓝图表格行措辞)
    • rules/hooks.md(Quick Reference)
    • rules/validation.md(外部校验示例)
    • references/data-hooks.md(定义示例、fillPositionOnHire 打标块、cookbook ×10、Method 3 约定扫描、组合/条件示例)
  • 「工厂优先于裸字面量」注记 ×2(rules/hooks.mdreferences/data-hooks.md 定义节),与 feat(spec): 补上 defineHook() 作者侧工厂,并修正 object.zod.ts 两处错误处方 (#4269) #4273schema.mdx 的注记同款措辞。
  • import 相应改为值导入(import { defineHook, HookContext }),无残留未用的 Hook 类型导入。

防「照抄即崩」核查

HookSchema 是 strict 的 —— 包上 defineHook() 后,示例里的未知顶层键会从装饰性类型变成运行时抛错。对全部 15 个改写块扫描顶层键,均只含合法 schema 键,无一例外。

验证

  • check:skill-examples:198 个 prose 片段对构建后 dist 类型检查全绿(含本次改写的打标块)。
  • 无包代码变更,不需要 changeset(skills/ 不在任何发布包的 files 白名单内)。

🤖 Generated with Claude Code

…k` literals (#4274)

#4273 shipped defineHook() and pointed docs + error prescriptions at it,
but skills/objectstack-data — the first thing an AI author reads — still
taught the bare-literal form in 18 places across SKILL.md,
rules/hooks.md, rules/validation.md, and references/data-hooks.md.

Mechanical rewrite: `const x: Hook = {…}` → `const x = defineHook({…})`
(imports switched to the value import), plus the factory-over-bare-literal
note in rules/hooks.md and references/data-hooks.md, phrased identically
to the schema.mdx note from #4273. Every rewritten block was scanned for
unknown top-level keys — HookSchema is strict, so a stray key inside a
defineHook() example would teach a crash — none found; the os:check gate
covers the tagged blocks (198 examples green).

Closes #4274

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@vercel

vercel Bot commented Jul 31, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
objectstack Ignored Ignored Jul 31, 2026 2:40am

Request Review

@github-actions github-actions Bot added documentation Improvements or additions to documentation size/m labels Jul 31, 2026
Same convention as #4279: the changeset gate wants an explicit statement
of release intent, and skills/ ships in no npm package.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@os-zhuang
os-zhuang merged commit 121ccea into main Jul 31, 2026
15 checks passed
@os-zhuang
os-zhuang deleted the claude/skills-definehook-4274 branch July 31, 2026 02:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/m tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

skills/objectstack-data 的 hook 示例仍教裸 : Hook 字面量 —— 应改用 defineHook()(#4269 后续)

1 participant