cortex-tms hooks
The cortex-tms hooks command installs a git pre-commit hook that runs cortex-tms validate automatically before every commit — catching documentation problems before they enter your history.
Synopsis
Section titled “Synopsis”cortex-tms hooks <subcommand> [options]Subcommands: install, uninstall, status
Subcommands
Section titled “Subcommands”hooks install
Section titled “hooks install”Installs a pre-commit hook in the current git repository.
cortex-tms hooks install [options]What it does:
- Verifies
.cortexrcexists (requirescortex-tms initto have been run) - Resolves the git hooks directory via
git rev-parse --git-path hooks - Refuses to overwrite any hook it didn’t create (safe by default)
- Writes a
pre-commitscript that runscortex-tms validatebefore each commit
Binary resolution — the installed hook tries three locations in order:
./node_modules/.bin/cortex-tms(local project install)cortex-tmson$PATH(global install)npx cortex-tms@<version>(automatic fallback — no install required)
Options
Section titled “Options”| Option | Description |
|---|---|
-s, --strict | Treat warnings as errors — commit is blocked if any warning is found |
--skip-staleness | Skip staleness detection in the hook (faster, avoids git log calls) |
--cortex-version <version> | Pin a specific version for the npx fallback (defaults to current CLI version) |
Output
Section titled “Output”✅ Pre-commit hook installed! Path: /your/repo/.git/hooks/pre-commit Mode: default Version: 4.1.0hooks uninstall
Section titled “hooks uninstall”Removes the cortex-tms pre-commit hook.
cortex-tms hooks uninstallSafety: Only removes hooks that cortex-tms installed. If the hook was created by another tool (husky, lefthook, etc.), the command refuses to delete it and exits with code 1.
hooks status
Section titled “hooks status”Shows the current hook configuration.
cortex-tms hooks statusOutput includes:
- Whether a hook is installed
- Whether cortex-tms manages it
- Hook path, mode (default/strict), and pinned version
Example output:
🔗 Git Hook Status
✓ Pre-commit hook installed (managed by cortex-tms) Path: /your/repo/.git/hooks/pre-commit Mode: strict Version: 4.1.0Exit Codes
Section titled “Exit Codes”| Code | Meaning |
|---|---|
0 | Success |
1 | Error — no .cortexrc, not a git repo, or foreign hook detected |
Examples
Section titled “Examples”Basic install (default mode)
Section titled “Basic install (default mode)”# Validate docs on every commit; warnings don't blockcortex-tms hooks installStrict mode — warnings block commits
Section titled “Strict mode — warnings block commits”cortex-tms hooks install --strictUseful for CI-adjacent workflows or teams enforcing zero-warning policy.
Speed-optimized for large repositories
Section titled “Speed-optimized for large repositories”# Skip staleness detection (avoids git log calls on every commit)cortex-tms hooks install --skip-stalenessPin a specific version for team consistency
Section titled “Pin a specific version for team consistency”cortex-tms hooks install --cortex-version 4.1.0All team members get the same validation behavior from the npx fallback regardless of their globally installed version.
Check what’s installed
Section titled “Check what’s installed”cortex-tms hooks statusRemove the hook
Section titled “Remove the hook”cortex-tms hooks uninstallCI usage — validate without a hook
Section titled “CI usage — validate without a hook”The hook is for local development. In CI, call validate directly:
- name: Validate documentation run: npx cortex-tms@latest validate --strict- Requires
.cortexrc: Runcortex-tms initbefore installing hooks. - Git worktrees: Hooks are installed into the correct hooks directory for the active worktree via
git rev-parse --git-path hooks. - Husky / lefthook compatibility: If you already use a hook manager, add
cortex-tms validateto your existing pre-commit script rather than using this command.
Related
Section titled “Related”- cortex-tms validate — the command the hook runs
- cortex-tms init — required before installing hooks