AGENT SKILL

Cratis 技术示例编写与验证

cratis-technical-examples

对照真实的 Cratis API 设计和验证面向开发者的代码示例、教程项目和文档片段。适用于添加或审查可运行示例、多客户端代码片段、示例应用、命令/输出对或迁移前后代码。不得杜撰 API 形态,也不得将渲染效果当作编译检查。

使用场景开发参考
License 许可
MIT
所属仓库
Cratis/Dockerfiles
最近更新
2026-11-14
Stars
★ 0
Forks
0

01 前言 Front Matter

name
cratis-technical-examples
license
MIT
metadata
{ "cratis-hint-paths": "**/Samples/**/*.{cs,ts,tsx}" }
description
Design and verify developer-facing code samples, tutorial projects, and documentation snippets against real Cratis APIs. Use when adding or reviewing a runnable example, multi-client snippet, sample app, command/output pair, or migration before/after code. Do not invent API shapes or treat rendering as a compilation check.

02 资源文件 1

03 SKILL.md 正文

<!-- cratis-ai-managed: skills/cratis-technical-examples/SKILL.md -->

Technical examples readers can trust

A reader will paste the example before they read its explanation. Make that first attempt work, and show how to tell. A substantial tutorial should have a real project behind it; a five-line illustration need not become a new sample repository. This skill owns the example workflow, not the owning product's language-tab layout or documentation site implementation.

Choose the right source

  • Short illustration: use the smallest self-contained block that proves one point. Verify every framework type, import, signature, and option against first-party source at the supported version. State any domain types or setup the excerpt assumes; do not present a partial excerpt as a standalone app.
  • Multi-step tutorial or long example: write or find a buildable sample or spec maintained with the product. Extract the displayed snippet from that source when tooling supports it. Otherwise keep a reproducible extraction or snippet-equality check beside the sample and run it with the sample build in CI. Manual comparison alone is a one-time review, not a drift guard; name that limitation when automation is unavailable. Do not copy once and let the page drift. Link each extracted block to its source file so a reader can follow it to the fuller example; that link is navigation, not a verification receipt. The Cratis site adds these links automatically to client-language tabs, so don't add them by hand there.
  • Multi-language client example: keep one explanation; use the established client-owned snippet mechanism, compile each client against its own SDK, and offer only implementations that exist. Do not translate a C# call by guess. Use the same domain type names in every tab; if the prose has to explain which name each tab uses, fix the snippets instead. State each backend's id and command-response wire type (for example Guid versus string) and keep one id type per concept across every page of a series. Shared frontend code that depends on those types must be backend-neutral or tabbed per backend.
  • Sample application: one realistic domain, explicit prerequisites and package versions, a documented run command, a reproducible state to start from, and a visible result. Keep it minimal enough for a new reader to finish. Link from the documentation step to the precise sample file, not just the repository root. State how to reset sample state safely, what resources the example creates, and any costs or security shortcuts that make it unsuitable for production. Never use real credentials or personal data.

For Cratis-specific API traps and source-location guidance, read Writing Correct Code Examples. A local Chronicle client documentation workflow takes precedence for shared language tabs. Never hand-edit a generated proxy or a synchronized docs copy.

Build the example as a reader would

  1. Decide what the example demonstrates and what it deliberately omits. Check the version the page targets, not an arbitrary sibling checkout at HEAD.
  2. Start with a working program, spec, or focused use of the public API. Model the product's intended idioms, not just a way that happens to compile. Name a common non-idiomatic trap where it helps the reader avoid a likely mistake. Check packages, imports, namespaces, required attributes, method receivers and overloads against product source. Invented domain names are fine; invented framework APIs are not.
  3. Show enough context to paste and run: required setup, the file or project location, a language-tagged fence, commands in execution order, and expected output or resulting state. Do not hide essential steps behind // ....
  4. Run the owning build/spec or snippet extractor and the sample command where feasible. Make the expected result an assertion or inspectable output, not just 'the command exited 0'. A rendered code fence proves syntax highlighting, not compilation or behavior.
  5. Check documentation links, accessibility of diagrams/images, and that the extracted block still matches the compiled source. For a sample that uses external services, name their setup and the check that could not run.
  6. Record the source revision and verification scope in the change summary, not as a permanent receipt embedded in the page.

Version constraints belong in the page; the test log does not

A reader needs the versions that change what they install or write. Published prose can say that a feature needs a minimum release ("This needs Chronicle <version> or later"), pin packages and images in the commands a reader runs, and name the one release where behavior changed.

