kb-health
Lint and health-check the knowledge base. Finds orphan pages, missing cross-references, stale claims, broken wiki-links, and regenerates the index.
What this skill does
# KB Health
Audit the knowledge base for structural and content issues. Reports problems and, with `--fix`, repairs what can be fixed automatically (broken links, missing index entries). Human review is required for content issues (stale claims, empty sections).
## Triggers
- "check KB health" → full audit
- "find orphan pages" → orphan check only
- "regenerate KB index" → `--index-only`
- `/kb-health` → direct invocation
## Parameters
### `--path <subtree>` (optional)
Scope the check to a subdirectory (e.g., `--path .aiwg/kb/entities/`). Defaults to full KB root.
### `--kb <path>` (optional)
Root of the knowledge base. **Default**: resolved by `aiwg kb path` (#965), which reads `resolveStorage('kb')` and honors any `roots.kb` override in `.aiwg/storage.config`. On the default `fs` backend this is `.aiwg/kb/`.
```bash
KB_ROOT=$(aiwg kb path)
aiwg kb list --prefix entities/
aiwg kb get entities/foo.md
```
### `--fix` (optional)
Automatically repair issues that are safe to fix without human judgment:
- Remove references to confirmed-missing pages from Sources tables
- Add pages missing from the index
- Normalize slug inconsistencies (spaces → hyphens in filenames)
Does NOT auto-fix: empty required sections, stale claim dates, ambiguous duplicates.
### `--index-only` (optional)
Skip all checks; only regenerate `index.md`.
---
## Checks
### 1. Orphan Pages
An orphan is a page with no incoming `[[wiki-link]]` references from any other KB page.
Procedure:
1. Collect all `.md` files under `<kb>/`.
2. For each file, extract all `[[...]]` references.
3. Build an inverted index: page → set of pages that link to it.
4. Pages with zero incoming links are orphans.
Orphans in `sources/` are less critical (sources are often terminal nodes). Report them separately.
### 2. Broken Wiki-Links
For every `[[link-target]]` found in any KB page:
1. Derive the expected file path (slug → filename in each subdirectory).
2. Check whether the file exists.
3. If not: report as a broken link with the containing file and line number.
With `--fix`: remove confirmed-broken links from Sources tables. Flag broken links in prose sections for manual review (do not silently remove).
### 3. Empty Required Sections
Templates define required sections (Overview, Definition, Key Takeaways, etc.).
Detect pages where a required section header exists but the body is a placeholder (`_..._` or a single empty line).
Report as warnings, not errors. Do not auto-fix content.
### 4. Stale Pages
A page is considered stale if:
- Its `_Last updated:` date is more than 180 days ago, AND
- At least one source it references was published after that date (detectable via source summary dates)
Report stale pages as advisory — staleness is informational, not a structural error.
### 5. Duplicate Slugs
Detect files with the same normalized slug in different subdirectories (e.g., `entities/python.md` and `concepts/python.md`). These may be legitimate or accidental duplicates. Report all cases; do not auto-resolve.
---
## Index Regeneration
Always regenerate `<kb>/index.md` at the end of a health check run (or when `--index-only` is used).
The index lists all KB pages grouped by directory with their first-line description (the `>` blockquote line from templates):
```markdown
# Knowledge Base Index
_Generated: YYYY-MM-DD — N pages_
## Entities (N)
- [Entity Name](entities/entity-name.md) — type · domain
## Concepts (N)
- [Concept Name](concepts/concept-name.md) — category · domain
## Sources (N)
- [Source Title](sources/source-slug.md) — type · author · date
## Comparisons (N)
- [A vs B](comparisons/a-vs-b.md) — purpose
## Syntheses (N)
- [Synthesis Title](syntheses/synthesis-slug.md) — type · confidence
```
---
## Report Format
```
KB Health Report — YYYY-MM-DD
Root: .aiwg/kb/
Pages scanned: N
ERRORS (must fix)
Broken links: N
entities/foo.md:12 — [[missing-page]] not found
WARNINGS (review recommended)
Orphan pages: N
sources/old-article.md — no incoming links
Empty sections: N
concepts/bar.md — Definition section is placeholder
Stale pages: N
entities/baz.md — last updated 2024-01-01 (>180 days)
INFO
Duplicate slugs: N
entities/python.md and concepts/python.md share slug "python"
Index regenerated: .aiwg/kb/index.md (N entries)
```
---
## Scope Limits
- Read-only by default. `--fix` enables targeted writes; `--index-only` writes only `index.md`.
- Do not delete any pages, even if they appear to be duplicates. Report and let the human decide.
- Maximum pages scanned per run: 500. If KB exceeds this, use `--path` to scope.
## References
- @$AIWG_ROOT/agentic/code/frameworks/knowledge-base/templates/entity-page.md
- @$AIWG_ROOT/agentic/code/frameworks/knowledge-base/templates/concept-page.md
- @$AIWG_ROOT/agentic/code/frameworks/knowledge-base/templates/source-summary.md
- @$AIWG_ROOT/agentic/code/frameworks/knowledge-base/skills/kb-ingest/SKILL.md
Related in Code Review
gstack
IncludedFast headless browser for QA testing and site dogfooding. Navigate pages, interact with elements, verify state, diff before/after, take annotated screenshots, test responsive layouts, forms, uploads, dialogs, and capture bug evidence. Use when asked to open or test a site, verify a deployment, dogfood a user flow, or file a bug with screenshots. (gstack)
startup-due-diligence
IncludedLegal due diligence review for seed-stage and Series A startups (US, Delaware C-Corp focus). Supports both investor and founder perspectives. Capabilities include: (1) Interactive document review and issue spotting; (2) Document request list generation; (3) Cap table and SAFE/convertible note analysis; (4) Red flag identification with severity ratings; (5) Diligence report generation. TRIGGERS: due diligence, DD, startup investment, cap table review, Series A, seed round, investor diligence, legal review startup, SAFE analysis, convertible note, 409A, founder vesting.
interview-master
IncludedThis skill should be used when the user asks to "generate interview questions", "prepare for interview", "optimize resume", "conduct mock interview", "analyze git commits for resume", "generate resume from code", "review my resume", or mentions interview preparation, career assistance, or extracting project experience from git history. Provides comprehensive interview and career development guidance for both job seekers and interviewers.
fix-issue
IncludedFixes GitHub issues using parallel analysis agents for root cause investigation, code exploration, and regression detection. Reads issue context from gh CLI, searches codebase and memory for related patterns, generates a fix with tests, and links the resolution back to the issue via PR. Includes prevention analysis to avoid recurrence. Use when debugging errors, resolving regressions, fixing bugs, or triaging issues.
sf-apex
IncludedGenerates and reviews Salesforce Apex code with 150-point scoring. TRIGGER when: user writes, reviews, or fixes Apex classes, triggers, test classes, batch/queueable/schedulable jobs, or touches .cls/.trigger files. DO NOT TRIGGER when: LWC JavaScript (use sf-lwc), Flow XML (use sf-flow), SOQL-only queries (use sf-soql), or non-Salesforce code.
swift-development
IncludedComprehensive Swift development for building, testing, and deploying iOS/macOS applications. Use when Claude needs to: (1) Build Swift packages or Xcode projects from command line, (2) Run tests with XCTest or Swift Testing framework, (3) Manage iOS simulators with simctl, (4) Handle code signing, provisioning profiles, and app distribution, (5) Format or lint Swift code with SwiftFormat/SwiftLint, (6) Work with Swift Package Manager (SPM), (7) Implement Swift 6 concurrency patterns (async/await, actors, Sendable), (8) Create SwiftUI views with MVVM architecture, (9) Set up Core Data or SwiftData persistence, or any other Swift/iOS/macOS development tasks.