/context-wikis:index-mdfrom context-wikis
Create or refresh INDEX.md files -- per-directory tables of contents that make file trees discoverable to agents. Use when a directory should be navigable without opening every file, when files were added, removed, or renamed in a directory that has an INDEX.md, when migrating an older lowercase index.md, or when asked to improve discoverability of docs/, a wiki, agent memory, or a reference collection.
Ships in context-wikis. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
An INDEX.md gives its directory a table of contents, so a reader opens only
what is relevant instead of crawling the tree. The name is uppercase, like
README.md and AGENTS.md: the file describes the directory rather than being
one of its documents, it sorts to the top of a listing, and a lowercase
index.md stays free for ordinary use. It is plain markdown -- no
frontmatter -- and it has four parts with three different owners:
# docs <- title. Yours.
Project documentation and specs. <- description. Yours.
- [Architecture](architecture.md): how the pieces fit
- [architecture.png](architecture.png): <!-- to-do -->
- [wip](wip/): work items in progress
^- the list. The generator's.
<!-- pinned -->
- [Upstream](https://example.com/): the spec we follow
^- pinned. Yours.
The title is the H1. The generator writes the directory's own name there when it creates the file, and never touches it again. The parent directory's index reads it as this directory's label.
The description is the first paragraph, and it is yours entirely. Say what belongs in the directory, so that a writer can tell where a new file goes. It is absent until you write it, and reported as a gap until you do. The parent's index reads it as this directory's description -- that is how a description propagates up the tree.
The list belongs to the generator. It writes every link, merges in labels
and descriptions, sorts by label, and drops entries whose file is gone. A
description you type here is kept. <!-- to-do --> marks one still missing.
The pinned block is yours, copied through verbatim and never reordered or dropped. Use it for a link the generator would otherwise manage badly or throw away: a member whose own frontmatter is wrong and not yours to fix, or a link to anything that is not a file in this directory.
Generate. Never write the list by hand. The generator is
scripts/generate_index.py next to this SKILL.md (stdlib-only, plain
python3). Resolve it against the base directory reported when this
skill was loaded. Run it only from this skill; other skills and agents
that need indexes go through /index-md.
python3 <skill-base-dir>/scripts/generate_index.py <dir> # one directory
python3 <skill-base-dir>/scripts/generate_index.py <dir> -r # whole tree, bottom-up
python3 <skill-base-dir>/scripts/generate_index.py <dir> --include '*.png' # also list matching files (repeatable)
python3 <skill-base-dir>/scripts/generate_index.py <dir> -r --exclude inbox/ # leave members out (repeatable)
--exclude matches the way .gitignore does: a pattern with no slash
matches a name at any depth, one with a slash matches the path from <dir>,
and a trailing slash matches directories only. An excluded directory is not
descended into. It wins over --include.
--refresh-only regenerates existing files and never creates one -- the
mode for machinery, since a new INDEX.md needs its description authored.
--max-desc-len N sets the description budget (default 250).
Write the description paragraph for any index the run reports without one.
Fill the <!-- to-do --> gaps. The report names where each belongs, because
the right place depends on what the entry points at:
.md file -> description in its frontmatterINDEX.mdINDEX.md..md file contributes its frontmatter name and description. title
is accepted in place of name, as the older spelling. Without either, the
label falls back to its first H1, then its filename. A first
paragraph is not read as a description outside an INDEX.md -- lifting a
sentence out of someone's prose would fill the index with descriptions nobody
wrote.diagram.png -> diagram), and is listed only when it matches an
--include pattern or already appears in the index.INDEX.md.--include set, unless it is excluded. Everything else goes: a vanished member, a ../ path, a
path into a subdirectory, a URL, a link to a section of a file. Each drop is
reported with the entry's full text, so the description survives in the run's
output. Pinning is how you keep such a line.<!-- pinned --> marker is a fatal error -- the generator will not guess
where to put your text.-r, the named directory gets one.-r, every directory that is not excluded gets one, even an empty
directory. Its description says what belongs there, which ls cannot. Use
--exclude for directories that should have no index.--refresh-only creates none.changed: is what the run did to text that already existed. needs attention:
is what you may want to fix -- an index without a description, a placeholder
still to fill, a dropped entry, a description over the budget, two files whose
labels collide, a pinned link whose target is missing, a subdirectory whose
index still carries the old index.md name.
A pinned link to a file that no longer exists is reported and never removed.
That is the one way an INDEX.md can end up pointing at nothing, so fix it when
you see it.
Two kinds of older index are fatal errors naming --migrate: one still named
index.md, and one carrying frontmatter. That flag converts either, or both at
once, in the same pass that regenerates the file. index.md is renamed to
INDEX.md. The frontmatter block is removed, and it supplies only what the body
lacks. The body wins, and anything the frontmatter did not contribute is quoted
in the report before it is discarded. A file the generator cannot parse is left
exactly as it was, name included.
On a case-insensitive filesystem, git (with core.ignorecase, the default
there) does not notice a rename that only changes case. Record it by hand:
git rm --cached -q <dir>/index.md && git add <dir>/INDEX.md
Next to an INDEX.md, a lowercase index.md is an ordinary member, listed like
any other .md file. That can only happen on a case-sensitive filesystem. On a
case-insensitive one (macOS by default), a file spelled Index.md or similar
holds the name, so the generator refuses to write INDEX.md over it.
What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub a3lem/knowledge-powerups --plugin context-wikis2 skills in this plugin