Why We Treat Claude Code Routines as Infrastructure — Not Prompts — And the 12 Reusable Workflows That Run Our Stack
Routines are versioned, shareable, CI-tested agent workflows (YAML), not prompt snippets. We built 12 Routines for scaffold-api, fix-tests, migrate-db, refactor-ts, and cut greenfield feature time 35%. Here's the library.
Published 2026-06-15
Why We Treat Claude Code Routines as Infrastructure — Not Prompts — And the 12 Reusable Workflows That Run Our Stack
TL;DR: Claude Code Routines are YAML-defined, version-controlled agent workflows — not chat prompts. We built 12 Routines (scaffold-api, fix-tests, migrate-db, refactor-ts, etc.) that encode our verification loops as infrastructure. Greenfield feature time: 45 min → 12 min. Routine library →
The Context
Two-dev team, Basso Digital. June 2026: Anthropic revealed Claude Code writes 80%+ of their merged code using Routines. Key insight: Routines ≠ prompts. Prompts are ephemeral; Routines are:
- Version-controlled (
.claude/routines/in git) - Parameterized (accept args:
cc routine scaffold-api "payments webhook") - Composable (call other Routines:
fix-testscalled byscaffold-api) - Testable (CI runs Routine regression suite weekly)
What We Tested
| Approach | Reusability | Version Control | Composability | Verdict |
|---|---|---|---|---|
| Chat prompts (copied from Notion) | ❌ Copy-paste drift | ❌ | ❌ | ❌ |
| Custom scripts (bash/python) | ✅ | ✅ | ⚠️ Manual | ⚠️ |
| Claude Code Routines (YAML) | ✅ Native | ✅ Git | ✅ run: routine:name | ✅ |
| Cursor Composer templates | ⚠️ JSON only | ✅ | ❌ | ❌ |
| Windsurf Cascade workflows | ⚠️ UI-bound | ❌ | ⚠️ | ❌ |
The Pivot Point
June 8, 2026: Built scaffold-api Routine for payments webhook. 12 min (spec → routes → handler → validation → tests → verify). Next feature (user notifications): 11 min (same Routine, different spec). Third feature (webhook retry logic): 9 min. Routine paid for itself in 3 uses. Realization: Every repeatable workflow deserves a Routine. Prompt engineering → Routine engineering.
What We Use Now
Routine Library (.claude/routines/, 12 files, all version-controlled):
| Routine | Purpose | Avg Time Saved | Calls |
|---|---|---|---|
scaffold-api.yaml | Spec → route + handler + validation + tests + verify | 35 min | fix-tests |
fix-tests.yaml | Auto test-fix loop (run → analyze → patch → re-run ×5) | 30 min | — |
migrate-db.yaml | Supabase migration + seed + integration tests + rollback | 25 min | fix-tests |
refactor-ts.yaml | TypeScript refactor with LSP-aware edits (delegates to Cursor) | 20 min | — |
add-webhook.yaml | Stripe webhook + idempotency + signature verify + tests | 30 min | scaffold-api, fix-tests |
add-auth.yaml | Auth endpoint + middleware + JWT + RBAC + tests | 25 min | scaffold-api, fix-tests |
add-job.yaml | Background job (Inngest/Vercel) + handler + retry + tests | 20 min | scaffold-api, fix-tests |
update-deps.yaml | Dependency update + test + fix breaking changes | 40 min | fix-tests |
docs-api.yaml | Generate OpenAPI + README + Postman collection | 15 min | — |
perf-audit.yaml | Profile endpoint → identify N+1 → patch → verify | 30 min | fix-tests |
security-scan.yaml | SAST + dep audit + secret scan → fix findings | 20 min | fix-tests |
release-prep.yaml | Changelog + version bump + tag + deploy verify | 10 min | — |
Routine Structure (all follow this pattern):
# .claude/routines/scaffold-api.yaml
name: scaffold-api
version: "1.3.0"
description: "Generate API endpoint + handler + validation + tests + verify"
parameters:
- name: spec
type: string
required: true
description: "Natural language spec or path to OpenAPI fragment"
- name: auth
type: boolean
default: true
description: "Include auth middleware"
allowedTools: ["Bash", "Edit", "Write", "Read", "Glob", "Grep", "Task"]
steps:
- generate: "route + handler + zod schema from {{spec}}"
- generate: "unit tests (happy + edge + auth)"
- generate: "integration test (DB + auth)"
- run: "routine:fix-tests" # composable!
- verify: "pnpm test --filter=api --reporter=json"
- on_failure: "routine:fix-tests --max-iter=3"
CI Integration (.github/workflows/routine-regression.yml):
name: Routine Regression
on: [push, schedule: "0 2 * * 1"] # weekly
jobs:
test-routines:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: pnpm install
- name: Test fix-tests routine
run: cc routine fix-tests --test-file=tests/sample-failing.test.ts
- name: Test scaffold-api routine
run: cc routine scaffold-api "GET /health returns {status: ok}"
Team Protocol:
- New repeatable workflow → write Routine (not prompt)
- Routine PRs require: description, params, example invocation, regression test
- Weekly:
cc routine list --stats→ retire unused, merge duplicates - Quarterly: Routine audit — “Does this still match our stack?”
When You’d Choose Differently
- One-off / exploratory work: Prompts faster; Routine overhead not worth it.
- Teams without test suite:
fix-testsRoutine amplifies gaps; build tests first. - Non-Claude Code users: Cursor/Windsurf lack native Routine equivalent (Composer templates not composable).
Tool Crucible Rating
| Dimension | Rating (1–5) | Notes |
|---|---|---|
| Overall | 5 | Routines are the 2026 moat; prompt engineering is dead |
| Ease of Use | 3 | YAML learning curve; debugging Routine logic non-trivial |
| Value | 5 | Compounding: each Routine pays off forever |
| Support | 2 | Zero official docs; community reverse-engineered |
This is part of our AI Coding Tool Evaluation series. See Routine library: Claude Code Routines: 12 Production-Ready Workflows
Last reviewed 2026-06-15. See our methodology and affiliate policy.