Skills DirectorySkills Directory
SkillsLearnSecurityCategoriesDocsBlogPro
Sign InSubmit Skill
Skills Directory

Security-tested agent skills for Claude, coding agents, and AI workflows.

Directory

  • Browse Skills
  • All Skills A–Z
  • Claude Skills
  • Claude Code Skills
  • Agent Skills
  • Categories
  • Authors
  • Submit a Skill

Learn

  • Learn Hub
  • Install Claude Skills
  • Write SKILL.md
  • Skills vs MCP
  • Directories Compared

Security

  • Security
  • Methodology
  • Secure Claude Skills
  • Security Badges
  • Chrome Extension
  • Skill Manager

Company

  • About
  • Community
  • Blog
  • API Docs
  • Advertise

2026 Skills Directory. All rights reserved.

ProTermsPrivacyRefunds
Back to skills

Example Testing Setup

ASecurity

Setup guide for testing code examples in documentation CI — covers doctest, snippet extraction, execution sandboxing, and the failure-handling policy to ensure every published example actually runs.

7 stars
0 votes
0 copies
0 views
Added 9/23/2026
ai-agentspythonshellbashnodeexpressdockertestinggitapidocumentation

Works with

cliapi

Security Analysis

A96/100
mediumInstalls packages at runtime which could introduce malicious dependencies

Pro shows the line behind each finding and how to fix it

Scanned 9/23/2026

$npx -y skills add mcorbett51090/RavenClaude --skill example-testing-setup --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Example Testing Setup?

Add the live security badge to your README — it updates automatically with every re-scan.

