CLAUDE LABJP
FORK — Claude Code 2.1.212 changes what /fork does: it copies your conversation into a new background session with its own row in claude agents, so you can keep working. The old in-session subagent is now /subtaskLIMITS — WebSearch calls are now capped at 200 per session by default, and subagent spawns get the same 200 ceiling, so a runaway search or delegation loop stops on its ownMCPBG — MCP tool calls running past two minutes now move to the background automatically, keeping the session usable. Tune the threshold with CLAUDE_CODE_MCP_AUTO_BACKGROUND_MSPLANFIX — Fixed plan mode auto-running file-modifying Bash commands such as touch and rm without a permission prompt or an SDK canUseTool callbackSONNET5 — Claude Sonnet 5 is running on introductory pricing of $2 per million input tokens and $10 per million output. After August 31 it moves to $3 and $15IPO — Bankers are reportedly lining up investor meetings for Anthropic ahead of a possible public listing as soon as OctoberFORK — Claude Code 2.1.212 changes what /fork does: it copies your conversation into a new background session with its own row in claude agents, so you can keep working. The old in-session subagent is now /subtaskLIMITS — WebSearch calls are now capped at 200 per session by default, and subagent spawns get the same 200 ceiling, so a runaway search or delegation loop stops on its ownMCPBG — MCP tool calls running past two minutes now move to the background automatically, keeping the session usable. Tune the threshold with CLAUDE_CODE_MCP_AUTO_BACKGROUND_MSPLANFIX — Fixed plan mode auto-running file-modifying Bash commands such as touch and rm without a permission prompt or an SDK canUseTool callbackSONNET5 — Claude Sonnet 5 is running on introductory pricing of $2 per million input tokens and $10 per million output. After August 31 it moves to $3 and $15IPO — Bankers are reportedly lining up investor meetings for Anthropic ahead of a possible public listing as soon as October
Articles/API & SDK
API & SDK/2026-05-02Intermediate

Calling Claude API from iOS Shortcuts: A Personal Setup for Reshaping Selected Text on the Fly

A personal setup guide for invoking the Claude API directly from iOS Shortcuts. Reshape selected text in seconds with a Cloudflare Workers proxy that keeps your API key off the device.

ios14shortcutsclaude-api81indie-dev14cloudflare-workers5

If you write apps or notes on iPhone, you have probably had the same small frustration I have: you want one sentence rewritten, or three lines summarized, and switching to the Claude app, pasting, prompting, copying back is just enough friction to break your flow. I rewrite App Store descriptions dozens of times a day, and that friction was quietly costing me momentum.

The fix that stuck for me was driving Claude directly from the iOS Shortcuts app. With three small recipes pinned to my share sheet — Polish, Summarize, and Translate-to-English — I can highlight any text in Mail, Notes, or Slack and get a Claude-edited version on the clipboard in two taps. After a couple of weeks I stopped opening the Claude app for short tasks entirely.

This article is the recipe I wish someone had handed me when I started. It is opinionated for indie developers: the API key never lives on the device, the proxy is one Cloudflare Workers file, and every mode is a single string change.

Why route through a Cloudflare Workers proxy

Shortcuts can fire HTTP requests directly using the "Get Contents of URL" action, so technically you could point it straight at https://api.anthropic.com/v1/messages. In day-to-day use, two things make me reach for a small proxy instead.

  • Your API key ends up everywhere. Shortcuts sync over iCloud, get AirDropped to friends, and live in plain text inside the recipe. Once that key is on your device, it is one accidental share away from being public.
  • You will want to change models or tweak prompts later. Editing every device individually gets old fast. With a proxy you change one Worker and every iPhone in the family picks it up instantly.

Here is the shape of the system:

iPhone Shortcut
   ↓ POST { text, mode } + X-Shortcut-Token
Cloudflare Workers (proxy, API key in secrets)
   ↓ Anthropic Messages API
Claude

If you have not built a thin Anthropic proxy on Workers before, the broader patterns are covered in Claude API × Cloudflare Workers — Building Edge AI Microservices. For this recipe we keep things deliberately small: no streaming, no auth backend, just a single POST endpoint.

Step 1 — Stand up the proxy on Cloudflare Workers

