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
| Pro | Con |
|---|---|
| Catches issues before git history | Modifies staged files |
| Auto-fix eliminates manual effort | Adds ~1-2s to commit time |
| Pre-commit matches CI behavior | May 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.