/ceh-documentation:write-examples [project-path]from ceh-documentation
Load this skill when writing runnable example programs under examples/: a feature tour and copy-paste recipes, each run before it is kept. Trigger on "write examples for this project", "add usage examples", "the examples are missing or broken".
Ships in ceh-documentation. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
An example has two readers, and they want opposite things:
One file cannot serve both well: a tour stays short by skipping error handling and configuration,
and a recipe earns its trust by including exactly those. So this skill writes two tracks under
<root>/examples/ and never mixes them in one file. Every file is run before it is kept. An
example that does not run is worse than none: it is the first thing a new user copies.
<root>. Confirm it
holds a project (a manifest such as pyproject.toml, package.json, Cargo.toml, go.mod, or
a source tree).<root> is the current working directory.If <root>/examples/ already exists, read it first. Fix what is broken and add only what is
missing. Never move or rename an existing example that runs: READMEs, docs, and issues link to
those paths. List it in the index under the track it fits, and put only new files in the layout
below. Never delete a user's example without listing it in the report.
Examples use the project the way an outsider does, so learn the outsider's view first:
| Question | Where to look |
|---|---|
| What kind of project is it: library, CLI, HTTP API, SDK, service? | Manifest, entry points, bin/scripts, route definitions |
| What is the public import path or command name, and how is it installed? | Package name in the manifest, __init__/index exports, README install line |
| Which features matter most? | README feature list, docs quickstart, the most-tested public functions, CLI subcommands |
| What does a caller have to configure? | Constructor parameters, env vars read (.env.example, settings code), required credentials |
| What fails in normal use and how does the caller see it? | Public exception or error types, HTTP error bodies, CLI exit codes |
| How does the project's own code call itself? | Tests that exercise the public API: the most reliable source of correct, current usage |
Rank the features. The tour gets the top three to five, chosen by how many users need them, not by how interesting they are to build. A feature that almost every user touches (create the client, make the core call, read the result) outranks a clever advanced one.
Write the plan as a short table before any code: file, track, the feature or integration it shows, and the one line it will print. Then write the files.
examples/
├── README.md # index: both tracks, how to run, what each file shows
├── tour/
│ ├── 01-<first-result>.<ext> # shortest path to a first working result
│ ├── 02-<core-feature>.<ext>
│ └── 03-<core-feature>.<ext>
└── recipes/
├── <integration-name>.<ext> # one integration scenario per file
└── ...
Use the project's language and file extension. A CLI project writes shell scripts. An HTTP API
writes curl scripts plus one client in the language its users most likely use. If the ecosystem
lays examples out differently by convention (Rust's flat examples/*.rs run by
cargo run --example, Go's one package main per examples/<name>/ directory), follow the
convention and keep the two tracks as a name prefix (tour_01_..., recipe_...) instead of
subfolders. Examples are programs, not tests: do not write them as Go Example* functions or
doctests, because a user must be able to run and copy each one as a standalone program.
Examples run against the working tree, but integrators install the latest release. Compare the
public surface the examples use against the latest release tag
(git -C <root> describe --tags --abbrev=0, then the changelog). If an example relies on something
unreleased, say so at its top and in the index, so nobody copies code their installed version
cannot run.
The tour answers "what does this do, and what does it feel like to use?" in as few lines as possible.
01 is always the shortest path to a first
working result. Each later file assumes only what an earlier file showed.created user usr_abc123), not a raw object repr.A recipe answers "how do I put this in my own project?" The test for every line: would the integrator have to change it or add to it before it is safe to ship? If yes, fix the recipe.
defer, finally, using).main guard below it that runs it. The lifted part must
not depend on the guard. A recipe that is config rather than code (a CI step, a compose service,
a shell alias) is instead the complete block to paste, with nothing around it.# change: your bucket name. There are few of them. If there are more than three, the recipe is
doing too much.retry-on-rate-limit,
fastapi-dependency, ci-step, batch-import-from-csv), never after the API they call.Pick recipes from the integrations the survey found: the frameworks the project mentions, the callers its own tests simulate, the questions in issues or the README FAQ. Three to six is typical. A recipe no real user would need is a tour step or nothing.
Run each file exactly the way examples/README.md will tell the reader to, from a clean shell in
<root>, using the project's own toolchain (uv run, bun run, cargo run --example, go run,
bash). Capture the output. Then act on the result:
not run: <reason> and
list it in the report. A tour example that cannot run is cut. The tour exists to be run.examples/README.mdThe index is the page a new user opens first, so it states the order and the one command per file:
# Examples
<One sentence: what these show and the version or commit they were run against.>
## Setup
```bash
<the one install or sync command>
```
## Tour — learn the main features in order
| File | Shows | Run |
| ----------------------------------------------- | --------------------------------------- | ------------------------------------------ |
| [01-first-request.py](tour/01-first-request.py) | Create a client and make the first call | `uv run examples/tour/01-first-request.py` |
## Recipes — copy into your own project
| File | Use it when | Change |
| -------------------------------------------------------- | -------------------------------- | ----------------- |
| [retry-on-rate-limit.py](recipes/retry-on-rate-limit.py) | Your app calls the API in a loop | `API_KEY` env var |
A table cell cannot hold a code block, so put tour output after the tables, in an ## Output
section with one ### heading per file and its output in a text block. If the project has a
docs/ set, link from examples/README.md to it.
uv run --with <pkg>, bunx, a temp venv.
Never add them to the project's manifest or lockfile: integrators install the released project,
so an example that needs project edits misleads them.Files under <root>/examples/ in the layout of step 3. End with a table of every example file:
track, what it shows, and whether it ran (ran, not run: <reason>, cut: <reason>). After it,
list anything the user must act on: project bugs found, examples that need credentials to verify,
and pre-existing examples changed or left alone.
docs/ to ceh-documentation:write-project-docs, which picks
them up from examples/.What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
5 skills in this plugin
/write-api-referenceLoad this skill when writing a project's user-facing reference docs: every public function, endpoint, CLI flag, config key, environment variable, and error. Trigger on "write the API reference", "document every endpoint", "document all the CLI flags"./write-concept-docsLoad this skill when writing user-facing concept pages: the mental model a user needs (core objects, lifecycle, data flow, error model) and why. Trigger on "explain how this works in the docs", "write a concepts section". Not for a maintainer architecture doc./write-guides-and-runbooksLoad this skill when writing or revising task docs for users or operators: user guides, getting-started and install guides, runbooks, troubleshooting. Trigger on "write a user guide", "ops runbook", "getting-started guide". Not for a whole docs set (use write-project-docs)./write-project-docsLoad this skill when writing a complete docs set under docs/: quickstart, guides, concepts, API reference, examples, troubleshooting. Trigger on "document this project", "write the docs for this library", "build out the docs folder". Not for a README refresh.npx claudepluginhub cheneeheng/ceh-claude-code-library --plugin ceh-documentation