Run wrangler init shortcut-claude-proxy and replace src/index.ts with the version below. This is what I actually run; comments included.

// src/index.ts — relays a single Shortcut request to Claude
export interface Env {
  ANTHROPIC_API_KEY: string;   // wrangler secret put ANTHROPIC_API_KEY
  SHORTCUT_TOKEN: string;      // shared secret for your phones
}
 
const SYSTEM_PROMPTS: Record<string, string> = {
  polish:  "Rewrite the input text so wording and sentence flow read naturally. Preserve meaning. Reply with the rewritten text only — no preamble or quotes.",
  summary: "Summarize the input in three or fewer bullet points, each under 80 characters.",
  english: "Translate the input to natural, idiomatic English as a native writer would phrase it.",
};
 
export default {
  async fetch(req: Request, env: Env): Promise<Response> {
    if (req.method !== "POST") return new Response("Method Not Allowed", { status: 405 });
 
    // Simple shared-secret check. If a token leaks, change it on the Worker side.
    if (req.headers.get("X-Shortcut-Token") !== env.SHORTCUT_TOKEN) {
      return new Response("Unauthorized", { status: 401 });
    }
 
    const { text, mode = "polish" } = await req.json<{ text: string; mode?: string }>();
    const system = SYSTEM_PROMPTS[mode] ?? SYSTEM_PROMPTS.polish;
 
    const apiRes = await fetch("https://api.anthropic.com/v1/messages", {
      method: "POST",
      headers: {
        "x-api-key": env.ANTHROPIC_API_KEY,
        "anthropic-version": "2023-06-01",
        "content-type": "application/json",
      },
      body: JSON.stringify({
        model: "claude-sonnet-4-6",
        max_tokens: 1024,
        system,
        messages: [{ role: "user", content: text }],
      }),
    });
 
    if (!apiRes.ok) {
      // Surfacing the upstream body makes the Shortcut error sheet useful.
      return new Response(await apiRes.text(), { status: apiRes.status });
    }
 
    const data = await apiRes.json<{ content: { type: string; text: string }[] }>();
    const out = data.content.find((c) => c.type === "text")?.text ?? "";
    return new Response(out, { headers: { "content-type": "text/plain; charset=utf-8" } });
  },
};

The endpoint deliberately returns plain text, not JSON. That removes one parsing step on the Shortcut side and means the rewritten text can flow straight into "Copy to Clipboard". The fewer Shortcut actions you stack, the more reliable the recipe is on flaky cellular connections.

Deploy in three commands:

# Store the API key as a secret — never embed it in the Shortcut
wrangler secret put ANTHROPIC_API_KEY
# Random long string, used by your phones to authenticate
wrangler secret put SHORTCUT_TOKEN
wrangler deploy

If you want a defensive layer for the inevitable 429, Handling Claude API Rate Limits and 429 Errors goes into the retry strategies that fit best with a single-request edge proxy like this one.

Step 2 — Build the iOS Shortcut

Open Shortcuts, create a new shortcut, and toggle "Show in Share Sheet" with "Text" allowed. Then assemble the actions:

  1. Get Shortcut Input — accept text from the share sheet.
  2. Text — build the JSON payload: {"text":"<input>","mode":"polish"}.
  3. URL — your Worker's URL (for example https://shortcut-claude-proxy.example.workers.dev).
  4. Get Contents of URL
    • Method: POST
    • Headers: Content-Type: application/json, X-Shortcut-Token: <your token>
    • Request Body: File → the Text from step 2
  5. Copy to Clipboard + Show Result

That is the whole recipe. From any Mail draft, Note, or Slack message, highlight the text, share to "Polish", and the cleaned-up version is on your clipboard a few seconds later. I keep three variants pinned: Polish, Summarize, and Translate. They differ only in the mode value embedded in the JSON.

One small detail on the Translate recipe: if you preserve newlines through the proxy by adding "Keep line breaks intact" to the system prompt, bullet lists translate without collapsing into a single paragraph. Edits like this happen in one Worker file and are live on every device the next second — no Shortcut redeploy needed.

Three things that bit me in real-world use

1. Long inputs make Shortcuts look frozen

