Skip to main content

A linter for your LLM-compiled knowledge base

Project description

kb-lint

PyPI Python License Tests

A linter for your LLM-compiled knowledge base.

Run health checks over markdown wikis to catch broken links, missing metadata, orphan pages, thin articles, and structural inconsistencies — all without requiring an LLM.

Inspired by Andrej Karpathy's LLM Knowledge Bases workflow — he runs "health checks" over his wiki to "find inconsistent data, impute missing data, find interesting connections for new article candidates."

Installation

pip install kb-lint

Quick Start

# Lint the current directory
kb-lint .

# Generate a health report
kb-lint ./my-wiki --report

# Auto-fix simple issues
kb-lint ./my-wiki --fix

Example Output

 Knowledge Base Health Report
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  Path:     ./wiki
  Articles: 47
  Links:    203

  3 errors  7 warnings  2 info

┌─────┬──────────────────────┬───────┬──────────────┬─────────────────────────────────────┐
│ Sev │ File                 │  Line │ Check        │ Message                             │
├─────┼──────────────────────┼───────┼──────────────┼─────────────────────────────────────┤
│ E   │ concepts/rlhf.md     │    23 │ links        │ Broken wiki-link: [[ppo-training]]  │
│ E   │ concepts/scaling.md  │     1 │ frontmatter  │ Missing required field: title         │
│ W   │ concepts/new-idea.md │     - │ content      │ Thin article: only 42 words (min 100)│
│ W   │ sources/paper-x.md   │     - │ orphans      │ Orphan page: no incoming links        │
│ I   │ concepts/nlp.md      │     - │ consistency  │ Inconsistent tag casing for 'nlp'     │
└─────┴──────────────────────┴───────┴──────────────┴─────────────────────────────────────┘

  2 issues can be auto-fixed with --fix

Health Score: 82/100

Checks Reference

Check What it catches Default severity Auto-fixable?
links Broken [[wiki-links]] (wiki-links only, no external URLs) Error No
frontmatter Missing/invalid YAML frontmatter Error/Info Yes (add defaults)
orphans Articles with no incoming links Warning No
structure Non-kebab-case filenames, spaces Error/Warning Yes (rename)
content Thin articles, {{PLACEHOLDERS}}, duplicate titles, empty sections Error/Warning No
index Missing/extra entries in _index.md Warning/Error Yes (update index)
consistency Inconsistent tags, dates, confidence levels Warning No

CLI Reference

# Basic lint
kb-lint [path]

# Output formats
kb-lint [path] --format terminal    # Rich colored output (default)
kb-lint [path] --format markdown    # Markdown report
kb-lint [path] --format json        # Machine-readable JSON

# Filter by severity
kb-lint [path] --severity error     # Only show errors
kb-lint [path] --severity warning   # Warnings and errors

# Run specific checks
kb-lint [path] --check links,frontmatter

# List available checks
kb-lint --list-checks

# Health report with score
kb-lint [path] --report

# CI mode (exit 1 on errors)
kb-lint [path] --ci

# Auto-fix
kb-lint [path] --fix

# Preview fixes without applying them
kb-lint [path] --fix --dry-run

--ci Mode

In CI mode, kb-lint exits with code 1 if any errors are found:

kb-lint [path] --ci

--fix Behavior

--fix creates .bak backup files before modifying any file. Use --fix --dry-run to preview what would be changed without writing to disk.

Exit Codes

Code Meaning
0 Success — no errors found (warnings/info may still be present)
1 Errors found (only in --ci mode)

Configuration

Configure via .kblintrc.yml in your wiki directory:

required_frontmatter:
  - title
recommended_frontmatter:
  - tags
  - sources
  - created
  - confidence
min_article_words: 100
ignore_patterns:
  - _templates/**
  - drafts/**
recognized_directories:
  - concepts
  - sources
  - comparisons
allowed_confidence_levels:
  - high
  - medium
  - low
severity_threshold: info

Or in pyproject.toml:

[tool.kb-lint]
required_frontmatter = ["title"]
min_article_words = 100

CI Integration

GitHub Actions

- name: Lint knowledge base
  run: |
    pip install kb-lint
    kb-lint ./wiki --ci

Part of the LLM KB Ecosystem

Development

git clone https://github.com/SingggggYee/kb-lint
cd kb-lint
pip install -e ".[dev]"
pytest -v
ruff check src/ tests/

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kb_lint-0.1.0.tar.gz (65.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kb_lint-0.1.0-py3-none-any.whl (27.1 kB view details)

Uploaded Python 3

File details

Details for the file kb_lint-0.1.0.tar.gz.

File metadata

  • Download URL: kb_lint-0.1.0.tar.gz
  • Upload date:
  • Size: 65.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.6

File hashes

Hashes for kb_lint-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1b1a512b0a1de61cd00b44fac7fc8b5aeeee72666bb2fc77e17f12dc21b61b04
MD5 01f5e1cc8723af279ddd988949c8d4f6
BLAKE2b-256 c4bef96bc1a96225b545ef4fbebffb3e0ae1aef068afcd14f743de1535d541da

See more details on using hashes here.

File details

Details for the file kb_lint-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: kb_lint-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 27.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.6

File hashes

Hashes for kb_lint-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e95f31b2f0d178c3bd0dec661b840d89c2364282c6695220cfdf6c001581478f
MD5 6947f9ac3b649c44c833958818ec9711
BLAKE2b-256 01508a372e7651eaad23cfacd64249a0f93e8f4c9016ce08d3a6ccc6140cd78e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page