Automation Tools
This page documents all automation tools available for maintaining and improving the knowledge base.
Quick Reference
Section titled “Quick Reference”| Tool | Purpose | Command |
|---|---|---|
| Content Commands | Improve, grade, create pages | npm run crux -- content |
| Validators | Check content quality | npm run crux -- validate |
| Analyzers | Analysis and reporting | npm run crux -- analyze |
| Auto-fixers | Fix common issues | npm run crux -- fix |
| Data Builder | Regenerate entity data | npm run build:data |
| Resources | External resource management | npm run crux -- resources |
Page Improvement Workflow
Section titled “Page Improvement Workflow”The recommended way to improve wiki pages to quality 5.
Commands
Section titled “Commands”# List pages that need improvement (sorted by priority)node scripts/page-improver.mjs --list
# Get improvement prompt for a specific pagenode scripts/page-improver.mjs economic-disruption
# Show page info only (no prompt)node scripts/page-improver.mjs racing-dynamics --info
# Filter by quality and importancenode scripts/page-improver.mjs --list --max-qual 3 --min-imp 50What Makes a Q5 Page
Section titled “What Makes a Q5 Page”| Element | Requirement |
|---|---|
| Quick Assessment Table | 5+ rows, 3 columns (Dimension, Assessment, Evidence) |
| Substantive Tables | 2+ additional tables with real data |
| Mermaid Diagram | 1+ showing key relationships |
| Citations | 10+ real URLs from authoritative sources |
| Quantified Claims | Replace “significant” with “25-40%” etc. |
| Word Count | 800+ words of substantive content |
Cost Estimates
Section titled “Cost Estimates”| Model | Cost per Page |
|---|---|
| Opus 4.5 | $3-5 |
| Sonnet 4.5 | $0.50-1.00 |
Reference Examples
Section titled “Reference Examples”- Gold standard:
src/content/docs/knowledge-base/risks/misuse/bioweapons.mdx - Good example:
src/content/docs/knowledge-base/risks/structural/racing-dynamics.mdx
Content Grading
Section titled “Content Grading”Uses Claude Sonnet API to automatically grade pages with importance, quality, and AI-generated summaries.
Commands
Section titled “Commands”# Preview what would be graded (no API calls)node scripts/grade-content.mjs --dry-run
# Grade a specific pagenode scripts/grade-content.mjs --page scheming
# Grade pages and apply to frontmatternode scripts/grade-content.mjs --limit 10 --apply
# Grade a category with parallel processingnode scripts/grade-content.mjs --category responses --parallel 3
# Skip already-graded pagesnode scripts/grade-content.mjs --skip-graded --limit 50Options
Section titled “Options”| Option | Description |
|---|---|
--page ID | Grade a single page |
--dry-run | Preview without API calls |
--limit N | Only process N pages |
--parallel N | Process N pages concurrently (default: 1) |
--category X | Only process pages in category |
--skip-graded | Skip pages with existing importance |
--apply | Write grades to frontmatter (caution) |
--output FILE | Write results to JSON file |
Grading Criteria
Section titled “Grading Criteria”Importance (0-100):
- 90-100: Essential for prioritization (core interventions, key risk mechanisms)
- 70-89: High value (concrete responses, major risk categories)
- 50-69: Useful context (supporting analysis, secondary risks)
- 30-49: Reference material (historical, profiles, niche)
- 0-29: Peripheral (internal docs, stubs)
Quality (0-100):
- 80-100: Comprehensive (2+ tables, 1+ diagram, 5+ citations, quantified claims)
- 60-79: Good (1+ table, 3+ citations, mostly prose)
- 40-59: Adequate (structure but lacks tables/citations)
- 20-39: Draft (poorly structured, heavy bullets, no evidence)
- 0-19: Stub (minimal content)
Cost Estimate
Section titled “Cost Estimate”≈$0.02 per page, ≈$6 for all 329 pages
Validation Suite
Section titled “Validation Suite”All validators are accessible via the unified crux CLI:
npm run validate # Run all validatorsnpm run crux -- validate --help # List all validatorsIndividual Validators
Section titled “Individual Validators”| Command | Description |
|---|---|
crux validate compile | MDX compilation check |
crux validate data | Entity data integrity |
crux validate refs | Internal reference validation |
crux validate mermaid | Mermaid diagram syntax |
crux validate sidebar | Sidebar configuration |
crux validate entity-links | EntityLink component validation |
crux validate templates | Template compliance |
crux validate quality | Content quality metrics |
crux validate unified | Unified rules engine (escaping, formatting) |
Advanced Usage
Section titled “Advanced Usage”# Run specific validatorsnpm run crux -- validate compile --quicknpm run crux -- validate unified --rules=dollar-signs,markdown-lists
# Skip specific checksnpm run crux -- validate all --skip=component-refs
# CI modenpm run validate:ciKnowledge Base System
Section titled “Knowledge Base System”SQLite-based system for managing content, sources, and AI summaries.
Requires .env file:
ANTHROPIC_API_KEY=sk-ant-...Commands
Section titled “Commands”npm run crux -- analyze scan # Scan MDX files, extract sourcesnpm run crux -- generate summaries # Generate AI summariesnode scripts/scan-content.mjs --stats # Show database statisticsDetailed Usage
Section titled “Detailed Usage”# Scan content (run after editing MDX files)node scripts/scan-content.mjsnode scripts/scan-content.mjs --force # Rescan all filesnode scripts/scan-content.mjs --verbose # Show per-file progress
# Generate summaries via cruxnpm run crux -- generate summaries --batch 50npm run crux -- generate summaries --model sonnetnpm run crux -- generate summaries --id deceptive-alignmentnpm run crux -- generate summaries --dry-runDatabase Location
Section titled “Database Location”All cached data is in .cache/ (gitignored):
.cache/knowledge.db- SQLite database.cache/sources/- Fetched source documents
Cost Estimates
Section titled “Cost Estimates”| Task | Model | Cost |
|---|---|---|
| Summarize all 311 articles | Haiku | ≈$2-3 |
| Summarize all 793 sources | Haiku | ≈$10-15 |
Data Layer
Section titled “Data Layer”Build Data
Section titled “Build Data”Important: Data build must run before site build.
npm run build:data # Regenerate all data filesnpm run dev # Auto-runs build:data firstnpm run build # Auto-runs build:data firstGenerated Files
Section titled “Generated Files”After running build:data:
src/data/database.json- Main entity databasesrc/data/entities.json- Entity definitionssrc/data/backlinks.json- Cross-referencessrc/data/tagIndex.json- Tag indexsrc/data/pathRegistry.json- URL path mappingssrc/data/pages.json- Page metadata for scripts
Other Data Scripts
Section titled “Other Data Scripts”npm run sync:descriptions # Sync model descriptions from filesnpm run extract # Extract data from pagesnpm run generate-yaml # Generate YAML from datanpm run cleanup-data # Clean up data filesContent Management CLI
Section titled “Content Management CLI”Unified tool for managing and improving content quality via crux content.
Commands
Section titled “Commands”# Improve pagesnpm run crux -- content improve <page-id>
# Grade pages using Claude APInpm run crux -- content grade --page schemingnpm run crux -- content grade --limit 5 --apply
# Regrade pagesnpm run crux -- content regrade --page scheming
# Create new pagesnpm run crux -- content create --type risk --file input.yamlOptions
Section titled “Options”| Option | Description |
|---|---|
--dry-run | Preview without API calls |
--limit N | Process only N pages |
--apply | Apply changes directly to files |
--page ID | Target specific page |
Resource Linking
Section titled “Resource Linking”Convert URLs to R Components
Section titled “Convert URLs to R Components”# Find URLs that can be converted to <R> componentsnode scripts/map-urls-to-resources.mjs expertise-atrophy # Specific filenode scripts/map-urls-to-resources.mjs # All filesnode scripts/map-urls-to-resources.mjs --stats # Statistics only
# Auto-convert markdown links to R componentsnode scripts/convert-links-to-r.mjs --dry-run # Previewnode scripts/convert-links-to-r.mjs --apply # Apply changesExport Resources
Section titled “Export Resources”node scripts/utils/export-resources.mjs # Export resource dataContent Generation
Section titled “Content Generation”Generate New Pages
Section titled “Generate New Pages”# Generate a model page from YAML inputnpm run crux -- generate content --type model --file input.yaml
# Generate a risk pagenpm run crux -- generate content --type risk --file input.yaml
# Generate a response pagenpm run crux -- generate content --type response --file input.yamlBatch Summaries
Section titled “Batch Summaries”npm run crux -- generate summaries --batch 50 # Generate summaries for multiple pagesTesting
Section titled “Testing”npm run test # Run all testsnpm run test:lib # Test library functionsnpm run test:validators # Test validator functionsLinting and Formatting
Section titled “Linting and Formatting”npm run lint # Check for linting issuesnpm run lint:fix # Fix linting issuesnpm run format # Format all filesnpm run format:check # Check formatting without changingTemporary Files
Section titled “Temporary Files”Convention: All temporary/intermediate files go in .claude/temp/ (gitignored).
Scripts that generate intermediate output (like grading results) write here by default. This keeps the project root clean and prevents accidental commits.
Common Workflows
Section titled “Common Workflows”Improve a Low-Quality Important Page
Section titled “Improve a Low-Quality Important Page”-
Find candidates:
Terminal window node scripts/page-improver.mjs --list --max-qual 3 -
Get improvement prompt:
Terminal window node scripts/page-improver.mjs economic-disruption -
Run in Claude Code with the generated prompt
-
Validate the result:
Terminal window npm run crux -- validate compilenpm run crux -- validate templates
Grade All New Pages
Section titled “Grade All New Pages”-
Preview:
Terminal window node scripts/grade-content.mjs --skip-graded --dry-run -
Grade and apply:
Terminal window node scripts/grade-content.mjs --skip-graded --apply --parallel 3 -
Review results:
Terminal window cat .claude/temp/grades-output.json
Check Content Quality Before PR
Section titled “Check Content Quality Before PR”npm run validateUpdate After Editing entities.yaml
Section titled “Update After Editing entities.yaml”npm run build:datanpm run crux -- validate data