Why We Codify Repetitive AI Workflows as Claude Code Routines — The 5-Hour Migration That Now Runs in 20 Minutes
Claude Code's cloud Routines (launched June 2026) capture terminal-autonomous patterns as reusable YAML. We turned our Stripe migration, auth refactor, and greenfield API patterns into Routines — cutting repeat work 90%. Here's the library.
Published 2026-06-10
Why We Codify Repetitive AI Workflows as Claude Code Routines — The 5-Hour Migration That Now Runs in 20 Minutes
TL;DR: Claude Code Routines (cloud, launched June 2026) let you save terminal-autonomous workflows as versioned YAML with sub-agent orchestration. We codified 3 patterns (Stripe migration, auth refactor, greenfield API) — repeat runs went from 3–5 hrs to 15–25 min. Routines are the force multiplier for terminal-autonomous mode. Routine library →
The Context
Two-dev team, 5 codebases. June 2026: Using cc (Claude Code) for terminal-autonomous mode (greenfield, infra, auth, migrations). Problem: Each similar task required re-explaining context, re-specifying allow-lists, re-orchestrating sub-agents. May 2026: Stripe webhook migration (14 files) took 2.8 hrs first run. Second similar migration (different provider) took 2.5 hrs — 80% same steps. June 15: Anthropic launches Routines — cloud-saved, versioned workflow definitions with sub-agent specs, allow-lists, and context priming.
What We Tested
| Approach | Repeat Task Time | Setup Overhead | Consistency | Verdict |
|---|---|---|---|---|
Ad-hoc cc each time | 2.5–5 hrs | High (re-explain, re-configure) | Low (drift) | ❌ Baseline |
| Saved prompts in Notion | 2–4 hrs | Medium (copy-paste, manual terminal) | Medium | ⚠️ Better but manual |
| Claude Code Routines (YAML, cloud) | 15–25 min | Zero (one-click load) | High (versioned, reviewed) | ✅ Winner |
Custom scripts + cc --resume | 1–2 hrs | High (maintenance) | Medium | ❌ Fragile |
The Pivot Point
June 18, 2026: Second Stripe-like migration (Paddle webhooks). Ad-hoc cc: estimated 2.5 hrs. Loaded stripe-migration Routine (created from first run): completed in 18 minutes. Routine included: sub-agent A (file edits), sub-agent B (prisma migrate + verification), sub-agent C (test generation + run), allow-list (prisma, npm, git, stripe CLI), context prime (schema, existing webhook pattern, test fixtures). Realization: Routines aren’t just “saved prompts” — they’re executable workflow specs with tool allow-lists, sub-agent topology, and context serialization. The force multiplier for terminal-autonomous mode.
What We Use Now
Routine Library (~/.claude-code/routines/, synced to team via .toolcrucible/routines/):
1. stripe-migration.yaml (and paddle-migration.yaml variant)
name: stripe-migration
version: 3
description: "Webhook migration: spec → route + handler + tests + migration + verification"
context_prime:
- "schemas/webhook-events.json"
- "src/webhooks/stripe/*.ts"
- "tests/fixtures/stripe-events.json"
sub_agents:
- name: file-editor
task: "Edit 10–15 files per spec. Follow existing patterns exactly."
allowed_tools: [read, write, edit, glob, grep]
- name: infra-runner
task: "Run prisma migrate dev, verify schema, seed test data."
allowed_tools: [bash: "prisma migrate dev", "prisma generate", "npm run seed:test"]
- name: test-generator
task: "Generate vitest cases for each webhook event. Run until pass."
allowed_tools: [read, write, bash: "npm test -- --run"]
hooks:
pre: "git stash -u && git checkout -b migrate/webhook-{{provider}}-{{date}}"
post: "npm test && git add -A && git commit -m 'migrate: {{provider}} webhooks via routine'"
2. auth-refactor.yaml
name: auth-refactor
version: 2
description: "JWT middleware → row-level security → token refresh → test matrix"
context_prime:
- "src/auth/*.ts"
- "src/middleware/auth.ts"
- "infra/supabase/rls-policies.sql"
sub_agents:
- name: middleware-editor
task: "Refactor auth middleware. Preserve JWT claims. Add RLS context."
allowed_tools: [read, write, edit]
blocked_paths: ["payments/", "billing/"] # Safety gate
- name: db-policy-writer
task: "Write Supabase RLS policies per table. Test with anon + authenticated roles."
allowed_tools: [read, write, bash: "supabase db push --dry-run"]
- name: test-matrix
task: "Generate auth matrix tests: valid/expired/malformed tokens, RLS bypass attempts."
allowed_tools: [read, write, bash: "npm test -- --run auth"]
3. greenfield-api.yaml
name: greenfield-api
version: 4
description: "OpenAPI spec → routes + handlers + validation + tests + docs + migration"
context_prime:
- "openapi/spec.yaml"
- "src/routes/*.ts"
- "src/db/schema.prisma"
sub_agents:
- name: route-generator
task: "Generate Hono routes from OpenAPI. Zod validation. Follow existing patterns."
allowed_tools: [read, write, edit, glob]
- name: handler-writer
task: "Implement handlers. Use service layer. No business logic in routes."
allowed_tools: [read, write, edit]
- name: migration-creator
task: "Create Prisma migration from spec changes. Run in dev. Verify rollback."
allowed_tools: [read, write, bash: "prisma migrate dev --name {{feature}}"]
- name: test-suite
task: "Contract tests from OpenAPI. Unit tests for services. E2E for happy paths."
allowed_tools: [read, write, bash: "npm test -- --run"]
Team workflow:
# Launch routine (tab-completes from ~/.claude-code/routines/)
cc routine run stripe-migration --provider=paddle --date=2026-06-20
# Or with custom context
cc routine run auth-refactor --context-file=./PRD-auth-v2.md
Version control: Routines committed to .toolcrucible/routines/. PR review required for changes. cc routine push syncs to cloud.
When You’d Choose Differently
- One-off / never-repeating tasks: Ad-hoc
ccfaster than writing Routine (15 min authoring overhead). - Teams without terminal-autonomous mode: If you use Cursor/Windsurf for everything, Routines don’t apply (no terminal autonomy).
- Strict local-only: Routines are cloud-synced; local alternative = saved prompt files + shell aliases (no sub-agent orchestration).
- Highly variable tasks: If no two migrations look alike, Routine maintenance > value.
Tool Crucible Rating
| Dimension | Rating (1–5) | Notes |
|---|---|---|
| Overall | 4.5 | Force multiplier for terminal-autonomous; unique in market |
| Ease of Use | 3 | YAML authoring learning curve (~2 hrs); cloud sync opaque |
| Value | 5 | 90% time reduction on repeat patterns; compounds across team |
| Support | 2 | Docs minimal; Discord only; versioning UI limited |
This is part of our AI Coding Tool Evaluation series. See full routine library: Claude Code Routines Library 2026: Executable Workflow Specs for Terminal-Autonomous Mode
Last reviewed 2026-06-10. See our methodology and affiliate policy.