tinkerers-labs

Tool Approval

AI chats

About

Asks before an agent runs a tool. Shows what the call will do, offers Allow once, Always allow and Deny, and leaves a one-line record of the answer.

Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Tool Approval to your project and fits it to your theme.

Code

How Tool Approval is used: the demo's code. The component's own source comes with a free account.

Usage.tsx

"use client"

import * as React from "react"

import {
  ToolApproval,
  type ToolApprovalDecision,
} from "@/components/ui/mischief-tool-approval"

const wait = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms))

const readInput = { path: "src/app/settings/page.tsx", lines: "1-120" }
const deleteInput = { branch: "release/0.7", remote: "origin", force: false }

export default function ToolApprovalDemo() {
  const [read, setRead] = React.useState<ToolApprovalDecision | null>(null)
  const [removal, setRemoval] = React.useState<ToolApprovalDecision | null>(
    null
  )

  return (
    <div className="grid w-full max-w-md gap-3">
      <p className="text-muted-foreground text-sm">
        The agent is cleaning up after the 0.8 release.
      </p>

      <ToolApproval
        input={readInput}
        name="read_file"
        onDecision={async (decision) => {
          await wait(500)
          setRead(decision)
        }}
      />

      <ToolApproval
        destructive
        input={deleteInput}
        name="delete_branch"
        summary={
          <p>
            Deletes <code>release/0.7</code> on origin. Anyone who has not
            pulled it loses the branch.
          </p>
        }
        onDecision={async (decision) => {
          await wait(500)
          setRemoval(decision)
        }}
      />

    </div>
  )
}

Dependencies

More by tinkerers-labs

View all
  • Prompt Input

    Prompt Input

    11
  • Burst

    Burst

    4
  • Undo Button

    Undo Button

  • Notification Stack

    Notification Stack

  • Swipe Actions

    Swipe Actions

  • Sparkline

    Sparkline

  • Ghost Text

    Ghost Text

  • Slash Menu

    Slash Menu

More in AI chats

View all
  • Agent Chat

    Agent Chat

    21
  • AI Actions

    AI Actions

    372
  • AI Suggestions

    AI Suggestions

    27
  • Interactive LLM Token & Context Window Visualizer

    Interactive LLM Token & Context Window Visualizer

    30
  • AI SaaS Workflow Hero

    AI SaaS Workflow Hero

    36
  • Aquarium Prompt

    Aquarium Prompt

    219
  • Message Parts

    Message Parts

    10
  • AI Chat Composer

    AI Chat Composer

    21