Register and share your invite link to earn from video plays and referrals.

cv usk
@cv_usk
AI / Software Research Notes AI Agent, LLMOps, MLOps, Software Architecture ๆŠ•็จฟใฏๅ€‹ไบบใฎๆ„่ฆ‹ใงใ™ใ€‚
Joined May 2026
258 Following    224 Followers
# Practical ways to use the Claude Agent SDK โœ… Request user approval before dangerous operations with 6 flexible response patterns. Approval and User Input uses the `canUseTool` callback to intercept dangerous operations and `AskUserQuestion` for requirements gathering. ๐Ÿ“Œ Title: Handling Approvals and User Input ๐Ÿ”— URL: ๐Ÿงฉ Overview `canUseTool` intercepts each tool call with 6 response patterns: approve, approve with modifications, approve and remember, deny, suggest alternative, or full redirect. `AskUserQuestion` lets Claude present multiple-choice questions to users. ๐Ÿ›  How to use it Define a `canUseTool` callback that returns `PermissionResultAllow` or `PermissionResultDeny` based on tool name and arguments. ๐Ÿ— Practical usage - Build an interactive approval UI that detects file deletions or Bash execution and prompts y/n. You can approve with modifications like "scope all Bash commands to /tmp/sandbox". - Use "approve and remember" with `updated_permissions` to persist rules in `.claude/settings.local.json`. - Combine `AskUserQuestion` with `plan` mode to gather requirements before making changes: "Which tech stack for the mobile app?" with multiple choice options. ๐Ÿ’ก Use cases ๐Ÿ›ก Interactive approval UI for dangerous operations ๐Ÿ“‹ Multi-choice requirements gathering ๐Ÿ” Persistent approval rule learning โš ๏ธ Watch out AskUserQuestion is not available in sub-agents. Questions are limited to 1-4, choices to 2-4. In Python, `can_use_tool` requires streaming mode plus a dummy PreToolUse hook. #ClaudeAgentSDK# #AI#
Show more