بنقرة واحدة
install-git-hooks
Install pre-commit hooks to automatically lint markdown files before commits
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Install pre-commit hooks to automatically lint markdown files before commits
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
Conduct thorough code reviews for pull requests and pre-commit changes
Run comprehensive project health checks including code quality, documentation, git status, and project structure
Check CI/CD workflow status and troubleshoot failing checks in GitHub Actions
Initialize .docent/ directory structure and configuration for a new project
Comprehensive guide for AI agents on proactive documentation capture using /docent:tell
Migrate a docent v0.9 project to v1.0 skills-based architecture
| name | install-git-hooks |
| description | Install pre-commit hooks to automatically lint markdown files before commits |
| group | git |
| author | @tnez |
| version | 1.0.0 |
| keywords | ["git","hooks","automation","linting"] |
Purpose: Install pre-commit hooks to automatically lint markdown files before commits Owner: Development Team Last Updated: 2025-10-20 Frequency: One-time setup per developer environment
This runbook provides the procedure for installing git hooks in your local docent repository. Git hooks automatically run quality checks before committing, helping catch markdown linting errors early in the development process.
Script Reference: ../../scripts/install-git-hooks.sh
Expected duration: 1-2 minutes
What this accomplishes:
.md filesNote: This is optional but recommended for all developers.
git - Version control systemnpm - Node.js package managernpm install).git/hooks directory (standard for any git repository)Before starting, ensure:
.git directory exists)ls node_modules/markdownlint-cli2.git/hooks: ls -ld .git/hooksPurpose: Ensure you're in the correct directory
Commands:
# Verify you're in the docent project root
pwd
# Expected: /Users/tnez/Code/tnez/docent (or your path to docent)
# Verify git repository exists
ls -d .git
# Expected: .git
# Verify hooks directory exists
ls -d .git/hooks
# Expected: .git/hooks
Validation:
.git directory exists.git/hooks directory existsIf step fails:
cd /path/to/docent.git doesn't exist: git init or clone the repository againPurpose: Install the pre-commit hook
Commands:
# Run the installation script
scripts/install-git-hooks.sh
# Expected output:
# Installing pre-commit hook...
# ✓ Git hooks installed successfully
#
# The pre-commit hook will now run markdown linting on staged .md files.
# To bypass the hook, use: git commit --no-verify
#
# To uninstall, run: rm .git/hooks/pre-commit
Validation:
If step fails:
Error: "Not in a git repository root directory"
.git directory existsError: "Permission denied"
ls -l scripts/install-git-hooks.shchmod +x scripts/install-git-hooks.shError: "No such file or directory"
ls scripts/hooks/pre-commitPurpose: Confirm the hook is properly installed and executable
Commands:
# Check hook file exists
ls -l .git/hooks/pre-commit
# Expected: -rwxr-xr-x ... .git/hooks/pre-commit
# View hook contents (first few lines)
head -5 .git/hooks/pre-commit
# Expected: Should show shell script starting with #!/bin/sh
Validation:
.git/hooks/pre-commit existsx)If step fails:
chmod +x .git/hooks/pre-commitPurpose: Verify the hook runs on commit
Commands:
# Create a test markdown file with linting errors
echo "# Test" > test-lint.md
echo "No blank line before list:" >> test-lint.md
echo "- item 1" >> test-lint.md
# Stage the file
git add test-lint.md
# Try to commit (hook should run and may fail if linting errors)
git commit -m "test: verify pre-commit hook"
# Expected: Hook runs markdown linting
# If there are errors, commit will be blocked
# Clean up test file
git reset HEAD test-lint.md
rm test-lint.md
Validation:
If step fails:
After completing all steps, verify:
Hook Installed:
ls -l .git/hooks/pre-commit
# Expected: File exists and is executable
Hook Runs on Commit:
git commitCan Bypass if Needed:
git commit --no-verify -m "test"
# Expected: Commit succeeds without running hook
git reset HEAD~1 # Undo test commit
If you need to remove the git hooks:
# Remove the hook
rm .git/hooks/pre-commit
# Verify removal
ls .git/hooks/pre-commit
# Expected: No such file or directory
When to uninstall:
Note: You can always reinstall by running the installation script again.
Symptoms:
Resolution:
# Check what files have linting errors
npm run lint:md
# Fix errors
scripts/lint-markdown.sh --fix
# Or bypass for urgent commits
git commit --no-verify -m "message"
# Then fix linting separately
Symptoms:
Resolution:
# Verify hook exists and is executable
ls -l .git/hooks/pre-commit
# If missing, reinstall
scripts/install-git-hooks.sh
# If not executable
chmod +x .git/hooks/pre-commit
# Test with verbose output
git commit --dry-run -m "test"
Symptoms:
Resolution:
# Install project dependencies
npm install
# Verify markdownlint-cli2 is available
npx markdownlint-cli2 --version
# If still failing, check hook script
cat .git/hooks/pre-commit
Escalate if:
Escalation Contact:
After installation:
--no-verify# Install hooks
scripts/install-git-hooks.sh
# Verify installation
ls -l .git/hooks/pre-commit
# Bypass hook for one commit
git commit --no-verify -m "message"
# Uninstall hook
rm .git/hooks/pre-commit
# Test linting manually
npm run lint:md
scripts/lint-markdown.sh
Important Notes:
git commit, not on git push or other commands--no-verify should be rare - prefer fixing linting errorsGotchas:
docs/.journal/ are gitignored and won't be lintedRelated Procedures:
| Date | Author | Changes |
|---|---|---|
| 2025-10-20 | @tnez | Initial creation |