From mcclowes-skills
Context-efficient codebase navigation and documentation using structured frontmatter headers. Use this when exploring an unfamiliar codebase, answering "where is X / how does Y work" questions, or when asked to add/maintain file-level documentation. Index a tree's headers in one pass instead of reading every file, and generate or validate frontmatter with the bundled scripts. Reach for it whenever token budget matters while navigating code, even if the user does not say "frontmatter".
How this skill is triggered — by the user, by Claude, or both
Slash command
/mcclowes-skills:code-frontmatterThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
A frontmatter block is a short YAML header in a comment at the top of a source file describing its **purpose** and its **related** files. The point is leverage: a 300-line file's header costs ~50 tokens to read instead of ~1500 for the whole file, so you can map a codebase from headers and only open the files that actually matter.
A frontmatter block is a short YAML header in a comment at the top of a source file describing its purpose and its related files. The point is leverage: a 300-line file's header costs ~50 tokens to read instead of ~1500 for the whole file, so you can map a codebase from headers and only open the files that actually matter.
There are two modes, and a codebase has to be in the first before the second pays off:
generate script does the mechanical part.index script does it in a single pass.Don't read the example files or SPECIFICATION.md unless you need the full schema — this file is enough for the common case.
scripts/frontmatter.py is stdlib-only (no install). Prefer it over doing this by hand — one script call beats N file reads.
# Navigate: print every documented file's purpose + related, in ONE pass.
# Also lists substantive files that are missing frontmatter (coverage gap).
python scripts/frontmatter.py index <dir> [--format md|json] [--min-lines N]
# Author: emit a skeleton header (purpose: TODO + related seeded from imports).
# --write inserts it in place (after any shebang); omit to print to stdout.
python scripts/frontmatter.py generate <file> [--write]
# Maintain: check frontmatter parses, has a purpose, and `related` paths resolve.
python scripts/frontmatter.py validate <dir> # exit 1 if any issue
Adjust the path to wherever the skill lives. If Python isn't available, the manual workflows below still apply.
Index the headers in one pass. Run index <dir>. You get every file's purpose and related links plus a list of substantive files lacking headers — far cheaper than reading files one by one.
If there are no scripts available, batch-read headers instead of opening whole files. One Grep for purpose: across the tree surfaces every header at once:
Grep pattern="^\s*[#*/!-]*\s*purpose:" output_mode="content" -n=true glob="*.{ts,py,go,rs}"
For a single file, Read it with limit: 20 to see only the header.
Build the map, then load selectively. From purposes and related links, decide which files are relevant. Only open a full file when you'll modify it or genuinely need its implementation. Follow related to discover connected files without loading them.
No frontmatter? Say so and fall back. If the codebase has little or no frontmatter, this skill's navigation benefit is limited — read files directly, and offer to add frontmatter (authoring mode) if the user will revisit this code.
When asked to document files, or when you notice a codebase would benefit:
Generate skeletons. Run generate <file> per file (or loop over a directory). It pre-fills related from the file's internal imports and leaves purpose as a TODO — you fill in the judgment calls.
Write a purpose that earns its tokens. State what the file does and why someone would open it — not a restatement of the filename. "Genetic algorithm for FPL squad optimisation" beats "GA module". Trim related to the files a reader would actually jump to.
Validate before you finish. Run validate <dir>; fix any unresolved related paths or empty purposes.
Be selective about what gets a header. Frontmatter is an index, not blanket documentation. Add it to files that carry responsibility someone would search for. Skip: files under ~30 lines, test files, index/barrel files (unless re-exports are non-obvious), and config files.
Two fields carry almost all the value. Everything else is optional and usually better expressed elsewhere (types, git history) — add it only when it genuinely aids navigation.
| Field | Status | Description |
|---|---|---|
purpose | required | One line: what the file does and why you'd open it (≤120 chars). |
related | recommended | Connected files as path - reason. The most valuable nav field. |
inputs | optional | Key parameters/data the file expects, as name: type - desc. |
outputs | optional | Main return values/side effects, as name: type - desc. |
note | optional | Non-obvious context (e.g. naming history, gotchas). |
Avoid dependencies (imports already say this), exports (types/export already say this), usage (prefer a doctest/JSDoc @example), and modified (git history is authoritative and never goes stale). Stale frontmatter is worse than none — it lies confidently — so document only what the header can keep true.
The block is always delimited by --- lines inside the file's leading comment. generate produces the right wrapper automatically; these are for reference.
"""
---
purpose: Brief description
related:
- ./other.py - relationship
---
"""
/**
* ---
* purpose: Brief description
* related:
* - ./other.ts - relationship
* ---
*/
/*
---
purpose: Brief description
---
*/
//! ---
//! purpose: Brief description
//! ---
Ruby, shell, and YAML use #-prefixed lines (after any shebang). See SPECIFICATION.md for the complete per-language reference and the full optional-field list.
Creates, edits, and optimizes skills for Claude Code, including drafting, evaluating with test prompts, iterating on performance, and improving skill descriptions for better triggering accuracy.
npx claudepluginhub mcclowes/skills --plugin mcclowes-skills