Skip to main content

cc-hooks-main-vs-subagent

How a Claude Code PreToolUse/PostToolUse hook can tell whether a tool call came from the MAIN conversation thread or from a SUBAGENT (Task/Agent tool), plus the gotchas of testing hooks via headless `claude -p`. Use when: (1) building a hook that should apply only to the main thread (e.g. orchestrator-only enforcement that denies Edit/Write in main but allows subagents) or only to subagents; (2) wondering if hook input contains an is_subagent / agent indicator — it does, but it's undocumented; (3) a hook behaves differently than expected under `claude -p` because CLAUDE_CODE_ENTRYPOINT is sdk-cli there and `env CLAUDE_CODE_ENTRYPOINT=cli` does NOT survive (the CLI overwrites it); (4) a headless hook test shows "Claude requested permissions ... but you haven't granted it yet" instead of the hook's deny reason — the permission gate fires before the hook surfaces; (5) you need to force the interactive code path in a headless test (use a --settings file with an env block).

Ir para a instalação

Informações da origem

Repositório
cajias/claude-skills
Última atividade na origem
20 de julho de 2026 às 07:29
Idioma detectado do SKILL.md
inglês
Estrelas
0
Forks
0

Opções de instalação

Por padrão, está selecionado o prompt que primeiro revisa a origem. Você pode mudar para um comando direto ou baixar uma cópia local.

Revise os arquivos de origem

Leia o SKILL.md e os arquivos complementares exibidos pelo SkillsMP antes de decidir se vai instalar.