docs-validate-code-samples

A documentation checker for code examples in Markdown files. It verifies details such as language labels, callouts, JSON format, ES|QL queries, and Painless scripts.

In plain words
What is it for?
Use it to audit code blocks in Elastic documentation before review, while writing new examples, or when checking a whole directory of Markdown files.
Why use it?
It catches example errors that can confuse readers or make copied code fail. It reports the issues and leaves the documentation unchanged.

Skill for Claude CodeCodex

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/elastic/elastic-docs-skills/docs-validate-code-samples
Any agent
npx skills add elastic/elastic-docs-skills --skill docs-validate-code-samples
Clone the repo
git clone --depth 1 https://github.com/elastic/elastic-docs-skills

Made for: Claude Code, Codex.

Per session 55 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,117 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. 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 $0.00055 $0.03117
Opus 5 $0.00028 $0.01558
Sonnet 5 $0.00011 $0.00623
Haiku 4.5 $0.00006 $0.00312

Measured 2d ago against content hash 199459a011bc, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

docs-validate-code-samples scanned grade A with 1 finding 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 2d 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.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

Infer the correct identifier from content: HTTP method line → `console`; starts with `{`/`[` → `json`; `key: value` lines → `yaml`; `curl`/`apt-get` → `bash`; `import`/`def`/`print(` → `python`; `public class` → `java`;
skills/review/docs-validate-code-samples/SKILL.md · 218 lines

How it starts

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

You are a code sample validator for Elastic documentation. Check every code block in one or more markdown files against the docs-builder style rules and report all violations.

Never modify documentation source files. Only analyze and report.


Step 1: Resolve files

Parse $ARGUMENTS for an optional --output <path> flag (strip it before continuing). Resolve the target:

  • Single .md file — analyze that file only.
  • Directory — find all .md files recursively with find <dir> -name "*.md" -type f | sort.
  • Glob — expand with bash -O globstar -c 'printf "%s\n" <glob>'.
  • No argument — ask: "Please provide a file path, directory, or glob pattern."

Step 2: Extract code blocks

For each file, use Grep with pattern ^``` to find fence line numbers, then Read the file to extract blocks. Also search for indented fences (^\s+```) to catch blocks inside list items.

  • Skip blocks inside HTML comments (<!-- ... -->).
  • Skip MyST directive blocks where the info string starts and ends with {} (e.g., ```{note}).

For each block capture: opening line number, fence info string, language identifier (first word), attributes (remaining tokens), and body.

Read the full file on GitHub · 218 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

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. 2d ago First seen · 218 lines · 55 tokens per session scan A 199459a011bc

Subscribe to this mod's changes

docs-validate-code-samples is a skill published in the GitHub repository elastic/elastic-docs-skills (71 stars, last pushed 4d ago), licensed Apache-2.0. It adds 55 tokens to every session and 3,117 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.