doctest-conventions

doctest-conventions is a skill for Claude Code from padamson/playwright-rust. It costs 49 tokens per session (732 once invoked), scanned A, original, Apache-2.0.

Guidelines for writing Rust documentation examples that are checked by the compiler as doctests.

In plain words
What is it for?
Use it when adding or reviewing rustdoc examples, especially examples involving browser automation or the Playwright server.
Why use it?
They help documentation stay correct over time and explain when browser-based examples should be compiled without being run.

Skill for Claude Code

Written for Claude Code: installed under .claude/.

Part of the playwright-rust plugin — 4 skills shipped together

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/padamson/playwright-rust/doctest-conventions
Any agent
npx skills add padamson/playwright-rust --skill doctest-conventions
Clone the repo
git clone --depth 1 https://github.com/padamson/playwright-rust

Made for: Claude Code.

Or install playwright-rust, the plugin that ships this one along with the rest of its 4 skills.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for doctest-conventions

README.md
[![agentmods](https://agentmods.dev/badge/skills/padamson/playwright-rust/doctest-conventions.svg)](https://agentmods.dev/skills/padamson/playwright-rust/doctest-conventions)
Your own site
<a href="https://agentmods.dev/skills/padamson/playwright-rust/doctest-conventions"><img src="https://agentmods.dev/badge/skills/padamson/playwright-rust/doctest-conventions.svg" alt="Measured on agentmods" height="20"></a>
Per session 49 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 732 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00049 $0.00732
Opus 5 $0.00024 $0.00366
Sonnet 5 $0.00010 $0.00146
Haiku 4.5 $0.00005 $0.00073

Measured 6d ago against content hash 0b708b51e60f, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

doctest-conventions scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 6d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/skills/doctest-conventions/SKILL.md · 89 lines

How it starts

The opening of the file, as written. The whole thing — 89 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Doctest Conventions

Philosophy: documentation that cannot rot

Every rustdoc example is compile-checked on every cargo test --doc (pre-commit and CI). Browser automation can't execute in a doctest harness, so examples are compiled but not run — same contract as the agent-doc snippets (verify-agent-docs) and landing-page snippets (verify-site-snippets).

The annotation: no_run

no_run  — compiled every time, never executed.  ← use this
ignore  — never compiled, never executed; rustdoc only highlights it.
(none)  — compiled AND executed; only for pure, browser-free examples.

Use ```no_run for anything that would launch a browser or talk to the Playwright server. Plain ```rust is fine for pure logic (selector builders, option construction) that can really execute.

Never use ```ignore except when the code genuinely cannot compile in this crate — the only sanctioned case is the macros/trace crates' module docs showing downstream playwright-rs usage, which would need a cyclic dev-dependency to compile.

History. Until 2026-06, the convention was ignore + a CI step running cargo test --doc -- --ignored, believed to execute them. It never did: rustdoc surfaces ignore blocks as empty always-pass stubs (83 "passed" in 0.00s). The examples had zero protection and ~10 had silently rotted. no_run is what the convention always intended.

Structure

Prefer one comprehensive module-level doctest (//!) per protocol file, demonstrating related APIs in a realistic scenario. Per-function examples are allowed where they pull their weight — they must compile like everything else.

Use hidden scaffolding lines (# -prefixed) so the rendered docs show only the instructive lines while the compiler sees a complete program:

/// # Example
///
/// ```no_run
/// # use playwright_rs::Playwright;
/// # async fn example() -> Result<(), Box<dyn std::error::Error>> {
/// # let pw = Playwright::launch().await?;
/// # let page = pw.chromium().launch().await?.new_page().await?;
/// page.goto("https://example.com", None).await?;
/// let title = page.title().await?;
/// # Ok(())
/// # }
/// ```

Read the full file on GitHub · 89 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 6d ago First seen · 89 lines · 49 tokens per session scan A 0b708b51e60f

Subscribe to this mod's changes

doctest-conventions is a skill published in the GitHub repository padamson/playwright-rust (143 stars, last pushed 6d ago), licensed Apache-2.0. It adds 49 tokens to every session and 732 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.