Skip to content
Back to skills

Code Examples

ASecurity

Add runnable, tested code examples to docs so snippets stay correct and never drift from the API.

  • 3 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added September 3, 2026
ai-agentsgoapi

Works with

  • api

Security analysis

A100/100

Scanned September 3, 2026

npx -y skills add black141312/ada --skill code-examples --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Code Examples?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Code Examples
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/black141312-code-examples/badge)](https://www.skillsdirectory.com/skills/black141312-code-examples)

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

Download with Pro
SKILL.md
---
name: code-examples
description: Add runnable, tested code examples to docs so snippets stay correct and never drift from the API.
category: docs
---

# Code Examples

Use when docs contain code snippets that must actually work — the most damaging doc bug is an example that no longer compiles or runs.

1. Make each example minimal and complete: imports included, no `...` hand-waving, runnable as-is.
2. Show the expected output or result right after the code so readers can confirm they got it right.
3. Extract examples to real source files in an `examples/` dir, then embed them into docs via includes/snippets rather than pasting.
4. Test them: compile/run examples in CI (doctests, `cargo test --doc`, `pytest --doctest`, or a script that executes each `examples/*`).
5. Pin the language/SDK version the examples target and state it, so readers know the context.
6. Cover the happy path first, then one error-handling example — real usage needs both.
7. Re-run examples on every release; a failing example fails the build.

## Rules
- Tested in CI or it will rot — untested examples drift from the API within one release.
- Single source of truth: keep code in real files and include it, don't maintain two copies.
- Examples must be complete and runnable; no pseudo-code, no elided imports.
- Show expected output; an example without a result leaves the reader guessing.
- Prefer realistic, idiomatic usage over contrived `foo`/`bar` that teaches nothing.

Attribution

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

Loading comments…