Run validation checks on the knowledge graph
Validates knowledge graph integrity by checking wikilinks, bidirectional relationships, and YAML frontmatter.
/plugin marketplace add witt3rd/claude-plugins/plugin install azkg@witt3rd-claude-pluginsRun validation checks on the knowledge graph to ensure integrity.
Check for AZKG_REPO_PATH environment variable:
if [ -z "$AZKG_REPO_PATH" ]; then REPO_PATH=$(pwd); else REPO_PATH="$AZKG_REPO_PATH"; fiAll file operations must use REPO_PATH:
Read(REPO_PATH/filename.md) or Read("$REPO_PATH/filename.md")Write(REPO_PATH/filename.md) or Write("$REPO_PATH/filename.md")Edit(REPO_PATH/filename.md) or Edit("$REPO_PATH/filename.md")Grep(pattern, path=REPO_PATH) or with explicit pathGlob(pattern, path=REPO_PATH) or with explicit pathExample usage:
# Check environment variable
if [ -z "$AZKG_REPO_PATH" ]; then
REPO_PATH=$(pwd)
else
REPO_PATH="$AZKG_REPO_PATH"
fi
# Then use REPO_PATH for all operations
Read("$REPO_PATH/agents.md")
Concrete examples:
Check markdown files for:
Use Grep to extract all wikilinks from all markdown files:
# Find all wikilinks in the format [[note_name]]
Grep "\[\[([^\]]+)\]\]" --glob="*.md" --output_mode="content" -n
Extract unique note names from results.
For each unique wikilink target found:
target.md exists in repository rootFor notes with "Related Concepts" sections:
Use Read tool to check a sample of notes:
--- and ends with ---tags: field is present and is an arraySuccess:
Graph Validation
============================================================
[OK] Knowledge graph is valid
All checks passed:
✓ All wikilinks point to existing notes (N wikilinks checked)
✓ No broken links found
✓ Bidirectional relationships are consistent
✓ YAML frontmatter is well-formed
✓ No orphaned notes detected
Statistics:
• Total notes: N
• Total wikilinks: M
• Total relationships: X
• MOC files: Y
Failure:
Graph Validation
============================================================
[ERROR] Found N issue(s):
1. Broken wikilink: file1.md:42 references [[non_existent_note]]
2. Broken wikilink: file2.md:18 references [[another_missing]]
3. Missing inverse: agents.md extends [[semantic_routing]] but inverse not found
4. Orphaned note: lonely_note.md has no "Related Concepts" section
5. Invalid YAML: broken_note.md frontmatter is malformed
Recommendations:
• Fix or remove broken wikilinks
• Add "Extended By" section to semantic_routing.md
• Consider adding relationships to lonely_note.md
• Fix YAML frontmatter in broken_note.md
Wikilink validation:
[[note_name]] must have corresponding note_name.md file.md in wikilink (use [[note]] not [[note.md]])Bidirectional validation:
YAML validation:
Structural validation:
For each error type, suggest fixes:
Broken wikilinks:
File: example.md:42
Issue: References [[missing_note]]
Fixes:
• Create the missing note
• Remove the wikilink
• Change to reference an existing note
Missing inverse relationships:
File: agents.md
Issue: Extends [[semantic_routing]] but inverse not found
Fix:
• Add to semantic_routing.md "Related Concepts" section:
### Extended By
- [[agents]] - Uses routing for agent task selection
Orphaned notes:
File: lonely_note.md
Issue: No "Related Concepts" section
Fix:
• Add "Related Concepts" section with at least one relationship
• Link to appropriate MOC
• Use /expand-graph to discover relationships