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).

설치로 이동

소스 정보

저장소
cajias/claude-skills
최근 소스 활동
2026년 7월 20일 07:29
감지된 SKILL.md 언어
영어
스타
0
포크
0

설치 방법

기본적으로 소스를 먼저 확인하는 Prompt가 선택됩니다. 직접 명령으로 전환하거나 로컬 사본을 다운로드할 수도 있습니다.

소스 파일 검토

설치 여부를 결정하기 전에 SKILL.md와 SkillsMP에 표시된 보조 파일을 읽어 보세요.