indexion readme — README Construction
Build project READMEs from templates, doc comments, hand-written prose, and
per-package READMEs. This skill covers the
construction side: scaffolding,
generating, planning, assembling, and verifying. For evaluating existing
documentation, see
.
Where things live
The conventions vary by project; check what actually exists before editing:
| Asset | Location patterns seen |
|---|
| Config | (repo root) or .indexion/readme/doc.json
|
| Per-package template | (no SoT constant; declared via ) |
| Static prose | , , , … |
| Per-package READMEs | , |
| Assembled root README | usually . Some projects use a suffix so the file is also a MoonBit doctest module — when so, is a symlink to . |
| / auto-load doc.json |
The first thing to check is
/
for: a symlink on
, a
(at root or under
), and
. The presence of these tells you whether the README is hand-maintained, build-assembled, or a hybrid.
Workflow overview
doc init → .indexion/readme/template.md + doc.json (greenfield)
edit doc.json + docs/*.md → declare sources of truth
doc readme --per-package → cmd/<pkg>/README.md (API skeletons; non-overwriting)
hand-write each per-package README's Overview / Usage / Options / Examples
doc readme --config → assembled root README
plan drift <prev> <new> → verify the assembled output (or hand-edit) is purely additive
Step 1: Initialize (greenfield only)
bash
indexion doc init <project-dir>
Creates
.indexion/readme/template.md
+
.indexion/readme/doc.json
. Skip this step on a project that already has
or
pointing at one.
Step 2: Configure doc.json
json
{
"$schema": "./schemas/doc-config.schema.json",
"version": "1.0",
"spec": "moonbit",
"output": { "format": "markdown", "filename": "README.md" },
"packages": [
{
"path": "cmd/<name>",
"title": "<command name>",
"include_in_root": true,
"sections": ["overview", "usage"]
}
// …one entry per package that should appear in the assembled root README
],
"root": {
"output": "README.md",
"sections": [
{ "type": "static", "file": "docs/intro.md" },
{ "type": "toc", "title": "Commands" },
{ "type": "packages", "filter": "cmd/**" },
{ "type": "static", "file": "docs/installation.md" },
{ "type": "static", "file": "docs/license.md" }
]
}
}
Root section types:
- — include a markdown file verbatim
- — insert a table-of-contents heading
- — pull in entries from the array, filtered by glob
Package fields:
- — whether to include in the assembled root README
- — README headings to extract; honored by per-package extraction
flows. Note that in the root currently emits a
table of package links, not the rich Overview/Usage expansion implied
by per-package . See "Known limitation" below.
Step 3: Generate per-package READMEs
bash
indexion doc readme --per-package src/ cmd/
Generates
in each package directory that doesn't already have one.
Non-overwriting — existing per-package READMEs are left alone.
The skeleton is API-only (extracted from
doc comments via KGF). Treat it as a starting point and hand-write the prose sections (Overview, Usage, Options, Examples) afterwards.
bash
# Single package to stdout
indexion doc readme src/kgf/lexer/
# Single package to a file
indexion doc readme -o=README.md src/kgf/lexer/
Note on side effects:
doc readme --template=<t> <paths...>
(the template-based mode below) walks the given paths and
auto-creates per-package READMEs for any package that lacks one — even without
. If you run it on a broad path (
,
), expect new files in unrelated packages. Run with a narrow path or grep
afterwards to clean up unintended creations.
Step 4: Write static content
Create
,
, etc. — whatever your
references. These are the hand-written prose; the assembler pulls them in verbatim.
Step 5: Generate writing plans (optional)
bash
indexion plan readme --template=docs/templates/readme.md --plans-dir=.indexion/plans src/
Emits per-section writing tasks for manual or LLM-assisted authoring.
Step 6: Assemble the README
bash
# Config-driven (preferred; doc.json controls layout and packages list)
indexion doc readme --config=doc.json
# Template-driven (alternative; {{include:…}} and {{packages}} placeholders)
indexion doc readme --template=docs/templates/readme.md -o=README.md cmd/
The config path can live at repo root or under
. With
's
, the
flag becomes optional.
Step 7: Verify with
After regeneration or any hand-edit of the root README, verify the change is purely additive (no silent deletions, no reflowing of unrelated sections):
bash
# Snapshot the previous version
git show HEAD:README.md > /tmp/README.before.md
# Compare against the new version
indexion plan drift --top=20 /tmp/README.before.md README.md
What to look for in the output:
Drift terms in /tmp/README.before.md (missing on the other side): (none)
— nothing was removed
Drift terms in README.md (missing on the other side): …
— exactly the new vocabulary you intended to add (command names, new flags, new concepts)
- near 1.0 for a small additive change; substantially lower if you reshaped a section
For CI integration:
bash
indexion plan drift --vocab-threshold=0.05 /tmp/README.before.md README.md
# exits 1 if cosine_distance > 0.05 — useful as a guard against accidental large rewrites
This same workflow applies to translated README pairs (
↔
): cross-lingual drift detection works natively because vocab sub-tokenization delegates to the natural-language KGFs in
.
Template syntax
The template file supports
substitution:
| Placeholder | Expansion |
|---|
| Contents of the file (relative to project root) |
| All discovered packages (filtered by CLI / ) |
| Module-level documentation only |
.indexion.toml integration
toml
[doc]
config_path = "doc.json" # auto-loads doc.json without --config
per_package = true # makes `doc readme <path>` default to --per-package
Explicit
always takes priority.
Known limitation: root section produces a table, not rich expansion
The
permits
sections: ["overview", "usage", …]
on each
, but the current
implementation does not expand those sections inline when emitting
in the root. The output is a markdown table of package links with empty descriptions.
Two practical consequences:
- If the project's checked-in root README has rich per-command Overview / Usage paragraphs, they were not produced by as it stands now. They are hand-maintained. Diff
doc readme --config -o=/tmp/regen.md
against the checked-in README to see how much of it is hand-curated; very large diffs mean the README is mostly hand-maintained.
- For new commands, you currently need to also hand-edit the rich section into the assembled README, in addition to adding the package entry to and writing the per-package README. Use the verification above to confirm the hand-edit only adds, never removes.
If you fix this limitation (so
honors per-entry
), update this skill to remove this section.
Common pitfalls
"doc readme --per-package generated nothing"
- All packages already have READMEs. The command only creates new files,
never overwrites. Delete existing READMEs first to regenerate.
"doc readme --template … on created READMEs in packages I didn't touch"
- Template mode auto-generates missing per-package READMEs as a side effect.
Either pass a narrow path, or revert unintended creations from .
"Auto-generated per-package READMEs are just API listings"
- By design. Hand-write Overview, Usage, Options, Examples. For CLI commands,
the authoritative behavior comes from
indexion <command> --help
.
"My hand-edit to README.md will be wiped out by "
- It will if the assembler ever produces the rich shape (see "Known
limitation"). Until then, the assembler produces a strict subset (the
table) and your hand-edits to the rich sections survive. Always run the
cross-check to be sure.
"README.md edit destroyed unrelated sections"
- Run
plan drift HEAD:README.md README.md
and look at the "missing on the
other side" output for the previous version. If it lists anything other
than , you removed content.