home/roleplay/wiki-link-audit

Wiki Link Audit

GPTClaudeGemini··845 copies·updated 2026-07-14
wiki-link-audit.prompt
# User-invoked prompt · wiki-link-audit (v1.8.2 · Obsidian-style)

> Standalone link-audit pass over `wiki/`. Replaces the 311-line bash
> script `scripts/wiki/wiki-link-audit.sh` (deleted in v1.8.1). The same
> audit also runs as the optional "+ link audit" branch inside
>
> **v1.8.2 HARD RULE #11**: Audit report renders in Obsidian. Apply
> `references/obsidian-style.md` — `> [!info]` for summary counts,
> `> [!warning]` for broken-link sections, `[[wikilinks]]` for entry refs,
> nested tags.
> `scripts/prompts/wiki-decay.md`.

## Trigger keywords

- `wiki 链接审计` / `wiki link audit` / `wiki link 完整性`
- `查 wiki 哪些链接断了` / `find broken wikilinks`
- `/wiki-link-audit` (slash command escape hatch)

## Goal

Produce a report at `meta/eval-history/wiki-link-audit-{YYYY-MM-DD}.md`
covering:

1. Counts (total entries, wikilinks, markdown links, broken, orphans, stale, low-confidence)
2. Broken wikilinks (`[[target]]` where target file doesn't exist)
3. Broken markdown links (`[text](path.md)` where path doesn't resolve)
4. Orphan entries (zero inbound + zero outbound links)
5. Stale entries (`last_tended` > 180 days, falling back to `last_updated`)
6. Low-confidence entries (`confidence` is `unlikely` or `impossible`)

## Pre-flight

1. Verify cwd is a second-brain repo (`meta/` + `wiki/` exist). If not,
   refuse and tell user this prompt only runs in a second-brain vault.
2. Glob `wiki/**/*.md`. Exclude:
   - `wiki/INDEX.md`
   - `wiki/SCHEMA.md`
   - `wiki/log.md`
   - `wiki/OBSIDIAN-SETUP.md`
   - `wiki/.templates/**`

## Step 1 · Build entry list + basename map

For each surviving `wiki/**/*.md` path:
- record full path (e.g. `wiki/fintech/stablecoin-b2b.md`)
- record basename without `.md` (e.g. `stablecoin-b2b`)

Obsidian wikilinks resolve by basename in default settings; markdown
links resolve by relative path. Both maps are needed.

## Step 2 · Per-entry scan

For each entry, Read the file and extract:

- **Wikilinks**: every `[[target]]` and `[[target|alias]]` and
  `[[target#section]]` — strip `|alias` and `#section` to get bare
  `target`.
- **Markdown links**: every `[text](path.md)` and `[text](path.md#sec)` —
  external (`http`, `https`, `mailto`) skipped.
- **Frontmatter**: `confidence`, `last_tended`, `last_updated`, `aliases`.

Use `Grep` with the patterns:
- wikilinks: `\[\[([^\]|#]+)(\|[^\]]*)?(#[^\]]*)?\]\]`
- markdown links: `\[[^\]]+\]\(([^)\s]+\.md)(#[^)]*)?\)`
- frontmatter `confidence:`: line-level grep on first 30 lines

## Step 3 · Resolve links

For each wikilink target:
- Look up in basename map. **Hit** → record edge `(source → target)`
  for inbound count; **Miss** → also check `aliases:` of every entry; if
  any entry's `aliases` array contains the target, treat as resolved.
  Otherwise → broken.

For each markdown link target:
- Resolve relative to source dir (e.g. `wiki/fintech/X.md` linking to
  `../methodology/Y.md` → `wiki/methodology/Y.md`).
- If absolute (starts with `/`), strip the leading `/` and resolve from
  vault root.
- Check whether the resolved path is in the entry list.

Track:
- `outbound[entry]` — set of resolved targets (for orphan detection)
- `inbound[entry]` — set of sources linking to it
- `broken_wikilinks: [(source, target)]`
- `broken_mdlinks: [(source, raw_target, resolved_target)]`

## Step 4 · Compute derived sets

- **Orphans**: entries where `outbound` is empty AND `inbound` is empty.
- **Stale**: entries where `last_tended` (fallback `last_updated`) is
  older than 180 days. If both missing, flag separately as
  "missing-freshness-marker".
- **Low confidence**: entries where `confidence` is `unlikely` or
  `impossible`. For legacy float `confidence`, map: `< 0.3` → unlikely,
  `< 0.05` → impossible.

## Step 5 · Write report

Write to `meta/eval-history/wiki-link-audit-{YYYY-MM-DD}.md` (overwrite
if exists):

fill the variables

This prompt has 1 variable. Pro fills them into a ready-to-paste prompt for you — no manual find-and-replace.

{YYYY-MM-DD}
Unlock with Pro →

when to use it

Community prompt sourced from the open-source GitHub repo jasonhnd/life_OS (NOASSERTION). A "Wiki Link Audit" style prompt — adapt the placeholders and specifics to your task. Imported as-is and not independently retested here, so check the output before relying on it.

tags

roleplaycommunitygeneral

source

jasonhnd/life_OS · NOASSERTION