From dark-factory
When a Claude Code PreToolUse hook intercepts an Agent tool call, the prompt and subagent_type live under .tool_input, not at the top level of the hook stdin JSON.
How this skill is triggered — by the user, by Claude, or both
Slash command
/dark-factory:agent-tool-json-nestingThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Whenever writing or modifying `pre-tool-use-hook.sh` logic that reads or writes
Whenever writing or modifying pre-tool-use-hook.sh logic that reads or writes
fields from an Agent tool call (e.g., to inject text into the prompt, read
subagent_type, or modify any other Agent parameter).
The raw hook stdin for an Agent tool call looks like this:
{
"tool_name": "Agent",
"tool_input": {
"subagent_type": "testing-agent",
"prompt": "original prompt text"
}
}
Note the extra nesting level: fields are under .tool_input, not at the
root of the JSON object.
Read subagent_type with:
AGENT_NAME=$(printf '%s' "$TOOL_INPUT" | jq -r '.tool_input.subagent_type // ""')
Read the prompt with:
ORIGINAL_PROMPT=$(printf '%s' "$TOOL_INPUT" | jq -r '.tool_input.prompt // ""')
Write a modified prompt back with:
TOOL_INPUT=$(printf '%s' "$TOOL_INPUT" | jq --arg p "$NEW_PROMPT" '.tool_input.prompt = $p')
When emitting the final output, handle both Agent tool calls (nested) and non-Agent tool calls (top-level prompt) defensively:
printf '%s' "$TOOL_INPUT" | jq --arg p "$NEW_PROMPT" \
'if .tool_input.prompt != null then .tool_input.prompt = $p else .prompt = $p end'
.tool_input.prompt
field. Using .tool_input.prompt // .prompt as a read path and the
conditional if .tool_input.prompt != null as a write path keeps the hook
safe for both shapes..prompt = $p directly on an Agent tool call
sets a new top-level .prompt field while leaving .tool_input.prompt
unchanged — the injected text is silently ignored by Claude Code.if [ "$TOOL_NAME" = "Agent" ] to
avoid accidentally reading .tool_input.subagent_type from other tools that
happen to have a tool_input wrapper.npx claudepluginhub lewibs/dark-factory --plugin dark-factoryFetches up-to-date documentation from Context7 for libraries and frameworks like React, Next.js, Prisma. Use for setup questions, API references, and code examples.
Applies a firm's KYC/AML rules grid to parsed onboarding records: assigns risk rating, checks required documents, outputs rule outcomes with citations, and routes for escalation.
Generates daily or weekly digests of activity from connected sources (chat, email, docs, tasks, CRM), highlighting action items, decisions, mentions, and project updates.