mia-code 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.miette/260321.md +1 -0
- package/.miette/260323.md +9 -0
- package/.miette/260331.md +2 -0
- package/.pde/2604011511--83a2d7f9-24a5-4cf4-98d5-036c82f872e8/2604020008--d3417f2c-df12-4f0f-8a1b-d88e7968f822/d3417f2c-df12-4f0f-8a1b-d88e7968f822.md +63 -0
- package/.pde/2604011511--83a2d7f9-24a5-4cf4-98d5-036c82f872e8/2604020008--e6c3fc5d-4a70-4523-ba7d-a3250da4c235/e6c3fc5d-4a70-4523-ba7d-a3250da4c235.md +72 -0
- package/.pde/2604011511--83a2d7f9-24a5-4cf4-98d5-036c82f872e8/2604020008--efeb00a2-b17a-4d32-b1f0-b90c37a8d24e/efeb00a2-b17a-4d32-b1f0-b90c37a8d24e.md +62 -0
- package/.pde/2604011511--83a2d7f9-24a5-4cf4-98d5-036c82f872e8/83a2d7f9-24a5-4cf4-98d5-036c82f872e8.json +302 -0
- package/.pde/2604011511--83a2d7f9-24a5-4cf4-98d5-036c82f872e8/83a2d7f9-24a5-4cf4-98d5-036c82f872e8.md +149 -0
- package/.pde/2604011511--83a2d7f9-24a5-4cf4-98d5-036c82f872e8/AGENTS.md +31 -0
- package/.pde/2604011511--83a2d7f9-24a5-4cf4-98d5-036c82f872e8/meta-decomposition-3-children.md +67 -0
- package/.pde/2604040129--61f9dd4d-7aa6-45e6-a58b-e480b1aa6737/61f9dd4d-7aa6-45e6-a58b-e480b1aa6737--from-mia-openclaw-workspace.md +125 -0
- package/.pde/2604040129--61f9dd4d-7aa6-45e6-a58b-e480b1aa6737/STATUS.md +1 -0
- package/.pde/4f02ba94-9f52-422e-9389-b16f9b37f358.json +177 -0
- package/.pde/4f02ba94-9f52-422e-9389-b16f9b37f358.md +77 -0
- package/.pde/6ad9244d-5340-490f-b76c-c86728b9de52.json +222 -0
- package/.pde/6ad9244d-5340-490f-b76c-c86728b9de52.md +99 -0
- package/.pde/8b566792-ed15-4606-96f9-2b6f593d7e6b.json +111 -0
- package/.pde/8b566792-ed15-4606-96f9-2b6f593d7e6b.md +67 -0
- package/.pde/c7f1e74b-05a5-40e2-9f01-4cc48d2528f7.json +349 -0
- package/.pde/c7f1e74b-05a5-40e2-9f01-4cc48d2528f7.md +147 -0
- package/.pde/dfc00a78-1da0-4c09-8a16-c6982644051b.json +118 -0
- package/.pde/dfc00a78-1da0-4c09-8a16-c6982644051b.md +64 -0
- package/GUILLAUME.md +8 -0
- package/KINSHIP.md +9 -0
- package/MIA_CODE_ARCHITECTURE_REPORT.md +718 -0
- package/contextual_research/260119-MIA-CODE--98090899-8aff-4e11-9dc3-8b99466d1.md +1101 -0
- package/contextual_research/MIA.md +38 -0
- package/contextual_research/MIAWAPASCONE.md +59 -0
- package/contextual_research/MIETTE.md +38 -0
- package/contextual_research/PDE-generalization--caefee82-efb1-4dbb-8733-691b01581464--260130/2504.00218v2.pdf +7483 -12
- package/contextual_research/PDE-generalization--caefee82-efb1-4dbb-8733-691b01581464--260130/2505.00212v3.pdf +0 -0
- package/contextual_research/PDE-generalization--caefee82-efb1-4dbb-8733-691b01581464--260130/CONTENT.md +1014 -0
- package/contextual_research/PDE-generalization--caefee82-efb1-4dbb-8733-691b01581464--260130/DESIGN.gemini.md +242 -0
- package/contextual_research/PDE-generalization--caefee82-efb1-4dbb-8733-691b01581464--260130/INDEX.md +45 -0
- package/contextual_research/PDE-generalization--caefee82-efb1-4dbb-8733-691b01581464--260130/sources/2504.00218v2.md +2025 -0
- package/contextual_research/PDE-generalization--caefee82-efb1-4dbb-8733-691b01581464--260130/sources/2504.00218v2.pdf +7483 -12
- package/contextual_research/PDE-generalization--caefee82-efb1-4dbb-8733-691b01581464--260130/sources/2505.00212v3.md +1755 -0
- package/contextual_research/PDE-generalization--caefee82-efb1-4dbb-8733-691b01581464--260130/sources/2505.00212v3.pdf +0 -0
- package/contextual_research/PDE-generalization--caefee82-efb1-4dbb-8733-691b01581464--260130/sources/footnote_1_12_decomposed_prompting.pdf +0 -0
- package/contextual_research/PDE-generalization--caefee82-efb1-4dbb-8733-691b01581464--260130/sources/footnote_1_19_hugginggpt_planning.pdf +0 -0
- package/contextual_research/PDE-generalization--caefee82-efb1-4dbb-8733-691b01581464--260130/sources/footnote_1_1_coordination_challenges.md +766 -0
- package/contextual_research/PDE-generalization--caefee82-efb1-4dbb-8733-691b01581464--260130/sources/footnote_1_1_coordination_challenges.pdf +3431 -4
- package/contextual_research/PDE-generalization--caefee82-efb1-4dbb-8733-691b01581464--260130/sources/footnote_1_28_guardrails_multi_agent.md +260 -0
- package/contextual_research/PDE-generalization--caefee82-efb1-4dbb-8733-691b01581464--260130/sources/footnote_1_28_guardrails_multi_agent.pdf +0 -0
- package/contextual_research/PDE-generalization--caefee82-efb1-4dbb-8733-691b01581464--260130/sources/footnote_1_2_navigating_complexity.md +558 -0
- package/contextual_research/PDE-generalization--caefee82-efb1-4dbb-8733-691b01581464--260130/sources/footnote_1_2_navigating_complexity.pdf +0 -0
- package/contextual_research/PDE-generalization--caefee82-efb1-4dbb-8733-691b01581464--260130/sources/footnote_1_34_hierarchical_multi_agent.pdf +0 -0
- package/contextual_research/PDE-generalization--caefee82-efb1-4dbb-8733-691b01581464--260130/sources/footnote_1_5_open_intent_extraction.pdf +0 -0
- package/contextual_research/PODCAST.md +109 -0
- package/contextual_research/langchain-principles-roadmap.md +157 -0
- package/contextual_research/persona-to-narrative-character-inquiry_260201.md +50 -0
- package/dist/cli.js +35 -11
- package/dist/geminiHeadless.js +8 -2
- package/dist/index.js +2 -1
- package/dist/mcp/miaco-server.js +10 -1
- package/dist/mcp/miatel-server.js +10 -1
- package/dist/mcp/miawa-server.js +10 -1
- package/dist/mcp/utils.d.ts +6 -1
- package/dist/mcp/utils.js +24 -3
- package/dist/sessionStore.d.ts +8 -2
- package/dist/sessionStore.js +39 -3
- package/dist/types.d.ts +1 -0
- package/miaco/README.md +124 -0
- package/miaco/dist/commands/chart.d.ts +6 -0
- package/miaco/dist/commands/chart.d.ts.map +1 -0
- package/miaco/dist/commands/chart.js +222 -0
- package/miaco/dist/commands/chart.js.map +1 -0
- package/miaco/dist/commands/decompose.d.ts +6 -0
- package/miaco/dist/commands/decompose.d.ts.map +1 -0
- package/miaco/dist/commands/decompose.js +98 -0
- package/miaco/dist/commands/decompose.js.map +1 -0
- package/miaco/dist/commands/schema.d.ts +6 -0
- package/miaco/dist/commands/schema.d.ts.map +1 -0
- package/miaco/dist/commands/schema.js +66 -0
- package/miaco/dist/commands/schema.js.map +1 -0
- package/miaco/dist/commands/stc.d.ts +11 -0
- package/miaco/dist/commands/stc.d.ts.map +1 -0
- package/miaco/dist/commands/stc.js +590 -0
- package/miaco/dist/commands/stc.js.map +1 -0
- package/miaco/dist/commands/trace.d.ts +6 -0
- package/miaco/dist/commands/trace.d.ts.map +1 -0
- package/miaco/dist/commands/trace.js +83 -0
- package/miaco/dist/commands/trace.js.map +1 -0
- package/miaco/dist/commands/validate.d.ts +6 -0
- package/miaco/dist/commands/validate.d.ts.map +1 -0
- package/miaco/dist/commands/validate.js +58 -0
- package/miaco/dist/commands/validate.js.map +1 -0
- package/miaco/dist/decompose.d.ts +93 -0
- package/miaco/dist/decompose.d.ts.map +1 -0
- package/miaco/dist/decompose.js +562 -0
- package/miaco/dist/decompose.js.map +1 -0
- package/miaco/dist/index.d.ts +18 -0
- package/miaco/dist/index.d.ts.map +1 -0
- package/miaco/dist/index.js +83 -0
- package/miaco/dist/index.js.map +1 -0
- package/miaco/dist/storage.d.ts +60 -0
- package/miaco/dist/storage.d.ts.map +1 -0
- package/miaco/dist/storage.js +100 -0
- package/miaco/dist/storage.js.map +1 -0
- package/miaco/package-lock.json +4103 -0
- package/miaco/package.json +40 -0
- package/miaco/tsconfig.json +18 -0
- package/miaco/version-patch-commit-and-publish.sh +1 -0
- package/miatel/MISSION_251231.md +3 -0
- package/miatel/README.md +107 -0
- package/miatel/dist/commands/analyze.d.ts +6 -0
- package/miatel/dist/commands/analyze.d.ts.map +1 -0
- package/miatel/dist/commands/analyze.js +100 -0
- package/miatel/dist/commands/analyze.js.map +1 -0
- package/miatel/dist/commands/arc.d.ts +6 -0
- package/miatel/dist/commands/arc.d.ts.map +1 -0
- package/miatel/dist/commands/arc.js +71 -0
- package/miatel/dist/commands/arc.js.map +1 -0
- package/miatel/dist/commands/beat.d.ts +6 -0
- package/miatel/dist/commands/beat.d.ts.map +1 -0
- package/miatel/dist/commands/beat.js +165 -0
- package/miatel/dist/commands/beat.js.map +1 -0
- package/miatel/dist/commands/theme.d.ts +6 -0
- package/miatel/dist/commands/theme.d.ts.map +1 -0
- package/miatel/dist/commands/theme.js +54 -0
- package/miatel/dist/commands/theme.js.map +1 -0
- package/miatel/dist/index.d.ts +18 -0
- package/miatel/dist/index.d.ts.map +1 -0
- package/miatel/dist/index.js +80 -0
- package/miatel/dist/index.js.map +1 -0
- package/miatel/dist/storage.d.ts +55 -0
- package/miatel/dist/storage.d.ts.map +1 -0
- package/miatel/dist/storage.js +100 -0
- package/miatel/dist/storage.js.map +1 -0
- package/miatel/package-lock.json +4103 -0
- package/miatel/package.json +35 -0
- package/miatel/src/commands/analyze.ts +109 -0
- package/miatel/src/commands/arc.ts +78 -0
- package/miatel/src/commands/beat.ts +176 -0
- package/miatel/src/commands/theme.ts +60 -0
- package/miatel/src/index.ts +94 -0
- package/miatel/src/storage.ts +156 -0
- package/miatel/tsconfig.json +18 -0
- package/miawa/MISSION_251231.md +144 -0
- package/miawa/README.md +133 -0
- package/miawa/dist/commands/beat.d.ts +6 -0
- package/miawa/dist/commands/beat.d.ts.map +1 -0
- package/miawa/dist/commands/beat.js +69 -0
- package/miawa/dist/commands/beat.js.map +1 -0
- package/miawa/dist/commands/ceremony.d.ts +6 -0
- package/miawa/dist/commands/ceremony.d.ts.map +1 -0
- package/miawa/dist/commands/ceremony.js +239 -0
- package/miawa/dist/commands/ceremony.js.map +1 -0
- package/miawa/dist/commands/circle.d.ts +6 -0
- package/miawa/dist/commands/circle.d.ts.map +1 -0
- package/miawa/dist/commands/circle.js +75 -0
- package/miawa/dist/commands/circle.js.map +1 -0
- package/miawa/dist/commands/eva.d.ts +6 -0
- package/miawa/dist/commands/eva.d.ts.map +1 -0
- package/miawa/dist/commands/eva.js +73 -0
- package/miawa/dist/commands/eva.js.map +1 -0
- package/miawa/dist/commands/wound.d.ts +6 -0
- package/miawa/dist/commands/wound.d.ts.map +1 -0
- package/miawa/dist/commands/wound.js +74 -0
- package/miawa/dist/commands/wound.js.map +1 -0
- package/miawa/dist/index.d.ts +19 -0
- package/miawa/dist/index.d.ts.map +1 -0
- package/miawa/dist/index.js +91 -0
- package/miawa/dist/index.js.map +1 -0
- package/miawa/dist/storage.d.ts +73 -0
- package/miawa/dist/storage.d.ts.map +1 -0
- package/miawa/dist/storage.js +100 -0
- package/miawa/dist/storage.js.map +1 -0
- package/miawa/package-lock.json +4103 -0
- package/miawa/package.json +36 -0
- package/miawa/src/commands/beat.ts +74 -0
- package/miawa/src/commands/ceremony.ts +256 -0
- package/miawa/src/commands/circle.ts +83 -0
- package/miawa/src/commands/eva.ts +84 -0
- package/miawa/src/commands/wound.ts +79 -0
- package/miawa/src/index.ts +108 -0
- package/miawa/src/storage.ts +179 -0
- package/miawa/tsconfig.json +18 -0
- package/package.json +7 -5
- package/references/acp/CLAUDE.md +7 -0
- package/references/acp/agent-plan.md +84 -0
- package/references/acp/clients.md +31 -0
- package/references/acp/extensibility.md +137 -0
- package/references/acp/initialization.md +225 -0
- package/references/acp/prompt-turn.md +321 -0
- package/references/acp/proxy-chains.md +562 -0
- package/references/acp/schema.md +3171 -0
- package/references/acp/session-list.md +334 -0
- package/references/acp/session-modes.md +170 -0
- package/references/acp/slash-commands.md +99 -0
- package/references/acp/terminals.md +281 -0
- package/references/acp/tool-calls.md +311 -0
- package/references/acp/typescript.md +29 -0
- package/references/claude/agent-teams.md +399 -0
- package/references/claude/chrome.md +231 -0
- package/references/claude/headless.md +158 -0
- package/references/claude/hooks-guide.md +708 -0
- package/references/claude/output-styles.md +112 -0
- package/references/claude/plugins.md +432 -0
- package/references/claude/skills.md +693 -0
- package/references/claude/sub-agents.md +816 -0
- package/references/copilot/acp/agents.md +32 -0
- package/references/copilot/acp/architecture.md +37 -0
- package/references/copilot/acp/clients.md +31 -0
- package/references/copilot/acp/introduction.md +42 -0
- package/references/copilot/acp/registry.md +339 -0
- package/references/copilot/acp-server.md +117 -0
- package/references/copilot/create-copilot-instructions.md +840 -0
- package/references/langchain/llms.txt +833 -0
- package/references/langchain/python/agents.md +677 -0
- package/references/langchain/python/context-engineering.md +1195 -0
- package/references/langchain/python/human-in-the-loop.md +326 -0
- package/references/langchain/python/long-term-memory.md +168 -0
- package/references/langchain/python/mcp.md +949 -0
- package/references/langchain/python/multi-agents/custom-workflow.md +187 -0
- package/references/langchain/python/multi-agents/handoffs.md +436 -0
- package/references/langchain/python/multi-agents/overview.md +295 -0
- package/references/langchain/python/multi-agents/router.md +150 -0
- package/references/langchain/python/multi-agents/skills.md +92 -0
- package/references/langchain/python/multi-agents/subagents.md +486 -0
- package/references/langchain/python/retrieval.md +320 -0
- package/references/langchain/python/runtime.md +141 -0
- package/references/langchain/python/short-term-memory.md +658 -0
- package/references/langchain/python/structured-output.md +712 -0
- package/references/langfuse/llms.txt +148 -0
- package/references/langgraph/javascript/llms.txt +275 -0
- package/references/skills/home.md +259 -0
- package/references/skills/integrate-skills.md +103 -0
- package/references/skills/specification.md +254 -0
- package/references/skills/what-are-skills.md +74 -0
- package/rispecs/README.md +164 -0
- package/rispecs/_sync_/miadi-code/SPEC.md +313 -0
- package/rispecs/_sync_/miadi-code/STATUS.md +177 -0
- package/rispecs/_sync_/miadi-code/dashboard/SPEC.md +465 -0
- package/rispecs/_sync_/miadi-code/dashboard/STATUS.md +212 -0
- package/rispecs/_sync_/miadi-code/multiline-input/SPEC.md +232 -0
- package/rispecs/_sync_/miadi-code/multiline-input/STATUS.md +108 -0
- package/rispecs/_sync_/miadi-code/pde/SPEC.md +253 -0
- package/rispecs/_sync_/miadi-code/pde/STATUS.md +56 -0
- package/rispecs/_sync_/miadi-code/stc/SPEC.md +397 -0
- package/rispecs/_sync_/miadi-code/stc/STATUS.md +70 -0
- package/rispecs/ava-langstack/inquiry-routing-upgrade.spec.md +119 -0
- package/rispecs/borrowed_from_opencode/001-client-server-architecture.rispec.md +98 -0
- package/rispecs/borrowed_from_opencode/002-event-bus-system.rispec.md +125 -0
- package/rispecs/borrowed_from_opencode/003-instance-state-pattern.rispec.md +136 -0
- package/rispecs/borrowed_from_opencode/004-namespace-module-pattern.rispec.md +151 -0
- package/rispecs/borrowed_from_opencode/005-zod-schema-validation.rispec.md +139 -0
- package/rispecs/borrowed_from_opencode/006-named-error-system.rispec.md +155 -0
- package/rispecs/borrowed_from_opencode/007-structured-logging.rispec.md +138 -0
- package/rispecs/borrowed_from_opencode/008-lazy-initialization.rispec.md +127 -0
- package/rispecs/borrowed_from_opencode/009-multi-agent-system.rispec.md +97 -0
- package/rispecs/borrowed_from_opencode/010-agent-definition-config.rispec.md +135 -0
- package/rispecs/borrowed_from_opencode/011-agent-permission-rulesets.rispec.md +151 -0
- package/rispecs/borrowed_from_opencode/012-agent-prompt-templates.rispec.md +141 -0
- package/rispecs/borrowed_from_opencode/013-agent-generation.rispec.md +142 -0
- package/rispecs/borrowed_from_opencode/014-plan-build-mode-toggle.rispec.md +155 -0
- package/rispecs/borrowed_from_opencode/015-subagent-task-delegation.rispec.md +146 -0
- package/rispecs/borrowed_from_opencode/016-agent-model-selection.rispec.md +151 -0
- package/rispecs/borrowed_from_opencode/017-compaction-agent.rispec.md +150 -0
- package/rispecs/borrowed_from_opencode/018-session-persistence.rispec.md +125 -0
- package/rispecs/borrowed_from_opencode/019-session-compaction.rispec.md +132 -0
- package/rispecs/borrowed_from_opencode/020-session-forking.rispec.md +134 -0
- package/rispecs/borrowed_from_opencode/021-session-revert-snapshot.rispec.md +135 -0
- package/rispecs/borrowed_from_opencode/022-session-sharing.rispec.md +165 -0
- package/rispecs/borrowed_from_opencode/023-session-summary-diffs.rispec.md +165 -0
- package/rispecs/borrowed_from_opencode/024-child-sessions.rispec.md +164 -0
- package/rispecs/borrowed_from_opencode/025-session-title-generation.rispec.md +162 -0
- package/rispecs/borrowed_from_opencode/026-message-parts-model.rispec.md +201 -0
- package/rispecs/borrowed_from_opencode/027-streaming-message-deltas.rispec.md +212 -0
- package/rispecs/borrowed_from_opencode/028-multi-provider-architecture.rispec.md +184 -0
- package/rispecs/borrowed_from_opencode/029-provider-authentication.rispec.md +225 -0
- package/rispecs/borrowed_from_opencode/030-model-registry.rispec.md +222 -0
- package/rispecs/borrowed_from_opencode/031-cost-tracking.rispec.md +243 -0
- package/rispecs/borrowed_from_opencode/032-provider-transform-pipeline.rispec.md +282 -0
- package/rispecs/borrowed_from_opencode/033-provider-sdk-abstraction.rispec.md +338 -0
- package/rispecs/borrowed_from_opencode/034-tool-registry.rispec.md +110 -0
- package/rispecs/borrowed_from_opencode/035-tool-context-injection.rispec.md +155 -0
- package/rispecs/borrowed_from_opencode/036-tool-output-truncation.rispec.md +138 -0
- package/rispecs/borrowed_from_opencode/037-batch-tool.rispec.md +129 -0
- package/rispecs/borrowed_from_opencode/038-multi-edit-tool.rispec.md +167 -0
- package/rispecs/borrowed_from_opencode/039-apply-patch-tool.rispec.md +161 -0
- package/rispecs/borrowed_from_opencode/040-code-search-tool.rispec.md +143 -0
- package/rispecs/borrowed_from_opencode/041-web-fetch-tool.rispec.md +131 -0
- package/rispecs/borrowed_from_opencode/042-web-search-tool.rispec.md +159 -0
- package/rispecs/borrowed_from_opencode/043-todo-tool.rispec.md +156 -0
- package/rispecs/borrowed_from_opencode/044-plan-mode-tool.rispec.md +139 -0
- package/rispecs/borrowed_from_opencode/045-task-tool.rispec.md +146 -0
- package/rispecs/borrowed_from_opencode/046-question-tool.rispec.md +170 -0
- package/rispecs/borrowed_from_opencode/047-external-directory-tool.rispec.md +166 -0
- package/rispecs/borrowed_from_opencode/048-file-read-write-tools.rispec.md +205 -0
- package/rispecs/borrowed_from_opencode/049-lsp-server-management.rispec.md +104 -0
- package/rispecs/borrowed_from_opencode/050-lsp-hover-completion.rispec.md +102 -0
- package/rispecs/borrowed_from_opencode/051-lsp-diagnostics.rispec.md +86 -0
- package/rispecs/borrowed_from_opencode/052-lsp-root-detection.rispec.md +109 -0
- package/rispecs/borrowed_from_opencode/053-remote-mcp-servers.rispec.md +119 -0
- package/rispecs/borrowed_from_opencode/054-mcp-oauth-flow.rispec.md +107 -0
- package/rispecs/borrowed_from_opencode/055-mcp-tool-conversion.rispec.md +118 -0
- package/rispecs/borrowed_from_opencode/056-mcp-connection-monitoring.rispec.md +106 -0
- package/rispecs/borrowed_from_opencode/057-local-mcp-servers.rispec.md +116 -0
- package/rispecs/borrowed_from_opencode/058-rich-tui.rispec.md +108 -0
- package/rispecs/borrowed_from_opencode/059-streaming-display.rispec.md +116 -0
- package/rispecs/borrowed_from_opencode/060-permission-prompts.rispec.md +130 -0
- package/rispecs/borrowed_from_opencode/061-session-navigation.rispec.md +155 -0
- package/rispecs/borrowed_from_opencode/062-syntax-highlighting.rispec.md +151 -0
- package/rispecs/borrowed_from_opencode/063-keybinding-system.rispec.md +181 -0
- package/rispecs/borrowed_from_opencode/064-multi-level-config.rispec.md +155 -0
- package/rispecs/borrowed_from_opencode/065-jsonc-config.rispec.md +190 -0
- package/rispecs/borrowed_from_opencode/066-config-env-variables.rispec.md +153 -0
- package/rispecs/borrowed_from_opencode/067-config-deep-merging.rispec.md +178 -0
- package/rispecs/borrowed_from_opencode/068-remote-org-config.rispec.md +183 -0
- package/rispecs/borrowed_from_opencode/069-config-markdown-frontmatter.rispec.md +206 -0
- package/rispecs/borrowed_from_opencode/070-managed-config-directory.rispec.md +232 -0
- package/rispecs/borrowed_from_opencode/071-plugin-architecture.rispec.md +104 -0
- package/rispecs/borrowed_from_opencode/072-plugin-hooks.rispec.md +123 -0
- package/rispecs/borrowed_from_opencode/073-plugin-auto-install.rispec.md +115 -0
- package/rispecs/borrowed_from_opencode/074-permission-system.rispec.md +133 -0
- package/rispecs/borrowed_from_opencode/075-git-worktree-management.rispec.md +126 -0
- package/rispecs/borrowed_from_opencode/076-snapshot-system.rispec.md +124 -0
- package/rispecs/borrowed_from_opencode/077-snapshot-diff.rispec.md +117 -0
- package/rispecs/borrowed_from_opencode/078-snapshot-restore.rispec.md +128 -0
- package/rispecs/borrowed_from_opencode/079-worktree-branch-naming.rispec.md +122 -0
- package/rispecs/borrowed_from_opencode/080-sqlite-storage.rispec.md +134 -0
- package/rispecs/borrowed_from_opencode/081-database-migrations.rispec.md +148 -0
- package/rispecs/borrowed_from_opencode/082-database-transactions.rispec.md +138 -0
- package/rispecs/borrowed_from_opencode/083-deferred-effects.rispec.md +148 -0
- package/rispecs/borrowed_from_opencode/084-permission-rules.rispec.md +123 -0
- package/rispecs/borrowed_from_opencode/085-permission-glob-patterns.rispec.md +113 -0
- package/rispecs/borrowed_from_opencode/086-permission-merging.rispec.md +134 -0
- package/rispecs/borrowed_from_opencode/087-permission-modes.rispec.md +145 -0
- package/rispecs/borrowed_from_opencode/088-http-api-server.rispec.md +165 -0
- package/rispecs/borrowed_from_opencode/089-openapi-spec-generation.rispec.md +164 -0
- package/rispecs/borrowed_from_opencode/090-websocket-support.rispec.md +136 -0
- package/rispecs/borrowed_from_opencode/091-sse-streaming.rispec.md +168 -0
- package/rispecs/borrowed_from_opencode/092-mdns-discovery.rispec.md +145 -0
- package/rispecs/borrowed_from_opencode/093-javascript-sdk.rispec.md +200 -0
- package/rispecs/borrowed_from_opencode/094-skill-system.rispec.md +187 -0
- package/rispecs/borrowed_from_opencode/095-skill-discovery.rispec.md +182 -0
- package/rispecs/borrowed_from_opencode/096-desktop-remote-driving.rispec.md +175 -0
- package/rispecs/borrowed_from_opencode/INDEX.md +255 -0
- package/rispecs/core.rispecs.md +261 -0
- package/rispecs/engines.rispecs.md +241 -0
- package/rispecs/formatting.rispecs.md +252 -0
- package/rispecs/living-specifications.rispecs.md +361 -0
- package/rispecs/mcp.rispecs.md +197 -0
- package/rispecs/pde.rispecs.md +399 -0
- package/rispecs/pi-mono-envisionning/ENVISIONING.md +366 -0
- package/rispecs/pi-mono-envisionning/storytelling-horizon.rispecs.md +76 -0
- package/rispecs/pi-mono-envisionning/widget.rispecs.md +2 -0
- package/rispecs/relation-to-mcp-structural-thinking.kin.md +72 -0
- package/rispecs/research-for-better-framework/CLAUDE.md +7 -0
- package/rispecs/research-for-better-framework/survey-pi-openclaw-opencode-openhands.md +210 -0
- package/rispecs/session.rispecs.md +277 -0
- package/rispecs/stc.rispecs.md +138 -0
- package/rispecs/unifier.rispecs.md +317 -0
- package/scripts/LAUNCH--mcp-mia-code--testing--2603141315--ac705a66-2c15-4a1c-a26d-9491018c5ba8.sh +2 -0
- package/scripts/RESUME--mia-code--mcps--260313--ac705a66-2c15-4a1c-a26d-9491018c5ba8.sh +1 -0
- package/scripts/install-widget-in-home-pi-agent-extensions.sh +4 -0
- package/scripts/sample-decompose--2604011535-prompt.sh +1 -0
- package/skills/deep-search/AGENTS.md +17 -0
- package/skills/deep-search/SKILL.md +281 -0
- package/skills/deep-search/agent-templates.md +224 -0
- package/skills/deep-search/orchestration-patterns.md +95 -0
- package/skills/miaco-pde-inquiry-routing-deep-search/AGENTS.md +13 -0
- package/skills/miaco-pde-inquiry-routing-deep-search/SKILL.md +136 -0
- package/skills/miaco-pde-inquiry-routing-internal-external-relationship/AGENTS.md +4 -0
- package/skills/miaco-pde-inquiry-routing-internal-external-relationship/SKILL.md +157 -0
- package/skills/miaco-pde-inquiry-routing-local-qmd/AGENTS.md +42 -0
- package/skills/miaco-pde-inquiry-routing-local-qmd/SKILL.md +135 -0
- package/skills/qmd/AGENTS.md +3 -0
- package/skills/qmd/SKILL.md +144 -0
- package/skills/qmd/references/mcp-setup.md +102 -0
- package/skills/rise-pde-inquiry-session-multi-agents-v3/SKILL.md +234 -0
- package/skills/rise-pde-inquiry-session-multi-agents-v3/agent-templates.md +436 -0
- package/skills/rise-pde-inquiry-session-multi-agents-v3/orchestration-patterns.md +197 -0
- package/skills/rise-pde-inquiry-session-multi-agents-v3/references/ceremonial-technology.md +102 -0
- package/skills/rise-pde-inquiry-session-multi-agents-v3/references/creative-orientation.md +99 -0
- package/skills/rise-pde-inquiry-session-multi-agents-v3/references/prompt-decomposition.md +73 -0
- package/skills/rise-pde-inquiry-session-multi-agents-v3/references/rise-framework.md +74 -0
- package/skills/rise-pde-inquiry-session-multi-agents-v3/references/structural-tension.md +82 -0
- package/src/cli.ts +35 -11
- package/src/geminiHeadless.ts +7 -2
- package/src/index.ts +2 -1
- package/src/mcp/miaco-server.ts +13 -1
- package/src/mcp/miatel-server.ts +13 -1
- package/src/mcp/miawa-server.ts +13 -1
- package/src/mcp/utils.ts +41 -8
- package/src/sessionStore.ts +44 -4
- package/src/types.ts +2 -1
- package/widget/mia-ceremony/README.md +36 -0
- package/widget/mia-ceremony/index.ts +143 -0
- package/widget/mia-interceptor/README.md +39 -0
- package/widget/mia-interceptor/index.ts +221 -0
- package/widget/mia-tools/README.md +37 -0
- package/widget/mia-tools/index.ts +569 -0
- package/widget/miette-echo/README.md +44 -0
- package/widget/miette-echo/index.ts +164 -0
- package/.claude/settings.local.json +0 -9
- package/.hch/issue_.env +0 -4
- package/.hch/issue_add__2601211715.json +0 -77
- package/.hch/issue_add__2601211715.md +0 -4
- package/.hch/issue_add__2602242020.json +0 -78
- package/.hch/issue_add__2602242020.md +0 -7
- package/.hch/issues.json +0 -2312
- package/.hch/issues.md +0 -30
- package/WS__mia-code__260214__IAIP_PDE.code-workspace +0 -29
- package/WS__mia-code__src332__260122.code-workspace +0 -23
- package/samples/copilot/session-state/be76abaa-a27f-4725-b2a9-22fb45f7e0f7/checkpoints/index.md +0 -6
- package/samples/copilot/session-state/be76abaa-a27f-4725-b2a9-22fb45f7e0f7/events.jsonl +0 -213
- package/samples/copilot/session-state/be76abaa-a27f-4725-b2a9-22fb45f7e0f7/plan.md +0 -243
- package/samples/copilot/session-state/be76abaa-a27f-4725-b2a9-22fb45f7e0f7/workspace.yaml +0 -5
|
@@ -0,0 +1,708 @@
|
|
|
1
|
+
> ## Documentation Index
|
|
2
|
+
> Fetch the complete documentation index at: https://code.claude.com/docs/llms.txt
|
|
3
|
+
> Use this file to discover all available pages before exploring further.
|
|
4
|
+
|
|
5
|
+
# Automate workflows with hooks
|
|
6
|
+
|
|
7
|
+
> Run shell commands automatically when Claude Code edits files, finishes tasks, or needs input. Format code, send notifications, validate commands, and enforce project rules.
|
|
8
|
+
|
|
9
|
+
Hooks are user-defined shell commands that execute at specific points in Claude Code's lifecycle. They provide deterministic control over Claude Code's behavior, ensuring certain actions always happen rather than relying on the LLM to choose to run them. Use hooks to enforce project rules, automate repetitive tasks, and integrate Claude Code with your existing tools.
|
|
10
|
+
|
|
11
|
+
For decisions that require judgment rather than deterministic rules, you can also use [prompt-based hooks](#prompt-based-hooks) or [agent-based hooks](#agent-based-hooks) that use a Claude model to evaluate conditions.
|
|
12
|
+
|
|
13
|
+
For other ways to extend Claude Code, see [skills](/en/skills) for giving Claude additional instructions and executable commands, [subagents](/en/sub-agents) for running tasks in isolated contexts, and [plugins](/en/plugins) for packaging extensions to share across projects.
|
|
14
|
+
|
|
15
|
+
<Tip>
|
|
16
|
+
This guide covers common use cases and how to get started. For full event schemas, JSON input/output formats, and advanced features like async hooks and MCP tool hooks, see the [Hooks reference](/en/hooks).
|
|
17
|
+
</Tip>
|
|
18
|
+
|
|
19
|
+
## Set up your first hook
|
|
20
|
+
|
|
21
|
+
The fastest way to create a hook is through the `/hooks` interactive menu in Claude Code. This walkthrough creates a desktop notification hook, so you get alerted whenever Claude is waiting for your input instead of watching the terminal.
|
|
22
|
+
|
|
23
|
+
<Steps>
|
|
24
|
+
<Step title="Open the hooks menu">
|
|
25
|
+
Type `/hooks` in the Claude Code CLI. You'll see a list of all available hook events, plus an option to disable all hooks. Each event corresponds to a point in Claude's lifecycle where you can run custom code. Select `Notification` to create a hook that fires when Claude needs your attention.
|
|
26
|
+
</Step>
|
|
27
|
+
|
|
28
|
+
<Step title="Configure the matcher">
|
|
29
|
+
The menu shows a list of matchers, which filter when the hook fires. Set the matcher to `*` to fire on all notification types. You can narrow it later by changing the matcher to a specific value like `permission_prompt` or `idle_prompt`.
|
|
30
|
+
</Step>
|
|
31
|
+
|
|
32
|
+
<Step title="Add your command">
|
|
33
|
+
Select `+ Add new hook…`. The menu prompts you for a shell command to run when the event fires. Hooks run any shell command you provide, so you can use your platform's built-in notification tool. Copy the command for your OS:
|
|
34
|
+
|
|
35
|
+
<Tabs>
|
|
36
|
+
<Tab title="macOS">
|
|
37
|
+
Uses [`osascript`](https://ss64.com/mac/osascript.html) to trigger a native macOS notification through AppleScript:
|
|
38
|
+
|
|
39
|
+
```bash theme={null}
|
|
40
|
+
osascript -e 'display notification "Claude Code needs your attention" with title "Claude Code"'
|
|
41
|
+
```
|
|
42
|
+
</Tab>
|
|
43
|
+
|
|
44
|
+
<Tab title="Linux">
|
|
45
|
+
Uses `notify-send`, which is pre-installed on most Linux desktops with a notification daemon:
|
|
46
|
+
|
|
47
|
+
```bash theme={null}
|
|
48
|
+
notify-send 'Claude Code' 'Claude Code needs your attention'
|
|
49
|
+
```
|
|
50
|
+
</Tab>
|
|
51
|
+
|
|
52
|
+
<Tab title="Windows (PowerShell)">
|
|
53
|
+
Uses PowerShell to show a native message box through .NET's Windows Forms:
|
|
54
|
+
|
|
55
|
+
```powershell theme={null}
|
|
56
|
+
powershell.exe -Command "[System.Reflection.Assembly]::LoadWithPartialName('System.Windows.Forms'); [System.Windows.Forms.MessageBox]::Show('Claude Code needs your attention', 'Claude Code')"
|
|
57
|
+
```
|
|
58
|
+
</Tab>
|
|
59
|
+
</Tabs>
|
|
60
|
+
</Step>
|
|
61
|
+
|
|
62
|
+
<Step title="Choose a storage location">
|
|
63
|
+
The menu asks where to save the hook configuration. Select `User settings` to store it in `~/.claude/settings.json`, which applies the hook to all your projects. You could also choose `Project settings` to scope it to the current project. See [Configure hook location](#configure-hook-location) for all available scopes.
|
|
64
|
+
</Step>
|
|
65
|
+
|
|
66
|
+
<Step title="Test the hook">
|
|
67
|
+
Press `Esc` to return to the CLI. Ask Claude to do something that requires permission, then switch away from the terminal. You should receive a desktop notification.
|
|
68
|
+
</Step>
|
|
69
|
+
</Steps>
|
|
70
|
+
|
|
71
|
+
## What you can automate
|
|
72
|
+
|
|
73
|
+
Hooks let you run code at key points in Claude Code's lifecycle: format files after edits, block commands before they execute, send notifications when Claude needs input, inject context at session start, and more. For the full list of hook events, see the [Hooks reference](/en/hooks#hook-lifecycle).
|
|
74
|
+
|
|
75
|
+
Each example includes a ready-to-use configuration block that you add to a [settings file](#configure-hook-location). The most common patterns:
|
|
76
|
+
|
|
77
|
+
* [Get notified when Claude needs input](#get-notified-when-claude-needs-input)
|
|
78
|
+
* [Auto-format code after edits](#auto-format-code-after-edits)
|
|
79
|
+
* [Block edits to protected files](#block-edits-to-protected-files)
|
|
80
|
+
* [Re-inject context after compaction](#re-inject-context-after-compaction)
|
|
81
|
+
* [Audit configuration changes](#audit-configuration-changes)
|
|
82
|
+
|
|
83
|
+
### Get notified when Claude needs input
|
|
84
|
+
|
|
85
|
+
Get a desktop notification whenever Claude finishes working and needs your input, so you can switch to other tasks without checking the terminal.
|
|
86
|
+
|
|
87
|
+
This hook uses the `Notification` event, which fires when Claude is waiting for input or permission. Each tab below uses the platform's native notification command. Add this to `~/.claude/settings.json`, or use the [interactive walkthrough](#set-up-your-first-hook) above to configure it with `/hooks`:
|
|
88
|
+
|
|
89
|
+
<Tabs>
|
|
90
|
+
<Tab title="macOS">
|
|
91
|
+
```json theme={null}
|
|
92
|
+
{
|
|
93
|
+
"hooks": {
|
|
94
|
+
"Notification": [
|
|
95
|
+
{
|
|
96
|
+
"matcher": "",
|
|
97
|
+
"hooks": [
|
|
98
|
+
{
|
|
99
|
+
"type": "command",
|
|
100
|
+
"command": "osascript -e 'display notification \"Claude Code needs your attention\" with title \"Claude Code\"'"
|
|
101
|
+
}
|
|
102
|
+
]
|
|
103
|
+
}
|
|
104
|
+
]
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
```
|
|
108
|
+
</Tab>
|
|
109
|
+
|
|
110
|
+
<Tab title="Linux">
|
|
111
|
+
```json theme={null}
|
|
112
|
+
{
|
|
113
|
+
"hooks": {
|
|
114
|
+
"Notification": [
|
|
115
|
+
{
|
|
116
|
+
"matcher": "",
|
|
117
|
+
"hooks": [
|
|
118
|
+
{
|
|
119
|
+
"type": "command",
|
|
120
|
+
"command": "notify-send 'Claude Code' 'Claude Code needs your attention'"
|
|
121
|
+
}
|
|
122
|
+
]
|
|
123
|
+
}
|
|
124
|
+
]
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
```
|
|
128
|
+
</Tab>
|
|
129
|
+
|
|
130
|
+
<Tab title="Windows (PowerShell)">
|
|
131
|
+
```json theme={null}
|
|
132
|
+
{
|
|
133
|
+
"hooks": {
|
|
134
|
+
"Notification": [
|
|
135
|
+
{
|
|
136
|
+
"matcher": "",
|
|
137
|
+
"hooks": [
|
|
138
|
+
{
|
|
139
|
+
"type": "command",
|
|
140
|
+
"command": "powershell.exe -Command \"[System.Reflection.Assembly]::LoadWithPartialName('System.Windows.Forms'); [System.Windows.Forms.MessageBox]::Show('Claude Code needs your attention', 'Claude Code')\""
|
|
141
|
+
}
|
|
142
|
+
]
|
|
143
|
+
}
|
|
144
|
+
]
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
```
|
|
148
|
+
</Tab>
|
|
149
|
+
</Tabs>
|
|
150
|
+
|
|
151
|
+
### Auto-format code after edits
|
|
152
|
+
|
|
153
|
+
Automatically run [Prettier](https://prettier.io/) on every file Claude edits, so formatting stays consistent without manual intervention.
|
|
154
|
+
|
|
155
|
+
This hook uses the `PostToolUse` event with an `Edit|Write` matcher, so it runs only after file-editing tools. The command extracts the edited file path with [`jq`](https://jqlang.github.io/jq/) and passes it to Prettier. Add this to `.claude/settings.json` in your project root:
|
|
156
|
+
|
|
157
|
+
```json theme={null}
|
|
158
|
+
{
|
|
159
|
+
"hooks": {
|
|
160
|
+
"PostToolUse": [
|
|
161
|
+
{
|
|
162
|
+
"matcher": "Edit|Write",
|
|
163
|
+
"hooks": [
|
|
164
|
+
{
|
|
165
|
+
"type": "command",
|
|
166
|
+
"command": "jq -r '.tool_input.file_path' | xargs npx prettier --write"
|
|
167
|
+
}
|
|
168
|
+
]
|
|
169
|
+
}
|
|
170
|
+
]
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
<Note>
|
|
176
|
+
The Bash examples on this page use `jq` for JSON parsing. Install it with `brew install jq` (macOS), `apt-get install jq` (Debian/Ubuntu), or see [`jq` downloads](https://jqlang.github.io/jq/download/).
|
|
177
|
+
</Note>
|
|
178
|
+
|
|
179
|
+
### Block edits to protected files
|
|
180
|
+
|
|
181
|
+
Prevent Claude from modifying sensitive files like `.env`, `package-lock.json`, or anything in `.git/`. Claude receives feedback explaining why the edit was blocked, so it can adjust its approach.
|
|
182
|
+
|
|
183
|
+
This example uses a separate script file that the hook calls. The script checks the target file path against a list of protected patterns and exits with code 2 to block the edit.
|
|
184
|
+
|
|
185
|
+
<Steps>
|
|
186
|
+
<Step title="Create the hook script">
|
|
187
|
+
Save this to `.claude/hooks/protect-files.sh`:
|
|
188
|
+
|
|
189
|
+
```bash theme={null}
|
|
190
|
+
#!/bin/bash
|
|
191
|
+
# protect-files.sh
|
|
192
|
+
|
|
193
|
+
INPUT=$(cat)
|
|
194
|
+
FILE_PATH=$(echo "$INPUT" | jq -r '.tool_input.file_path // empty')
|
|
195
|
+
|
|
196
|
+
PROTECTED_PATTERNS=(".env" "package-lock.json" ".git/")
|
|
197
|
+
|
|
198
|
+
for pattern in "${PROTECTED_PATTERNS[@]}"; do
|
|
199
|
+
if [[ "$FILE_PATH" == *"$pattern"* ]]; then
|
|
200
|
+
echo "Blocked: $FILE_PATH matches protected pattern '$pattern'" >&2
|
|
201
|
+
exit 2
|
|
202
|
+
fi
|
|
203
|
+
done
|
|
204
|
+
|
|
205
|
+
exit 0
|
|
206
|
+
```
|
|
207
|
+
</Step>
|
|
208
|
+
|
|
209
|
+
<Step title="Make the script executable (macOS/Linux)">
|
|
210
|
+
Hook scripts must be executable for Claude Code to run them:
|
|
211
|
+
|
|
212
|
+
```bash theme={null}
|
|
213
|
+
chmod +x .claude/hooks/protect-files.sh
|
|
214
|
+
```
|
|
215
|
+
</Step>
|
|
216
|
+
|
|
217
|
+
<Step title="Register the hook">
|
|
218
|
+
Add a `PreToolUse` hook to `.claude/settings.json` that runs the script before any `Edit` or `Write` tool call:
|
|
219
|
+
|
|
220
|
+
```json theme={null}
|
|
221
|
+
{
|
|
222
|
+
"hooks": {
|
|
223
|
+
"PreToolUse": [
|
|
224
|
+
{
|
|
225
|
+
"matcher": "Edit|Write",
|
|
226
|
+
"hooks": [
|
|
227
|
+
{
|
|
228
|
+
"type": "command",
|
|
229
|
+
"command": "\"$CLAUDE_PROJECT_DIR\"/.claude/hooks/protect-files.sh"
|
|
230
|
+
}
|
|
231
|
+
]
|
|
232
|
+
}
|
|
233
|
+
]
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
```
|
|
237
|
+
</Step>
|
|
238
|
+
</Steps>
|
|
239
|
+
|
|
240
|
+
### Re-inject context after compaction
|
|
241
|
+
|
|
242
|
+
When Claude's context window fills up, compaction summarizes the conversation to free space. This can lose important details. Use a `SessionStart` hook with a `compact` matcher to re-inject critical context after every compaction.
|
|
243
|
+
|
|
244
|
+
Any text your command writes to stdout is added to Claude's context. This example reminds Claude of project conventions and recent work. Add this to `.claude/settings.json` in your project root:
|
|
245
|
+
|
|
246
|
+
```json theme={null}
|
|
247
|
+
{
|
|
248
|
+
"hooks": {
|
|
249
|
+
"SessionStart": [
|
|
250
|
+
{
|
|
251
|
+
"matcher": "compact",
|
|
252
|
+
"hooks": [
|
|
253
|
+
{
|
|
254
|
+
"type": "command",
|
|
255
|
+
"command": "echo 'Reminder: use Bun, not npm. Run bun test before committing. Current sprint: auth refactor.'"
|
|
256
|
+
}
|
|
257
|
+
]
|
|
258
|
+
}
|
|
259
|
+
]
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
You can replace the `echo` with any command that produces dynamic output, like `git log --oneline -5` to show recent commits. For injecting context on every session start, consider using [CLAUDE.md](/en/memory) instead. For environment variables, see [`CLAUDE_ENV_FILE`](/en/hooks#persist-environment-variables) in the reference.
|
|
265
|
+
|
|
266
|
+
### Audit configuration changes
|
|
267
|
+
|
|
268
|
+
Track when settings or skills files change during a session. The `ConfigChange` event fires when an external process or editor modifies a configuration file, so you can log changes for compliance or block unauthorized modifications.
|
|
269
|
+
|
|
270
|
+
This example appends each change to an audit log. Add this to `~/.claude/settings.json`:
|
|
271
|
+
|
|
272
|
+
```json theme={null}
|
|
273
|
+
{
|
|
274
|
+
"hooks": {
|
|
275
|
+
"ConfigChange": [
|
|
276
|
+
{
|
|
277
|
+
"matcher": "",
|
|
278
|
+
"hooks": [
|
|
279
|
+
{
|
|
280
|
+
"type": "command",
|
|
281
|
+
"command": "jq -c '{timestamp: now | todate, source: .source, file: .file_path}' >> ~/claude-config-audit.log"
|
|
282
|
+
}
|
|
283
|
+
]
|
|
284
|
+
}
|
|
285
|
+
]
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
The matcher filters by configuration type: `user_settings`, `project_settings`, `local_settings`, `policy_settings`, or `skills`. To block a change from taking effect, exit with code 2 or return `{"decision": "block"}`. See the [ConfigChange reference](/en/hooks#configchange) for the full input schema.
|
|
291
|
+
|
|
292
|
+
## How hooks work
|
|
293
|
+
|
|
294
|
+
Hook events fire at specific lifecycle points in Claude Code. When an event fires, all matching hooks run in parallel, and identical hook commands are automatically deduplicated. The table below shows each event and when it triggers:
|
|
295
|
+
|
|
296
|
+
| Event | When it fires |
|
|
297
|
+
| :------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
298
|
+
| `SessionStart` | When a session begins or resumes |
|
|
299
|
+
| `UserPromptSubmit` | When you submit a prompt, before Claude processes it |
|
|
300
|
+
| `PreToolUse` | Before a tool call executes. Can block it |
|
|
301
|
+
| `PermissionRequest` | When a permission dialog appears |
|
|
302
|
+
| `PostToolUse` | After a tool call succeeds |
|
|
303
|
+
| `PostToolUseFailure` | After a tool call fails |
|
|
304
|
+
| `Notification` | When Claude Code sends a notification |
|
|
305
|
+
| `SubagentStart` | When a subagent is spawned |
|
|
306
|
+
| `SubagentStop` | When a subagent finishes |
|
|
307
|
+
| `Stop` | When Claude finishes responding |
|
|
308
|
+
| `TeammateIdle` | When an [agent team](/en/agent-teams) teammate is about to go idle |
|
|
309
|
+
| `TaskCompleted` | When a task is being marked as completed |
|
|
310
|
+
| `InstructionsLoaded` | When a CLAUDE.md or `.claude/rules/*.md` file is loaded into context. Fires at session start and when files are lazily loaded during a session |
|
|
311
|
+
| `ConfigChange` | When a configuration file changes during a session |
|
|
312
|
+
| `WorktreeCreate` | When a worktree is being created via `--worktree` or `isolation: "worktree"`. Replaces default git behavior |
|
|
313
|
+
| `WorktreeRemove` | When a worktree is being removed, either at session exit or when a subagent finishes |
|
|
314
|
+
| `PreCompact` | Before context compaction |
|
|
315
|
+
| `SessionEnd` | When a session terminates |
|
|
316
|
+
|
|
317
|
+
Each hook has a `type` that determines how it runs. Most hooks use `"type": "command"`, which runs a shell command. Three other types are available:
|
|
318
|
+
|
|
319
|
+
* `"type": "http"`: POST event data to a URL. See [HTTP hooks](#http-hooks).
|
|
320
|
+
* `"type": "prompt"`: single-turn LLM evaluation. See [Prompt-based hooks](#prompt-based-hooks).
|
|
321
|
+
* `"type": "agent"`: multi-turn verification with tool access. See [Agent-based hooks](#agent-based-hooks).
|
|
322
|
+
|
|
323
|
+
### Read input and return output
|
|
324
|
+
|
|
325
|
+
Hooks communicate with Claude Code through stdin, stdout, stderr, and exit codes. When an event fires, Claude Code passes event-specific data as JSON to your script's stdin. Your script reads that data, does its work, and tells Claude Code what to do next via the exit code.
|
|
326
|
+
|
|
327
|
+
#### Hook input
|
|
328
|
+
|
|
329
|
+
Every event includes common fields like `session_id` and `cwd`, but each event type adds different data. For example, when Claude runs a Bash command, a `PreToolUse` hook receives something like this on stdin:
|
|
330
|
+
|
|
331
|
+
```json theme={null}
|
|
332
|
+
{
|
|
333
|
+
"session_id": "abc123", // unique ID for this session
|
|
334
|
+
"cwd": "/Users/sarah/myproject", // working directory when the event fired
|
|
335
|
+
"hook_event_name": "PreToolUse", // which event triggered this hook
|
|
336
|
+
"tool_name": "Bash", // the tool Claude is about to use
|
|
337
|
+
"tool_input": { // the arguments Claude passed to the tool
|
|
338
|
+
"command": "npm test" // for Bash, this is the shell command
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
Your script can parse that JSON and act on any of those fields. `UserPromptSubmit` hooks get the `prompt` text instead, `SessionStart` hooks get the `source` (startup, resume, clear, compact), and so on. See [Common input fields](/en/hooks#common-input-fields) in the reference for shared fields, and each event's section for event-specific schemas.
|
|
344
|
+
|
|
345
|
+
#### Hook output
|
|
346
|
+
|
|
347
|
+
Your script tells Claude Code what to do next by writing to stdout or stderr and exiting with a specific code. For example, a `PreToolUse` hook that wants to block a command:
|
|
348
|
+
|
|
349
|
+
```bash theme={null}
|
|
350
|
+
#!/bin/bash
|
|
351
|
+
INPUT=$(cat)
|
|
352
|
+
COMMAND=$(echo "$INPUT" | jq -r '.tool_input.command')
|
|
353
|
+
|
|
354
|
+
if echo "$COMMAND" | grep -q "drop table"; then
|
|
355
|
+
echo "Blocked: dropping tables is not allowed" >&2 # stderr becomes Claude's feedback
|
|
356
|
+
exit 2 # exit 2 = block the action
|
|
357
|
+
fi
|
|
358
|
+
|
|
359
|
+
exit 0 # exit 0 = let it proceed
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
The exit code determines what happens next:
|
|
363
|
+
|
|
364
|
+
* **Exit 0**: the action proceeds. For `UserPromptSubmit` and `SessionStart` hooks, anything you write to stdout is added to Claude's context.
|
|
365
|
+
* **Exit 2**: the action is blocked. Write a reason to stderr, and Claude receives it as feedback so it can adjust.
|
|
366
|
+
* **Any other exit code**: the action proceeds. Stderr is logged but not shown to Claude. Toggle verbose mode with `Ctrl+O` to see these messages in the transcript.
|
|
367
|
+
|
|
368
|
+
#### Structured JSON output
|
|
369
|
+
|
|
370
|
+
Exit codes give you two options: allow or block. For more control, exit 0 and print a JSON object to stdout instead.
|
|
371
|
+
|
|
372
|
+
<Note>
|
|
373
|
+
Use exit 2 to block with a stderr message, or exit 0 with JSON for structured control. Don't mix them: Claude Code ignores JSON when you exit 2.
|
|
374
|
+
</Note>
|
|
375
|
+
|
|
376
|
+
For example, a `PreToolUse` hook can deny a tool call and tell Claude why, or escalate it to the user for approval:
|
|
377
|
+
|
|
378
|
+
```json theme={null}
|
|
379
|
+
{
|
|
380
|
+
"hookSpecificOutput": {
|
|
381
|
+
"hookEventName": "PreToolUse",
|
|
382
|
+
"permissionDecision": "deny",
|
|
383
|
+
"permissionDecisionReason": "Use rg instead of grep for better performance"
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
Claude Code reads `permissionDecision` and cancels the tool call, then feeds `permissionDecisionReason` back to Claude as feedback. These three options are specific to `PreToolUse`:
|
|
389
|
+
|
|
390
|
+
* `"allow"`: proceed without showing a permission prompt
|
|
391
|
+
* `"deny"`: cancel the tool call and send the reason to Claude
|
|
392
|
+
* `"ask"`: show the permission prompt to the user as normal
|
|
393
|
+
|
|
394
|
+
Other events use different decision patterns. For example, `PostToolUse` and `Stop` hooks use a top-level `decision: "block"` field, while `PermissionRequest` uses `hookSpecificOutput.decision.behavior`. See the [summary table](/en/hooks#decision-control) in the reference for a full breakdown by event.
|
|
395
|
+
|
|
396
|
+
For `UserPromptSubmit` hooks, use `additionalContext` instead to inject text into Claude's context. Prompt-based hooks (`type: "prompt"`) handle output differently: see [Prompt-based hooks](#prompt-based-hooks).
|
|
397
|
+
|
|
398
|
+
### Filter hooks with matchers
|
|
399
|
+
|
|
400
|
+
Without a matcher, a hook fires on every occurrence of its event. Matchers let you narrow that down. For example, if you want to run a formatter only after file edits (not after every tool call), add a matcher to your `PostToolUse` hook:
|
|
401
|
+
|
|
402
|
+
```json theme={null}
|
|
403
|
+
{
|
|
404
|
+
"hooks": {
|
|
405
|
+
"PostToolUse": [
|
|
406
|
+
{
|
|
407
|
+
"matcher": "Edit|Write",
|
|
408
|
+
"hooks": [
|
|
409
|
+
{ "type": "command", "command": "prettier --write ..." }
|
|
410
|
+
]
|
|
411
|
+
}
|
|
412
|
+
]
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
```
|
|
416
|
+
|
|
417
|
+
The `"Edit|Write"` matcher is a regex pattern that matches the tool name. The hook only fires when Claude uses the `Edit` or `Write` tool, not when it uses `Bash`, `Read`, or any other tool.
|
|
418
|
+
|
|
419
|
+
Each event type matches on a specific field. Matchers support exact strings and regex patterns:
|
|
420
|
+
|
|
421
|
+
| Event | What the matcher filters | Example matcher values |
|
|
422
|
+
| :---------------------------------------------------------------------------------------------- | :------------------------ | :--------------------------------------------------------------------------------- |
|
|
423
|
+
| `PreToolUse`, `PostToolUse`, `PostToolUseFailure`, `PermissionRequest` | tool name | `Bash`, `Edit\|Write`, `mcp__.*` |
|
|
424
|
+
| `SessionStart` | how the session started | `startup`, `resume`, `clear`, `compact` |
|
|
425
|
+
| `SessionEnd` | why the session ended | `clear`, `logout`, `prompt_input_exit`, `bypass_permissions_disabled`, `other` |
|
|
426
|
+
| `Notification` | notification type | `permission_prompt`, `idle_prompt`, `auth_success`, `elicitation_dialog` |
|
|
427
|
+
| `SubagentStart` | agent type | `Bash`, `Explore`, `Plan`, or custom agent names |
|
|
428
|
+
| `PreCompact` | what triggered compaction | `manual`, `auto` |
|
|
429
|
+
| `SubagentStop` | agent type | same values as `SubagentStart` |
|
|
430
|
+
| `ConfigChange` | configuration source | `user_settings`, `project_settings`, `local_settings`, `policy_settings`, `skills` |
|
|
431
|
+
| `UserPromptSubmit`, `Stop`, `TeammateIdle`, `TaskCompleted`, `WorktreeCreate`, `WorktreeRemove` | no matcher support | always fires on every occurrence |
|
|
432
|
+
|
|
433
|
+
A few more examples showing matchers on different event types:
|
|
434
|
+
|
|
435
|
+
<Tabs>
|
|
436
|
+
<Tab title="Log every Bash command">
|
|
437
|
+
Match only `Bash` tool calls and log each command to a file. The `PostToolUse` event fires after the command completes, so `tool_input.command` contains what ran. The hook receives the event data as JSON on stdin, and `jq -r '.tool_input.command'` extracts just the command string, which `>>` appends to the log file:
|
|
438
|
+
|
|
439
|
+
```json theme={null}
|
|
440
|
+
{
|
|
441
|
+
"hooks": {
|
|
442
|
+
"PostToolUse": [
|
|
443
|
+
{
|
|
444
|
+
"matcher": "Bash",
|
|
445
|
+
"hooks": [
|
|
446
|
+
{
|
|
447
|
+
"type": "command",
|
|
448
|
+
"command": "jq -r '.tool_input.command' >> ~/.claude/command-log.txt"
|
|
449
|
+
}
|
|
450
|
+
]
|
|
451
|
+
}
|
|
452
|
+
]
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
```
|
|
456
|
+
</Tab>
|
|
457
|
+
|
|
458
|
+
<Tab title="Match MCP tools">
|
|
459
|
+
MCP tools use a different naming convention than built-in tools: `mcp__<server>__<tool>`, where `<server>` is the MCP server name and `<tool>` is the tool it provides. For example, `mcp__github__search_repositories` or `mcp__filesystem__read_file`. Use a regex matcher to target all tools from a specific server, or match across servers with a pattern like `mcp__.*__write.*`. See [Match MCP tools](/en/hooks#match-mcp-tools) in the reference for the full list of examples.
|
|
460
|
+
|
|
461
|
+
The command below extracts the tool name from the hook's JSON input with `jq` and writes it to stderr, where it shows up in verbose mode (`Ctrl+O`):
|
|
462
|
+
|
|
463
|
+
```json theme={null}
|
|
464
|
+
{
|
|
465
|
+
"hooks": {
|
|
466
|
+
"PreToolUse": [
|
|
467
|
+
{
|
|
468
|
+
"matcher": "mcp__github__.*",
|
|
469
|
+
"hooks": [
|
|
470
|
+
{
|
|
471
|
+
"type": "command",
|
|
472
|
+
"command": "echo \"GitHub tool called: $(jq -r '.tool_name')\" >&2"
|
|
473
|
+
}
|
|
474
|
+
]
|
|
475
|
+
}
|
|
476
|
+
]
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
```
|
|
480
|
+
</Tab>
|
|
481
|
+
|
|
482
|
+
<Tab title="Clean up on session end">
|
|
483
|
+
The `SessionEnd` event supports matchers on the reason the session ended. This hook only fires on `clear` (when you run `/clear`), not on normal exits:
|
|
484
|
+
|
|
485
|
+
```json theme={null}
|
|
486
|
+
{
|
|
487
|
+
"hooks": {
|
|
488
|
+
"SessionEnd": [
|
|
489
|
+
{
|
|
490
|
+
"matcher": "clear",
|
|
491
|
+
"hooks": [
|
|
492
|
+
{
|
|
493
|
+
"type": "command",
|
|
494
|
+
"command": "rm -f /tmp/claude-scratch-*.txt"
|
|
495
|
+
}
|
|
496
|
+
]
|
|
497
|
+
}
|
|
498
|
+
]
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
```
|
|
502
|
+
</Tab>
|
|
503
|
+
</Tabs>
|
|
504
|
+
|
|
505
|
+
For full matcher syntax, see the [Hooks reference](/en/hooks#configuration).
|
|
506
|
+
|
|
507
|
+
### Configure hook location
|
|
508
|
+
|
|
509
|
+
Where you add a hook determines its scope:
|
|
510
|
+
|
|
511
|
+
| Location | Scope | Shareable |
|
|
512
|
+
| :--------------------------------------------------------- | :--------------------------------- | :--------------------------------- |
|
|
513
|
+
| `~/.claude/settings.json` | All your projects | No, local to your machine |
|
|
514
|
+
| `.claude/settings.json` | Single project | Yes, can be committed to the repo |
|
|
515
|
+
| `.claude/settings.local.json` | Single project | No, gitignored |
|
|
516
|
+
| Managed policy settings | Organization-wide | Yes, admin-controlled |
|
|
517
|
+
| [Plugin](/en/plugins) `hooks/hooks.json` | When plugin is enabled | Yes, bundled with the plugin |
|
|
518
|
+
| [Skill](/en/skills) or [agent](/en/sub-agents) frontmatter | While the skill or agent is active | Yes, defined in the component file |
|
|
519
|
+
|
|
520
|
+
You can also use the [`/hooks` menu](/en/hooks#the-hooks-menu) in Claude Code to add, delete, and view hooks interactively. To disable all hooks at once, use the toggle at the bottom of the `/hooks` menu or set `"disableAllHooks": true` in your settings file.
|
|
521
|
+
|
|
522
|
+
Hooks added through the `/hooks` menu take effect immediately. If you edit settings files directly while Claude Code is running, the changes won't take effect until you review them in the `/hooks` menu or restart your session.
|
|
523
|
+
|
|
524
|
+
## Prompt-based hooks
|
|
525
|
+
|
|
526
|
+
For decisions that require judgment rather than deterministic rules, use `type: "prompt"` hooks. Instead of running a shell command, Claude Code sends your prompt and the hook's input data to a Claude model (Haiku by default) to make the decision. You can specify a different model with the `model` field if you need more capability.
|
|
527
|
+
|
|
528
|
+
The model's only job is to return a yes/no decision as JSON:
|
|
529
|
+
|
|
530
|
+
* `"ok": true`: the action proceeds
|
|
531
|
+
* `"ok": false`: the action is blocked. The model's `"reason"` is fed back to Claude so it can adjust.
|
|
532
|
+
|
|
533
|
+
This example uses a `Stop` hook to ask the model whether all requested tasks are complete. If the model returns `"ok": false`, Claude keeps working and uses the `reason` as its next instruction:
|
|
534
|
+
|
|
535
|
+
```json theme={null}
|
|
536
|
+
{
|
|
537
|
+
"hooks": {
|
|
538
|
+
"Stop": [
|
|
539
|
+
{
|
|
540
|
+
"hooks": [
|
|
541
|
+
{
|
|
542
|
+
"type": "prompt",
|
|
543
|
+
"prompt": "Check if all tasks are complete. If not, respond with {\"ok\": false, \"reason\": \"what remains to be done\"}."
|
|
544
|
+
}
|
|
545
|
+
]
|
|
546
|
+
}
|
|
547
|
+
]
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
```
|
|
551
|
+
|
|
552
|
+
For full configuration options, see [Prompt-based hooks](/en/hooks#prompt-based-hooks) in the reference.
|
|
553
|
+
|
|
554
|
+
## Agent-based hooks
|
|
555
|
+
|
|
556
|
+
When verification requires inspecting files or running commands, use `type: "agent"` hooks. Unlike prompt hooks which make a single LLM call, agent hooks spawn a subagent that can read files, search code, and use other tools to verify conditions before returning a decision.
|
|
557
|
+
|
|
558
|
+
Agent hooks use the same `"ok"` / `"reason"` response format as prompt hooks, but with a longer default timeout of 60 seconds and up to 50 tool-use turns.
|
|
559
|
+
|
|
560
|
+
This example verifies that tests pass before allowing Claude to stop:
|
|
561
|
+
|
|
562
|
+
```json theme={null}
|
|
563
|
+
{
|
|
564
|
+
"hooks": {
|
|
565
|
+
"Stop": [
|
|
566
|
+
{
|
|
567
|
+
"hooks": [
|
|
568
|
+
{
|
|
569
|
+
"type": "agent",
|
|
570
|
+
"prompt": "Verify that all unit tests pass. Run the test suite and check the results. $ARGUMENTS",
|
|
571
|
+
"timeout": 120
|
|
572
|
+
}
|
|
573
|
+
]
|
|
574
|
+
}
|
|
575
|
+
]
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
```
|
|
579
|
+
|
|
580
|
+
Use prompt hooks when the hook input data alone is enough to make a decision. Use agent hooks when you need to verify something against the actual state of the codebase.
|
|
581
|
+
|
|
582
|
+
For full configuration options, see [Agent-based hooks](/en/hooks#agent-based-hooks) in the reference.
|
|
583
|
+
|
|
584
|
+
## HTTP hooks
|
|
585
|
+
|
|
586
|
+
Use `type: "http"` hooks to POST event data to an HTTP endpoint instead of running a shell command. The endpoint receives the same JSON that a command hook would receive on stdin, and returns results through the HTTP response body using the same JSON format.
|
|
587
|
+
|
|
588
|
+
HTTP hooks are useful when you want a web server, cloud function, or external service to handle hook logic: for example, a shared audit service that logs tool use events across a team.
|
|
589
|
+
|
|
590
|
+
This example posts every tool use to a local logging service:
|
|
591
|
+
|
|
592
|
+
```json theme={null}
|
|
593
|
+
{
|
|
594
|
+
"hooks": {
|
|
595
|
+
"PostToolUse": [
|
|
596
|
+
{
|
|
597
|
+
"hooks": [
|
|
598
|
+
{
|
|
599
|
+
"type": "http",
|
|
600
|
+
"url": "http://localhost:8080/hooks/tool-use",
|
|
601
|
+
"headers": {
|
|
602
|
+
"Authorization": "Bearer $MY_TOKEN"
|
|
603
|
+
},
|
|
604
|
+
"allowedEnvVars": ["MY_TOKEN"]
|
|
605
|
+
}
|
|
606
|
+
]
|
|
607
|
+
}
|
|
608
|
+
]
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
```
|
|
612
|
+
|
|
613
|
+
The endpoint should return a JSON response body using the same [output format](/en/hooks#json-output) as command hooks. To block a tool call, return a 2xx response with the appropriate `hookSpecificOutput` fields. HTTP status codes alone cannot block actions.
|
|
614
|
+
|
|
615
|
+
Header values support environment variable interpolation using `$VAR_NAME` or `${VAR_NAME}` syntax. Only variables listed in the `allowedEnvVars` array are resolved; all other `$VAR` references remain empty.
|
|
616
|
+
|
|
617
|
+
<Note>
|
|
618
|
+
HTTP hooks must be configured by editing your settings JSON directly. The `/hooks` interactive menu only supports adding command hooks.
|
|
619
|
+
</Note>
|
|
620
|
+
|
|
621
|
+
For full configuration options and response handling, see [HTTP hooks](/en/hooks#http-hook-fields) in the reference.
|
|
622
|
+
|
|
623
|
+
## Limitations and troubleshooting
|
|
624
|
+
|
|
625
|
+
### Limitations
|
|
626
|
+
|
|
627
|
+
* Command hooks communicate through stdout, stderr, and exit codes only. They cannot trigger commands or tool calls directly. HTTP hooks communicate through the response body instead.
|
|
628
|
+
* Hook timeout is 10 minutes by default, configurable per hook with the `timeout` field (in seconds).
|
|
629
|
+
* `PostToolUse` hooks cannot undo actions since the tool has already executed.
|
|
630
|
+
* `PermissionRequest` hooks do not fire in [non-interactive mode](/en/headless) (`-p`). Use `PreToolUse` hooks for automated permission decisions.
|
|
631
|
+
* `Stop` hooks fire whenever Claude finishes responding, not only at task completion. They do not fire on user interrupts.
|
|
632
|
+
|
|
633
|
+
### Hook not firing
|
|
634
|
+
|
|
635
|
+
The hook is configured but never executes.
|
|
636
|
+
|
|
637
|
+
* Run `/hooks` and confirm the hook appears under the correct event
|
|
638
|
+
* Check that the matcher pattern matches the tool name exactly (matchers are case-sensitive)
|
|
639
|
+
* Verify you're triggering the right event type (e.g., `PreToolUse` fires before tool execution, `PostToolUse` fires after)
|
|
640
|
+
* If using `PermissionRequest` hooks in non-interactive mode (`-p`), switch to `PreToolUse` instead
|
|
641
|
+
|
|
642
|
+
### Hook error in output
|
|
643
|
+
|
|
644
|
+
You see a message like "PreToolUse hook error: ..." in the transcript.
|
|
645
|
+
|
|
646
|
+
* Your script exited with a non-zero code unexpectedly. Test it manually by piping sample JSON:
|
|
647
|
+
```bash theme={null}
|
|
648
|
+
echo '{"tool_name":"Bash","tool_input":{"command":"ls"}}' | ./my-hook.sh
|
|
649
|
+
echo $? # Check the exit code
|
|
650
|
+
```
|
|
651
|
+
* If you see "command not found", use absolute paths or `$CLAUDE_PROJECT_DIR` to reference scripts
|
|
652
|
+
* If you see "jq: command not found", install `jq` or use Python/Node.js for JSON parsing
|
|
653
|
+
* If the script isn't running at all, make it executable: `chmod +x ./my-hook.sh`
|
|
654
|
+
|
|
655
|
+
### `/hooks` shows no hooks configured
|
|
656
|
+
|
|
657
|
+
You edited a settings file but the hooks don't appear in the menu.
|
|
658
|
+
|
|
659
|
+
* Restart your session or open `/hooks` to reload. Hooks added through the `/hooks` menu take effect immediately, but manual file edits require a reload.
|
|
660
|
+
* Verify your JSON is valid (trailing commas and comments are not allowed)
|
|
661
|
+
* Confirm the settings file is in the correct location: `.claude/settings.json` for project hooks, `~/.claude/settings.json` for global hooks
|
|
662
|
+
|
|
663
|
+
### Stop hook runs forever
|
|
664
|
+
|
|
665
|
+
Claude keeps working in an infinite loop instead of stopping.
|
|
666
|
+
|
|
667
|
+
Your Stop hook script needs to check whether it already triggered a continuation. Parse the `stop_hook_active` field from the JSON input and exit early if it's `true`:
|
|
668
|
+
|
|
669
|
+
```bash theme={null}
|
|
670
|
+
#!/bin/bash
|
|
671
|
+
INPUT=$(cat)
|
|
672
|
+
if [ "$(echo "$INPUT" | jq -r '.stop_hook_active')" = "true" ]; then
|
|
673
|
+
exit 0 # Allow Claude to stop
|
|
674
|
+
fi
|
|
675
|
+
# ... rest of your hook logic
|
|
676
|
+
```
|
|
677
|
+
|
|
678
|
+
### JSON validation failed
|
|
679
|
+
|
|
680
|
+
Claude Code shows a JSON parsing error even though your hook script outputs valid JSON.
|
|
681
|
+
|
|
682
|
+
When Claude Code runs a hook, it spawns a shell that sources your profile (`~/.zshrc` or `~/.bashrc`). If your profile contains unconditional `echo` statements, that output gets prepended to your hook's JSON:
|
|
683
|
+
|
|
684
|
+
```text theme={null}
|
|
685
|
+
Shell ready on arm64
|
|
686
|
+
{"decision": "block", "reason": "Not allowed"}
|
|
687
|
+
```
|
|
688
|
+
|
|
689
|
+
Claude Code tries to parse this as JSON and fails. To fix this, wrap echo statements in your shell profile so they only run in interactive shells:
|
|
690
|
+
|
|
691
|
+
```bash theme={null}
|
|
692
|
+
# In ~/.zshrc or ~/.bashrc
|
|
693
|
+
if [[ $- == *i* ]]; then
|
|
694
|
+
echo "Shell ready"
|
|
695
|
+
fi
|
|
696
|
+
```
|
|
697
|
+
|
|
698
|
+
The `$-` variable contains shell flags, and `i` means interactive. Hooks run in non-interactive shells, so the echo is skipped.
|
|
699
|
+
|
|
700
|
+
### Debug techniques
|
|
701
|
+
|
|
702
|
+
Toggle verbose mode with `Ctrl+O` to see hook output in the transcript, or run `claude --debug` for full execution details including which hooks matched and their exit codes.
|
|
703
|
+
|
|
704
|
+
## Learn more
|
|
705
|
+
|
|
706
|
+
* [Hooks reference](/en/hooks): full event schemas, JSON output format, async hooks, and MCP tool hooks
|
|
707
|
+
* [Security considerations](/en/hooks#security-considerations): review before deploying hooks in shared or production environments
|
|
708
|
+
* [Bash command validator example](https://github.com/anthropics/claude-code/blob/main/examples/hooks/bash_command_validator_example.py): complete reference implementation
|