claude-code-templates 1.21.0 → 1.21.1
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/.claude/agents/agent-expert.md +477 -0
- package/.claude/agents/cli-ui-designer.md +405 -0
- package/.claude/agents/command-expert.md +421 -0
- package/.claude/agents/docusaurus-expert.md +51 -0
- package/.claude/agents/mcp-expert.md +258 -0
- package/.claude/commands/lint.md +111 -0
- package/.claude/commands/test.md +73 -0
- package/.claude/settings.local.json +34 -0
- package/.github/WORKFLOWS_REFERENCE.md +88 -0
- package/.github/workflows/deploy-docusaurus.yml +31 -0
- package/.github/workflows/deploy.yml +33 -0
- package/.github/workflows/publish-package.yml +125 -0
- package/.mcp.json +4 -0
- package/CLAUDE.md +482 -0
- package/CODE_OF_CONDUCT.md +82 -0
- package/CONTRIBUTING.md +505 -0
- package/DEPLOYMENT.md +60 -0
- package/LICENSE +21 -0
- package/README.md +77 -79
- package/ROADMAP.md +278 -0
- package/SECURITY.md +65 -0
- package/api/index.html +1 -0
- package/api/package.json +7 -0
- package/api/track-download-supabase.js +150 -0
- package/cli-tool/Makefile +102 -0
- package/cli-tool/README.md +126 -0
- package/cli-tool/TESTING.md +262 -0
- package/cli-tool/components/agents/ai-specialists/ai-ethics-advisor.md +195 -0
- package/cli-tool/components/agents/ai-specialists/hackathon-ai-strategist.md +46 -0
- package/cli-tool/components/agents/ai-specialists/llms-maintainer.md +94 -0
- package/cli-tool/components/agents/ai-specialists/model-evaluator.md +150 -0
- package/cli-tool/components/agents/ai-specialists/prompt-engineer.md +112 -0
- package/cli-tool/components/agents/ai-specialists/search-specialist.md +59 -0
- package/cli-tool/components/agents/ai-specialists/task-decomposition-expert.md +97 -0
- package/cli-tool/components/agents/api-graphql/graphql-architect.md +208 -0
- package/cli-tool/components/agents/api-graphql/graphql-performance-optimizer.md +357 -0
- package/cli-tool/components/agents/api-graphql/graphql-security-specialist.md +519 -0
- package/cli-tool/components/agents/blockchain-web3/smart-contract-auditor.md +32 -0
- package/cli-tool/components/agents/blockchain-web3/smart-contract-specialist.md +32 -0
- package/cli-tool/components/agents/blockchain-web3/web3-integration-specialist.md +32 -0
- package/cli-tool/components/agents/business-marketing/business-analyst.md +194 -0
- package/cli-tool/components/agents/business-marketing/content-marketer.md +36 -0
- package/cli-tool/components/agents/business-marketing/customer-support.md +36 -0
- package/cli-tool/components/agents/business-marketing/legal-advisor.md +50 -0
- package/cli-tool/components/agents/business-marketing/marketing-attribution-analyst.md +352 -0
- package/cli-tool/components/agents/business-marketing/payment-integration.md +33 -0
- package/cli-tool/components/agents/business-marketing/product-strategist.md +212 -0
- package/cli-tool/components/agents/business-marketing/risk-manager.md +42 -0
- package/cli-tool/components/agents/business-marketing/sales-automator.md +36 -0
- package/cli-tool/components/agents/data-ai/ai-engineer.md +33 -0
- package/cli-tool/components/agents/data-ai/computer-vision-engineer.md +562 -0
- package/cli-tool/components/agents/data-ai/data-engineer.md +33 -0
- package/cli-tool/components/agents/data-ai/data-scientist.md +337 -0
- package/cli-tool/components/agents/data-ai/ml-engineer.md +33 -0
- package/cli-tool/components/agents/data-ai/mlops-engineer.md +58 -0
- package/cli-tool/components/agents/data-ai/nlp-engineer.md +680 -0
- package/cli-tool/components/agents/data-ai/quant-analyst.md +33 -0
- package/cli-tool/components/agents/database/database-admin.md +33 -0
- package/cli-tool/components/agents/database/database-architect.md +590 -0
- package/cli-tool/components/agents/database/database-optimization.md +33 -0
- package/cli-tool/components/agents/database/database-optimizer.md +33 -0
- package/cli-tool/components/agents/database/nosql-specialist.md +708 -0
- package/cli-tool/components/agents/database/supabase-schema-architect.md +138 -0
- package/cli-tool/components/agents/deep-research-team/academic-researcher.md +33 -0
- package/cli-tool/components/agents/deep-research-team/agent-overview.md +235 -0
- package/cli-tool/components/agents/deep-research-team/competitive-intelligence-analyst.md +530 -0
- package/cli-tool/components/agents/deep-research-team/data-analyst.md +112 -0
- package/cli-tool/components/agents/deep-research-team/fact-checker.md +553 -0
- package/cli-tool/components/agents/deep-research-team/query-clarifier.md +73 -0
- package/cli-tool/components/agents/deep-research-team/report-generator.md +108 -0
- package/cli-tool/components/agents/deep-research-team/research-brief-generator.md +108 -0
- package/cli-tool/components/agents/deep-research-team/research-coordinator.md +94 -0
- package/cli-tool/components/agents/deep-research-team/research-orchestrator.md +119 -0
- package/cli-tool/components/agents/deep-research-team/research-synthesizer.md +109 -0
- package/cli-tool/components/agents/deep-research-team/technical-researcher.md +95 -0
- package/cli-tool/components/agents/development-team/backend-architect.md +31 -0
- package/cli-tool/components/agents/development-team/cli-ui-designer.md +405 -0
- package/cli-tool/components/agents/development-team/devops-engineer.md +886 -0
- package/cli-tool/components/agents/development-team/frontend-developer.md +32 -0
- package/cli-tool/components/agents/development-team/fullstack-developer.md +1205 -0
- package/cli-tool/components/agents/development-team/ios-developer.md +36 -0
- package/cli-tool/components/agents/development-team/mobile-developer.md +33 -0
- package/cli-tool/components/agents/development-team/ui-ux-designer.md +36 -0
- package/cli-tool/components/agents/development-tools/code-reviewer.md +30 -0
- package/cli-tool/components/agents/development-tools/command-expert.md +422 -0
- package/cli-tool/components/agents/development-tools/context-manager.md +65 -0
- package/cli-tool/components/agents/development-tools/debugger.md +31 -0
- package/cli-tool/components/agents/development-tools/dx-optimizer.md +64 -0
- package/cli-tool/components/agents/development-tools/error-detective.md +33 -0
- package/cli-tool/components/agents/development-tools/mcp-expert.md +259 -0
- package/cli-tool/components/agents/development-tools/performance-profiler.md +799 -0
- package/cli-tool/components/agents/development-tools/test-engineer.md +936 -0
- package/cli-tool/components/agents/devops-infrastructure/cloud-architect.md +33 -0
- package/cli-tool/components/agents/devops-infrastructure/deployment-engineer.md +33 -0
- package/cli-tool/components/agents/devops-infrastructure/devops-troubleshooter.md +33 -0
- package/cli-tool/components/agents/devops-infrastructure/monitoring-specialist.md +36 -0
- package/cli-tool/components/agents/devops-infrastructure/network-engineer.md +33 -0
- package/cli-tool/components/agents/devops-infrastructure/security-engineer.md +971 -0
- package/cli-tool/components/agents/devops-infrastructure/terraform-specialist.md +36 -0
- package/cli-tool/components/agents/devops-infrastructure/vercel-deployment-specialist.md +357 -0
- package/cli-tool/components/agents/documentation/api-documenter.md +33 -0
- package/cli-tool/components/agents/documentation/changelog-generator.md +37 -0
- package/cli-tool/components/agents/documentation/docusaurus-expert.md +52 -0
- package/cli-tool/components/agents/documentation/technical-writer.md +37 -0
- package/cli-tool/components/agents/expert-advisors/agent-expert.md +477 -0
- package/cli-tool/components/agents/expert-advisors/architect-review.md +50 -0
- package/cli-tool/components/agents/expert-advisors/dependency-manager.md +45 -0
- package/cli-tool/components/agents/expert-advisors/documentation-expert.md +47 -0
- package/cli-tool/components/agents/ffmpeg-clip-team/audio-mixer.md +37 -0
- package/cli-tool/components/agents/ffmpeg-clip-team/audio-quality-controller.md +100 -0
- package/cli-tool/components/agents/ffmpeg-clip-team/podcast-content-analyzer.md +60 -0
- package/cli-tool/components/agents/ffmpeg-clip-team/podcast-metadata-specialist.md +46 -0
- package/cli-tool/components/agents/ffmpeg-clip-team/podcast-transcriber.md +68 -0
- package/cli-tool/components/agents/ffmpeg-clip-team/social-media-clip-creator.md +69 -0
- package/cli-tool/components/agents/ffmpeg-clip-team/timestamp-precision-specialist.md +98 -0
- package/cli-tool/components/agents/ffmpeg-clip-team/video-editor.md +37 -0
- package/cli-tool/components/agents/game-development/3d-artist.md +37 -0
- package/cli-tool/components/agents/game-development/game-designer.md +37 -0
- package/cli-tool/components/agents/game-development/unity-game-developer.md +110 -0
- package/cli-tool/components/agents/game-development/unreal-engine-developer.md +128 -0
- package/cli-tool/components/agents/mcp-dev-team/mcp-deployment-orchestrator.md +101 -0
- package/cli-tool/components/agents/mcp-dev-team/mcp-integration-engineer.md +37 -0
- package/cli-tool/components/agents/mcp-dev-team/mcp-protocol-specialist.md +37 -0
- package/cli-tool/components/agents/mcp-dev-team/mcp-registry-navigator.md +112 -0
- package/cli-tool/components/agents/mcp-dev-team/mcp-security-auditor.md +70 -0
- package/cli-tool/components/agents/mcp-dev-team/mcp-server-architect.md +74 -0
- package/cli-tool/components/agents/mcp-dev-team/mcp-testing-engineer.md +106 -0
- package/cli-tool/components/agents/modernization/architecture-modernizer.md +37 -0
- package/cli-tool/components/agents/modernization/cloud-migration-specialist.md +37 -0
- package/cli-tool/components/agents/modernization/legacy-modernizer.md +33 -0
- package/cli-tool/components/agents/obsidian-ops-team/Scripts/daily_notes_connector.py +306 -0
- package/cli-tool/components/agents/obsidian-ops-team/Scripts/enhance_tag_standardizer.py +343 -0
- package/cli-tool/components/agents/obsidian-ops-team/Scripts/find_keyword_connections.py +216 -0
- package/cli-tool/components/agents/obsidian-ops-team/Scripts/fix_quoted_tags.py +82 -0
- package/cli-tool/components/agents/obsidian-ops-team/Scripts/implement_entity_connections.py +195 -0
- package/cli-tool/components/agents/obsidian-ops-team/Scripts/link_suggester.py +301 -0
- package/cli-tool/components/agents/obsidian-ops-team/Scripts/metadata_adder.py +197 -0
- package/cli-tool/components/agents/obsidian-ops-team/Scripts/moc_generator.py +296 -0
- package/cli-tool/components/agents/obsidian-ops-team/Scripts/parse_keyword_connections.py +122 -0
- package/cli-tool/components/agents/obsidian-ops-team/Scripts/tag_standardizer.py +387 -0
- package/cli-tool/components/agents/obsidian-ops-team/connection-agent.md +67 -0
- package/cli-tool/components/agents/obsidian-ops-team/content-curator.md +81 -0
- package/cli-tool/components/agents/obsidian-ops-team/metadata-agent.md +51 -0
- package/cli-tool/components/agents/obsidian-ops-team/moc-agent.md +112 -0
- package/cli-tool/components/agents/obsidian-ops-team/review-agent.md +94 -0
- package/cli-tool/components/agents/obsidian-ops-team/tag-agent.md +92 -0
- package/cli-tool/components/agents/obsidian-ops-team/vault-optimizer.md +76 -0
- package/cli-tool/components/agents/ocr-extraction-team/document-structure-analyzer.md +37 -0
- package/cli-tool/components/agents/ocr-extraction-team/markdown-syntax-formatter.md +58 -0
- package/cli-tool/components/agents/ocr-extraction-team/ocr-grammar-fixer.md +36 -0
- package/cli-tool/components/agents/ocr-extraction-team/ocr-preprocessing-optimizer.md +37 -0
- package/cli-tool/components/agents/ocr-extraction-team/ocr-quality-assurance.md +62 -0
- package/cli-tool/components/agents/ocr-extraction-team/text-comparison-validator.md +60 -0
- package/cli-tool/components/agents/ocr-extraction-team/visual-analysis-ocr.md +52 -0
- package/cli-tool/components/agents/performance-testing/load-testing-specialist.md +37 -0
- package/cli-tool/components/agents/performance-testing/performance-engineer.md +33 -0
- package/cli-tool/components/agents/performance-testing/react-performance-optimization.md +65 -0
- package/cli-tool/components/agents/performance-testing/test-automator.md +33 -0
- package/cli-tool/components/agents/performance-testing/web-vitals-optimizer.md +37 -0
- package/cli-tool/components/agents/podcast-creator-team/academic-research-synthesizer.md +61 -0
- package/cli-tool/components/agents/podcast-creator-team/comprehensive-researcher.md +49 -0
- package/cli-tool/components/agents/podcast-creator-team/episode-orchestrator.md +52 -0
- package/cli-tool/components/agents/podcast-creator-team/guest-outreach-coordinator.md +37 -0
- package/cli-tool/components/agents/podcast-creator-team/market-research-analyst.md +54 -0
- package/cli-tool/components/agents/podcast-creator-team/podcast-editor.md +37 -0
- package/cli-tool/components/agents/podcast-creator-team/podcast-trend-scout.md +60 -0
- package/cli-tool/components/agents/podcast-creator-team/project-supervisor-orchestrator.md +48 -0
- package/cli-tool/components/agents/podcast-creator-team/seo-podcast-optimizer.md +58 -0
- package/cli-tool/components/agents/podcast-creator-team/social-media-copywriter.md +57 -0
- package/cli-tool/components/agents/podcast-creator-team/twitter-ai-influencer-manager.md +62 -0
- package/cli-tool/components/agents/programming-languages/c-pro.md +36 -0
- package/cli-tool/components/agents/programming-languages/c-sharp-pro.md +40 -0
- package/cli-tool/components/agents/programming-languages/cpp-pro.md +39 -0
- package/cli-tool/components/agents/programming-languages/golang-pro.md +33 -0
- package/cli-tool/components/agents/programming-languages/javascript-pro.md +36 -0
- package/cli-tool/components/agents/programming-languages/php-pro.md +44 -0
- package/cli-tool/components/agents/programming-languages/python-pro.md +33 -0
- package/cli-tool/components/agents/programming-languages/rust-pro.md +36 -0
- package/cli-tool/components/agents/programming-languages/shell-scripting-pro.md +38 -0
- package/cli-tool/components/agents/programming-languages/sql-pro.md +36 -0
- package/cli-tool/components/agents/programming-languages/typescript-pro.md +38 -0
- package/cli-tool/components/agents/realtime/supabase-realtime-optimizer.md +193 -0
- package/cli-tool/components/agents/security/api-security-audit.md +93 -0
- package/cli-tool/components/agents/security/compliance-specialist.md +37 -0
- package/cli-tool/components/agents/security/incident-responder.md +75 -0
- package/cli-tool/components/agents/security/penetration-tester.md +37 -0
- package/cli-tool/components/agents/security/security-auditor.md +33 -0
- package/cli-tool/components/agents/web-tools/nextjs-architecture-expert.md +194 -0
- package/cli-tool/components/agents/web-tools/react-performance-optimizer.md +425 -0
- package/cli-tool/components/agents/web-tools/seo-analyzer.md +37 -0
- package/cli-tool/components/agents/web-tools/url-context-validator.md +61 -0
- package/cli-tool/components/agents/web-tools/url-link-extractor.md +59 -0
- package/cli-tool/components/agents/web-tools/web-accessibility-checker.md +37 -0
- package/cli-tool/components/commands/automation/act.md +57 -0
- package/cli-tool/components/commands/automation/ci-pipeline.md +378 -0
- package/cli-tool/components/commands/automation/husky.md +130 -0
- package/cli-tool/components/commands/automation/workflow-orchestrator.md +576 -0
- package/cli-tool/components/commands/database/supabase-backup-manager.md +37 -0
- package/cli-tool/components/commands/database/supabase-data-explorer.md +37 -0
- package/cli-tool/components/commands/database/supabase-migration-assistant.md +37 -0
- package/cli-tool/components/commands/database/supabase-performance-optimizer.md +37 -0
- package/cli-tool/components/commands/database/supabase-realtime-monitor.md +37 -0
- package/cli-tool/components/commands/database/supabase-schema-sync.md +37 -0
- package/cli-tool/components/commands/database/supabase-security-audit.md +37 -0
- package/cli-tool/components/commands/database/supabase-type-generator.md +37 -0
- package/cli-tool/components/commands/deployment/add-changelog.md +92 -0
- package/cli-tool/components/commands/deployment/blue-green-deployment.md +824 -0
- package/cli-tool/components/commands/deployment/changelog-demo-command.md +43 -0
- package/cli-tool/components/commands/deployment/ci-setup.md +323 -0
- package/cli-tool/components/commands/deployment/containerize-application.md +93 -0
- package/cli-tool/components/commands/deployment/deployment-monitoring.md +1228 -0
- package/cli-tool/components/commands/deployment/hotfix-deploy.md +283 -0
- package/cli-tool/components/commands/deployment/prepare-release.md +357 -0
- package/cli-tool/components/commands/deployment/rollback-deploy.md +145 -0
- package/cli-tool/components/commands/deployment/setup-automated-releases.md +143 -0
- package/cli-tool/components/commands/deployment/setup-kubernetes-deployment.md +93 -0
- package/cli-tool/components/commands/documentation/create-architecture-documentation.md +95 -0
- package/cli-tool/components/commands/documentation/create-onboarding-guide.md +93 -0
- package/cli-tool/components/commands/documentation/doc-api.md +242 -0
- package/cli-tool/components/commands/documentation/docs-maintenance.md +119 -0
- package/cli-tool/components/commands/documentation/generate-api-documentation.md +97 -0
- package/cli-tool/components/commands/documentation/interactive-documentation.md +133 -0
- package/cli-tool/components/commands/documentation/load-llms-txt.md +39 -0
- package/cli-tool/components/commands/documentation/migration-guide.md +250 -0
- package/cli-tool/components/commands/documentation/troubleshooting-guide.md +370 -0
- package/cli-tool/components/commands/documentation/update-docs.md +107 -0
- package/cli-tool/components/commands/game-development/game-analytics-integration.md +128 -0
- package/cli-tool/components/commands/game-development/game-asset-pipeline.md +108 -0
- package/cli-tool/components/commands/game-development/game-performance-profiler.md +78 -0
- package/cli-tool/components/commands/game-development/game-testing-framework.md +112 -0
- package/cli-tool/components/commands/game-development/unity-project-setup.md +190 -0
- package/cli-tool/components/commands/git-workflow/branch-cleanup.md +181 -0
- package/cli-tool/components/commands/git-workflow/commit.md +167 -0
- package/cli-tool/components/commands/git-workflow/create-pr.md +19 -0
- package/cli-tool/components/commands/git-workflow/create-pull-request.md +126 -0
- package/cli-tool/components/commands/git-workflow/create-worktrees.md +174 -0
- package/cli-tool/components/commands/git-workflow/fix-github-issue.md +13 -0
- package/cli-tool/components/commands/git-workflow/git-bisect-helper.md +261 -0
- package/cli-tool/components/commands/git-workflow/pr-review.md +76 -0
- package/cli-tool/components/commands/git-workflow/update-branch-name.md +9 -0
- package/cli-tool/components/commands/nextjs-vercel/nextjs-api-tester.md +480 -0
- package/cli-tool/components/commands/nextjs-vercel/nextjs-bundle-analyzer.md +406 -0
- package/cli-tool/components/commands/nextjs-vercel/nextjs-component-generator.md +489 -0
- package/cli-tool/components/commands/nextjs-vercel/nextjs-middleware-creator.md +712 -0
- package/cli-tool/components/commands/nextjs-vercel/nextjs-migration-helper.md +778 -0
- package/cli-tool/components/commands/nextjs-vercel/nextjs-performance-audit.md +653 -0
- package/cli-tool/components/commands/nextjs-vercel/nextjs-scaffold.md +237 -0
- package/cli-tool/components/commands/nextjs-vercel/vercel-deploy-optimize.md +341 -0
- package/cli-tool/components/commands/nextjs-vercel/vercel-edge-function.md +810 -0
- package/cli-tool/components/commands/nextjs-vercel/vercel-env-sync.md +666 -0
- package/cli-tool/components/commands/orchestration/archive.md +414 -0
- package/cli-tool/components/commands/orchestration/commit.md +305 -0
- package/cli-tool/components/commands/orchestration/find.md +272 -0
- package/cli-tool/components/commands/orchestration/log.md +355 -0
- package/cli-tool/components/commands/orchestration/move.md +220 -0
- package/cli-tool/components/commands/orchestration/optimize.md +375 -0
- package/cli-tool/components/commands/orchestration/remove.md +301 -0
- package/cli-tool/components/commands/orchestration/report.md +292 -0
- package/cli-tool/components/commands/orchestration/resume.md +256 -0
- package/cli-tool/components/commands/orchestration/start.md +169 -0
- package/cli-tool/components/commands/orchestration/status.md +219 -0
- package/cli-tool/components/commands/orchestration/sync.md +294 -0
- package/cli-tool/components/commands/performance/add-performance-monitoring.md +84 -0
- package/cli-tool/components/commands/performance/implement-caching-strategy.md +84 -0
- package/cli-tool/components/commands/performance/optimize-api-performance.md +119 -0
- package/cli-tool/components/commands/performance/optimize-build.md +139 -0
- package/cli-tool/components/commands/performance/optimize-bundle-size.md +84 -0
- package/cli-tool/components/commands/performance/optimize-database-performance.md +84 -0
- package/cli-tool/components/commands/performance/optimize-memory-usage.md +91 -0
- package/cli-tool/components/commands/performance/performance-audit.md +89 -0
- package/cli-tool/components/commands/performance/setup-cdn-optimization.md +84 -0
- package/cli-tool/components/commands/performance/system-behavior-simulator.md +415 -0
- package/cli-tool/components/commands/project-management/add-package.md +90 -0
- package/cli-tool/components/commands/project-management/add-to-changelog.md +37 -0
- package/cli-tool/components/commands/project-management/create-feature.md +130 -0
- package/cli-tool/components/commands/project-management/create-jtbd.md +37 -0
- package/cli-tool/components/commands/project-management/create-prd.md +36 -0
- package/cli-tool/components/commands/project-management/create-prp.md +37 -0
- package/cli-tool/components/commands/project-management/init-project.md +80 -0
- package/cli-tool/components/commands/project-management/milestone-tracker.md +44 -0
- package/cli-tool/components/commands/project-management/pac-configure.md +32 -0
- package/cli-tool/components/commands/project-management/pac-create-epic.md +41 -0
- package/cli-tool/components/commands/project-management/pac-create-ticket.md +42 -0
- package/cli-tool/components/commands/project-management/pac-update-status.md +39 -0
- package/cli-tool/components/commands/project-management/pac-validate.md +35 -0
- package/cli-tool/components/commands/project-management/project-health-check.md +58 -0
- package/cli-tool/components/commands/project-management/project-timeline-simulator.md +37 -0
- package/cli-tool/components/commands/project-management/project-to-linear.md +38 -0
- package/cli-tool/components/commands/project-management/release.md +31 -0
- package/cli-tool/components/commands/project-management/todo.md +62 -0
- package/cli-tool/components/commands/security/add-authentication-system.md +34 -0
- package/cli-tool/components/commands/security/dependency-audit.md +32 -0
- package/cli-tool/components/commands/security/penetration-test.md +40 -0
- package/cli-tool/components/commands/security/secrets-scanner.md +39 -0
- package/cli-tool/components/commands/security/security-audit.md +82 -0
- package/cli-tool/components/commands/security/security-hardening.md +33 -0
- package/cli-tool/components/commands/setup/create-database-migrations.md +35 -0
- package/cli-tool/components/commands/setup/design-database-schema.md +37 -0
- package/cli-tool/components/commands/setup/design-rest-api.md +37 -0
- package/cli-tool/components/commands/setup/implement-graphql-api.md +37 -0
- package/cli-tool/components/commands/setup/migrate-to-typescript.md +37 -0
- package/cli-tool/components/commands/setup/setup-ci-cd-pipeline.md +37 -0
- package/cli-tool/components/commands/setup/setup-development-environment.md +37 -0
- package/cli-tool/components/commands/setup/setup-docker-containers.md +37 -0
- package/cli-tool/components/commands/setup/setup-formatting.md +37 -0
- package/cli-tool/components/commands/setup/setup-linting.md +37 -0
- package/cli-tool/components/commands/setup/setup-monitoring-observability.md +37 -0
- package/cli-tool/components/commands/setup/setup-monorepo.md +37 -0
- package/cli-tool/components/commands/setup/setup-rate-limiting.md +37 -0
- package/cli-tool/components/commands/setup/update-dependencies.md +35 -0
- package/cli-tool/components/commands/simulation/business-scenario-explorer.md +37 -0
- package/cli-tool/components/commands/simulation/constraint-modeler.md +37 -0
- package/cli-tool/components/commands/simulation/decision-tree-explorer.md +37 -0
- package/cli-tool/components/commands/simulation/digital-twin-creator.md +37 -0
- package/cli-tool/components/commands/simulation/future-scenario-generator.md +37 -0
- package/cli-tool/components/commands/simulation/market-response-modeler.md +37 -0
- package/cli-tool/components/commands/simulation/monte-carlo-simulator.md +37 -0
- package/cli-tool/components/commands/simulation/simulation-calibrator.md +37 -0
- package/cli-tool/components/commands/simulation/system-dynamics-modeler.md +37 -0
- package/cli-tool/components/commands/simulation/timeline-compressor.md +37 -0
- package/cli-tool/components/commands/svelte/svelte:a11y.md +105 -0
- package/cli-tool/components/commands/svelte/svelte:component.md +81 -0
- package/cli-tool/components/commands/svelte/svelte:debug.md +48 -0
- package/cli-tool/components/commands/svelte/svelte:migrate.md +79 -0
- package/cli-tool/components/commands/svelte/svelte:optimize.md +99 -0
- package/cli-tool/components/commands/svelte/svelte:scaffold.md +89 -0
- package/cli-tool/components/commands/svelte/svelte:storybook-migrate.md +204 -0
- package/cli-tool/components/commands/svelte/svelte:storybook-mock.md +213 -0
- package/cli-tool/components/commands/svelte/svelte:storybook-setup.md +113 -0
- package/cli-tool/components/commands/svelte/svelte:storybook-story.md +145 -0
- package/cli-tool/components/commands/svelte/svelte:storybook-troubleshoot.md +191 -0
- package/cli-tool/components/commands/svelte/svelte:storybook.md +48 -0
- package/cli-tool/components/commands/svelte/svelte:test-coverage.md +77 -0
- package/cli-tool/components/commands/svelte/svelte:test-fix.md +74 -0
- package/cli-tool/components/commands/svelte/svelte:test-setup.md +85 -0
- package/cli-tool/components/commands/svelte/svelte:test.md +60 -0
- package/cli-tool/components/commands/sync/bidirectional-sync.md +37 -0
- package/cli-tool/components/commands/sync/bulk-import-issues.md +37 -0
- package/cli-tool/components/commands/sync/cross-reference-manager.md +37 -0
- package/cli-tool/components/commands/sync/issue-to-linear-task.md +37 -0
- package/cli-tool/components/commands/sync/linear-task-to-issue.md +37 -0
- package/cli-tool/components/commands/sync/sync-automation-setup.md +37 -0
- package/cli-tool/components/commands/sync/sync-conflict-resolver.md +37 -0
- package/cli-tool/components/commands/sync/sync-health-monitor.md +37 -0
- package/cli-tool/components/commands/sync/sync-issues-to-linear.md +37 -0
- package/cli-tool/components/commands/sync/sync-linear-to-issues.md +37 -0
- package/cli-tool/components/commands/sync/sync-migration-assistant.md +37 -0
- package/cli-tool/components/commands/sync/sync-pr-to-task.md +37 -0
- package/cli-tool/components/commands/sync/sync-status.md +391 -0
- package/cli-tool/components/commands/sync/task-from-pr.md +37 -0
- package/cli-tool/components/commands/team/architecture-review.md +37 -0
- package/cli-tool/components/commands/team/decision-quality-analyzer.md +37 -0
- package/cli-tool/components/commands/team/dependency-mapper.md +37 -0
- package/cli-tool/components/commands/team/estimate-assistant.md +37 -0
- package/cli-tool/components/commands/team/issue-triage.md +37 -0
- package/cli-tool/components/commands/team/memory-spring-cleaning.md +37 -0
- package/cli-tool/components/commands/team/migration-assistant.md +37 -0
- package/cli-tool/components/commands/team/retrospective-analyzer.md +37 -0
- package/cli-tool/components/commands/team/session-learning-capture.md +37 -0
- package/cli-tool/components/commands/team/sprint-planning.md +189 -0
- package/cli-tool/components/commands/team/standup-report.md +37 -0
- package/cli-tool/components/commands/team/team-knowledge-mapper.md +37 -0
- package/cli-tool/components/commands/team/team-velocity-tracker.md +37 -0
- package/cli-tool/components/commands/team/team-workload-balancer.md +37 -0
- package/cli-tool/components/commands/testing/add-mutation-testing.md +37 -0
- package/cli-tool/components/commands/testing/add-property-based-testing.md +37 -0
- package/cli-tool/components/commands/testing/e2e-setup.md +37 -0
- package/cli-tool/components/commands/testing/generate-test-cases.md +37 -0
- package/cli-tool/components/commands/testing/generate-tests.md +82 -0
- package/cli-tool/components/commands/testing/setup-comprehensive-testing.md +37 -0
- package/cli-tool/components/commands/testing/setup-load-testing.md +37 -0
- package/cli-tool/components/commands/testing/setup-visual-testing.md +37 -0
- package/cli-tool/components/commands/testing/test-automation-orchestrator.md +37 -0
- package/cli-tool/components/commands/testing/test-changelog-automation.md +37 -0
- package/cli-tool/components/commands/testing/test-coverage.md +37 -0
- package/cli-tool/components/commands/testing/test-quality-analyzer.md +37 -0
- package/cli-tool/components/commands/testing/testing_plan_integration.md +37 -0
- package/cli-tool/components/commands/testing/write-tests.md +37 -0
- package/cli-tool/components/commands/utilities/all-tools.md +31 -0
- package/cli-tool/components/commands/utilities/architecture-scenario-explorer.md +375 -0
- package/cli-tool/components/commands/utilities/check-file.md +53 -0
- package/cli-tool/components/commands/utilities/clean-branches.md +243 -0
- package/cli-tool/components/commands/utilities/clean.md +1 -0
- package/cli-tool/components/commands/utilities/code-permutation-tester.md +341 -0
- package/cli-tool/components/commands/utilities/code-review.md +70 -0
- package/cli-tool/components/commands/utilities/code-to-task.md +583 -0
- package/cli-tool/components/commands/utilities/context-prime.md +1 -0
- package/cli-tool/components/commands/utilities/debug-error.md +121 -0
- package/cli-tool/components/commands/utilities/directory-deep-dive.md +34 -0
- package/cli-tool/components/commands/utilities/explain-code.md +194 -0
- package/cli-tool/components/commands/utilities/fix-issue.md +85 -0
- package/cli-tool/components/commands/utilities/generate-linear-worklog.md +113 -0
- package/cli-tool/components/commands/utilities/git-status.md +39 -0
- package/cli-tool/components/commands/utilities/initref.md +3 -0
- package/cli-tool/components/commands/utilities/prime.md +41 -0
- package/cli-tool/components/commands/utilities/refactor-code.md +116 -0
- package/cli-tool/components/commands/utilities/ultra-think.md +153 -0
- package/cli-tool/components/hooks/HOOK_PATTERNS_COMPRESSED.json +1 -0
- package/cli-tool/components/hooks/automation/build-on-change.json +16 -0
- package/cli-tool/components/hooks/automation/dependency-checker.json +16 -0
- package/cli-tool/components/hooks/automation/deployment-health-monitor.json +29 -0
- package/cli-tool/components/hooks/automation/discord-detailed-notifications.json +26 -0
- package/cli-tool/components/hooks/automation/discord-error-notifications.json +37 -0
- package/cli-tool/components/hooks/automation/discord-notifications.json +25 -0
- package/cli-tool/components/hooks/automation/simple-notifications.json +16 -0
- package/cli-tool/components/hooks/automation/slack-detailed-notifications.json +26 -0
- package/cli-tool/components/hooks/automation/slack-error-notifications.json +37 -0
- package/cli-tool/components/hooks/automation/slack-notifications.json +25 -0
- package/cli-tool/components/hooks/automation/telegram-detailed-notifications.json +26 -0
- package/cli-tool/components/hooks/automation/telegram-error-notifications.json +37 -0
- package/cli-tool/components/hooks/automation/telegram-notifications.json +25 -0
- package/cli-tool/components/hooks/automation/vercel-auto-deploy.json +17 -0
- package/cli-tool/components/hooks/automation/vercel-environment-sync.json +29 -0
- package/cli-tool/components/hooks/development-tools/change-tracker.json +25 -0
- package/cli-tool/components/hooks/development-tools/command-logger.json +16 -0
- package/cli-tool/components/hooks/development-tools/file-backup.json +16 -0
- package/cli-tool/components/hooks/development-tools/lint-on-save.json +16 -0
- package/cli-tool/components/hooks/development-tools/nextjs-code-quality-enforcer.json +17 -0
- package/cli-tool/components/hooks/development-tools/smart-formatting.json +16 -0
- package/cli-tool/components/hooks/git-workflow/auto-git-add.json +16 -0
- package/cli-tool/components/hooks/git-workflow/smart-commit.json +25 -0
- package/cli-tool/components/hooks/performance/performance-budget-guard.json +27 -0
- package/cli-tool/components/hooks/performance/performance-monitor.json +27 -0
- package/cli-tool/components/hooks/post-tool/format-javascript-files.json +16 -0
- package/cli-tool/components/hooks/post-tool/format-python-files.json +16 -0
- package/cli-tool/components/hooks/post-tool/git-add-changes.json +25 -0
- package/cli-tool/components/hooks/post-tool/run-tests-after-changes.json +16 -0
- package/cli-tool/components/hooks/pre-tool/backup-before-edit.json +16 -0
- package/cli-tool/components/hooks/pre-tool/notify-before-bash.json +16 -0
- package/cli-tool/components/hooks/security/file-protection.json +16 -0
- package/cli-tool/components/hooks/security/security-scanner.json +16 -0
- package/cli-tool/components/hooks/testing/test-runner.json +16 -0
- package/cli-tool/components/mcps/browser_automation/browser-use-mcp-server.json +20 -0
- package/cli-tool/components/mcps/browser_automation/browsermcp.json +9 -0
- package/cli-tool/components/mcps/browser_automation/mcp-server-browserbase.json +14 -0
- package/cli-tool/components/mcps/browser_automation/mcp-server-playwright.json +9 -0
- package/cli-tool/components/mcps/browser_automation/playwright-mcp-server.json +9 -0
- package/cli-tool/components/mcps/browser_automation/playwright-mcp.json +11 -0
- package/cli-tool/components/mcps/database/mysql-integration.json +12 -0
- package/cli-tool/components/mcps/database/postgresql-integration.json +12 -0
- package/cli-tool/components/mcps/database/supabase.json +17 -0
- package/cli-tool/components/mcps/deepgraph/deepgraph-nextjs.json +13 -0
- package/cli-tool/components/mcps/deepgraph/deepgraph-react.json +13 -0
- package/cli-tool/components/mcps/deepgraph/deepgraph-typescript.json +13 -0
- package/cli-tool/components/mcps/deepgraph/deepgraph-vue.json +13 -0
- package/cli-tool/components/mcps/devtools/circleci.json +13 -0
- package/cli-tool/components/mcps/devtools/context7.json +9 -0
- package/cli-tool/components/mcps/devtools/firefly-mcp.json +13 -0
- package/cli-tool/components/mcps/devtools/ios-simulator-mcp.json +9 -0
- package/cli-tool/components/mcps/devtools/just-mcp.json +9 -0
- package/cli-tool/components/mcps/devtools/leetcode.json +8 -0
- package/cli-tool/components/mcps/devtools/mcp-server-atlassian-bitbucket.json +9 -0
- package/cli-tool/components/mcps/devtools/mcp-server-trello.json +12 -0
- package/cli-tool/components/mcps/filesystem/filesystem-access.json +13 -0
- package/cli-tool/components/mcps/integration/github-integration.json +12 -0
- package/cli-tool/components/mcps/integration/memory-integration.json +9 -0
- package/cli-tool/components/mcps/marketing/facebook-ads-mcp-server.json +13 -0
- package/cli-tool/components/mcps/marketing/google-ads-mcp-server.json +11 -0
- package/cli-tool/components/mcps/web/web-fetch.json +9 -0
- package/cli-tool/components/sandbox/README.md +169 -0
- package/cli-tool/components/sandbox/e2b/.env.example +10 -0
- package/cli-tool/components/sandbox/e2b/SANDBOX_DEBUGGING.md +203 -0
- package/cli-tool/components/sandbox/e2b/claude-code-sandbox.md +110 -0
- package/cli-tool/components/sandbox/e2b/e2b-launcher.py +355 -0
- package/cli-tool/components/sandbox/e2b/e2b-monitor.py +229 -0
- package/cli-tool/components/sandbox/e2b/requirements.txt +1 -0
- package/cli-tool/components/settings/api/bedrock-configuration.json +7 -0
- package/cli-tool/components/settings/api/corporate-proxy.json +7 -0
- package/cli-tool/components/settings/api/custom-headers.json +6 -0
- package/cli-tool/components/settings/api/vertex-configuration.json +8 -0
- package/cli-tool/components/settings/authentication/api-key-helper.json +7 -0
- package/cli-tool/components/settings/authentication/force-claudeai-login.json +4 -0
- package/cli-tool/components/settings/authentication/force-console-login.json +4 -0
- package/cli-tool/components/settings/cleanup/retention-7-days.json +4 -0
- package/cli-tool/components/settings/cleanup/retention-90-days.json +4 -0
- package/cli-tool/components/settings/environment/bash-timeouts.json +8 -0
- package/cli-tool/components/settings/environment/development-utils.json +8 -0
- package/cli-tool/components/settings/environment/performance-optimization.json +8 -0
- package/cli-tool/components/settings/environment/privacy-focused.json +10 -0
- package/cli-tool/components/settings/global/aws-credentials.json +5 -0
- package/cli-tool/components/settings/global/custom-model.json +7 -0
- package/cli-tool/components/settings/global/git-commit-settings.json +4 -0
- package/cli-tool/components/settings/mcp/disable-risky-servers.json +8 -0
- package/cli-tool/components/settings/mcp/enable-all-project-servers.json +4 -0
- package/cli-tool/components/settings/mcp/enable-specific-servers.json +8 -0
- package/cli-tool/components/settings/mcp/mcp-timeouts.json +8 -0
- package/cli-tool/components/settings/model/use-haiku.json +4 -0
- package/cli-tool/components/settings/model/use-sonnet.json +4 -0
- package/cli-tool/components/settings/permissions/additional-directories.json +11 -0
- package/cli-tool/components/settings/permissions/allow-git-operations.json +14 -0
- package/cli-tool/components/settings/permissions/allow-npm-commands.json +11 -0
- package/cli-tool/components/settings/permissions/deny-sensitive-files.json +11 -0
- package/cli-tool/components/settings/permissions/development-mode.json +31 -0
- package/cli-tool/components/settings/permissions/read-only-mode.json +18 -0
- package/cli-tool/components/settings/statusline/asset-pipeline-controller-statusline.json +7 -0
- package/cli-tool/components/settings/statusline/bug-circus-statusline.json +7 -0
- package/cli-tool/components/settings/statusline/code-casino-statusline.json +7 -0
- package/cli-tool/components/settings/statusline/code-spaceship-statusline.json +7 -0
- package/cli-tool/components/settings/statusline/colorful-statusline.json +7 -0
- package/cli-tool/components/settings/statusline/command-statusline.json +8 -0
- package/cli-tool/components/settings/statusline/context-monitor.json +7 -0
- package/cli-tool/components/settings/statusline/context-monitor.py +236 -0
- package/cli-tool/components/settings/statusline/data-ocean-statusline.json +7 -0
- package/cli-tool/components/settings/statusline/emotion-theater-statusline.json +7 -0
- package/cli-tool/components/settings/statusline/game-performance-monitor-statusline.json +7 -0
- package/cli-tool/components/settings/statusline/git-branch-statusline.json +7 -0
- package/cli-tool/components/settings/statusline/minimal-statusline.json +7 -0
- package/cli-tool/components/settings/statusline/multiplatform-build-status-statusline.json +7 -0
- package/cli-tool/components/settings/statusline/productivity-rainbow-statusline.json +7 -0
- package/cli-tool/components/settings/statusline/programmer-tamagotchi-statusline.json +7 -0
- package/cli-tool/components/settings/statusline/programming-fitness-tracker-statusline.json +7 -0
- package/cli-tool/components/settings/statusline/project-info-statusline.json +7 -0
- package/cli-tool/components/settings/statusline/rpg-status-bar-statusline.json +7 -0
- package/cli-tool/components/settings/statusline/time-statusline.json +7 -0
- package/cli-tool/components/settings/statusline/unity-project-dashboard-statusline.json +7 -0
- package/cli-tool/components/settings/statusline/vercel-deployment-monitor.json +7 -0
- package/cli-tool/components/settings/statusline/vercel-error-alert-system.json +7 -0
- package/cli-tool/components/settings/statusline/vercel-multi-env-status.json +7 -0
- package/cli-tool/components/settings/statusline/virtual-code-garden-statusline.json +7 -0
- package/cli-tool/components/settings/statusline/zero-config-deployment-monitor.json +7 -0
- package/cli-tool/components/settings/telemetry/custom-telemetry.json +7 -0
- package/cli-tool/components/settings/telemetry/disable-telemetry.json +6 -0
- package/cli-tool/components/settings/telemetry/enable-telemetry.json +6 -0
- package/cli-tool/docs_to_claude/ANALYTICS_STATE_DETECTION.md +183 -0
- package/cli-tool/docs_to_claude/ARCHITECTURE.md +472 -0
- package/cli-tool/docs_to_claude/BLOG_WRITING_GUIDE.md +438 -0
- package/cli-tool/docs_to_claude/CLAUDE_DATA_STRUCTURE.md +400 -0
- package/cli-tool/docs_to_claude/COMMANDS_GUIDE.md +909 -0
- package/cli-tool/docs_to_claude/CONVERSATION_STATE_IMPROVEMENTS.md +154 -0
- package/cli-tool/docs_to_claude/DEBUG_TYPING_DETECTION.md +95 -0
- package/cli-tool/docs_to_claude/DOWNLOAD_TRACKING.md +291 -0
- package/cli-tool/docs_to_claude/ENHANCED_STATE_DETECTION.md +122 -0
- package/cli-tool/docs_to_claude/HEALTH_CHECK_IMPLEMENTATION.md +135 -0
- package/cli-tool/docs_to_claude/HOOKS_GUIDE.md +1249 -0
- package/cli-tool/docs_to_claude/STATUSLINE_GUIDE.md +1123 -0
- package/cli-tool/docs_to_claude/SUBAGENTS_GUIDE.md +566 -0
- package/cli-tool/docs_to_claude/SUB_AGENTS.md +329 -0
- package/cli-tool/jest.config.js +84 -0
- package/cli-tool/package-lock.json +5471 -0
- package/cli-tool/package.json +95 -0
- package/{src → cli-tool/src}/index.js +104 -23
- package/cli-tool/templates/common/.claude/commands/git-workflow.md +239 -0
- package/cli-tool/templates/common/.claude/commands/project-setup.md +316 -0
- package/cli-tool/templates/common/.mcp.json +41 -0
- package/cli-tool/templates/common/CLAUDE.md +109 -0
- package/cli-tool/templates/common/README.md +96 -0
- package/cli-tool/templates/go/.mcp.json +78 -0
- package/cli-tool/templates/go/README.md +25 -0
- package/cli-tool/templates/javascript-typescript/.claude/commands/api-endpoint.md +51 -0
- package/cli-tool/templates/javascript-typescript/.claude/commands/debug.md +52 -0
- package/cli-tool/templates/javascript-typescript/.claude/commands/lint.md +48 -0
- package/cli-tool/templates/javascript-typescript/.claude/commands/npm-scripts.md +48 -0
- package/cli-tool/templates/javascript-typescript/.claude/commands/refactor.md +55 -0
- package/cli-tool/templates/javascript-typescript/.claude/commands/test.md +61 -0
- package/cli-tool/templates/javascript-typescript/.claude/commands/typescript-migrate.md +51 -0
- package/cli-tool/templates/javascript-typescript/.claude/settings.json +142 -0
- package/cli-tool/templates/javascript-typescript/.mcp.json +80 -0
- package/cli-tool/templates/javascript-typescript/CLAUDE.md +185 -0
- package/cli-tool/templates/javascript-typescript/README.md +259 -0
- package/cli-tool/templates/javascript-typescript/examples/angular-app/.claude/commands/components.md +63 -0
- package/cli-tool/templates/javascript-typescript/examples/angular-app/.claude/commands/services.md +62 -0
- package/cli-tool/templates/javascript-typescript/examples/node-api/.claude/commands/api-endpoint.md +46 -0
- package/cli-tool/templates/javascript-typescript/examples/node-api/.claude/commands/database.md +56 -0
- package/cli-tool/templates/javascript-typescript/examples/node-api/.claude/commands/middleware.md +61 -0
- package/cli-tool/templates/javascript-typescript/examples/node-api/.claude/commands/route.md +57 -0
- package/cli-tool/templates/javascript-typescript/examples/node-api/CLAUDE.md +102 -0
- package/cli-tool/templates/javascript-typescript/examples/react-app/.claude/commands/component.md +29 -0
- package/cli-tool/templates/javascript-typescript/examples/react-app/.claude/commands/hooks.md +44 -0
- package/cli-tool/templates/javascript-typescript/examples/react-app/.claude/commands/state-management.md +45 -0
- package/cli-tool/templates/javascript-typescript/examples/react-app/CLAUDE.md +81 -0
- package/cli-tool/templates/javascript-typescript/examples/react-app/agents/react-performance-optimization.md +530 -0
- package/cli-tool/templates/javascript-typescript/examples/react-app/agents/react-state-management.md +295 -0
- package/cli-tool/templates/javascript-typescript/examples/vue-app/.claude/commands/components.md +46 -0
- package/cli-tool/templates/javascript-typescript/examples/vue-app/.claude/commands/composables.md +51 -0
- package/cli-tool/templates/python/.claude/commands/lint.md +111 -0
- package/cli-tool/templates/python/.claude/commands/test.md +73 -0
- package/cli-tool/templates/python/.claude/settings.json +153 -0
- package/cli-tool/templates/python/.mcp.json +78 -0
- package/cli-tool/templates/python/CLAUDE.md +276 -0
- package/cli-tool/templates/python/examples/django-app/.claude/commands/admin.md +264 -0
- package/cli-tool/templates/python/examples/django-app/.claude/commands/django-model.md +124 -0
- package/cli-tool/templates/python/examples/django-app/.claude/commands/views.md +222 -0
- package/cli-tool/templates/python/examples/django-app/CLAUDE.md +313 -0
- package/cli-tool/templates/python/examples/fastapi-app/.claude/commands/api-endpoints.md +513 -0
- package/cli-tool/templates/python/examples/fastapi-app/.claude/commands/auth.md +775 -0
- package/cli-tool/templates/python/examples/fastapi-app/.claude/commands/database.md +657 -0
- package/cli-tool/templates/python/examples/fastapi-app/.claude/commands/deployment.md +160 -0
- package/cli-tool/templates/python/examples/fastapi-app/.claude/commands/testing.md +927 -0
- package/cli-tool/templates/python/examples/fastapi-app/CLAUDE.md +229 -0
- package/cli-tool/templates/python/examples/flask-app/.claude/commands/app-factory.md +384 -0
- package/cli-tool/templates/python/examples/flask-app/.claude/commands/blueprint.md +243 -0
- package/cli-tool/templates/python/examples/flask-app/.claude/commands/database.md +410 -0
- package/cli-tool/templates/python/examples/flask-app/.claude/commands/deployment.md +620 -0
- package/cli-tool/templates/python/examples/flask-app/.claude/commands/flask-route.md +217 -0
- package/cli-tool/templates/python/examples/flask-app/.claude/commands/testing.md +559 -0
- package/cli-tool/templates/python/examples/flask-app/CLAUDE.md +391 -0
- package/cli-tool/templates/ruby/.claude/commands/model.md +360 -0
- package/cli-tool/templates/ruby/.claude/commands/test.md +480 -0
- package/cli-tool/templates/ruby/.claude/settings.json +146 -0
- package/cli-tool/templates/ruby/.mcp.json +83 -0
- package/cli-tool/templates/ruby/CLAUDE.md +284 -0
- package/cli-tool/templates/ruby/examples/rails-app/.claude/commands/authentication.md +490 -0
- package/cli-tool/templates/ruby/examples/rails-app/CLAUDE.md +376 -0
- package/cli-tool/templates/rust/.mcp.json +78 -0
- package/cli-tool/templates/rust/README.md +26 -0
- package/cli-tool/test-commands.sh +85 -0
- package/cli-tool/test-detailed.sh +267 -0
- package/docs/CNAME +1 -0
- package/docs/README.md +49 -0
- package/docs/_config.yml +43 -0
- package/docs/blog/assets/aitmpl-nextjs-search.png +0 -0
- package/docs/blog/assets/aitmpl-supabase-search.png +0 -0
- package/docs/blog/assets/nextjs-vercel-claude-code-templates-cover.png +0 -0
- package/docs/blog/assets/supabase-claude-code-templates-cover.png +0 -0
- package/docs/blog/e2b-claude-code-sandbox/index.html +1061 -0
- package/docs/blog/index.html +239 -0
- package/docs/blog/nextjs-vercel-claude-code-integration/index.html +1021 -0
- package/docs/blog/supabase-claude-code-integration/index.html +837 -0
- package/docs/components-metadata.json +303 -0
- package/docs/components.json +4072 -0
- package/docs/css/blog.css +821 -0
- package/docs/css/stack-page.css +776 -0
- package/docs/css/styles.css +4480 -0
- package/docs/css/trending.css +971 -0
- package/docs/css/workflows-modal.css +739 -0
- package/docs/css/workflows.css +1234 -0
- package/docs/download-stats.html +514 -0
- package/docs/index.html +634 -0
- package/docs/js/carousel.js +177 -0
- package/docs/js/cart-manager.js +529 -0
- package/docs/js/data-loader.js +626 -0
- package/docs/js/generate-search-data.js +82 -0
- package/docs/js/index-events.js +1707 -0
- package/docs/js/modal-helpers.js +334 -0
- package/docs/js/script.js +2167 -0
- package/docs/js/search-functionality.js +992 -0
- package/docs/js/stack-router.js +561 -0
- package/docs/js/trending.js +493 -0
- package/docs/js/utils.js +43 -0
- package/docs/js/workflows-events.js +1146 -0
- package/docs/js/workflows.js +627 -0
- package/docs/sandbox-interface.html +1406 -0
- package/docs/static/img/logo.svg +23 -0
- package/docs/trending-data.json +579 -0
- package/docs/trending.html +179 -0
- package/docs/workflows.html +379 -0
- package/docu/README.md +41 -0
- package/docu/docs/analytics/agent-chats-manager.md +33 -0
- package/docu/docs/analytics/analysis-tools.md +54 -0
- package/docu/docs/analytics/overview.md +48 -0
- package/docu/docs/analytics/real-time-monitoring.md +16 -0
- package/docu/docs/cli-options.md +90 -0
- package/docu/docs/components/agents.md +296 -0
- package/docu/docs/components/commands.md +426 -0
- package/docu/docs/components/discord-notifications.md +59 -0
- package/docu/docs/components/hooks.md +381 -0
- package/docu/docs/components/mcps.md +510 -0
- package/docu/docs/components/overview.md +287 -0
- package/docu/docs/components/settings.md +223 -0
- package/docu/docs/components/slack-notifications.md +67 -0
- package/docu/docs/components/telegram-notifications.md +73 -0
- package/docu/docs/contributing.md +11 -0
- package/docu/docs/health-check/overview.md +33 -0
- package/docu/docs/intro.md +109 -0
- package/docu/docs/project-setup/automation-hooks.md +14 -0
- package/docu/docs/project-setup/framework-specific-setup.md +86 -0
- package/docu/docs/project-setup/interactive-setup.md +59 -0
- package/docu/docs/project-setup/mcp-integration.md +17 -0
- package/docu/docs/project-setup/supported-languages-frameworks.md +15 -0
- package/docu/docs/project-setup/what-gets-installed.md +176 -0
- package/docu/docs/safety-features.md +13 -0
- package/docu/docs/support.md +13 -0
- package/docu/docs/usage-examples/advanced-options.md +87 -0
- package/docu/docs/usage-examples/alternative-commands.md +31 -0
- package/docu/docs/usage-examples/framework-specific-quick-setup.md +47 -0
- package/docu/docs/usage-examples/interactive-setup.md +16 -0
- package/docu/docusaurus.config.ts +163 -0
- package/docu/package-lock.json +16185 -0
- package/docu/package.json +47 -0
- package/docu/sidebars.ts +85 -0
- package/docu/src/components/HomepageFeatures/index.tsx +82 -0
- package/docu/src/components/HomepageFeatures/styles.module.css +131 -0
- package/docu/src/css/custom.css +475 -0
- package/docu/src/pages/index.module.css +109 -0
- package/docu/src/pages/index.tsx +65 -0
- package/docu/src/pages/markdown-page.md +7 -0
- package/docu/static/img/favicon.ico +0 -0
- package/docu/static/img/logo.svg +23 -0
- package/docu/tsconfig.json +8 -0
- package/generate_components_json.py +199 -0
- package/package.json +19 -86
- package/social-preview.png +0 -0
- package/vercel.json +75 -0
- /package/{bin → cli-tool/bin}/create-claude-config.js +0 -0
- /package/{src → cli-tool/src}/agents.js +0 -0
- /package/{src → cli-tool/src}/analytics/core/AgentAnalyzer.js +0 -0
- /package/{src → cli-tool/src}/analytics/core/ConversationAnalyzer.js +0 -0
- /package/{src → cli-tool/src}/analytics/core/FileWatcher.js +0 -0
- /package/{src → cli-tool/src}/analytics/core/ProcessDetector.js +0 -0
- /package/{src → cli-tool/src}/analytics/core/SessionAnalyzer.js +0 -0
- /package/{src → cli-tool/src}/analytics/core/StateCalculator.js +0 -0
- /package/{src → cli-tool/src}/analytics/data/DataCache.js +0 -0
- /package/{src → cli-tool/src}/analytics/notifications/NotificationManager.js +0 -0
- /package/{src → cli-tool/src}/analytics/notifications/WebSocketServer.js +0 -0
- /package/{src → cli-tool/src}/analytics/utils/PerformanceMonitor.js +0 -0
- /package/{src → cli-tool/src}/analytics-web/FRONT_ARCHITECTURE.md +0 -0
- /package/{src → cli-tool/src}/analytics-web/assets/js/main.js.deprecated +0 -0
- /package/{src → cli-tool/src}/analytics-web/chats_mobile.html +0 -0
- /package/{src → cli-tool/src}/analytics-web/components/ActivityHeatmap.js +0 -0
- /package/{src → cli-tool/src}/analytics-web/components/AgentAnalytics.js +0 -0
- /package/{src → cli-tool/src}/analytics-web/components/App.js +0 -0
- /package/{src → cli-tool/src}/analytics-web/components/Charts.js +0 -0
- /package/{src → cli-tool/src}/analytics-web/components/ConversationTable.js +0 -0
- /package/{src → cli-tool/src}/analytics-web/components/DashboardPage.js +0 -0
- /package/{src → cli-tool/src}/analytics-web/components/HeaderComponent.js +0 -0
- /package/{src → cli-tool/src}/analytics-web/components/SessionTimer.js +0 -0
- /package/{src → cli-tool/src}/analytics-web/components/Sidebar.js +0 -0
- /package/{src → cli-tool/src}/analytics-web/components/ToolDisplay.js +0 -0
- /package/{src → cli-tool/src}/analytics-web/index.html +0 -0
- /package/{src → cli-tool/src}/analytics-web/index.html.original +0 -0
- /package/{src → cli-tool/src}/analytics-web/services/DataService.js +0 -0
- /package/{src → cli-tool/src}/analytics-web/services/StateService.js +0 -0
- /package/{src → cli-tool/src}/analytics-web/services/WebSocketService.js +0 -0
- /package/{src → cli-tool/src}/analytics.js +0 -0
- /package/{src → cli-tool/src}/chats-mobile.js +0 -0
- /package/{src → cli-tool/src}/claude-api-proxy.js +0 -0
- /package/{src → cli-tool/src}/command-scanner.js +0 -0
- /package/{src → cli-tool/src}/command-stats.js +0 -0
- /package/{src → cli-tool/src}/console-bridge.js +0 -0
- /package/{src → cli-tool/src}/file-operations.js +0 -0
- /package/{src → cli-tool/src}/health-check.js +0 -0
- /package/{src → cli-tool/src}/hook-scanner.js +0 -0
- /package/{src → cli-tool/src}/hook-stats.js +0 -0
- /package/{src → cli-tool/src}/mcp-stats.js +0 -0
- /package/{src → cli-tool/src}/prompts.js +0 -0
- /package/{src → cli-tool/src}/sandbox-server.js +0 -0
- /package/{src → cli-tool/src}/sdk/global-agent-manager.js +0 -0
- /package/{src → cli-tool/src}/templates.js +0 -0
- /package/{src → cli-tool/src}/test-activity-data.json +0 -0
- /package/{src → cli-tool/src}/test-console-bridge.js +0 -0
- /package/{src → cli-tool/src}/tracking-service.js +0 -0
- /package/{src → cli-tool/src}/utils.js +0 -0
- /package/{src/analytics.log → docu/static/.nojekyll} +0 -0
|
@@ -0,0 +1,1249 @@
|
|
|
1
|
+
# Complete Guide to Claude Code Hooks
|
|
2
|
+
|
|
3
|
+
This guide teaches you how to create and configure custom hooks for Claude Code to automate workflows, validate operations, and enhance your development experience.
|
|
4
|
+
|
|
5
|
+
## What are Claude Code Hooks?
|
|
6
|
+
|
|
7
|
+
Hooks are automated scripts that execute at specific points during Claude Code sessions. Each hook:
|
|
8
|
+
|
|
9
|
+
- **Responds to specific events** like tool usage, prompt submission, or session start/end
|
|
10
|
+
- **Can validate, modify, or block operations** based on your criteria
|
|
11
|
+
- **Executes shell commands automatically** with access to session data
|
|
12
|
+
- **Integrates seamlessly with your development workflow**
|
|
13
|
+
- **Provides fine-grained control** over Claude's behavior
|
|
14
|
+
|
|
15
|
+
## Key Benefits
|
|
16
|
+
|
|
17
|
+
### 🔄 Automated Workflows
|
|
18
|
+
Execute custom scripts automatically when specific events occur during Claude Code sessions.
|
|
19
|
+
|
|
20
|
+
### 🛡️ Enhanced Security
|
|
21
|
+
Validate and block potentially dangerous operations before they execute.
|
|
22
|
+
|
|
23
|
+
### 📊 Session Monitoring
|
|
24
|
+
Track usage patterns, log operations, and gather analytics from your Claude Code sessions.
|
|
25
|
+
|
|
26
|
+
### 🔧 Custom Validation
|
|
27
|
+
Implement project-specific rules and requirements that Claude must follow.
|
|
28
|
+
|
|
29
|
+
### ⚡ Real-time Feedback
|
|
30
|
+
Provide immediate feedback to Claude based on the results of operations.
|
|
31
|
+
|
|
32
|
+
## Hook Configuration
|
|
33
|
+
|
|
34
|
+
### Configuration Files
|
|
35
|
+
|
|
36
|
+
Hooks are configured in your Claude Code settings files with the following priority order:
|
|
37
|
+
|
|
38
|
+
| Type | Location | Scope | Usage |
|
|
39
|
+
|------|----------|-------|--------|
|
|
40
|
+
| **User Settings** | `~/.claude/settings.json` | All projects | Personal hooks across all projects |
|
|
41
|
+
| **Project Settings** | `.claude/settings.json` | Current project | Shared team hooks (committed to repo) |
|
|
42
|
+
| **Local Project Settings** | `.claude/settings.local.json` | Current project | Personal project hooks (not committed) |
|
|
43
|
+
| **Enterprise Settings** | Managed by policy | Organization | Company-wide hooks and policies |
|
|
44
|
+
|
|
45
|
+
*When there are conflicts, settings files lower in the list take precedence.*
|
|
46
|
+
|
|
47
|
+
### Basic Hook Structure
|
|
48
|
+
|
|
49
|
+
Each hook is defined using event-based configuration:
|
|
50
|
+
|
|
51
|
+
```json
|
|
52
|
+
{
|
|
53
|
+
"hooks": {
|
|
54
|
+
"EventName": [
|
|
55
|
+
{
|
|
56
|
+
"matcher": "ToolPattern",
|
|
57
|
+
"hooks": [
|
|
58
|
+
{
|
|
59
|
+
"type": "command",
|
|
60
|
+
"command": "your-script-here",
|
|
61
|
+
"timeout": 60
|
|
62
|
+
}
|
|
63
|
+
]
|
|
64
|
+
}
|
|
65
|
+
]
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Configuration Elements
|
|
71
|
+
|
|
72
|
+
#### Event Names
|
|
73
|
+
- **PreToolUse**: Before Claude executes a tool
|
|
74
|
+
- **PostToolUse**: After Claude executes a tool successfully
|
|
75
|
+
- **UserPromptSubmit**: When user submits a prompt
|
|
76
|
+
- **Notification**: When Claude Code sends notifications
|
|
77
|
+
- **Stop**: When Claude finishes responding
|
|
78
|
+
- **SubagentStop**: When a subagent completes
|
|
79
|
+
- **SessionStart**: When a session begins or resumes
|
|
80
|
+
- **SessionEnd**: When a session terminates
|
|
81
|
+
- **PreCompact**: Before compacting conversation history
|
|
82
|
+
|
|
83
|
+
#### Matchers
|
|
84
|
+
For tool-based events (PreToolUse, PostToolUse):
|
|
85
|
+
```json
|
|
86
|
+
"matcher": "Write" // Exact match for Write tool
|
|
87
|
+
"matcher": "Edit|Write" // Regex pattern for multiple tools
|
|
88
|
+
"matcher": "Bash.*" // Pattern matching with wildcards
|
|
89
|
+
"matcher": "*" // Match all tools
|
|
90
|
+
"matcher": "" // Also matches all tools
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
#### Hook Commands
|
|
94
|
+
```json
|
|
95
|
+
{
|
|
96
|
+
"type": "command", // Currently only "command" supported
|
|
97
|
+
"command": "/path/to/script.sh", // Shell command to execute
|
|
98
|
+
"timeout": 30 // Optional timeout in seconds (default: 60)
|
|
99
|
+
}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Hook Events Reference
|
|
103
|
+
|
|
104
|
+
### PreToolUse
|
|
105
|
+
|
|
106
|
+
**Purpose**: Validate or modify tool usage before execution
|
|
107
|
+
**Common Use Cases**: Permission control, input validation, security checks
|
|
108
|
+
|
|
109
|
+
**Input Data**:
|
|
110
|
+
```json
|
|
111
|
+
{
|
|
112
|
+
"session_id": "abc123",
|
|
113
|
+
"transcript_path": "/path/to/conversation.jsonl",
|
|
114
|
+
"cwd": "/current/working/directory",
|
|
115
|
+
"hook_event_name": "PreToolUse",
|
|
116
|
+
"tool_name": "Write",
|
|
117
|
+
"tool_input": {
|
|
118
|
+
"file_path": "/path/to/file.txt",
|
|
119
|
+
"content": "file content"
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
**Common Matchers**:
|
|
125
|
+
- `Bash` - Shell commands
|
|
126
|
+
- `Write` - File creation
|
|
127
|
+
- `Edit`, `MultiEdit` - File modifications
|
|
128
|
+
- `Read` - File reading
|
|
129
|
+
- `Task` - Subagent tasks
|
|
130
|
+
- `WebFetch`, `WebSearch` - Web operations
|
|
131
|
+
|
|
132
|
+
### PostToolUse
|
|
133
|
+
|
|
134
|
+
**Purpose**: React to completed tool operations, provide feedback, or trigger follow-up actions
|
|
135
|
+
**Common Use Cases**: Logging, validation, cleanup, triggering builds
|
|
136
|
+
|
|
137
|
+
**Input Data**:
|
|
138
|
+
```json
|
|
139
|
+
{
|
|
140
|
+
"session_id": "abc123",
|
|
141
|
+
"transcript_path": "/path/to/conversation.jsonl",
|
|
142
|
+
"cwd": "/current/working/directory",
|
|
143
|
+
"hook_event_name": "PostToolUse",
|
|
144
|
+
"tool_name": "Write",
|
|
145
|
+
"tool_input": {
|
|
146
|
+
"file_path": "/path/to/file.txt",
|
|
147
|
+
"content": "file content"
|
|
148
|
+
},
|
|
149
|
+
"tool_response": {
|
|
150
|
+
"filePath": "/path/to/file.txt",
|
|
151
|
+
"success": true
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### UserPromptSubmit
|
|
157
|
+
|
|
158
|
+
**Purpose**: Process or validate user prompts before Claude sees them
|
|
159
|
+
**Common Use Cases**: Adding context, blocking sensitive prompts, prompt transformation
|
|
160
|
+
|
|
161
|
+
**Input Data**:
|
|
162
|
+
```json
|
|
163
|
+
{
|
|
164
|
+
"session_id": "abc123",
|
|
165
|
+
"transcript_path": "/path/to/conversation.jsonl",
|
|
166
|
+
"cwd": "/current/working/directory",
|
|
167
|
+
"hook_event_name": "UserPromptSubmit",
|
|
168
|
+
"prompt": "Write a function to calculate factorial"
|
|
169
|
+
}
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### SessionStart
|
|
173
|
+
|
|
174
|
+
**Purpose**: Initialize session context and load project-specific information
|
|
175
|
+
**Common Use Cases**: Loading project state, setting up environment, adding context
|
|
176
|
+
|
|
177
|
+
**Input Data**:
|
|
178
|
+
```json
|
|
179
|
+
{
|
|
180
|
+
"session_id": "abc123",
|
|
181
|
+
"transcript_path": "/path/to/conversation.jsonl",
|
|
182
|
+
"hook_event_name": "SessionStart",
|
|
183
|
+
"source": "startup" // "startup", "resume", or "clear"
|
|
184
|
+
}
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
**Matchers**:
|
|
188
|
+
- `startup` - Normal Claude Code startup
|
|
189
|
+
- `resume` - Resumed from `--resume`, `--continue`, or `/resume`
|
|
190
|
+
- `clear` - After `/clear` command
|
|
191
|
+
|
|
192
|
+
### Stop and SubagentStop
|
|
193
|
+
|
|
194
|
+
**Purpose**: Control whether Claude can finish responding or trigger additional actions
|
|
195
|
+
**Common Use Cases**: Automated testing, continuous workflows, quality checks
|
|
196
|
+
|
|
197
|
+
**Input Data**:
|
|
198
|
+
```json
|
|
199
|
+
{
|
|
200
|
+
"session_id": "abc123",
|
|
201
|
+
"transcript_path": "/path/to/conversation.jsonl",
|
|
202
|
+
"hook_event_name": "Stop",
|
|
203
|
+
"stop_hook_active": false
|
|
204
|
+
}
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
### SessionEnd
|
|
208
|
+
|
|
209
|
+
**Purpose**: Cleanup tasks when a session terminates
|
|
210
|
+
**Common Use Cases**: Saving session data, cleanup, logging statistics
|
|
211
|
+
|
|
212
|
+
**Input Data**:
|
|
213
|
+
```json
|
|
214
|
+
{
|
|
215
|
+
"session_id": "abc123",
|
|
216
|
+
"transcript_path": "/path/to/conversation.jsonl",
|
|
217
|
+
"cwd": "/current/working/directory",
|
|
218
|
+
"hook_event_name": "SessionEnd",
|
|
219
|
+
"reason": "exit" // "clear", "logout", "prompt_input_exit", "other"
|
|
220
|
+
}
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
## Hook Output and Control
|
|
224
|
+
|
|
225
|
+
### Simple Exit Code Control
|
|
226
|
+
|
|
227
|
+
**Exit Code 0**: Success
|
|
228
|
+
- For most hooks: stdout shown to user in transcript mode (Ctrl+R)
|
|
229
|
+
- For UserPromptSubmit and SessionStart: stdout added as context for Claude
|
|
230
|
+
|
|
231
|
+
**Exit Code 2**: Blocking error
|
|
232
|
+
- Blocks the operation and shows stderr to Claude for automated handling
|
|
233
|
+
- Behavior varies by hook type (see reference table below)
|
|
234
|
+
|
|
235
|
+
**Other Exit Codes**: Non-blocking error
|
|
236
|
+
- Shows stderr to user and continues execution
|
|
237
|
+
|
|
238
|
+
#### Exit Code 2 Behavior by Hook Type
|
|
239
|
+
|
|
240
|
+
| Hook Event | Behavior |
|
|
241
|
+
|------------|----------|
|
|
242
|
+
| `PreToolUse` | Blocks tool execution, shows stderr to Claude |
|
|
243
|
+
| `PostToolUse` | Shows stderr to Claude (tool already executed) |
|
|
244
|
+
| `UserPromptSubmit` | Blocks prompt, erases it, shows stderr to user only |
|
|
245
|
+
| `Stop`/`SubagentStop` | Blocks stopping, shows stderr to Claude |
|
|
246
|
+
| `Notification` | Shows stderr to user only |
|
|
247
|
+
| `SessionStart`/`SessionEnd`/`PreCompact` | Shows stderr to user only |
|
|
248
|
+
|
|
249
|
+
### Advanced JSON Output
|
|
250
|
+
|
|
251
|
+
For sophisticated control, hooks can return structured JSON:
|
|
252
|
+
|
|
253
|
+
#### Common JSON Fields
|
|
254
|
+
```json
|
|
255
|
+
{
|
|
256
|
+
"continue": true, // Whether to continue execution (default: true)
|
|
257
|
+
"stopReason": "string", // Message when continue is false
|
|
258
|
+
"suppressOutput": true, // Hide stdout from transcript (default: false)
|
|
259
|
+
"systemMessage": "string" // Warning message for user
|
|
260
|
+
}
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
#### PreToolUse Permission Control
|
|
264
|
+
```json
|
|
265
|
+
{
|
|
266
|
+
"hookSpecificOutput": {
|
|
267
|
+
"hookEventName": "PreToolUse",
|
|
268
|
+
"permissionDecision": "allow", // "allow", "deny", or "ask"
|
|
269
|
+
"permissionDecisionReason": "Auto-approved safe operation"
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
#### PostToolUse Feedback Control
|
|
275
|
+
```json
|
|
276
|
+
{
|
|
277
|
+
"decision": "block", // "block" or undefined
|
|
278
|
+
"reason": "Code style violations detected",
|
|
279
|
+
"hookSpecificOutput": {
|
|
280
|
+
"hookEventName": "PostToolUse",
|
|
281
|
+
"additionalContext": "Additional context for Claude"
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
#### UserPromptSubmit Processing
|
|
287
|
+
```json
|
|
288
|
+
{
|
|
289
|
+
"decision": "block", // "block" or undefined
|
|
290
|
+
"reason": "Sensitive information detected",
|
|
291
|
+
"hookSpecificOutput": {
|
|
292
|
+
"hookEventName": "UserPromptSubmit",
|
|
293
|
+
"additionalContext": "Current project status: Ready for deployment"
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
#### SessionStart Context Loading
|
|
299
|
+
```json
|
|
300
|
+
{
|
|
301
|
+
"hookSpecificOutput": {
|
|
302
|
+
"hookEventName": "SessionStart",
|
|
303
|
+
"additionalContext": "Recent issues: #123 (bug fix needed), #124 (feature ready)"
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
## Complete Hook Examples
|
|
309
|
+
|
|
310
|
+
### 1. Code Style Enforcement
|
|
311
|
+
|
|
312
|
+
```json
|
|
313
|
+
{
|
|
314
|
+
"hooks": {
|
|
315
|
+
"PostToolUse": [
|
|
316
|
+
{
|
|
317
|
+
"matcher": "Write|Edit|MultiEdit",
|
|
318
|
+
"hooks": [
|
|
319
|
+
{
|
|
320
|
+
"type": "command",
|
|
321
|
+
"command": "$CLAUDE_PROJECT_DIR/.claude/hooks/format-code.sh",
|
|
322
|
+
"timeout": 30
|
|
323
|
+
}
|
|
324
|
+
]
|
|
325
|
+
}
|
|
326
|
+
]
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
**format-code.sh**:
|
|
332
|
+
```bash
|
|
333
|
+
#!/bin/bash
|
|
334
|
+
# Code formatting hook
|
|
335
|
+
|
|
336
|
+
set -e
|
|
337
|
+
|
|
338
|
+
# Read hook input
|
|
339
|
+
input=$(cat)
|
|
340
|
+
tool_name=$(echo "$input" | jq -r '.tool_name')
|
|
341
|
+
file_path=$(echo "$input" | jq -r '.tool_input.file_path // empty')
|
|
342
|
+
|
|
343
|
+
# Only process code files
|
|
344
|
+
if [[ ! "$file_path" =~ \.(js|ts|jsx|tsx|py|go|rs)$ ]]; then
|
|
345
|
+
exit 0
|
|
346
|
+
fi
|
|
347
|
+
|
|
348
|
+
echo "🔧 Formatting $file_path..."
|
|
349
|
+
|
|
350
|
+
# Format based on file type
|
|
351
|
+
case "$file_path" in
|
|
352
|
+
*.js|*.jsx|*.ts|*.tsx)
|
|
353
|
+
if command -v prettier >/dev/null 2>&1; then
|
|
354
|
+
prettier --write "$file_path" 2>/dev/null || echo "❌ Prettier formatting failed"
|
|
355
|
+
fi
|
|
356
|
+
;;
|
|
357
|
+
*.py)
|
|
358
|
+
if command -v black >/dev/null 2>&1; then
|
|
359
|
+
black "$file_path" 2>/dev/null || echo "❌ Black formatting failed"
|
|
360
|
+
fi
|
|
361
|
+
;;
|
|
362
|
+
*.go)
|
|
363
|
+
if command -v gofmt >/dev/null 2>&1; then
|
|
364
|
+
gofmt -w "$file_path" 2>/dev/null || echo "❌ Go formatting failed"
|
|
365
|
+
fi
|
|
366
|
+
;;
|
|
367
|
+
*.rs)
|
|
368
|
+
if command -v rustfmt >/dev/null 2>&1; then
|
|
369
|
+
rustfmt "$file_path" 2>/dev/null || echo "❌ Rust formatting failed"
|
|
370
|
+
fi
|
|
371
|
+
;;
|
|
372
|
+
esac
|
|
373
|
+
|
|
374
|
+
echo "✅ Code formatting complete"
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
### 2. Security Validation
|
|
378
|
+
|
|
379
|
+
```json
|
|
380
|
+
{
|
|
381
|
+
"hooks": {
|
|
382
|
+
"PreToolUse": [
|
|
383
|
+
{
|
|
384
|
+
"matcher": "Bash",
|
|
385
|
+
"hooks": [
|
|
386
|
+
{
|
|
387
|
+
"type": "command",
|
|
388
|
+
"command": "$CLAUDE_PROJECT_DIR/.claude/hooks/validate-bash.py"
|
|
389
|
+
}
|
|
390
|
+
]
|
|
391
|
+
}
|
|
392
|
+
],
|
|
393
|
+
"UserPromptSubmit": [
|
|
394
|
+
{
|
|
395
|
+
"hooks": [
|
|
396
|
+
{
|
|
397
|
+
"type": "command",
|
|
398
|
+
"command": "$CLAUDE_PROJECT_DIR/.claude/hooks/check-sensitive.py"
|
|
399
|
+
}
|
|
400
|
+
]
|
|
401
|
+
}
|
|
402
|
+
]
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
**validate-bash.py**:
|
|
408
|
+
```python
|
|
409
|
+
#!/usr/bin/env python3
|
|
410
|
+
import json
|
|
411
|
+
import sys
|
|
412
|
+
import re
|
|
413
|
+
|
|
414
|
+
# Dangerous command patterns
|
|
415
|
+
DANGEROUS_PATTERNS = [
|
|
416
|
+
(r'\brm\s+-rf\s+/', 'Dangerous: rm -rf with absolute path'),
|
|
417
|
+
(r'\bdd\s+if=', 'Dangerous: dd command detected'),
|
|
418
|
+
(r'\bchmod\s+777', 'Security risk: chmod 777 detected'),
|
|
419
|
+
(r'>\s*/dev/(sd[a-z]|hd[a-z])', 'Dangerous: writing to disk device'),
|
|
420
|
+
(r'\bcurl.*\|\s*bash', 'Security risk: piping curl to bash'),
|
|
421
|
+
(r'\bwget.*\|\s*bash', 'Security risk: piping wget to bash'),
|
|
422
|
+
]
|
|
423
|
+
|
|
424
|
+
try:
|
|
425
|
+
input_data = json.load(sys.stdin)
|
|
426
|
+
command = input_data.get('tool_input', {}).get('command', '')
|
|
427
|
+
|
|
428
|
+
if not command:
|
|
429
|
+
sys.exit(0)
|
|
430
|
+
|
|
431
|
+
# Check for dangerous patterns
|
|
432
|
+
for pattern, message in DANGEROUS_PATTERNS:
|
|
433
|
+
if re.search(pattern, command, re.IGNORECASE):
|
|
434
|
+
print(f"🚨 {message}", file=sys.stderr)
|
|
435
|
+
print(f"Command: {command}", file=sys.stderr)
|
|
436
|
+
print("Please review and confirm this command is safe.", file=sys.stderr)
|
|
437
|
+
sys.exit(2) # Block the command
|
|
438
|
+
|
|
439
|
+
# Auto-approve safe commands
|
|
440
|
+
output = {
|
|
441
|
+
"hookSpecificOutput": {
|
|
442
|
+
"hookEventName": "PreToolUse",
|
|
443
|
+
"permissionDecision": "allow",
|
|
444
|
+
"permissionDecisionReason": "Command passed security validation"
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
print(json.dumps(output))
|
|
448
|
+
|
|
449
|
+
except Exception as e:
|
|
450
|
+
print(f"Hook error: {e}", file=sys.stderr)
|
|
451
|
+
sys.exit(1)
|
|
452
|
+
```
|
|
453
|
+
|
|
454
|
+
**check-sensitive.py**:
|
|
455
|
+
```python
|
|
456
|
+
#!/usr/bin/env python3
|
|
457
|
+
import json
|
|
458
|
+
import sys
|
|
459
|
+
import re
|
|
460
|
+
|
|
461
|
+
# Sensitive information patterns
|
|
462
|
+
SENSITIVE_PATTERNS = [
|
|
463
|
+
(r'(?i)(password|pwd)\s*[:=]\s*[\'"]?[^\s\'"]+', 'Password detected'),
|
|
464
|
+
(r'(?i)(api[_-]?key|apikey)\s*[:=]\s*[\'"]?[a-zA-Z0-9]+', 'API key detected'),
|
|
465
|
+
(r'(?i)(secret|token)\s*[:=]\s*[\'"]?[^\s\'"]+', 'Secret/token detected'),
|
|
466
|
+
(r'\b[A-Za-z0-9+/]{40,}={0,2}\b', 'Base64-encoded secret detected'),
|
|
467
|
+
(r'-----BEGIN [A-Z ]+-----', 'Private key detected'),
|
|
468
|
+
]
|
|
469
|
+
|
|
470
|
+
try:
|
|
471
|
+
input_data = json.load(sys.stdin)
|
|
472
|
+
prompt = input_data.get('prompt', '')
|
|
473
|
+
|
|
474
|
+
# Check for sensitive information
|
|
475
|
+
for pattern, message in SENSITIVE_PATTERNS:
|
|
476
|
+
if re.search(pattern, prompt):
|
|
477
|
+
output = {
|
|
478
|
+
"decision": "block",
|
|
479
|
+
"reason": f"🚨 Security violation: {message}. Please remove sensitive information and try again."
|
|
480
|
+
}
|
|
481
|
+
print(json.dumps(output))
|
|
482
|
+
sys.exit(0)
|
|
483
|
+
|
|
484
|
+
# Add security reminder
|
|
485
|
+
security_context = """
|
|
486
|
+
🔒 Security reminder: This session is being monitored for sensitive information.
|
|
487
|
+
Current security status: All prompts are scanned for passwords, API keys, and secrets.
|
|
488
|
+
"""
|
|
489
|
+
|
|
490
|
+
output = {
|
|
491
|
+
"hookSpecificOutput": {
|
|
492
|
+
"hookEventName": "UserPromptSubmit",
|
|
493
|
+
"additionalContext": security_context
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
print(json.dumps(output))
|
|
497
|
+
|
|
498
|
+
except Exception as e:
|
|
499
|
+
print(f"Hook error: {e}", file=sys.stderr)
|
|
500
|
+
sys.exit(1)
|
|
501
|
+
```
|
|
502
|
+
|
|
503
|
+
### 3. Project Context Loading
|
|
504
|
+
|
|
505
|
+
```json
|
|
506
|
+
{
|
|
507
|
+
"hooks": {
|
|
508
|
+
"SessionStart": [
|
|
509
|
+
{
|
|
510
|
+
"matcher": "startup|resume",
|
|
511
|
+
"hooks": [
|
|
512
|
+
{
|
|
513
|
+
"type": "command",
|
|
514
|
+
"command": "$CLAUDE_PROJECT_DIR/.claude/hooks/load-context.sh"
|
|
515
|
+
}
|
|
516
|
+
]
|
|
517
|
+
}
|
|
518
|
+
]
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
```
|
|
522
|
+
|
|
523
|
+
**load-context.sh**:
|
|
524
|
+
```bash
|
|
525
|
+
#!/bin/bash
|
|
526
|
+
# Project context loading hook
|
|
527
|
+
|
|
528
|
+
set -e
|
|
529
|
+
|
|
530
|
+
# Read hook input
|
|
531
|
+
input=$(cat)
|
|
532
|
+
session_id=$(echo "$input" | jq -r '.session_id')
|
|
533
|
+
source=$(echo "$input" | jq -r '.source // "startup"')
|
|
534
|
+
|
|
535
|
+
echo "🚀 Loading project context for $source..."
|
|
536
|
+
|
|
537
|
+
# Load git status
|
|
538
|
+
echo "## Git Repository Status"
|
|
539
|
+
echo "**Current branch:** $(git rev-parse --abbrev-ref HEAD 2>/dev/null || echo 'not a git repo')"
|
|
540
|
+
echo "**Last commit:** $(git log -1 --pretty=format:'%h - %s (%cr)' 2>/dev/null || echo 'no commits')"
|
|
541
|
+
|
|
542
|
+
# Check for uncommitted changes
|
|
543
|
+
if git diff-index --quiet HEAD -- 2>/dev/null; then
|
|
544
|
+
echo "**Working tree:** clean"
|
|
545
|
+
else
|
|
546
|
+
echo "**Working tree:** has uncommitted changes"
|
|
547
|
+
echo "**Modified files:**"
|
|
548
|
+
git diff --name-only HEAD 2>/dev/null | sed 's/^/ - /' || echo " - (unable to detect)"
|
|
549
|
+
fi
|
|
550
|
+
|
|
551
|
+
# Load recent issues/todos
|
|
552
|
+
echo -e "\n## Recent Issues & TODOs"
|
|
553
|
+
if [[ -f "TODO.md" ]]; then
|
|
554
|
+
echo "**From TODO.md:**"
|
|
555
|
+
head -10 "TODO.md" | sed 's/^/ /'
|
|
556
|
+
elif command -v rg >/dev/null 2>&1; then
|
|
557
|
+
echo "**TODOs in codebase:**"
|
|
558
|
+
rg -i "todo|fixme|hack|bug" --type-add 'code:*.{js,ts,py,go,rs,java,c,cpp,h}' -t code -n | head -5 | sed 's/^/ /'
|
|
559
|
+
fi
|
|
560
|
+
|
|
561
|
+
# Load package info
|
|
562
|
+
echo -e "\n## Project Configuration"
|
|
563
|
+
if [[ -f "package.json" ]]; then
|
|
564
|
+
name=$(jq -r '.name // "unknown"' package.json)
|
|
565
|
+
version=$(jq -r '.version // "unknown"' package.json)
|
|
566
|
+
echo "**Project:** $name v$version"
|
|
567
|
+
echo "**Scripts available:** $(jq -r '.scripts | keys | join(", ")' package.json 2>/dev/null || echo 'none')"
|
|
568
|
+
elif [[ -f "Cargo.toml" ]]; then
|
|
569
|
+
name=$(grep '^name' Cargo.toml | cut -d'"' -f2 2>/dev/null || echo 'unknown')
|
|
570
|
+
version=$(grep '^version' Cargo.toml | cut -d'"' -f2 2>/dev/null || echo 'unknown')
|
|
571
|
+
echo "**Rust project:** $name v$version"
|
|
572
|
+
elif [[ -f "go.mod" ]]; then
|
|
573
|
+
module=$(head -1 go.mod | cut -d' ' -f2 2>/dev/null || echo 'unknown')
|
|
574
|
+
echo "**Go module:** $module"
|
|
575
|
+
elif [[ -f "pyproject.toml" ]] || [[ -f "setup.py" ]]; then
|
|
576
|
+
echo "**Python project detected**"
|
|
577
|
+
fi
|
|
578
|
+
|
|
579
|
+
# Load recent changes
|
|
580
|
+
echo -e "\n## Recent Activity"
|
|
581
|
+
echo "**Last 3 commits:**"
|
|
582
|
+
git log -3 --pretty=format:' - %h %s (%cr)' 2>/dev/null || echo " - No git history available"
|
|
583
|
+
|
|
584
|
+
echo -e "\n✅ Project context loaded successfully"
|
|
585
|
+
```
|
|
586
|
+
|
|
587
|
+
### 4. Automated Testing
|
|
588
|
+
|
|
589
|
+
```json
|
|
590
|
+
{
|
|
591
|
+
"hooks": {
|
|
592
|
+
"PostToolUse": [
|
|
593
|
+
{
|
|
594
|
+
"matcher": "Write|Edit",
|
|
595
|
+
"hooks": [
|
|
596
|
+
{
|
|
597
|
+
"type": "command",
|
|
598
|
+
"command": "$CLAUDE_PROJECT_DIR/.claude/hooks/auto-test.sh",
|
|
599
|
+
"timeout": 120
|
|
600
|
+
}
|
|
601
|
+
]
|
|
602
|
+
}
|
|
603
|
+
]
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
```
|
|
607
|
+
|
|
608
|
+
**auto-test.sh**:
|
|
609
|
+
```bash
|
|
610
|
+
#!/bin/bash
|
|
611
|
+
# Automated testing hook
|
|
612
|
+
|
|
613
|
+
set -e
|
|
614
|
+
|
|
615
|
+
# Read hook input
|
|
616
|
+
input=$(cat)
|
|
617
|
+
file_path=$(echo "$input" | jq -r '.tool_input.file_path // empty')
|
|
618
|
+
|
|
619
|
+
# Only run tests for source files
|
|
620
|
+
if [[ ! "$file_path" =~ \.(js|ts|jsx|tsx|py|go|rs)$ ]]; then
|
|
621
|
+
exit 0
|
|
622
|
+
fi
|
|
623
|
+
|
|
624
|
+
echo "🧪 Running automated tests for $file_path..."
|
|
625
|
+
|
|
626
|
+
# Determine test command based on project type
|
|
627
|
+
run_tests() {
|
|
628
|
+
if [[ -f "package.json" ]] && jq -e '.scripts.test' package.json >/dev/null 2>&1; then
|
|
629
|
+
echo "📦 Running npm tests..."
|
|
630
|
+
npm test 2>&1 | tail -10
|
|
631
|
+
elif [[ -f "Cargo.toml" ]]; then
|
|
632
|
+
echo "🦀 Running Rust tests..."
|
|
633
|
+
cargo test 2>&1 | tail -10
|
|
634
|
+
elif [[ -f "go.mod" ]]; then
|
|
635
|
+
echo "🐹 Running Go tests..."
|
|
636
|
+
go test ./... 2>&1 | tail -10
|
|
637
|
+
elif [[ -f "pytest.ini" ]] || [[ -f "pyproject.toml" ]]; then
|
|
638
|
+
echo "🐍 Running Python tests..."
|
|
639
|
+
python -m pytest -x --tb=short 2>&1 | tail -10
|
|
640
|
+
else
|
|
641
|
+
echo "ℹ️ No test configuration found, skipping tests"
|
|
642
|
+
return 0
|
|
643
|
+
fi
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
# Run tests and capture result
|
|
647
|
+
if test_output=$(run_tests); then
|
|
648
|
+
echo "✅ Tests passed"
|
|
649
|
+
echo "$test_output"
|
|
650
|
+
else
|
|
651
|
+
echo "❌ Tests failed - informing Claude"
|
|
652
|
+
echo "Test failures detected in modified code:" >&2
|
|
653
|
+
echo "$test_output" >&2
|
|
654
|
+
exit 2 # This will show the error to Claude
|
|
655
|
+
fi
|
|
656
|
+
```
|
|
657
|
+
|
|
658
|
+
### 5. File Protection
|
|
659
|
+
|
|
660
|
+
```json
|
|
661
|
+
{
|
|
662
|
+
"hooks": {
|
|
663
|
+
"PreToolUse": [
|
|
664
|
+
{
|
|
665
|
+
"matcher": "Write|Edit|MultiEdit",
|
|
666
|
+
"hooks": [
|
|
667
|
+
{
|
|
668
|
+
"type": "command",
|
|
669
|
+
"command": "$CLAUDE_PROJECT_DIR/.claude/hooks/protect-files.py"
|
|
670
|
+
}
|
|
671
|
+
]
|
|
672
|
+
}
|
|
673
|
+
]
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
```
|
|
677
|
+
|
|
678
|
+
**protect-files.py**:
|
|
679
|
+
```python
|
|
680
|
+
#!/usr/bin/env python3
|
|
681
|
+
import json
|
|
682
|
+
import sys
|
|
683
|
+
import os
|
|
684
|
+
from pathlib import Path
|
|
685
|
+
|
|
686
|
+
# Protected file patterns
|
|
687
|
+
PROTECTED_PATTERNS = [
|
|
688
|
+
'.env*',
|
|
689
|
+
'*.key',
|
|
690
|
+
'*.pem',
|
|
691
|
+
'id_rsa*',
|
|
692
|
+
'id_ed25519*',
|
|
693
|
+
'.aws/credentials',
|
|
694
|
+
'.ssh/config',
|
|
695
|
+
'secrets.*',
|
|
696
|
+
'private.*'
|
|
697
|
+
]
|
|
698
|
+
|
|
699
|
+
# Critical system files
|
|
700
|
+
CRITICAL_FILES = [
|
|
701
|
+
'/etc/passwd',
|
|
702
|
+
'/etc/shadow',
|
|
703
|
+
'/etc/hosts',
|
|
704
|
+
'/etc/fstab',
|
|
705
|
+
'~/.bashrc',
|
|
706
|
+
'~/.zshrc',
|
|
707
|
+
'~/.profile'
|
|
708
|
+
]
|
|
709
|
+
|
|
710
|
+
def is_protected_file(file_path):
|
|
711
|
+
"""Check if file matches protection patterns"""
|
|
712
|
+
path = Path(file_path)
|
|
713
|
+
|
|
714
|
+
# Check against patterns
|
|
715
|
+
for pattern in PROTECTED_PATTERNS:
|
|
716
|
+
if path.match(pattern) or any(part.match(pattern) for part in path.parts):
|
|
717
|
+
return True, f"matches protected pattern: {pattern}"
|
|
718
|
+
|
|
719
|
+
# Check critical system files
|
|
720
|
+
resolved_path = str(path.resolve())
|
|
721
|
+
for critical in CRITICAL_FILES:
|
|
722
|
+
critical_resolved = str(Path(critical).expanduser().resolve())
|
|
723
|
+
if resolved_path == critical_resolved:
|
|
724
|
+
return True, f"is a critical system file"
|
|
725
|
+
|
|
726
|
+
return False, None
|
|
727
|
+
|
|
728
|
+
try:
|
|
729
|
+
input_data = json.load(sys.stdin)
|
|
730
|
+
tool_input = input_data.get('tool_input', {})
|
|
731
|
+
file_path = tool_input.get('file_path', '')
|
|
732
|
+
|
|
733
|
+
if not file_path:
|
|
734
|
+
sys.exit(0)
|
|
735
|
+
|
|
736
|
+
# Check if file is protected
|
|
737
|
+
is_protected, reason = is_protected_file(file_path)
|
|
738
|
+
|
|
739
|
+
if is_protected:
|
|
740
|
+
output = {
|
|
741
|
+
"hookSpecificOutput": {
|
|
742
|
+
"hookEventName": "PreToolUse",
|
|
743
|
+
"permissionDecision": "ask",
|
|
744
|
+
"permissionDecisionReason": f"⚠️ Protected file detected: {file_path} {reason}. Confirm this operation."
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
print(json.dumps(output))
|
|
748
|
+
else:
|
|
749
|
+
# Auto-approve safe files
|
|
750
|
+
output = {
|
|
751
|
+
"hookSpecificOutput": {
|
|
752
|
+
"hookEventName": "PreToolUse",
|
|
753
|
+
"permissionDecision": "allow",
|
|
754
|
+
"permissionDecisionReason": "File passed protection checks"
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
print(json.dumps(output))
|
|
758
|
+
|
|
759
|
+
except Exception as e:
|
|
760
|
+
print(f"Hook error: {e}", file=sys.stderr)
|
|
761
|
+
sys.exit(1)
|
|
762
|
+
```
|
|
763
|
+
|
|
764
|
+
## MCP Integration
|
|
765
|
+
|
|
766
|
+
### Understanding MCP Tools in Hooks
|
|
767
|
+
|
|
768
|
+
Claude Code hooks work seamlessly with [Model Context Protocol (MCP)](/en/docs/claude-code/mcp) tools. MCP tools follow the naming pattern `mcp__<server>__<tool>`:
|
|
769
|
+
|
|
770
|
+
- `mcp__github__create_issue` - GitHub MCP server's issue creation tool
|
|
771
|
+
- `mcp__database__execute_query` - Database MCP server's query tool
|
|
772
|
+
- `mcp__filesystem__write_file` - Filesystem MCP server's write tool
|
|
773
|
+
|
|
774
|
+
### MCP Hook Configuration
|
|
775
|
+
|
|
776
|
+
```json
|
|
777
|
+
{
|
|
778
|
+
"hooks": {
|
|
779
|
+
"PreToolUse": [
|
|
780
|
+
{
|
|
781
|
+
"matcher": "mcp__github__.*",
|
|
782
|
+
"hooks": [
|
|
783
|
+
{
|
|
784
|
+
"type": "command",
|
|
785
|
+
"command": "$CLAUDE_PROJECT_DIR/.claude/hooks/log-github-operations.sh"
|
|
786
|
+
}
|
|
787
|
+
]
|
|
788
|
+
},
|
|
789
|
+
{
|
|
790
|
+
"matcher": "mcp__.*__write.*|mcp__.*__delete.*",
|
|
791
|
+
"hooks": [
|
|
792
|
+
{
|
|
793
|
+
"type": "command",
|
|
794
|
+
"command": "$CLAUDE_PROJECT_DIR/.claude/hooks/validate-destructive-mcp.py"
|
|
795
|
+
}
|
|
796
|
+
]
|
|
797
|
+
}
|
|
798
|
+
]
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
```
|
|
802
|
+
|
|
803
|
+
## Advanced Hook Patterns
|
|
804
|
+
|
|
805
|
+
### 1. Conditional Hook Execution
|
|
806
|
+
|
|
807
|
+
```python
|
|
808
|
+
#!/usr/bin/env python3
|
|
809
|
+
# Conditional hook based on project type and environment
|
|
810
|
+
|
|
811
|
+
import json
|
|
812
|
+
import sys
|
|
813
|
+
import os
|
|
814
|
+
|
|
815
|
+
try:
|
|
816
|
+
input_data = json.load(sys.stdin)
|
|
817
|
+
|
|
818
|
+
# Only run in production-like environments
|
|
819
|
+
env = os.environ.get('NODE_ENV', 'development')
|
|
820
|
+
if env not in ['staging', 'production']:
|
|
821
|
+
sys.exit(0)
|
|
822
|
+
|
|
823
|
+
# Only for specific project types
|
|
824
|
+
if not os.path.exists('package.json'):
|
|
825
|
+
sys.exit(0)
|
|
826
|
+
|
|
827
|
+
# Your hook logic here
|
|
828
|
+
print("🚀 Production hook executed")
|
|
829
|
+
|
|
830
|
+
except Exception as e:
|
|
831
|
+
print(f"Hook error: {e}", file=sys.stderr)
|
|
832
|
+
sys.exit(1)
|
|
833
|
+
```
|
|
834
|
+
|
|
835
|
+
### 2. Multi-Tool Coordination
|
|
836
|
+
|
|
837
|
+
```json
|
|
838
|
+
{
|
|
839
|
+
"hooks": {
|
|
840
|
+
"PostToolUse": [
|
|
841
|
+
{
|
|
842
|
+
"matcher": "Write",
|
|
843
|
+
"hooks": [
|
|
844
|
+
{
|
|
845
|
+
"type": "command",
|
|
846
|
+
"command": "$CLAUDE_PROJECT_DIR/.claude/hooks/coordinate-tools.sh"
|
|
847
|
+
}
|
|
848
|
+
]
|
|
849
|
+
}
|
|
850
|
+
]
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
```
|
|
854
|
+
|
|
855
|
+
**coordinate-tools.sh**:
|
|
856
|
+
```bash
|
|
857
|
+
#!/bin/bash
|
|
858
|
+
# Multi-tool coordination example
|
|
859
|
+
|
|
860
|
+
set -e
|
|
861
|
+
|
|
862
|
+
# Read hook input
|
|
863
|
+
input=$(cat)
|
|
864
|
+
file_path=$(echo "$input" | jq -r '.tool_input.file_path')
|
|
865
|
+
tool_name=$(echo "$input" | jq -r '.tool_name')
|
|
866
|
+
|
|
867
|
+
# Create a coordination log
|
|
868
|
+
mkdir -p .claude/logs
|
|
869
|
+
echo "$(date): $tool_name - $file_path" >> .claude/logs/tool-coordination.log
|
|
870
|
+
|
|
871
|
+
# Trigger related actions based on file type
|
|
872
|
+
case "$file_path" in
|
|
873
|
+
*.md)
|
|
874
|
+
echo "📝 Documentation updated, checking for broken links..."
|
|
875
|
+
# Link check could go here
|
|
876
|
+
;;
|
|
877
|
+
*.js|*.ts)
|
|
878
|
+
echo "📄 JavaScript updated, checking dependencies..."
|
|
879
|
+
if [[ -f package.json ]]; then
|
|
880
|
+
npm audit --audit-level=moderate || echo "⚠️ npm audit found issues"
|
|
881
|
+
fi
|
|
882
|
+
;;
|
|
883
|
+
Dockerfile)
|
|
884
|
+
echo "🐳 Dockerfile updated, validating..."
|
|
885
|
+
docker build --dry-run . || echo "⚠️ Docker build validation failed"
|
|
886
|
+
;;
|
|
887
|
+
*.yml|*.yaml)
|
|
888
|
+
echo "📋 YAML updated, validating syntax..."
|
|
889
|
+
python -c "import yaml; yaml.safe_load(open('$file_path'))" 2>/dev/null || echo "⚠️ YAML syntax error"
|
|
890
|
+
;;
|
|
891
|
+
esac
|
|
892
|
+
|
|
893
|
+
echo "✅ Tool coordination complete"
|
|
894
|
+
```
|
|
895
|
+
|
|
896
|
+
### 3. Session Analytics
|
|
897
|
+
|
|
898
|
+
```python
|
|
899
|
+
#!/usr/bin/env python3
|
|
900
|
+
# Session analytics and usage tracking
|
|
901
|
+
|
|
902
|
+
import json
|
|
903
|
+
import sys
|
|
904
|
+
import sqlite3
|
|
905
|
+
from datetime import datetime
|
|
906
|
+
import os
|
|
907
|
+
|
|
908
|
+
DATABASE = os.path.expanduser('~/.claude/analytics.db')
|
|
909
|
+
|
|
910
|
+
def init_db():
|
|
911
|
+
"""Initialize analytics database"""
|
|
912
|
+
conn = sqlite3.connect(DATABASE)
|
|
913
|
+
conn.execute('''
|
|
914
|
+
CREATE TABLE IF NOT EXISTS tool_usage (
|
|
915
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
916
|
+
session_id TEXT,
|
|
917
|
+
tool_name TEXT,
|
|
918
|
+
timestamp DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
919
|
+
file_path TEXT,
|
|
920
|
+
success BOOLEAN
|
|
921
|
+
)
|
|
922
|
+
''')
|
|
923
|
+
conn.commit()
|
|
924
|
+
return conn
|
|
925
|
+
|
|
926
|
+
try:
|
|
927
|
+
input_data = json.load(sys.stdin)
|
|
928
|
+
|
|
929
|
+
# Initialize database
|
|
930
|
+
conn = init_db()
|
|
931
|
+
|
|
932
|
+
# Log tool usage
|
|
933
|
+
conn.execute('''
|
|
934
|
+
INSERT INTO tool_usage (session_id, tool_name, file_path, success)
|
|
935
|
+
VALUES (?, ?, ?, ?)
|
|
936
|
+
''', (
|
|
937
|
+
input_data.get('session_id'),
|
|
938
|
+
input_data.get('tool_name'),
|
|
939
|
+
input_data.get('tool_input', {}).get('file_path', ''),
|
|
940
|
+
input_data.get('tool_response', {}).get('success', True)
|
|
941
|
+
))
|
|
942
|
+
|
|
943
|
+
conn.commit()
|
|
944
|
+
|
|
945
|
+
# Generate usage summary periodically
|
|
946
|
+
cursor = conn.cursor()
|
|
947
|
+
cursor.execute('SELECT COUNT(*) FROM tool_usage WHERE date(timestamp) = date("now")')
|
|
948
|
+
daily_count = cursor.fetchone()[0]
|
|
949
|
+
|
|
950
|
+
if daily_count % 10 == 0: # Every 10th operation
|
|
951
|
+
print(f"📊 Daily tool usage: {daily_count} operations")
|
|
952
|
+
|
|
953
|
+
# Show top tools today
|
|
954
|
+
cursor.execute('''
|
|
955
|
+
SELECT tool_name, COUNT(*) as count
|
|
956
|
+
FROM tool_usage
|
|
957
|
+
WHERE date(timestamp) = date("now")
|
|
958
|
+
GROUP BY tool_name
|
|
959
|
+
ORDER BY count DESC
|
|
960
|
+
LIMIT 3
|
|
961
|
+
''')
|
|
962
|
+
|
|
963
|
+
top_tools = cursor.fetchall()
|
|
964
|
+
print("🏆 Most used tools today:")
|
|
965
|
+
for tool, count in top_tools:
|
|
966
|
+
print(f" {tool}: {count} times")
|
|
967
|
+
|
|
968
|
+
conn.close()
|
|
969
|
+
|
|
970
|
+
except Exception as e:
|
|
971
|
+
print(f"Analytics error: {e}", file=sys.stderr)
|
|
972
|
+
sys.exit(0) # Don't fail the operation for analytics errors
|
|
973
|
+
```
|
|
974
|
+
|
|
975
|
+
## Best Practices
|
|
976
|
+
|
|
977
|
+
### 1. Hook Design Principles
|
|
978
|
+
- **Single Responsibility**: Each hook should have one clear purpose
|
|
979
|
+
- **Fail Gracefully**: Use exit code 0 for non-critical failures to avoid blocking operations
|
|
980
|
+
- **Be Fast**: Keep hook execution time minimal to avoid slowing down Claude
|
|
981
|
+
- **Idempotent**: Hooks should be safe to run multiple times with the same input
|
|
982
|
+
|
|
983
|
+
### 2. Error Handling
|
|
984
|
+
```python
|
|
985
|
+
#!/usr/bin/env python3
|
|
986
|
+
import json
|
|
987
|
+
import sys
|
|
988
|
+
import logging
|
|
989
|
+
|
|
990
|
+
# Set up logging
|
|
991
|
+
logging.basicConfig(
|
|
992
|
+
filename=os.path.expanduser('~/.claude/hooks.log'),
|
|
993
|
+
level=logging.INFO,
|
|
994
|
+
format='%(asctime)s - %(levelname)s - %(message)s'
|
|
995
|
+
)
|
|
996
|
+
|
|
997
|
+
try:
|
|
998
|
+
input_data = json.load(sys.stdin)
|
|
999
|
+
|
|
1000
|
+
# Your hook logic here
|
|
1001
|
+
|
|
1002
|
+
except json.JSONDecodeError as e:
|
|
1003
|
+
logging.error(f"JSON decode error: {e}")
|
|
1004
|
+
print(f"Invalid JSON input: {e}", file=sys.stderr)
|
|
1005
|
+
sys.exit(1)
|
|
1006
|
+
except Exception as e:
|
|
1007
|
+
logging.error(f"Unexpected error: {e}")
|
|
1008
|
+
print(f"Hook error: {e}", file=sys.stderr)
|
|
1009
|
+
sys.exit(0) # Don't block on unexpected errors
|
|
1010
|
+
```
|
|
1011
|
+
|
|
1012
|
+
### 3. Input Validation
|
|
1013
|
+
```python
|
|
1014
|
+
def validate_input(input_data):
|
|
1015
|
+
"""Validate hook input data"""
|
|
1016
|
+
required_fields = ['session_id', 'hook_event_name']
|
|
1017
|
+
|
|
1018
|
+
for field in required_fields:
|
|
1019
|
+
if field not in input_data:
|
|
1020
|
+
raise ValueError(f"Missing required field: {field}")
|
|
1021
|
+
|
|
1022
|
+
# Validate file paths for path traversal
|
|
1023
|
+
file_path = input_data.get('tool_input', {}).get('file_path')
|
|
1024
|
+
if file_path and '..' in file_path:
|
|
1025
|
+
raise ValueError(f"Invalid file path: {file_path}")
|
|
1026
|
+
|
|
1027
|
+
return True
|
|
1028
|
+
```
|
|
1029
|
+
|
|
1030
|
+
### 4. Configuration Management
|
|
1031
|
+
```json
|
|
1032
|
+
{
|
|
1033
|
+
"hooks": {
|
|
1034
|
+
"PostToolUse": [
|
|
1035
|
+
{
|
|
1036
|
+
"matcher": "Write|Edit",
|
|
1037
|
+
"hooks": [
|
|
1038
|
+
{
|
|
1039
|
+
"type": "command",
|
|
1040
|
+
"command": "$CLAUDE_PROJECT_DIR/.claude/hooks/configurable-hook.py --config=$CLAUDE_PROJECT_DIR/.claude/hook-config.json"
|
|
1041
|
+
}
|
|
1042
|
+
]
|
|
1043
|
+
}
|
|
1044
|
+
]
|
|
1045
|
+
}
|
|
1046
|
+
}
|
|
1047
|
+
```
|
|
1048
|
+
|
|
1049
|
+
## Security and Safety
|
|
1050
|
+
|
|
1051
|
+
### Security Best Practices
|
|
1052
|
+
|
|
1053
|
+
1. **Input Sanitization**: Always validate and sanitize inputs from Claude Code
|
|
1054
|
+
2. **Path Security**: Check for directory traversal attacks (`../` patterns)
|
|
1055
|
+
3. **Command Injection**: Never pass user input directly to shell commands
|
|
1056
|
+
4. **File Permissions**: Use minimal required permissions for hook scripts
|
|
1057
|
+
5. **Secrets Management**: Never log or expose sensitive information
|
|
1058
|
+
|
|
1059
|
+
### Security Example
|
|
1060
|
+
```python
|
|
1061
|
+
#!/usr/bin/env python3
|
|
1062
|
+
import json
|
|
1063
|
+
import sys
|
|
1064
|
+
import os
|
|
1065
|
+
import re
|
|
1066
|
+
from pathlib import Path
|
|
1067
|
+
|
|
1068
|
+
def sanitize_path(file_path):
|
|
1069
|
+
"""Sanitize file path to prevent directory traversal"""
|
|
1070
|
+
if not file_path:
|
|
1071
|
+
return None
|
|
1072
|
+
|
|
1073
|
+
# Check for directory traversal
|
|
1074
|
+
if '..' in file_path or file_path.startswith('/'):
|
|
1075
|
+
raise ValueError(f"Unsafe path detected: {file_path}")
|
|
1076
|
+
|
|
1077
|
+
# Resolve to absolute path within project
|
|
1078
|
+
project_dir = os.environ.get('CLAUDE_PROJECT_DIR', '.')
|
|
1079
|
+
safe_path = Path(project_dir) / file_path
|
|
1080
|
+
|
|
1081
|
+
# Ensure path stays within project directory
|
|
1082
|
+
try:
|
|
1083
|
+
safe_path.resolve().relative_to(Path(project_dir).resolve())
|
|
1084
|
+
return str(safe_path)
|
|
1085
|
+
except ValueError:
|
|
1086
|
+
raise ValueError(f"Path outside project directory: {file_path}")
|
|
1087
|
+
|
|
1088
|
+
try:
|
|
1089
|
+
input_data = json.load(sys.stdin)
|
|
1090
|
+
file_path = input_data.get('tool_input', {}).get('file_path')
|
|
1091
|
+
|
|
1092
|
+
if file_path:
|
|
1093
|
+
safe_path = sanitize_path(file_path)
|
|
1094
|
+
print(f"✅ Safe path validated: {safe_path}")
|
|
1095
|
+
|
|
1096
|
+
except Exception as e:
|
|
1097
|
+
print(f"Security validation failed: {e}", file=sys.stderr)
|
|
1098
|
+
sys.exit(2) # Block unsafe operations
|
|
1099
|
+
```
|
|
1100
|
+
|
|
1101
|
+
### Hook Execution Safety
|
|
1102
|
+
|
|
1103
|
+
- **Timeout Limits**: Always set reasonable timeouts to prevent hanging
|
|
1104
|
+
- **Resource Limits**: Be mindful of CPU and memory usage
|
|
1105
|
+
- **Concurrent Execution**: Hooks run in parallel - design for thread safety
|
|
1106
|
+
- **Environment Isolation**: Use containers or sandboxing for untrusted hooks
|
|
1107
|
+
|
|
1108
|
+
## Troubleshooting and Debugging
|
|
1109
|
+
|
|
1110
|
+
### Common Issues
|
|
1111
|
+
|
|
1112
|
+
1. **Hook Not Executing**
|
|
1113
|
+
- Check hook registration with `/hooks` command
|
|
1114
|
+
- Verify JSON syntax in settings files
|
|
1115
|
+
- Ensure script is executable (`chmod +x script.sh`)
|
|
1116
|
+
- Check matcher patterns are correct (case-sensitive)
|
|
1117
|
+
|
|
1118
|
+
2. **Permission Errors**
|
|
1119
|
+
- Verify script file permissions
|
|
1120
|
+
- Check `$CLAUDE_PROJECT_DIR` environment variable
|
|
1121
|
+
- Ensure scripts use absolute paths
|
|
1122
|
+
|
|
1123
|
+
3. **Timeout Issues**
|
|
1124
|
+
- Increase timeout values for long-running operations
|
|
1125
|
+
- Optimize hook performance
|
|
1126
|
+
- Run expensive operations asynchronously
|
|
1127
|
+
|
|
1128
|
+
### Debug Mode
|
|
1129
|
+
|
|
1130
|
+
Use `claude --debug` to see detailed hook execution:
|
|
1131
|
+
|
|
1132
|
+
```bash
|
|
1133
|
+
claude --debug
|
|
1134
|
+
```
|
|
1135
|
+
|
|
1136
|
+
Debug output includes:
|
|
1137
|
+
- Hook discovery and matching
|
|
1138
|
+
- Command execution details
|
|
1139
|
+
- Execution time and exit codes
|
|
1140
|
+
- stdout/stderr from hooks
|
|
1141
|
+
|
|
1142
|
+
### Testing Hooks
|
|
1143
|
+
|
|
1144
|
+
Test hooks independently:
|
|
1145
|
+
|
|
1146
|
+
```bash
|
|
1147
|
+
# Test hook script directly
|
|
1148
|
+
echo '{"session_id":"test","hook_event_name":"PreToolUse","tool_name":"Write","tool_input":{"file_path":"test.txt"}}' | ./.claude/hooks/your-hook.py
|
|
1149
|
+
|
|
1150
|
+
# Test JSON output
|
|
1151
|
+
echo '{"session_id":"test"}' | python3 -c "
|
|
1152
|
+
import json, sys
|
|
1153
|
+
data = json.load(sys.stdin)
|
|
1154
|
+
print(json.dumps({'continue': True, 'systemMessage': 'Test successful'}))
|
|
1155
|
+
"
|
|
1156
|
+
```
|
|
1157
|
+
|
|
1158
|
+
### Hook Development Workflow
|
|
1159
|
+
|
|
1160
|
+
1. **Start Simple**: Begin with basic exit code hooks
|
|
1161
|
+
2. **Add Logging**: Include debug output for troubleshooting
|
|
1162
|
+
3. **Test Thoroughly**: Test all code paths and edge cases
|
|
1163
|
+
4. **Add Error Handling**: Graceful degradation on failures
|
|
1164
|
+
5. **Optimize Performance**: Minimize execution time
|
|
1165
|
+
6. **Document Behavior**: Clear comments and documentation
|
|
1166
|
+
|
|
1167
|
+
## Hook Ecosystem
|
|
1168
|
+
|
|
1169
|
+
### Community Hooks
|
|
1170
|
+
|
|
1171
|
+
Share and discover hooks with the community:
|
|
1172
|
+
- [Claude Code Hooks Repository](https://github.com/anthropic/claude-code-hooks) (example)
|
|
1173
|
+
- Project-specific hook collections
|
|
1174
|
+
- Team-shared hook libraries
|
|
1175
|
+
|
|
1176
|
+
### Hook Templates
|
|
1177
|
+
|
|
1178
|
+
Use these templates as starting points:
|
|
1179
|
+
|
|
1180
|
+
**Basic Hook Template**:
|
|
1181
|
+
```python
|
|
1182
|
+
#!/usr/bin/env python3
|
|
1183
|
+
import json
|
|
1184
|
+
import sys
|
|
1185
|
+
import os
|
|
1186
|
+
|
|
1187
|
+
def main():
|
|
1188
|
+
try:
|
|
1189
|
+
# Read input
|
|
1190
|
+
input_data = json.load(sys.stdin)
|
|
1191
|
+
|
|
1192
|
+
# Your hook logic here
|
|
1193
|
+
|
|
1194
|
+
# Success
|
|
1195
|
+
print("Hook executed successfully")
|
|
1196
|
+
sys.exit(0)
|
|
1197
|
+
|
|
1198
|
+
except Exception as e:
|
|
1199
|
+
print(f"Hook error: {e}", file=sys.stderr)
|
|
1200
|
+
sys.exit(1)
|
|
1201
|
+
|
|
1202
|
+
if __name__ == "__main__":
|
|
1203
|
+
main()
|
|
1204
|
+
```
|
|
1205
|
+
|
|
1206
|
+
**JSON Output Template**:
|
|
1207
|
+
```python
|
|
1208
|
+
#!/usr/bin/env python3
|
|
1209
|
+
import json
|
|
1210
|
+
import sys
|
|
1211
|
+
|
|
1212
|
+
def main():
|
|
1213
|
+
try:
|
|
1214
|
+
input_data = json.load(sys.stdin)
|
|
1215
|
+
|
|
1216
|
+
# Your logic here
|
|
1217
|
+
|
|
1218
|
+
output = {
|
|
1219
|
+
"continue": True,
|
|
1220
|
+
"hookSpecificOutput": {
|
|
1221
|
+
"hookEventName": input_data.get('hook_event_name'),
|
|
1222
|
+
# Event-specific output
|
|
1223
|
+
}
|
|
1224
|
+
}
|
|
1225
|
+
|
|
1226
|
+
print(json.dumps(output))
|
|
1227
|
+
sys.exit(0)
|
|
1228
|
+
|
|
1229
|
+
except Exception as e:
|
|
1230
|
+
print(f"Hook error: {e}", file=sys.stderr)
|
|
1231
|
+
sys.exit(1)
|
|
1232
|
+
|
|
1233
|
+
if __name__ == "__main__":
|
|
1234
|
+
main()
|
|
1235
|
+
```
|
|
1236
|
+
|
|
1237
|
+
## Conclusion
|
|
1238
|
+
|
|
1239
|
+
Claude Code hooks provide powerful automation capabilities that can significantly enhance your development workflow. With hooks, you can:
|
|
1240
|
+
|
|
1241
|
+
- **Automate repetitive tasks** like code formatting and testing
|
|
1242
|
+
- **Enhance security** through validation and monitoring
|
|
1243
|
+
- **Customize Claude's behavior** to match your team's requirements
|
|
1244
|
+
- **Integrate with external tools** and services
|
|
1245
|
+
- **Monitor and analyze** your development patterns
|
|
1246
|
+
|
|
1247
|
+
Start with simple hooks and gradually build more sophisticated automation as you become comfortable with the system. Remember to prioritize security, test thoroughly, and document your hooks for team collaboration.
|
|
1248
|
+
|
|
1249
|
+
For more examples and community resources, see the [Claude Code documentation](/en/docs/claude-code) and join the community discussions.
|