Skip to content

feat: add validate command for note quality checking#101

Closed
leobrival wants to merge 1 commit intoYakitrak:mainfrom
leobrival:feat/validate-command
Closed

feat: add validate command for note quality checking#101
leobrival wants to merge 1 commit intoYakitrak:mainfrom
leobrival:feat/validate-command

Conversation

@leobrival
Copy link

Summary

Add a new validate command that checks Obsidian vault notes for common quality issues.

Usage

# Validate entire vault
notesmd-cli validate --vault MyVault

# Validate a single note
notesmd-cli validate daily/2024-01-15 --vault MyVault

# JSON output
notesmd-cli validate --vault MyVault -f json

# Errors only
notesmd-cli validate --vault MyVault -s error

Rules implemented

Rule ID Severity Description
frontmatter.parse-error error Invalid YAML frontmatter
frontmatter.missing warning Note without frontmatter
frontmatter.deprecated-singular warning tag/alias/cssclass should be tags/aliases/cssclasses
frontmatter.list-type error tags/aliases/cssclasses must be lists
frontmatter.tags-hash warning Tags with # prefix in YAML
structure.empty-note warning Empty or whitespace-only note
structure.heading-hierarchy warning Skipped heading levels (e.g. H1 to H3)

Flags

Flag Short Default Description
--vault -v "" Vault name
--format -f text Output: text, json, summary
--severity -s warning Minimum severity: error, warning, info

Architecture

  • cmd/validate.go — Cobra command (registered via init())
  • pkg/validate/result.go — Types (ValidationResult, Severity, Summary)
  • pkg/validate/config.go — Default config and directory exclusions
  • pkg/validate/validate.go — Orchestrator (walk vault, collect results)
  • pkg/validate/rules/frontmatter.go — 5 frontmatter rules
  • pkg/validate/rules/structure.go — 2 structure rules

Reuses existing patterns: VaultManager interface, frontmatter.Parse(), filepath.WalkDir, mock pattern from mocks/vault.go.

Exit code 1 when errors are found (useful for CI).

Checklist

  • I have written unit tests for my changes
  • I have updated the documentation accordingly
  • All tests pass (go test ./...)

Add a new validate command that checks Obsidian vault notes for
common issues including frontmatter syntax, deprecated properties,
tag formatting, empty notes, and heading hierarchy.

Rules implemented:
- frontmatter.parse-error (error): invalid YAML frontmatter
- frontmatter.missing (warning): note without frontmatter
- frontmatter.deprecated-singular (warning): tag/alias/cssclass
- frontmatter.list-type (error): tags/aliases/cssclasses as string
- frontmatter.tags-hash (warning): hash prefix in YAML tags
- structure.empty-note (warning): empty or whitespace-only note
- structure.heading-hierarchy (warning): skipped heading levels

Supports text/json/summary output, severity filtering,
single note validation, and directory exclusions.
@Yakitrak
Copy link
Owner

Yakitrak commented Mar 4, 2026

Hey thanks for the PR! It is well-written code, but it feels like it belongs in a dedicated vault-linting tool rather than here. If someone wanted serious vault validation, they'd want more rules, configurable rule sets, ignore files, etc., then scope creep would start pulling the project in a different direction. If this gets requested more then I can revisit but otherwise I don't think its the best fit here. Please feel free to contribute on anything else on the issues list if you want to.

@Yakitrak Yakitrak closed this Mar 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants