ai-playbook 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +146 -0
- package/agents/README.md +168 -0
- package/agents/SKILL.md +633 -0
- package/agents/architect/AGENT.md +44 -0
- package/agents/architect/README.md +5 -0
- package/agents/coder/AGENT.md +43 -0
- package/agents/coder/README.md +5 -0
- package/agents/debugger/AGENT.md +42 -0
- package/agents/debugger/README.md +6 -0
- package/agents/devops/AGENT.md +43 -0
- package/agents/devops/README.md +5 -0
- package/agents/documentation/AGENT.md +45 -0
- package/agents/documentation/README.md +5 -0
- package/agents/examples.md +550 -0
- package/agents/performance/AGENT.md +45 -0
- package/agents/performance/README.md +6 -0
- package/agents/planner/AGENT.md +44 -0
- package/agents/planner/README.md +6 -0
- package/agents/product-owner/AGENT.md +46 -0
- package/agents/product-owner/README.md +6 -0
- package/agents/refactorer/AGENT.md +44 -0
- package/agents/refactorer/README.md +6 -0
- package/agents/release-manager/AGENT.md +45 -0
- package/agents/release-manager/README.md +6 -0
- package/agents/researcher/AGENT.md +44 -0
- package/agents/researcher/README.md +6 -0
- package/agents/reviewer/AGENT.md +43 -0
- package/agents/reviewer/README.md +6 -0
- package/agents/security/AGENT.md +46 -0
- package/agents/security/README.md +6 -0
- package/agents/support/AGENT.md +45 -0
- package/agents/support/README.md +6 -0
- package/agents/tester/AGENT.md +46 -0
- package/agents/tester/README.md +5 -0
- package/bin/cli.js +186 -0
- package/commands/README.md +266 -0
- package/commands/build.md +135 -0
- package/commands/clean.md +126 -0
- package/commands/deploy-prod.md +171 -0
- package/commands/deploy-staging.md +147 -0
- package/commands/deps.md +169 -0
- package/commands/dev.md +132 -0
- package/commands/format.md +142 -0
- package/commands/lint.md +125 -0
- package/commands/migrate.md +159 -0
- package/commands/release.md +183 -0
- package/commands/rollback.md +152 -0
- package/commands/seed.md +178 -0
- package/commands/setup.md +109 -0
- package/commands/test.md +134 -0
- package/commands/validate.md +147 -0
- package/context/README.md +7 -0
- package/context/aem.md +47 -0
- package/context/architecture.md +51 -0
- package/context/bullminder.md +57 -0
- package/context/coding-style.md +42 -0
- package/context/communication.md +53 -0
- package/context/company.md +46 -0
- package/context/engineering.md +63 -0
- package/context/project-template.md +71 -0
- package/context/trading.md +52 -0
- package/hooks/README.md +326 -0
- package/hooks/code-review/README.md +6 -0
- package/hooks/code-review/check-coverage.md +101 -0
- package/hooks/custom/README.md +6 -0
- package/hooks/custom/project-specific-hooks.md +273 -0
- package/hooks/deployment/README.md +6 -0
- package/hooks/deployment/health-check.md +102 -0
- package/hooks/deployment/pre-deploy-check.md +84 -0
- package/hooks/documentation/README.md +6 -0
- package/hooks/documentation/update-changelog.md +146 -0
- package/hooks/post-task/README.md +5 -0
- package/hooks/post-task/run-tests.md +61 -0
- package/hooks/pre-commit/README.md +6 -0
- package/hooks/pre-commit/format.md +63 -0
- package/hooks/pre-commit/lint.md +62 -0
- package/hooks/pre-commit/type-check.md +78 -0
- package/hooks/pre-task/README.md +6 -0
- package/hooks/pre-task/check-branch.md +48 -0
- package/hooks/pre-task/validate-environment.md +48 -0
- package/hooks/security-check/README.md +6 -0
- package/hooks/security-check/dependency-audit.md +85 -0
- package/hooks/security-check/secrets-scan.md +77 -0
- package/hooks/test-before-finish/README.md +6 -0
- package/hooks/test-before-finish/run-all-tests.md +128 -0
- package/index.js +69 -0
- package/knowledge/README.md +33 -0
- package/knowledge/ai-agents.md +74 -0
- package/knowledge/decision-making.md +73 -0
- package/knowledge/documentation.md +67 -0
- package/knowledge/engineering-principles.md +65 -0
- package/knowledge/product-discovery.md +68 -0
- package/knowledge/security-privacy.md +54 -0
- package/knowledge/testing-quality.md +63 -0
- package/package.json +63 -0
- package/patterns/README.md +7 -0
- package/prompts/README.md +208 -0
- package/prompts/architect/README.md +96 -0
- package/prompts/architect/design-system.md +140 -0
- package/prompts/debugger/README.md +96 -0
- package/prompts/debugger/diagnose-issue.md +141 -0
- package/prompts/developer/README.md +129 -0
- package/prompts/developer/fix-bug.md +136 -0
- package/prompts/developer/implement-feature.md +133 -0
- package/prompts/product-owner/README.md +116 -0
- package/prompts/product-owner/define-feature.md +145 -0
- package/prompts/reviewer/README.md +91 -0
- package/prompts/reviewer/code-review.md +129 -0
- package/prompts/support/README.md +154 -0
- package/prompts/support/resolve-issue.md +124 -0
- package/roles/README.md +6 -0
- package/roles/design-architect/README.md +98 -0
- package/roles/design-architect/accessibility/README.md +33 -0
- package/roles/design-architect/accessibility/checklists.md +29 -0
- package/roles/design-architect/accessibility/examples.md +35 -0
- package/roles/design-architect/checklists.md +76 -0
- package/roles/design-architect/component-library/README.md +35 -0
- package/roles/design-architect/component-library/checklists.md +29 -0
- package/roles/design-architect/component-library/examples.md +35 -0
- package/roles/design-architect/design-system/README.md +35 -0
- package/roles/design-architect/design-system/checklists.md +27 -0
- package/roles/design-architect/design-system/examples.md +41 -0
- package/roles/design-architect/examples/README.md +31 -0
- package/roles/design-architect/examples/checklists.md +26 -0
- package/roles/design-architect/examples/examples.md +46 -0
- package/roles/design-architect/examples.md +90 -0
- package/roles/design-architect/figma/README.md +33 -0
- package/roles/design-architect/figma/checklists.md +27 -0
- package/roles/design-architect/figma/examples.md +38 -0
- package/roles/design-architect/responsibilities.md +73 -0
- package/roles/design-architect/responsive/README.md +34 -0
- package/roles/design-architect/responsive/checklists.md +26 -0
- package/roles/design-architect/responsive/examples.md +39 -0
- package/roles/design-architect/role.md +129 -0
- package/roles/design-architect/skill-map.md +42 -0
- package/roles/design-architect/triggers.md +110 -0
- package/roles/design-architect/ui/README.md +36 -0
- package/roles/design-architect/ui/checklists.md +29 -0
- package/roles/design-architect/ui/examples.md +28 -0
- package/roles/design-architect/usability/README.md +34 -0
- package/roles/design-architect/usability/checklists.md +28 -0
- package/roles/design-architect/usability/examples.md +31 -0
- package/roles/design-architect/ux/README.md +36 -0
- package/roles/design-architect/ux/checklists.md +28 -0
- package/roles/design-architect/ux/examples.md +37 -0
- package/roles/design-architect/wireframes/README.md +34 -0
- package/roles/design-architect/wireframes/checklists.md +25 -0
- package/roles/design-architect/wireframes/examples.md +32 -0
- package/roles/design-architect/workflow.md +80 -0
- package/roles/devops/README.md +101 -0
- package/roles/devops/ansible/README.md +6 -0
- package/roles/devops/checklists.md +413 -0
- package/roles/devops/ci-cd/README.md +169 -0
- package/roles/devops/ci-cd/checklists.md +289 -0
- package/roles/devops/ci-cd/examples.md +429 -0
- package/roles/devops/cloud-platforms/README.md +109 -0
- package/roles/devops/cost-optimization/README.md +131 -0
- package/roles/devops/disaster-recovery/README.md +118 -0
- package/roles/devops/docker/README.md +6 -0
- package/roles/devops/examples/README.md +6 -0
- package/roles/devops/examples.md +775 -0
- package/roles/devops/github-actions/README.md +6 -0
- package/roles/devops/helm/README.md +6 -0
- package/roles/devops/infrastructure-as-code/README.md +160 -0
- package/roles/devops/infrastructure-as-code/checklists.md +124 -0
- package/roles/devops/jenkins/README.md +6 -0
- package/roles/devops/kubernetes/README.md +150 -0
- package/roles/devops/kubernetes/checklists.md +192 -0
- package/roles/devops/kubernetes/examples.md +189 -0
- package/roles/devops/monitoring/README.md +93 -0
- package/roles/devops/networking/README.md +83 -0
- package/roles/devops/performance/README.md +104 -0
- package/roles/devops/responsibilities.md +95 -0
- package/roles/devops/role.md +130 -0
- package/roles/devops/security/README.md +126 -0
- package/roles/devops/skill-map.md +162 -0
- package/roles/devops/terraform/README.md +6 -0
- package/roles/devops/triggers.md +241 -0
- package/roles/devops/workflow.md +197 -0
- package/roles/qa/README.md +16 -0
- package/roles/qa/api-testing/README.md +6 -0
- package/roles/qa/automation/README.md +6 -0
- package/roles/qa/checklists.md +24 -0
- package/roles/qa/examples/README.md +6 -0
- package/roles/qa/examples.md +27 -0
- package/roles/qa/performance/README.md +6 -0
- package/roles/qa/playwright/README.md +6 -0
- package/roles/qa/responsibilities.md +16 -0
- package/roles/qa/role.md +47 -0
- package/roles/qa/selenium/README.md +6 -0
- package/roles/qa/skill-map.md +14 -0
- package/roles/qa/triggers.md +10 -0
- package/roles/qa/workflow.md +9 -0
- package/roles/software-architect/README.md +16 -0
- package/roles/software-architect/agents/README.md +6 -0
- package/roles/software-architect/ai-architecture/README.md +6 -0
- package/roles/software-architect/aws/README.md +6 -0
- package/roles/software-architect/azure/README.md +6 -0
- package/roles/software-architect/caching/README.md +6 -0
- package/roles/software-architect/checklists.md +25 -0
- package/roles/software-architect/cloud/README.md +6 -0
- package/roles/software-architect/database-design/README.md +6 -0
- package/roles/software-architect/diagrams/README.md +6 -0
- package/roles/software-architect/distributed-systems/README.md +7 -0
- package/roles/software-architect/docker/README.md +6 -0
- package/roles/software-architect/event-driven/README.md +7 -0
- package/roles/software-architect/examples/README.md +6 -0
- package/roles/software-architect/examples.md +22 -0
- package/roles/software-architect/gcp/README.md +6 -0
- package/roles/software-architect/kubernetes/README.md +6 -0
- package/roles/software-architect/messaging/README.md +6 -0
- package/roles/software-architect/rag/README.md +7 -0
- package/roles/software-architect/responsibilities.md +17 -0
- package/roles/software-architect/role.md +46 -0
- package/roles/software-architect/scalability/README.md +6 -0
- package/roles/software-architect/security/README.md +6 -0
- package/roles/software-architect/skill-map.md +15 -0
- package/roles/software-architect/system-design/README.md +6 -0
- package/roles/software-architect/triggers.md +10 -0
- package/roles/software-architect/vector-db/README.md +6 -0
- package/roles/software-architect/workflow.md +9 -0
- package/roles/software-developer/README.md +116 -0
- package/roles/software-developer/api/README.md +365 -0
- package/roles/software-developer/api/checklist.md +131 -0
- package/roles/software-developer/api/examples.md +459 -0
- package/roles/software-developer/authentication/README.md +26 -0
- package/roles/software-developer/authentication/checklists.md +22 -0
- package/roles/software-developer/authentication/examples.md +32 -0
- package/roles/software-developer/authorization/README.md +26 -0
- package/roles/software-developer/authorization/checklists.md +21 -0
- package/roles/software-developer/authorization/examples.md +27 -0
- package/roles/software-developer/backend/README.md +26 -0
- package/roles/software-developer/backend/checklists.md +21 -0
- package/roles/software-developer/backend/examples.md +21 -0
- package/roles/software-developer/cache/README.md +25 -0
- package/roles/software-developer/cache/checklists.md +21 -0
- package/roles/software-developer/cache/examples.md +22 -0
- package/roles/software-developer/checklists.md +122 -0
- package/roles/software-developer/code-review/README.md +23 -0
- package/roles/software-developer/code-review/checklists.md +22 -0
- package/roles/software-developer/code-review/examples.md +20 -0
- package/roles/software-developer/database/README.md +27 -0
- package/roles/software-developer/database/checklists.md +21 -0
- package/roles/software-developer/database/examples.md +27 -0
- package/roles/software-developer/debugging/README.md +24 -0
- package/roles/software-developer/debugging/checklists.md +20 -0
- package/roles/software-developer/debugging/examples.md +28 -0
- package/roles/software-developer/examples/README.md +22 -0
- package/roles/software-developer/examples/checklists.md +8 -0
- package/roles/software-developer/examples/examples.md +25 -0
- package/roles/software-developer/examples.md +378 -0
- package/roles/software-developer/frontend/README.md +76 -0
- package/roles/software-developer/frontend/accessibility/README.md +136 -0
- package/roles/software-developer/frontend/accessibility/best-practices.md +368 -0
- package/roles/software-developer/frontend/code-quality/README.md +136 -0
- package/roles/software-developer/frontend/code-quality/best-practices.md +309 -0
- package/roles/software-developer/frontend/components/README.md +65 -0
- package/roles/software-developer/frontend/components/best-practices.md +273 -0
- package/roles/software-developer/frontend/debugging/README.md +149 -0
- package/roles/software-developer/frontend/debugging/best-practices.md +329 -0
- package/roles/software-developer/frontend/examples/README.md +19 -0
- package/roles/software-developer/frontend/examples/checklists.md +8 -0
- package/roles/software-developer/frontend/examples/examples.md +17 -0
- package/roles/software-developer/frontend/logging-observability/README.md +196 -0
- package/roles/software-developer/frontend/logging-observability/best-practices.md +430 -0
- package/roles/software-developer/frontend/performance/README.md +99 -0
- package/roles/software-developer/frontend/performance/best-practices.md +350 -0
- package/roles/software-developer/frontend/state-management/README.md +85 -0
- package/roles/software-developer/frontend/state-management/best-practices.md +344 -0
- package/roles/software-developer/frontend/testing/README.md +114 -0
- package/roles/software-developer/frontend/testing/best-practices.md +272 -0
- package/roles/software-developer/fullstack/README.md +25 -0
- package/roles/software-developer/fullstack/checklists.md +19 -0
- package/roles/software-developer/fullstack/examples.md +14 -0
- package/roles/software-developer/graphql/README.md +24 -0
- package/roles/software-developer/graphql/checklists.md +20 -0
- package/roles/software-developer/graphql/examples.md +24 -0
- package/roles/software-developer/integration-tests/README.md +25 -0
- package/roles/software-developer/integration-tests/checklists.md +20 -0
- package/roles/software-developer/integration-tests/examples.md +18 -0
- package/roles/software-developer/java/README.md +24 -0
- package/roles/software-developer/java/checklists.md +16 -0
- package/roles/software-developer/java/examples.md +22 -0
- package/roles/software-developer/javascript/README.md +24 -0
- package/roles/software-developer/javascript/checklists.md +15 -0
- package/roles/software-developer/javascript/examples.md +18 -0
- package/roles/software-developer/logging/README.md +105 -0
- package/roles/software-developer/logging/checklists.md +48 -0
- package/roles/software-developer/logging/examples.md +135 -0
- package/roles/software-developer/messaging/README.md +24 -0
- package/roles/software-developer/messaging/checklists.md +21 -0
- package/roles/software-developer/messaging/examples.md +26 -0
- package/roles/software-developer/microservices/README.md +25 -0
- package/roles/software-developer/microservices/checklists.md +21 -0
- package/roles/software-developer/microservices/examples.md +21 -0
- package/roles/software-developer/node/README.md +25 -0
- package/roles/software-developer/node/checklists.md +15 -0
- package/roles/software-developer/node/examples.md +15 -0
- package/roles/software-developer/nosql/README.md +24 -0
- package/roles/software-developer/nosql/checklists.md +21 -0
- package/roles/software-developer/nosql/examples.md +20 -0
- package/roles/software-developer/observability/README.md +25 -0
- package/roles/software-developer/observability/checklists.md +21 -0
- package/roles/software-developer/observability/examples.md +22 -0
- package/roles/software-developer/performance/README.md +26 -0
- package/roles/software-developer/performance/checklists.md +20 -0
- package/roles/software-developer/performance/examples.md +20 -0
- package/roles/software-developer/python/README.md +25 -0
- package/roles/software-developer/python/checklists.md +15 -0
- package/roles/software-developer/python/examples.md +17 -0
- package/roles/software-developer/react/README.md +24 -0
- package/roles/software-developer/react/checklists.md +15 -0
- package/roles/software-developer/react/examples.md +22 -0
- package/roles/software-developer/refactoring/README.md +23 -0
- package/roles/software-developer/refactoring/checklists.md +21 -0
- package/roles/software-developer/refactoring/examples.md +11 -0
- package/roles/software-developer/responsibilities.md +58 -0
- package/roles/software-developer/role.md +127 -0
- package/roles/software-developer/skill-map.md +88 -0
- package/roles/software-developer/springboot/README.md +25 -0
- package/roles/software-developer/springboot/checklists.md +15 -0
- package/roles/software-developer/springboot/examples.md +21 -0
- package/roles/software-developer/sql/README.md +24 -0
- package/roles/software-developer/sql/checklists.md +22 -0
- package/roles/software-developer/sql/examples.md +20 -0
- package/roles/software-developer/testing/README.md +25 -0
- package/roles/software-developer/testing/checklists.md +21 -0
- package/roles/software-developer/testing/examples.md +19 -0
- package/roles/software-developer/triggers.md +550 -0
- package/roles/software-developer/typescript/README.md +25 -0
- package/roles/software-developer/typescript/checklists.md +15 -0
- package/roles/software-developer/typescript/examples.md +18 -0
- package/roles/software-developer/unit-tests/README.md +24 -0
- package/roles/software-developer/unit-tests/checklists.md +19 -0
- package/roles/software-developer/unit-tests/examples.md +22 -0
- package/roles/software-developer/workflow.md +196 -0
- package/roles/sre/README.md +16 -0
- package/roles/sre/alerts/README.md +6 -0
- package/roles/sre/availability/README.md +6 -0
- package/roles/sre/chaos/README.md +6 -0
- package/roles/sre/checklists.md +24 -0
- package/roles/sre/examples/README.md +6 -0
- package/roles/sre/examples.md +19 -0
- package/roles/sre/observability/README.md +6 -0
- package/roles/sre/reliability/README.md +6 -0
- package/roles/sre/responsibilities.md +16 -0
- package/roles/sre/role.md +46 -0
- package/roles/sre/skill-map.md +14 -0
- package/roles/sre/slos/README.md +6 -0
- package/roles/sre/triggers.md +10 -0
- package/roles/sre/workflow.md +9 -0
- package/roles/support-engineer/README.md +16 -0
- package/roles/support-engineer/checklists.md +24 -0
- package/roles/support-engineer/datadog/README.md +6 -0
- package/roles/support-engineer/examples/README.md +6 -0
- package/roles/support-engineer/examples.md +17 -0
- package/roles/support-engineer/incident-response/README.md +6 -0
- package/roles/support-engineer/kubernetes/README.md +6 -0
- package/roles/support-engineer/linux/README.md +6 -0
- package/roles/support-engineer/logs/README.md +6 -0
- package/roles/support-engineer/monitoring/README.md +6 -0
- package/roles/support-engineer/networking/README.md +6 -0
- package/roles/support-engineer/newrelic/README.md +6 -0
- package/roles/support-engineer/postmortem/README.md +6 -0
- package/roles/support-engineer/production/README.md +6 -0
- package/roles/support-engineer/responsibilities.md +16 -0
- package/roles/support-engineer/role.md +47 -0
- package/roles/support-engineer/root-cause-analysis/README.md +6 -0
- package/roles/support-engineer/runbooks/README.md +6 -0
- package/roles/support-engineer/skill-map.md +14 -0
- package/roles/support-engineer/splunk/README.md +6 -0
- package/roles/support-engineer/triggers.md +10 -0
- package/roles/support-engineer/troubleshooting/README.md +6 -0
- package/roles/support-engineer/workflow.md +9 -0
- package/setup.sh +204 -0
- package/skills/.claude/README.md +7 -0
- package/skills/README.md +21 -0
- package/skills/ai-agents/README.md +207 -0
- package/skills/ai-agents/examples.md +335 -0
- package/skills/ai-agents/skill.md +392 -0
- package/skills/architecture/README.md +198 -0
- package/skills/architecture/examples.md +316 -0
- package/skills/architecture/skill.md +189 -0
- package/skills/design-architecture/README.md +107 -0
- package/skills/design-architecture/examples.md +84 -0
- package/skills/design-architecture/skill.md +192 -0
- package/skills/devops/README.md +177 -0
- package/skills/devops/examples.md +376 -0
- package/skills/devops/skill.md +210 -0
- package/skills/documentation/README.md +182 -0
- package/skills/documentation/examples.md +364 -0
- package/skills/documentation/skill.md +200 -0
- package/skills/performance/README.md +177 -0
- package/skills/performance/examples.md +376 -0
- package/skills/performance/skill.md +199 -0
- package/skills/qa/README.md +106 -0
- package/skills/qa/examples.md +84 -0
- package/skills/qa/skill.md +384 -0
- package/skills/security/README.md +108 -0
- package/skills/security/examples.md +85 -0
- package/skills/security/skill.md +223 -0
- package/skills/software-development/README.md +239 -0
- package/skills/software-development/assessment.md +0 -0
- package/skills/software-development/checklists.md +0 -0
- package/skills/software-development/examples.md +375 -0
- package/skills/software-development/prompts.md +0 -0
- package/skills/software-development/skill.md +390 -0
- package/skills/software-development/templates/README.md +7 -0
- package/skills/software-development/templates/api-development.md +0 -0
- package/skills/software-development/templates/bug-fix.md +0 -0
- package/skills/software-development/templates/code-review.md +0 -0
- package/skills/software-development/templates/feature-implementation.md +0 -0
- package/skills/software-development/templates/llm-integration.md +0 -0
- package/skills/software-development/templates/performance-review.md +0 -0
- package/skills/software-development/templates/security-review.md +0 -0
- package/skills/software-development/templates/test-generation.md +0 -0
- package/skills/software-development/tools.md +0 -0
- package/skills/software-development/workflows.md +0 -0
- package/skills/sre/README.md +107 -0
- package/skills/sre/examples.md +379 -0
- package/skills/sre/skill.md +256 -0
- package/skills/support-engineering/README.md +107 -0
- package/skills/support-engineering/examples.md +85 -0
- package/skills/support-engineering/skill.md +103 -0
package/hooks/README.md
ADDED
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
# Hooks
|
|
2
|
+
|
|
3
|
+
Automation triggers and workflows for common development scenarios.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
Hooks are triggered at specific points in workflows to automate checks, validations, and processes. They can:
|
|
8
|
+
- Run before/after tasks or commits
|
|
9
|
+
- Validate code quality
|
|
10
|
+
- Execute security checks
|
|
11
|
+
- Generate documentation
|
|
12
|
+
- Deploy applications
|
|
13
|
+
- Run tests
|
|
14
|
+
|
|
15
|
+
## Hook Categories
|
|
16
|
+
|
|
17
|
+
### Pre-Task Hooks
|
|
18
|
+
|
|
19
|
+
Run before starting a task:
|
|
20
|
+
- `validate-environment` - Check environment is ready
|
|
21
|
+
- `check-branch` - Verify on correct branch
|
|
22
|
+
- `fetch-latest` - Pull latest changes
|
|
23
|
+
- `backup-state` - Save current state before changes
|
|
24
|
+
|
|
25
|
+
### Post-Task Hooks
|
|
26
|
+
|
|
27
|
+
Run after task completion:
|
|
28
|
+
- `run-tests` - Validate changes work
|
|
29
|
+
- `update-docs` - Update documentation
|
|
30
|
+
- `commit-changes` - Auto-commit if needed
|
|
31
|
+
- `notify-team` - Alert team of progress
|
|
32
|
+
|
|
33
|
+
### Pre-Commit Hooks
|
|
34
|
+
|
|
35
|
+
Run before committing:
|
|
36
|
+
- `lint` - Check code quality
|
|
37
|
+
- `format` - Auto-format code
|
|
38
|
+
- `type-check` - Validate types
|
|
39
|
+
- `security-scan` - Check for vulnerabilities
|
|
40
|
+
|
|
41
|
+
### Code Review Hooks
|
|
42
|
+
|
|
43
|
+
Run during code review:
|
|
44
|
+
- `check-coverage` - Verify test coverage
|
|
45
|
+
- `analyze-complexity` - Check code complexity
|
|
46
|
+
- `security-review` - Security assessment
|
|
47
|
+
- `performance-check` - Performance analysis
|
|
48
|
+
|
|
49
|
+
### Test Hooks
|
|
50
|
+
|
|
51
|
+
Run test validations:
|
|
52
|
+
- `unit-tests` - Run unit tests
|
|
53
|
+
- `integration-tests` - Run integration tests
|
|
54
|
+
- `e2e-tests` - Run end-to-end tests
|
|
55
|
+
- `coverage-report` - Generate coverage report
|
|
56
|
+
|
|
57
|
+
### Deployment Hooks
|
|
58
|
+
|
|
59
|
+
Run during deployment:
|
|
60
|
+
- `pre-deploy-check` - Verify readiness
|
|
61
|
+
- `health-check` - Verify system health
|
|
62
|
+
- `smoke-tests` - Run quick tests
|
|
63
|
+
- `post-deploy-notify` - Notify of deployment
|
|
64
|
+
|
|
65
|
+
### Security Hooks
|
|
66
|
+
|
|
67
|
+
Run security checks:
|
|
68
|
+
- `dependency-audit` - Check for vulnerabilities
|
|
69
|
+
- `secrets-scan` - Scan for exposed secrets
|
|
70
|
+
- `sast` - Static application security testing
|
|
71
|
+
- `dast` - Dynamic application security testing
|
|
72
|
+
|
|
73
|
+
### Documentation Hooks
|
|
74
|
+
|
|
75
|
+
Generate and update docs:
|
|
76
|
+
- `update-changelog` - Update changelog
|
|
77
|
+
- `generate-api-docs` - Generate API documentation
|
|
78
|
+
- `update-readme` - Update README
|
|
79
|
+
- `generate-diagrams` - Generate architecture diagrams
|
|
80
|
+
|
|
81
|
+
### Custom Hooks
|
|
82
|
+
|
|
83
|
+
Project-specific automation:
|
|
84
|
+
- Define custom hooks per project
|
|
85
|
+
- Extend standard hooks
|
|
86
|
+
- Create domain-specific automation
|
|
87
|
+
|
|
88
|
+
## Using Hooks
|
|
89
|
+
|
|
90
|
+
### In Claude Code Settings
|
|
91
|
+
|
|
92
|
+
Hooks are configured in `.claude/settings.json`:
|
|
93
|
+
|
|
94
|
+
```json
|
|
95
|
+
{
|
|
96
|
+
"hooks": {
|
|
97
|
+
"before_commit": ["lint", "type-check"],
|
|
98
|
+
"before_push": ["test", "security-scan"],
|
|
99
|
+
"after_task": ["update-docs"],
|
|
100
|
+
"on_pr_creation": ["code-review-checklist"]
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Running Hooks Manually
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
# Run specific hook
|
|
109
|
+
bash hooks/pre-commit/lint.sh
|
|
110
|
+
|
|
111
|
+
# Run all hooks in category
|
|
112
|
+
for hook in hooks/pre-commit/*.sh; do bash "$hook"; done
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### CI/CD Integration
|
|
116
|
+
|
|
117
|
+
```yaml
|
|
118
|
+
# GitHub Actions example
|
|
119
|
+
- name: Run pre-commit hooks
|
|
120
|
+
run: |
|
|
121
|
+
for hook in hooks/pre-commit/*.sh; do
|
|
122
|
+
bash "$hook"
|
|
123
|
+
done
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## Hook Format
|
|
127
|
+
|
|
128
|
+
Each hook follows this structure:
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
#!/bin/bash
|
|
132
|
+
# [hook-name].sh
|
|
133
|
+
# Category: [pre-task|post-task|pre-commit|etc]
|
|
134
|
+
# Purpose: [what this hook does]
|
|
135
|
+
# Trigger: [when this runs]
|
|
136
|
+
|
|
137
|
+
set -e
|
|
138
|
+
|
|
139
|
+
echo "Running [hook-name]..."
|
|
140
|
+
|
|
141
|
+
# Validation
|
|
142
|
+
if ! command -v [tool] &> /dev/null; then
|
|
143
|
+
echo "Error: [tool] not found"
|
|
144
|
+
exit 1
|
|
145
|
+
fi
|
|
146
|
+
|
|
147
|
+
# Main logic
|
|
148
|
+
echo "Checking..."
|
|
149
|
+
|
|
150
|
+
# Actions
|
|
151
|
+
if [ problem ]; then
|
|
152
|
+
echo "Found issue..."
|
|
153
|
+
exit 1
|
|
154
|
+
fi
|
|
155
|
+
|
|
156
|
+
echo "✓ [hook-name] passed"
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## Hook Best Practices
|
|
160
|
+
|
|
161
|
+
**Do:**
|
|
162
|
+
- ✅ Keep hooks focused on one concern
|
|
163
|
+
- ✅ Make hooks idempotent (safe to run multiple times)
|
|
164
|
+
- ✅ Provide clear output about what passed/failed
|
|
165
|
+
- ✅ Return meaningful exit codes (0 = pass, 1 = fail)
|
|
166
|
+
- ✅ Support dry-run mode
|
|
167
|
+
- ✅ Document hook purpose and triggers
|
|
168
|
+
- ✅ Make hooks fast (avoid slow operations)
|
|
169
|
+
- ✅ Allow disabling hooks when necessary
|
|
170
|
+
|
|
171
|
+
**Don't:**
|
|
172
|
+
- ❌ Make hooks take too long
|
|
173
|
+
- ❌ Fail silently without feedback
|
|
174
|
+
- ❌ Require manual interaction
|
|
175
|
+
- ❌ Hardcode paths or configuration
|
|
176
|
+
- ❌ Have interdependencies between hooks
|
|
177
|
+
- ❌ Modify code without permission
|
|
178
|
+
|
|
179
|
+
## Common Hook Patterns
|
|
180
|
+
|
|
181
|
+
### Exit Codes
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
# Success
|
|
185
|
+
exit 0
|
|
186
|
+
|
|
187
|
+
# Failure
|
|
188
|
+
exit 1
|
|
189
|
+
|
|
190
|
+
# Conditional based on environment
|
|
191
|
+
if [ "$CI" = "true" ]; then
|
|
192
|
+
exit 1 # Strict in CI
|
|
193
|
+
else
|
|
194
|
+
exit 0 # Warning only locally
|
|
195
|
+
fi
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### Dry Run Support
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
if [ "$DRY_RUN" = "true" ]; then
|
|
202
|
+
echo "[Would execute: command]"
|
|
203
|
+
else
|
|
204
|
+
command
|
|
205
|
+
fi
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
### Skip Hooks
|
|
209
|
+
|
|
210
|
+
```bash
|
|
211
|
+
if [ "$SKIP_HOOKS" = "true" ]; then
|
|
212
|
+
echo "Skipping hooks"
|
|
213
|
+
exit 0
|
|
214
|
+
fi
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
### Environment Checks
|
|
218
|
+
|
|
219
|
+
```bash
|
|
220
|
+
if ! command -v tool &> /dev/null; then
|
|
221
|
+
echo "Warning: tool not found, skipping"
|
|
222
|
+
exit 0
|
|
223
|
+
fi
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
## Hook Configuration
|
|
227
|
+
|
|
228
|
+
### Environment Variables
|
|
229
|
+
|
|
230
|
+
Standard variables hooks can use:
|
|
231
|
+
|
|
232
|
+
- `CI` - Running in CI environment
|
|
233
|
+
- `DRY_RUN` - Show what would execute
|
|
234
|
+
- `SKIP_HOOKS` - Skip all hooks
|
|
235
|
+
- `VERBOSE` - More output
|
|
236
|
+
- `ENVIRONMENT` - Current environment (dev/staging/prod)
|
|
237
|
+
|
|
238
|
+
### File Paths
|
|
239
|
+
|
|
240
|
+
Hooks should be resilient to different working directories:
|
|
241
|
+
|
|
242
|
+
```bash
|
|
243
|
+
# Good: relative to hook location
|
|
244
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
245
|
+
|
|
246
|
+
# Better: use git root
|
|
247
|
+
GIT_ROOT=$(git rev-parse --show-toplevel)
|
|
248
|
+
cd "$GIT_ROOT"
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
## Extending Hooks
|
|
252
|
+
|
|
253
|
+
### Add Hook to Category
|
|
254
|
+
|
|
255
|
+
```bash
|
|
256
|
+
# Create new hook
|
|
257
|
+
touch hooks/[category]/[new-hook].sh
|
|
258
|
+
|
|
259
|
+
# Make executable
|
|
260
|
+
chmod +x hooks/[category]/[new-hook].sh
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
### Create Custom Category
|
|
264
|
+
|
|
265
|
+
```bash
|
|
266
|
+
# Create new category directory
|
|
267
|
+
mkdir -p hooks/[custom-category]
|
|
268
|
+
|
|
269
|
+
# Add hooks to new category
|
|
270
|
+
touch hooks/[custom-category]/[hook].sh
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
## Troubleshooting Hooks
|
|
274
|
+
|
|
275
|
+
### Hook Not Running
|
|
276
|
+
|
|
277
|
+
- Check file is executable: `chmod +x hooks/[category]/[hook].sh`
|
|
278
|
+
- Verify it's configured in settings.json
|
|
279
|
+
- Check environment variables are set
|
|
280
|
+
- Review logs for errors
|
|
281
|
+
|
|
282
|
+
### Hook Too Slow
|
|
283
|
+
|
|
284
|
+
- Profile hook to find bottleneck
|
|
285
|
+
- Consider running only in CI
|
|
286
|
+
- Cache expensive operations
|
|
287
|
+
- Split into smaller hooks
|
|
288
|
+
|
|
289
|
+
### Hook Breaking Workflow
|
|
290
|
+
|
|
291
|
+
- Add `SKIP_HOOKS=true` to bypass
|
|
292
|
+
- Debug with `VERBOSE=true`
|
|
293
|
+
- Check for hook dependencies
|
|
294
|
+
- Review recent changes to hook
|
|
295
|
+
|
|
296
|
+
## Hook Integration Examples
|
|
297
|
+
|
|
298
|
+
### Complete Workflow
|
|
299
|
+
|
|
300
|
+
```bash
|
|
301
|
+
# Pre-task
|
|
302
|
+
hooks/pre-task/validate-environment.sh
|
|
303
|
+
hooks/pre-task/check-branch.sh
|
|
304
|
+
|
|
305
|
+
# Development
|
|
306
|
+
# [work on code]
|
|
307
|
+
|
|
308
|
+
# Pre-commit
|
|
309
|
+
hooks/pre-commit/lint.sh
|
|
310
|
+
hooks/pre-commit/type-check.sh
|
|
311
|
+
hooks/pre-commit/format.sh
|
|
312
|
+
|
|
313
|
+
# Push
|
|
314
|
+
# [git push]
|
|
315
|
+
|
|
316
|
+
# CI/CD
|
|
317
|
+
# runs all test hooks
|
|
318
|
+
# runs security hooks
|
|
319
|
+
# runs deployment hooks
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
## Version
|
|
323
|
+
|
|
324
|
+
**Version:** 1.0
|
|
325
|
+
|
|
326
|
+
Hooks provide flexible automation at key workflow points. Customize per project and team.
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# check-coverage Hook
|
|
2
|
+
|
|
3
|
+
**Category:** code-review
|
|
4
|
+
**Purpose:** Verify test coverage meets minimum threshold
|
|
5
|
+
**Trigger:** During code review / in CI
|
|
6
|
+
|
|
7
|
+
## Description
|
|
8
|
+
|
|
9
|
+
Validates that code changes are covered by tests and meet the project's minimum coverage threshold.
|
|
10
|
+
|
|
11
|
+
## Coverage Metrics Checked
|
|
12
|
+
|
|
13
|
+
- **Line coverage** - Percentage of code lines executed by tests
|
|
14
|
+
- **Branch coverage** - Percentage of conditional branches tested
|
|
15
|
+
- **Function coverage** - Percentage of functions called by tests
|
|
16
|
+
- **Statement coverage** - Percentage of statements executed
|
|
17
|
+
|
|
18
|
+
## Default Threshold
|
|
19
|
+
|
|
20
|
+
- **Minimum:** 80% line coverage
|
|
21
|
+
- **Can be configured** in `package.json` or environment
|
|
22
|
+
|
|
23
|
+
## Supported Tools
|
|
24
|
+
|
|
25
|
+
| Language | Tool |
|
|
26
|
+
|----------|------|
|
|
27
|
+
| JavaScript/TypeScript | Istanbul/nyc, Jest coverage |
|
|
28
|
+
| Python | coverage.py |
|
|
29
|
+
| Go | go coverage |
|
|
30
|
+
|
|
31
|
+
## Success Criteria
|
|
32
|
+
|
|
33
|
+
✓ Coverage >= configured minimum
|
|
34
|
+
✓ No significant drops from main
|
|
35
|
+
✓ New code has tests
|
|
36
|
+
|
|
37
|
+
## Configuration
|
|
38
|
+
|
|
39
|
+
Set threshold in `package.json`:
|
|
40
|
+
```json
|
|
41
|
+
{
|
|
42
|
+
"jest": {
|
|
43
|
+
"coverageThreshold": {
|
|
44
|
+
"global": {
|
|
45
|
+
"lines": 80,
|
|
46
|
+
"functions": 80,
|
|
47
|
+
"branches": 75
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Environment Variables
|
|
55
|
+
|
|
56
|
+
- `MIN_COVERAGE=90` - Override threshold
|
|
57
|
+
- `SKIP_HOOKS=true` - Skip check
|
|
58
|
+
- `CI=true` - Strict mode
|
|
59
|
+
|
|
60
|
+
## Failure Handling
|
|
61
|
+
|
|
62
|
+
| Scenario | Local | CI |
|
|
63
|
+
|---|---|---|
|
|
64
|
+
| Below threshold | Warning | Error |
|
|
65
|
+
| Coverage drops | Warning | Error |
|
|
66
|
+
| No test changes | Prompt | Error |
|
|
67
|
+
|
|
68
|
+
## Coverage Reports
|
|
69
|
+
|
|
70
|
+
View detailed reports:
|
|
71
|
+
```bash
|
|
72
|
+
npm run test:coverage
|
|
73
|
+
open coverage/lcov-report/index.html
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## How to Improve Coverage
|
|
77
|
+
|
|
78
|
+
1. Add tests for uncovered code
|
|
79
|
+
2. Write integration tests
|
|
80
|
+
3. Test error scenarios
|
|
81
|
+
4. Test edge cases
|
|
82
|
+
|
|
83
|
+
## Related Hooks
|
|
84
|
+
|
|
85
|
+
- `post-task/run-tests.md` - Run tests
|
|
86
|
+
- `test-before-finish/run-all-tests.md` - Comprehensive tests
|
|
87
|
+
|
|
88
|
+
## Common Issues
|
|
89
|
+
|
|
90
|
+
| Issue | Solution |
|
|
91
|
+
|---|---|
|
|
92
|
+
| Coverage drops | Add tests for new code |
|
|
93
|
+
| Excluded files hurt coverage | Adjust coverage config |
|
|
94
|
+
| Unrealistic threshold | Adjust to project needs |
|
|
95
|
+
|
|
96
|
+
## Implementation Notes
|
|
97
|
+
|
|
98
|
+
- Generated from test runs
|
|
99
|
+
- HTML reports available
|
|
100
|
+
- Badge-friendly output
|
|
101
|
+
- CI/CD integration ready
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
# Project-Specific Hooks
|
|
2
|
+
|
|
3
|
+
**Category:** custom
|
|
4
|
+
**Purpose:** Define domain or project-specific automation
|
|
5
|
+
**Trigger:** Custom (project-defined)
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
Custom hooks allow teams to extend the standard hook system with checks, validations, and automations specific to their project or domain.
|
|
10
|
+
|
|
11
|
+
## Creating Custom Hooks
|
|
12
|
+
|
|
13
|
+
### 1. Define Hook Purpose
|
|
14
|
+
|
|
15
|
+
Create a .md file describing what the hook does:
|
|
16
|
+
|
|
17
|
+
```markdown
|
|
18
|
+
# hook-name Hook
|
|
19
|
+
|
|
20
|
+
**Category:** custom
|
|
21
|
+
**Purpose:** [What this validates]
|
|
22
|
+
**Trigger:** [When it runs]
|
|
23
|
+
|
|
24
|
+
## Description
|
|
25
|
+
...
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### 2. Document Success Criteria
|
|
29
|
+
|
|
30
|
+
What must pass for the hook to succeed?
|
|
31
|
+
|
|
32
|
+
### 3. Define Configuration
|
|
33
|
+
|
|
34
|
+
How is the hook configured for your project?
|
|
35
|
+
|
|
36
|
+
### 4. Document Failure Handling
|
|
37
|
+
|
|
38
|
+
What happens if the hook fails?
|
|
39
|
+
|
|
40
|
+
## Common Custom Hooks
|
|
41
|
+
|
|
42
|
+
### 1. Commit Message Format
|
|
43
|
+
|
|
44
|
+
Validates commit messages follow conventional format:
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
feat(feature): description
|
|
48
|
+
fix(bug): description
|
|
49
|
+
docs: documentation
|
|
50
|
+
refactor: code cleanup
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
**Trigger:** Before commit
|
|
54
|
+
**Tools:** commitlint, husky
|
|
55
|
+
|
|
56
|
+
### 2. Branch Naming
|
|
57
|
+
|
|
58
|
+
Validates branch names follow convention:
|
|
59
|
+
|
|
60
|
+
```
|
|
61
|
+
feature/short-description
|
|
62
|
+
bugfix/issue-123
|
|
63
|
+
hotfix/description
|
|
64
|
+
release/1.2.3
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
**Trigger:** Before push
|
|
68
|
+
**Tools:** Custom regex validation
|
|
69
|
+
|
|
70
|
+
### 3. File Size Limits
|
|
71
|
+
|
|
72
|
+
Prevents large files from being committed:
|
|
73
|
+
|
|
74
|
+
**Trigger:** Before commit
|
|
75
|
+
**Limits:**
|
|
76
|
+
- Images: < 2MB
|
|
77
|
+
- Videos: < 50MB
|
|
78
|
+
- Documents: < 10MB
|
|
79
|
+
|
|
80
|
+
### 4. API Contract Validation
|
|
81
|
+
|
|
82
|
+
Validates API changes match contract:
|
|
83
|
+
|
|
84
|
+
**Trigger:** Before commit (API files)
|
|
85
|
+
**Checks:**
|
|
86
|
+
- Breaking changes documented
|
|
87
|
+
- Examples updated
|
|
88
|
+
- Schema validation
|
|
89
|
+
- Backward compatibility
|
|
90
|
+
|
|
91
|
+
### 5. Database Schema
|
|
92
|
+
|
|
93
|
+
Validates database schema changes:
|
|
94
|
+
|
|
95
|
+
**Trigger:** Before commit (migration files)
|
|
96
|
+
**Checks:**
|
|
97
|
+
- Migration is reversible
|
|
98
|
+
- Data loss prevented
|
|
99
|
+
- Indexes defined
|
|
100
|
+
- Foreign keys valid
|
|
101
|
+
|
|
102
|
+
### 6. Configuration Validation
|
|
103
|
+
|
|
104
|
+
Validates config files are correct:
|
|
105
|
+
|
|
106
|
+
**Trigger:** Before commit
|
|
107
|
+
**Checks:**
|
|
108
|
+
- Valid JSON/YAML syntax
|
|
109
|
+
- Required fields present
|
|
110
|
+
- No hardcoded secrets
|
|
111
|
+
- Values in valid range
|
|
112
|
+
|
|
113
|
+
### 7. Dependency License Check
|
|
114
|
+
|
|
115
|
+
Validates dependencies have compatible licenses:
|
|
116
|
+
|
|
117
|
+
**Trigger:** After `npm install`
|
|
118
|
+
**Checks:**
|
|
119
|
+
- No GPL in non-GPL project
|
|
120
|
+
- License compliance
|
|
121
|
+
- Restriction tracking
|
|
122
|
+
|
|
123
|
+
### 8. Code Architecture
|
|
124
|
+
|
|
125
|
+
Validates code follows architecture patterns:
|
|
126
|
+
|
|
127
|
+
**Trigger:** Before commit
|
|
128
|
+
**Checks:**
|
|
129
|
+
- Import paths follow conventions
|
|
130
|
+
- Circular dependencies prevented
|
|
131
|
+
- Layer violations caught
|
|
132
|
+
- Module organization validated
|
|
133
|
+
|
|
134
|
+
## Template
|
|
135
|
+
|
|
136
|
+
```markdown
|
|
137
|
+
# [hook-name] Hook
|
|
138
|
+
|
|
139
|
+
**Category:** custom
|
|
140
|
+
**Purpose:** [What this checks]
|
|
141
|
+
**Trigger:** [When this runs]
|
|
142
|
+
|
|
143
|
+
## Description
|
|
144
|
+
[What the hook does]
|
|
145
|
+
|
|
146
|
+
## Checks Performed
|
|
147
|
+
- Check 1
|
|
148
|
+
- Check 2
|
|
149
|
+
- Check 3
|
|
150
|
+
|
|
151
|
+
## Success Criteria
|
|
152
|
+
✓ Criteria 1
|
|
153
|
+
✓ Criteria 2
|
|
154
|
+
✓ Criteria 3
|
|
155
|
+
|
|
156
|
+
## Failure Handling
|
|
157
|
+
| Scenario | Behavior |
|
|
158
|
+
|----------|----------|
|
|
159
|
+
| Failure 1 | Action |
|
|
160
|
+
| Failure 2 | Action |
|
|
161
|
+
|
|
162
|
+
## Configuration
|
|
163
|
+
[How to configure]
|
|
164
|
+
|
|
165
|
+
## Examples
|
|
166
|
+
[Example scenarios]
|
|
167
|
+
|
|
168
|
+
## Related Hooks
|
|
169
|
+
- Hook A
|
|
170
|
+
- Hook B
|
|
171
|
+
|
|
172
|
+
## Implementation Notes
|
|
173
|
+
- Note 1
|
|
174
|
+
- Note 2
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## Implementation Strategies
|
|
178
|
+
|
|
179
|
+
### Shell Script (Simple)
|
|
180
|
+
```bash
|
|
181
|
+
#!/bin/bash
|
|
182
|
+
# Check condition
|
|
183
|
+
if [ condition ]; then
|
|
184
|
+
echo "✓ Check passed"
|
|
185
|
+
else
|
|
186
|
+
echo "❌ Check failed"
|
|
187
|
+
exit 1
|
|
188
|
+
fi
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### npm Package (JavaScript)
|
|
192
|
+
```javascript
|
|
193
|
+
module.exports = {
|
|
194
|
+
name: 'hook-name',
|
|
195
|
+
check: async () => {
|
|
196
|
+
// validation logic
|
|
197
|
+
return { passed: true, message: 'Check passed' }
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
### GitHub Actions (CI/CD)
|
|
203
|
+
```yaml
|
|
204
|
+
- name: Custom Check
|
|
205
|
+
run: npm run custom:check
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
## Best Practices
|
|
209
|
+
|
|
210
|
+
✓ **Single responsibility** - Each hook does one thing
|
|
211
|
+
✓ **Clear feedback** - Tell users why they failed
|
|
212
|
+
✓ **Fast execution** - Hooks should complete in seconds
|
|
213
|
+
✓ **Idempotent** - Safe to run multiple times
|
|
214
|
+
✓ **Documented** - Clear README explaining behavior
|
|
215
|
+
✓ **Configurable** - Allow teams to tune behavior
|
|
216
|
+
✓ **Graceful failure** - Good error messages
|
|
217
|
+
|
|
218
|
+
## Integration
|
|
219
|
+
|
|
220
|
+
### With Husky
|
|
221
|
+
|
|
222
|
+
```bash
|
|
223
|
+
# Create hook
|
|
224
|
+
npx husky add .husky/commit-msg 'npm run custom:check'
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
### With GitHub Actions
|
|
228
|
+
|
|
229
|
+
```yaml
|
|
230
|
+
- name: Custom checks
|
|
231
|
+
run: |
|
|
232
|
+
for hook in hooks/custom/*.sh; do
|
|
233
|
+
bash "$hook"
|
|
234
|
+
done
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
## Maintenance
|
|
238
|
+
|
|
239
|
+
- Review hooks quarterly
|
|
240
|
+
- Update for new dependencies
|
|
241
|
+
- Remove unused hooks
|
|
242
|
+
- Document changes
|
|
243
|
+
- Test in CI environment
|
|
244
|
+
|
|
245
|
+
## Examples by Domain
|
|
246
|
+
|
|
247
|
+
**E-commerce:**
|
|
248
|
+
- Product data validation
|
|
249
|
+
- Price calculation accuracy
|
|
250
|
+
- Inventory constraints
|
|
251
|
+
|
|
252
|
+
**Healthcare:**
|
|
253
|
+
- HIPAA compliance checks
|
|
254
|
+
- Data privacy validation
|
|
255
|
+
- Audit logging
|
|
256
|
+
|
|
257
|
+
**Finance:**
|
|
258
|
+
- Transaction validation
|
|
259
|
+
- Regulatory compliance
|
|
260
|
+
- Data accuracy
|
|
261
|
+
|
|
262
|
+
**SaaS:**
|
|
263
|
+
- Multi-tenant isolation
|
|
264
|
+
- API rate limiting config
|
|
265
|
+
- Security policies
|
|
266
|
+
|
|
267
|
+
## Support
|
|
268
|
+
|
|
269
|
+
For help creating custom hooks:
|
|
270
|
+
- Review existing hooks in `hooks/` directory
|
|
271
|
+
- Consult team documentation
|
|
272
|
+
- Check integration examples
|
|
273
|
+
- Run in dry-run mode first
|