Pre-commit format enforcement

Enforce formatting at commit time to prevent CI failures from synced or manually created content.

Problem

Knowledge repositories aggregate content from multiple sources (manual authoring, automated syncs, templates). Each source may have different formatting conventions, leading to formatting drift that only surfaces when CI runs.

Solution

Configure lint-staged to run Prettier with --write on all supported file types:

"lint-staged": {
  "*.{js,mjs,ts,json,yml,yaml,md}": ["prettier --write"],
  "obsidian/**/*.md": ["node scripts/security-scan.mjs"]
}

Trade-offs

ProCon
Catches issues before git historyModifies staged files
Auto-fix eliminates manual effortAdds ~1-2s to commit time
Pre-commit matches CI behaviorMay surprise unfamiliar devs

Source

Discovered after 59-file formatting failure in deploy pipeline (January 2026). Root cause: files synced from ops-core without local formatting.