> Agent-ready spec from Diff of the Day (2026-12-04, idea 3). Give this file to your coding agent (Claude Code, Codex, Cursor) and ask it to build the P0 requirements first.

# Spec: Phone approval for risky coding-agent tool calls

## Problem Statement
Claude on Apple Watch now shows a card with Allow once, Always allow or Decline when the assistant needs a tool permission. Coding agents in a terminal still wait at the desk for a yes. When you step away, a long session stops at the first risky command and nobody sees it.

## Goals
- Send a push notification to your phone for each tool call that matches a risk rule.
- Let you allow or decline from the phone, with the answer back to the agent in under 10 seconds.
- Default to decline after a timeout, so silence never means yes.
- Keep a local log of every request and answer.

## Non-Goals
- Approving every tool call: safe reads stay automatic so the phone is not flooded.
- A native mobile app: a push service and a web page are enough for the first version.
- Multi-user teams: one developer and one phone first.

## User Stories
- As a developer, I want a phone prompt before my agent runs a deploy or a database migration so that I can leave the desk.
- As a cautious user, I want unanswered requests declined after 5 minutes so that nothing runs without me.
- Edge case: if the phone is offline, the request times out, is declined, and the agent gets a clear message.

## Requirements
### P0
- [ ] A pre-tool-use hook for one coding agent (for example a Claude Code hook) that sends the command text and a request id to a small local server. Accept: the hook blocks until it gets an answer.
- [ ] The server sends a push with Allow and Decline links signed with a one-time code. Accept: a reused link is refused.
- [ ] Timeout with decline. Accept: an unanswered request is declined after the set time.
### P1
- [ ] Risk rules in a config file (command patterns, paths, network targets). Accept: a read of a source file does not prompt; a deploy command does.
- [ ] Show the working directory and git branch in the push. Accept: both appear on the phone.
### P2
- [ ] Always-allow for a rule, valid for one session. Accept: the second match in the session runs without a prompt.

## Success Metrics
- Median time from push to answer under 30 seconds in daily use.
- Zero risky commands run without an explicit Allow during a week of use.
- Fewer than 5 prompts per hour of agent work after tuning rules.

## Open Questions
- Which push service to use (a self-hosted one or a hosted one)?
- Should the server run on the laptop or on a small always-on box?

## Timeline
- Saturday: hook, local server and push with links.
- Sunday: risk rules, timeout, logging and a week of tuning notes.

## Agent Instructions
- Stack: a small Python or Node web server, the hook system of your coding agent, and a push service.
- Build order: hook to server, push, answer path, timeout, rules.
- Safety: bind the server to localhost or a private network; sign links with one-time codes; never include secrets from the command in the push text; decline on any error.
- Done when: all P0 acceptance checks pass and a deploy command waits for an Allow from the phone.

## Sources
- Claude changelog, Claude is now available on Apple Watch, https://claude.com/changelog/claude-comes-to-apple-watch
- Claude Help Center, Use Claude for Apple Watch, https://support.claude.com/en/articles/18637277-use-claude-for-apple-watch