Keep the author's verification record out of the page. Exact SDK builds, image digests or commit SHAs recorded for provenance, the date it was run, "tested with X on Y", "also checked against a development server", counts of passing specifications and a list of which tabs were not run are all a log of what the author did. A reader cannot act on them, they are stale by the next release, and a page that ends in an audit trail reads as generated, not written. Put them in the change summary, the pull request comment or .ai-work/, per the step above.

Test each version sentence: would a reader install or write something different because of it? If not, remove it. A real limitation stays, stated as a fact about the product ("the Kotlin client has no equivalent yet"), not as a record of what was and was not run. A digest in a command the reader runs is part of the command, not a note, and stays.

Know what the owning gate actually checks

Look for a snippet validator before designing another checker. Arc and Chronicle's .NET repositories use Documentation/validate-client-snippets.py for supported C# fences in Documentation/client-snippets/**; Arc's validator has a --self-test that plants a failing snippet. Other client repositories own their own validators and toolchains. Check the validator's reported count and exclusions: unsupported markers or legacy snippets are not proved compilable just because the run passed. Run the owning validator for every changed client snippet, or name a missing toolchain and rely on its required CI gate. These checks do not compile ordinary Markdown/MDX fences elsewhere in product documentation. For those, verify against real source and a runnable sample/spec or an explicit snippet comparison; do not claim coverage from a site build or a validator that never scans the page.

A compiling tab is not a working tab. For each backend, confirm that the artifact is discovered and registered, that proxy generation emits the file and types the page names, and that any runtime behavior the page claims (live updates, constraint rejection) was observed against a real kernel and sink. If a tab's code compiles but fails at runtime, don't publish it with a workaround in the prose after it. Put working code in the tab and reference the tracking issue in a code comment.

A simple process beats a large unmaintained examples gallery: give the reader one small success first, then link to a fuller sample when they need it. Update examples alongside public API changes and incoming reports of copy/paste failure.

Stop conditions

Do not claim a sample is runnable when a dependency, runtime, credential, external service, supported client, or version needed to reproduce it is unknown. Do not silently replace a source-verified example with plausible looking pseudo-code. Identify the missing check or narrow the claim instead.

04 同仓库更多 Skills

Cratis
Cratis/Dockerfiles

文案语气与节奏优化

cratis-writing-voice-and-cadence

审查和修订现有文字,使其读起来像出自真人手笔:找出单篇文章中过度使用的句式和陈词滥调,以及一批文章中的结构雷同,然后用具体内容加以修正,而非刻意注入变化,且不改变任何技术论断。标记只是编辑提示,绝不是对作者身份的判定。适用于审查或改写文档、发布说明、PR 描述、帖子或评论的语气。不用于技术准确性审查、原创起草、作者身份检测,也不作为未经授权改动已批准文案的理由。

技术文档工程师内容质量审核与优化
★ 0
Cratis
Cratis/Dockerfiles

Cratis 发布说明撰写

cratis-release-notes

基于已验证的变更,为特定 Cratis 产品版本起草或审查面向开发者的发布说明和迁移指南。适用于 GitHub Releases、升级指南和发布公告;不用于决定发布权限、执行发布或选择版本标签。

技术文档工程师部署与发布管理
★ 0
Cratis
Cratis/Dockerfiles

LLM 友好文档设计

cratis-llm-friendly-documentation

为 AI 助手设计或审查机器可读的文档索引、Markdown 镜像和限定范围的产品/主题导出。适用于 llms.txt、llms-full.txt、按产品划分的上下文集以及文档检索质量。不要将公开导出视为系统指令,也不要承诺爬虫会采用。

技术文档工程师知识管理与沉淀
★ 0
Cratis
Cratis/Dockerfiles

Cratis 技术文档编写

cratis-documentation-writing

规划、编写和改进以用户为中心的 Cratis 文档,确保清晰的读者旅程,每个页面只承担一个主要的 Diátaxis 目的。适用于产品文档、教程、操作指南、参考、解释和文档审查。可执行示例请使用 cratis-technical-examples;发布说明请使用 cratis-release-notes。不得杜撰 API 或发布内容。

技术文档工程师技术文档编写
★ 0
Cratis
Cratis/Dockerfiles

Cratis 内容可发现性审查

cratis-discoverability

在发布前检查 Cratis 内容的可发现性,使其便于搜索和 AI 回答,同时不牺牲可读性。适用于审查可发现性、SEO、AEO 或 GEO;撰写事实块或下载声明;编辑包/仓库元数据;检查文档标题、描述或 LLM 导出预算;或审查创始人/公司 JSON-LD 和成员资料索引。不适用于页面语气和结构(cratis-documentation-writing)、llms.txt 设计(cratis-llm-friendly-documentation)、分发计划(cratis-developer-marketing)或篇幅决策(cratis-content-length)。

技术文档工程师网站 SEO 审计与优化
★ 0