lewibs/dark-factory/agent-tool-json-nesting

Claude Code and agent skill by lewibs/dark-factory

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

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.

Install

npx vskill@latest install lewibs/dark-factory/agent-tool-json-nesting

SKILL.md

The same SKILL.md was published earlier as lewibs/dark-factory/agent-tool-json-nesting.

When to use

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

Steps

  1. The raw hook stdin for an Agent tool call looks like this:

``json { "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.

  1. Read subagent_type with:

``bash AGENT_NAME=$(printf '%s' "$TOOL_INPUT" | jq -r '.tool_input.subagent_type // ""') ``

  1. Read the prompt with:

``bash ORIGINAL_PROMPT=$(printf '%s' "$TOOL_INPUT" | jq -r '.tool_input.prompt // ""') ``

  1. Write a modified prompt back with:

``bash TOOL_INPUT=$(printf '%s' "$TOOL_INPUT" | jq --arg p "$NEW_PROMPT" '.tool_input.prompt = $p') ``

  1. When emitting the final output, handle both Agent tool calls (nested) and

non-Agent tool calls (top-level prompt) defensively: ``bash printf '%s' "$TOOL_INPUT" | jq --arg p "$NEW_PROMPT" \ 'if .tool_input.prompt != null then .tool_input.prompt = $p else .prompt = $p end' ``

Notes

  • Non-Agent tool calls (e.g., Bash, Read) do NOT have a .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.

  • The bug this prevents: using .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.

  • Always guard Agent-specific logic behind if [ "$TOOL_NAME" = "Agent" ] to

avoid accidentally reading .tool_input.subagent_type from other tools that happen to have a tool_input wrapper.

Security

  • Security scanPassed, 90 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository forks
1
7-day trend score
0

Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/lewibs/dark-factory/agent-tool-json-nesting/badge)](https://verified-skill.com/skills/lewibs/dark-factory/agent-tool-json-nesting)

Something wrong with this skill or its page? Tell us.