AGENT SKILL

index

Use after creating, promoting, or editing docs in a directory whose INDEX.md should be regenerated, when frontmatter needs validating against the documentation standard, or to audit knowledge-base health. The sole writer of INDEX.md files.

License 许可
Apache-2.0
最近更新
2026-11-15
Stars
★ 0
Forks
1

01 前言 Front Matter

name
index
requires
[ { "cli": "claudron", "reason": "Optional — engine-managed-root detection in Step 1 only (a `(claudron vault)` root is never indexed); without it, index degrades per the standard notice in ../_shared/claudron-engine.md §3.1 and treats the target as a raw tree" } ]
description
Use after creating, promoting, or editing docs in a directory whose INDEX.md should be regenerated, when frontmatter needs validating against the documentation standard, or to audit knowledge-base health. The sole writer of INDEX.md files.
argument-hint
[directory-path] [--validate-only] [--recursive] [--fix] [--stale]
user-invocable
true

03 SKILL.md 正文

Index

Codex: Read ../_shared/codex-tools.md before following this skill. Apply its tool, root and dispatch mappings throughout.

Scan, validate, and index shared documentation. INDEX.md is the discovery layer — other bots scan it to find relevant docs without reading every file.

This skill is the SOLE writer of INDEX.md files. Other skills (/claudna:capture, /claudna:publish) create or update docs, then call /claudna:index to regenerate the index.

Arguments

Parse $ARGUMENTS at invocation:

  • First positional arg: Directory path to index. Defaults to the shared docs root, resolved per ../_shared/documentation-standard.md §10 ("locating the root" — env override, else the CLAUDE.md ## Shared Documentation section; env wins on disagreement, note the mismatch). §10 owns which env name applies; do not re-derive it here. No root resolves → detect from cwd.
  • --validate-only: Check frontmatter without regenerating INDEX.md.
  • --recursive: Index all subdirectories, not just the target.
  • --fix: Auto-fill missing required fields where inferrable.
  • --stale: Flag docs past their expires: date; apply the >90-day age checks below according to the document's role.

Step 1: Discover Documents

Engine-managed roots are never indexed. If the target is a root annotated (claudron vault) in CLAUDE.md's ## Shared Documentation section, or came from the engine env var, stop and emit §10's engine-managed-root message (../_shared/documentation-standard.md §10, Annotation semantics — including its env-derived suffix). The engine owns vault indexing; an INDEX.md written there would be stale on arrival.

With Claudron absent, say so rather than assuming. The annotation above is the only signal that survives without the CLI, so a root that is engine-managed but carries no annotation is indistinguishable from a raw tree. When claudron is not on PATH, emit the standard degradation notice (../_shared/claudron-engine.md §3.1 — the /claudna:index row) before indexing, and in --auto put the same line in errors[]. Indexing an unannotated engine-managed root is the failure this notice exists to make visible; it is never a silent assumption.

Walk all .md files in the target directory (excluding INDEX.md itself).

# Find all markdown files, skip INDEX.md
find <target-dir> -maxdepth 1 -name '*.md' ! -name 'INDEX.md' -type f | sort

If --recursive, walk subdirectories too. Each subdirectory gets its own INDEX.md.

Step 2: Parse and Validate Frontmatter

For each file, read and parse YAML frontmatter. Validate against the schema (vocabulary SSOT: ../_shared/output-guide.md §3 — the repo's only type/status enum table):

Required fields:

Field Type Validation
title string Non-empty
type enum A valid note type per the output-guide §3 vocabulary table
status enum Valid for the type per the §3 table — canonical or accepted legacy (legacy gets a mapping note, not an error)
owner string Non-empty
created date Valid YYYY-MM-DD

Pass-through fields (accepted, never flagged, never required — output-guide §3): maturity, schema_version, and any x-*-prefixed field. Index reads past them; they are never validation errors.

For each validation error, record: file path, field name, issue (missing, invalid value, wrong type).

--fix Mode

When --fix is set, auto-fill missing fields where inferrable:

  • created: — use file modification time (stat or git log --format=%aI --diff-filter=A -- <file>)
  • owner: — use git log --format=%an -1 -- <file>
  • status: — default per type: current for knowledge/runbook, draft for plan/decision/audit/review (the §3 type defaults; unchanged by the SSOT rendering)
  • type: — infer from parent directory name if possible (planning/ → plan, knowledge/ → knowledge, decisions/ → decision, runbooks/ → runbook)

Write the fixed frontmatter back to the file. Report each auto-fix applied.

--stale Mode

When --stale is set, check expires: on every document and flag any date in the past, including on historical records.

If a document is a settled historical decision record whose content preserves a past choice rather than current guidance, skip the age checks below. Otherwise, apply every age check below, including to living policies/runbooks and abandoned drafts. Establish that role from the content and existing type/status; a folder name or type: decision alone does not establish it.

  • No updated: field and created: is >90 days ago
  • updated: is >90 days ago
  • last_verified: is >90 days ago

Report stale docs separately from validation errors.

Step 3: Regenerate INDEX.md

Skip this step if --validate-only is set.

Sort documents:

  1. Primary: active/current/ratified/draft first, then completed/stale/superseded/archived
  2. Secondary: alphabetical by title

Generate INDEX.md with one line per doc, including inline tags for grep-friendly filtering:

# Index: <directory-name>

- [Title](filename.md) — description (status: active, owner: greg, tags: auth, oauth)
- [Another Doc](another.md) — description (status: current, owner: clog)

The description is the first sentence of the document body (after frontmatter), truncated to 80 characters. If the doc has a description: in frontmatter, use that instead.

Write the generated INDEX.md to the target directory.

Step 4: Report

Output a summary:

Indexed: <target-dir>
  Documents: N
  Validation warnings: M
  Stale (if --stale): K
  Auto-fixed (if --fix): J

Warnings:
  - path/to/file.md: missing required field 'owner'
  - path/to/other.md: invalid status 'done' for type 'plan'

Stale:
  - path/to/old.md: expires 2026-03-01 (expired 71 days ago)

Rules

  • Never modify document content — only frontmatter (and only with --fix).
  • INDEX.md is always fully regenerated, never appended to. This avoids stale entries.
  • If the target directory doesn't exist, error clearly — don't create it.
  • Never index an engine-managed root — Step 1's refusal applies before any walk.
  • If no .md files are found (excluding INDEX.md), write an empty INDEX.md with just the header.

$ARGUMENTS

04 同仓库更多 Skills