Install git hooks and Claude Code hooks for automatic QA on commit and push
From scout-qanpx claudepluginhub anicol/scout-qa --plugin scout-qa/install-hooksManage git hooks for Jira smart commit integration. Auto-prepend issue keys, validate smart commits, process commands.
Wire Scout QA into your git pipeline. Installs git hooks (pre-commit, pre-push) and Claude Code hooks (auto-test after edits) so QA runs automatically without thinking about it.
/scout:install-hooks # Install everything
/scout:install-hooks --git-only # Only git hooks (pre-commit + pre-push)
/scout:install-hooks --uninstall # Remove all Scout hooks
.git/hooks/pre-commit)git commit --no-verify.git/hooks/pre-push)export SCOUT_MODE=smart)git push --no-verify.claude/settings.local.json)git commit via Bash, suggests running /scout:testVerify:
git rev-parse --git-dir).git/hooks/ directory existsCopy hook scripts from the plugin's hooks/ directory:
# Pre-commit hook
cp "${CLAUDE_PLUGIN_ROOT}/hooks/pre-commit.sh" .git/hooks/pre-commit
chmod +x .git/hooks/pre-commit
# Pre-push hook
cp "${CLAUDE_PLUGIN_ROOT}/hooks/pre-push.sh" .git/hooks/pre-push
chmod +x .git/hooks/pre-push
If existing hooks are found, do NOT overwrite. Instead:
If Husky is detected (node_modules/.husky/ or .husky/ exists):
.git/hooks/, create Husky hook files:
npx husky add .husky/pre-commit "$(cat ${CLAUDE_PLUGIN_ROOT}/hooks/pre-commit.sh)"
npx husky add .husky/pre-push "$(cat ${CLAUDE_PLUGIN_ROOT}/hooks/pre-push.sh)"
.husky/pre-commit and .husky/pre-pushIf lefthook is detected (lefthook.yml):
Read .claude/settings.local.json if it exists. Merge in the Scout hooks:
{
"hooks": {
"PostToolUse": [
{
"matcher": "Edit|Write",
"hooks": [
{
"type": "command",
"command": "bash \"${CLAUDE_PLUGIN_ROOT}/hooks/post-edit-test.sh\"",
"timeout": 30
}
]
},
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "jq -r '.tool_input.command // empty' | grep -q 'git commit' && echo '[Scout QA] Commit detected. Run /scout:test to check affected tests.' || exit 0"
}
]
}
]
}
}
Write to .claude/settings.local.json (gitignored, local-only). If the file exists, merge hooks arrays — don't overwrite existing hooks.
Run each hook in dry-run mode:
# Test pre-commit
bash .git/hooks/pre-commit --dry-run 2>/dev/null || echo "Pre-commit installed (will run on next commit)"
# Test pre-push
bash .git/hooks/pre-push --dry-run 2>/dev/null || echo "Pre-push installed (will run on next push)"
Scout QA Hooks Installed
========================
Git Hooks:
.git/hooks/pre-commit ............ Installed (lint on staged files)
.git/hooks/pre-push .............. Installed (quality gate before push)
Claude Code Hooks:
PostToolUse (Edit/Write) ......... Auto-run affected tests after edits
PostToolUse (Bash/git commit) .... Suggest /scout:test after commits
Pre-Push Mode: fast (direct tools, no AI)
Switch to smart mode: export SCOUT_MODE=smart
Skip any hook: --no-verify
git commit --no-verify
git push --no-verify
If $ARGUMENTS contains --uninstall:
Remove Scout git hooks (only if they contain "Scout QA" marker):
grep -q "Scout QA" .git/hooks/pre-commit && rm .git/hooks/pre-commit
grep -q "Scout QA" .git/hooks/pre-push && rm .git/hooks/pre-push
Remove Scout entries from .claude/settings.local.json (remove hooks that reference scout or SCOUT).
Report what was removed.