A 2,000-character input to Sonnet can take 5–10 seconds to come back, and Shortcuts shows nothing during the wait. The first week I assumed the recipe was broken and triggered the share sheet three times in a row, generating duplicate API calls I did not want to pay for. Fix: I added a "Show Notification: Working…" action right before the URL fetch. It is dumb but it works — once you see "the action started" you stop double-tapping.

2. Hidden characters from Notes break JSON parsing

iOS Notes embeds invisible rich-text artifacts that can corrupt the JSON body. Symptom: the Worker rejects the request with a JSON parse error and you stare at the recipe wondering what changed. Fix: insert a "Replace Text" action that strips zero-width spaces (U+200B) and BOM characters (U+FEFF) before serializing. I lost two hours to this; you should not.

3. One token = bad blast radius

I started with a single SHORTCUT_TOKEN. Then I gave my partner the same Shortcut, and when she sold an old iPhone we realized the Shortcut went with it. Now I provision per-device tokens — SHORTCUT_TOKEN_MASAKI, SHORTCUT_TOKEN_FAMILY — and the Worker checks against an allow-list. Revoking one device is a one-line edit. This is the kind of thing you only get burned by once.

Recipes worth adding once the basics feel natural

Once Polish, Summarize, and Translate are wired up, adding a fourth or fifth recipe is just a new entry in SYSTEM_PROMPTS and a clone of the Shortcut. These are the ones I use daily:

  • Task splitmode=split with a system prompt like "Extract concrete next actions from the input as a bulleted list of at most five items." Turns rambling notes into a clean to-do.
  • Title candidatesmode=titles returns three to five headline options for a draft. I use this for App Store promotional text more than for blog posts now.
  • Meeting follow-upsmode=followups separates "decisions made" and "action items" from a transcript. Pasting the result into Notes finishes half of my meeting minutes.

The title candidates recipe pairs nicely with Mastering Claude API Structured Output — JSON Mode and Tool Use if you want JSON-shaped responses. With JSON output you can return a title plus three description variants in one call, and the Shortcut can populate multiple clipboard targets.

What to do next

If you already have an iPhone, the whole setup takes about 30 minutes. Sign up for Cloudflare, deploy the Worker, build one Shortcut, and live with just the Polish recipe for a day. That single recipe is enough to convince you whether the friction of switching to the Claude app was actually slowing you down. After a week, add a second mode by appending one entry to SYSTEM_PROMPTS. I was up to five within ten days.

Keeping the API key off the phone is the part that quietly matters. The day you want to share the same recipe with a partner, family member, or teammate, the proxy lets you hand over the convenience without handing over the key — that is a small architectural choice with a big peace-of-mind payoff.

Share

Thank You for Reading

Claude Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • Copy-paste ready implementation code
  • New advanced guides published daily
  • $5/mo or $10 for lifetime access
View Membership →

If you found this article helpful, a small tip ($1.50) would mean a lot to us. Your support helps keep this site ad-free and covers server and hosting costs.

Related Articles

API & SDK2026-05-23
Absorbing the Claude API "Tool Result Submitted" Error in a Retry Layer: A Small Conversation-History Repair
How I absorbed the Claude API "Tool result could not be submitted because the previous turn was not a tool use" error inside a small retry layer, with the diagnosis order I followed after it hit a production batch.
API & SDK2026-05-13
Design Decisions Every Indie Developer Faces When Integrating Claude API into Mobile Apps
A practical guide to the design decisions that indie mobile developers face when integrating Claude API — covering model selection, async UX patterns, context management, offline resilience, and cost control, drawn from 10+ years of personal app development experience.
API & SDK2026-05-02
Building a Budget Circuit Breaker for Claude API in Production — Auto-Halt When Daily Token Spend Exceeds Your Cap
A practical guide to enforcing daily and monthly Claude API budget caps in production. Includes copy-paste Cloudflare Workers + KV / Durable Objects code, three response strategies (halt, degrade, alert), and the operational habits that keep the breaker honest.
📚RECOMMENDED BOOKS
Build a Large Language Model (From Scratch)
Sebastian Raschka
LLM Dev
Prompt Engineering for LLMs
Berryman & Ziegler
Prompting
AI Engineering
Chip Huyen
AI Eng
* Contains affiliate links
See all →