Security grade badge for Example Testing Setup
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/mcorbett51090-example-testing-setup/badge)](https://www.skillsdirectory.com/skills/mcorbett51090-example-testing-setup)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
Files
SKILL.md
---
name: example-testing-setup
description: "Setup guide for testing code examples in documentation CI — covers doctest, snippet extraction, execution sandboxing, and the failure-handling policy to ensure every published example actually runs."
---

# Example Testing Setup

## When to Use This

Your docs contain code examples that may silently rot as the API evolves. Use this skill to wire example testing into CI so every example is verified on every PR and release.

## Strategy Selection

| Doc toolchain | Example type | Recommended approach |
|---|---|---|
| Any | Shell/CLI commands | Extract + run in CI with `script -q -c "..."` or bash |
| Python project | Python snippets | doctest or pytest with extracted snippets |
| Node/JS project | JS/TS snippets | Jest or Vitest with imported snippet files |
| OpenAPI spec | Request/response examples | Dredd or Schemathesis against a running service |
| Any | Multi-language | mdbook's `{{#include}}` or Docusaurus `@theme/CodeBlock` with test runner |

**Core principle:** examples live in source files that are imported into docs, never pasted inline. The test runs the source file; the doc renders it.

## Pattern 1 — Include-from-File

Instead of inline fenced code blocks, maintain runnable source files:

```
docs/
  examples/
    quickstart.py       ← the actual runnable file
    auth-example.py
  quickstart.md         ← imports from examples/
```

In Docusaurus MDX:
```mdx
import CodeBlock from '@theme/CodeBlock';
import QuickstartSource from '!!raw-loader!./examples/quickstart.py';

<CodeBlock language="python">{QuickstartSource}</CodeBlock>
```

The test CI step simply runs all files under `docs/examples/`:

```yaml
- name: Test documentation examples
  run: |
    for f in docs/examples/*.py; do
      echo "Testing $f"
      python "$f" || exit 1
    done
```

## Pattern 2 — Doctest (Python)

Embed testable examples directly in docstrings and markdown using `doctest`:

```python
def calculate_discount(price: float, pct: float) -> float:
    """
    >>> calculate_discount(100.0, 10)
    90.0
    >>> calculate_discount(50.0, 0)
    50.0
    """
    return price * (1 - pct / 100)
```

CI step:
```yaml
- name: Run doctests
  run: python -m doctest -v docs/**/*.md
```

Limit doctest to **self-contained expressions**. Long setup sequences belong in Pattern 1.

## Pattern 3 — OpenAPI Request/Response Validation

For API reference docs, validate that request/response examples in the OpenAPI spec actually match the live service:

```yaml
# Using Schemathesis
- name: Test API examples
  run: |
    schemathesis run docs/openapi.yaml \
      --base-url http://localhost:8080 \
      --checks all \
      --contrib-openapi-formats-uuid \
      --hypothesis-max-examples 50
```

Or with Dredd for exact example matching:
```yaml
- name: Dredd API tests
  run: dredd docs/openapi.yaml http://localhost:8080
```

## CI Integration

```yaml
# .github/workflows/docs.yml (relevant excerpt)
jobs:
  test-examples:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: '3.12'
      - name: Install dependencies
        run: pip install -r requirements.txt
      - name: Start service
        run: docker compose up -d && sleep 5
      - name: Test examples
        run: make test-docs-examples
      - name: Link check
        run: npx --yes @umbrellio/check-links docs/
```

## Failure Handling Policy

When an example fails in CI:

1. **The PR is blocked** — a failing example is a bug in the docs, not a documentation style issue.
2. **The fix must come before the merge** — no exceptions for "we'll fix the docs later."
3. **If an example is intentionally broken** (illustrating an error condition), mark it explicitly:
   ```python
   # This example deliberately raises an error:
   # >>> connect_without_auth()
   # AuthenticationError: No credentials provided
   ```
   Wrap it in an expect-failure harness or exclude it from the test runner with a comment.

## Pitfalls

- Inline copy-pasted examples that drift from the actual API — fix by using Pattern 1 (include from file).
- Testing examples only against a mock/stub service — if the mock is out of date, examples can pass and still be wrong for real users. Run against a real service in at least one CI stage.
- Letting the example test job be advisory (allowed to fail) — the moment it's advisory, nobody fixes it and it becomes noise within weeks.
- Long-running setup in examples — each example should set up and tear down its own state; shared state between examples makes failures hard to diagnose.

## See Also

- [`../../agents/docs-site-engineer.md`](../../agents/docs-site-engineer.md) — CI build/deploy, link-checking, and example testing wiring
- [`../../agents/api-reference-writer.md`](../../agents/api-reference-writer.md) — runnable examples in API reference

Attribution

mcorbett51090mcorbett51090
View sourceSee grades on GitHubMore from mcorbett51090 →
SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments (0)

No comments yet. Be the first to comment!

SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Related Skills

Caveman

Terse caveman voice: answer first, fluff gone, every technical fact kept. Use for /caveman, "caveman mode", "talk like caveman", "be brief", "less tokens". Stays on until "stop caveman" or "normal mode".

1100021 votes

Hyperplan

Adversarial multi-agent planning skill. Self-orchestrates 5 hostile category members (unspecified-low, unspecified-high, deep, ultrabrain, artistry) via team-mode for ruthless cross-critique debate, distills only the defensible insights, then MANDATORILY hands the distilled insight bundle to the `plan` agent for executable plan formalization. Use when planning needs maximum rigor and surfacing of weak assumptions, blind spots, and over-engineering. Triggers: 'hyperplan', 'hpp', '/hyperplan', ...

698621 votes

Writing Skills

Create and manage Claude Code skills in HASH repository following Anthropic best practices. Use when creating new skills, modifying skill-rules.json, understanding trigger patterns, working with hooks, debugging skill activation, or implementing progressive disclosure. Covers skill structure, YAML frontmatter, trigger types (keywords, intent patterns), UserPromptSubmit hook, and the 500-line rule. Includes validation and debugging with SKILL_DEBUG. Examples include rust-error-stack, cargo-dep...

3931 votes

Mcp Code Execution

Routes multi-tool workflows through MCP servers for large datasets and pipelines. Use when Bash tool overhead is limiting throughput on data-heavy tasks.

3421 votes

catchup

Recovers the conversation and failed tool calls of a previous Codex, Amp, Claude Code, Antigravity, Cline, Copilot CLI, Cursor, DeepSeek Harness, Grok Build, Kimi, OpenCode, Pi Agent, or ZCode session. Use when the user says "catch up", "what did the last session do", "get me up to speed", "I switched agents", asks to recover/summarize a previous session before continuing, or asks to diagnose or report a catchup failure. Do NOT use for the current conversation, git history, or any non-agent log.

741 votes
View all in ai-agents →