# Digest Index Skill
Trigger this skill when the user asks to **update the digest index**, **generate the digest index**, **regenerate `digests/README.md`**, or otherwise refresh the index/table of contents of the `digests/` directory.
## What this skill does
Scans every digest file in `digests/` and regenerates `digests/README.md` as a single Markdown table, sorted newest-first, that serves as an index of every digest ever produced. Each row lists the digest's date (or date range), its type, which sources had activity, and a brief note on the notable cross-notebook themes.
**This index is always regenerated from scratch.** Never append to or edit the existing `digests/README.md` incrementally — read the current digest files, rebuild the whole table, and overwrite the file completely. This keeps the index correct even when digests are deleted, renamed, or edited.
## Steps
1. **List the digest files.** From the repository root, list the Markdown digests to index:
```bash
git ls-files --cached --others --exclude-standard 'digests/*.md'
```
This lists tracked files plus untracked-but-not-ignored files, and automatically **excludes anything gitignored**. Then drop two entries from the result:
- `digests/README.md` (the index itself — never index the index)
- `digests/.digest-state.json` is not a `.md` file so it won't appear, but never include it regardless.
If the glob returns nothing, still generate a `README.md` with the header and an empty-state note ("_No digests yet._") instead of a table.
2. **Parse each remaining file.** Read each file and extract four things:
- **Date / date range** — read it from the H1 title line, which looks like `# <Something> — <start> to <end>` and may carry a `(N days)` suffix (e.g. `# Full Lab Digest — 2026-07-27 to 2026-07-30 (4 days)`). Record the range as `<start> to <end>`. If the title has a single "Week of" date or a lone date, record that. If no parseable date appears in the title, fall back to the `YYYY-MM-DD` date embedded in the filename.
- **Type** — infer from the filename:
- starts with `full-lab-digest-` → **full-lab-digest**
- starts with `weekly-lab-digest-` → **weekly-lab-digest**
- starts with `tumbling-oysters-` → **tumbling-oysters** (single source)
- starts with `ariana-` → **ariana-notebook** (single source)
- starts with `sams-` → **sams-notebook** (single source)
- starts with `grace-` → **grace-notebook** (single source)
- starts with `wordpress-` → **wordpress** (single source)
- a bare `YYYY-MM-DD.md` with no prefix → **weekly-lab-digest** (these are the WordPress-only weekly digests)
- anything else → derive a sensible type from the filename prefix and note it.
- **Sources with activity** — which notebooks actually had new posts in this digest:
- **Full digests** are organized into `## <Source>` sections. A source "had activity" if its section contains real post content; it did **not** if the section body is only a placeholder such as `_No new posts…_` or `_No posts…_`. When tallying sources, ignore the non-source sections `## Cross-Notebook Patterns & Connections` and `## Literature Connections`.
- **Single-source digests** cover exactly one source; mark it active if the file contains any posts.
- Report sources using these short labels: `Tumbling Oysters`, `Ariana Huffmyer`, `Sam White`, `Grace Crandall`, `WordPress`. Join multiple with commas. If none had activity, write `none`.
- **Notable themes** — if the file contains a `## Cross-Notebook Patterns` section (heading may read `## Cross-Notebook Patterns & Connections`), read the bolded theme leads under it (the `- **…**` items, typically under `### Shared Themes`) and write a brief one-line note (roughly ≤ 20 words) capturing the standout connection(s). If there is no such section, write `—`.
3. **Sort newest-first.** Order rows by the end date of the range descending (for single-date entries use that date). Break ties by the date embedded in the filename, then filename, descending, so same-day digests stay grouped.
4. **Write `digests/README.md`**, overwriting it entirely, with this structure:
```markdown
# Digest Index
> Auto-generated by the `digest-index` skill. Regenerated from scratch — do not edit by hand.
| Date | Type | Sources with activity | Notable themes |
|------|------|-----------------------|----------------|
| 2026-07-28 to 2026-08-03 (7 days) | full-lab-digest | Sam White, Grace Crandall, WordPress | Sea-star GO-enrichment pipelines span Grace's and WordPress notebooks |
| … | … | … | … |
```
Escape any `|` characters that appear inside a cell's text as `\|` so the table stays valid. Keep the theme note concise — this is an index, not a summary.
5. **Report** to the user how many digests were indexed and confirm `digests/README.md` was regenerated.