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-tests called by scaffold-api)
  • Testable (CI runs Routine regression suite weekly)

What We Tested

ApproachReusabilityVersion ControlComposabilityVerdict
Chat prompts (copied from Notion)❌ Copy-paste drift
Custom scripts (bash/python)⚠️ Manual⚠️
Claude Code Routines (YAML)✅ Native✅ Gitrun: 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):

RoutinePurposeAvg Time SavedCalls
scaffold-api.yamlSpec → route + handler + validation + tests + verify35 minfix-tests
fix-tests.yamlAuto test-fix loop (run → analyze → patch → re-run ×5)30 min
migrate-db.yamlSupabase migration + seed + integration tests + rollback25 minfix-tests
refactor-ts.yamlTypeScript refactor with LSP-aware edits (delegates to Cursor)20 min
add-webhook.yamlStripe webhook + idempotency + signature verify + tests30 minscaffold-api, fix-tests
add-auth.yamlAuth endpoint + middleware + JWT + RBAC + tests25 minscaffold-api, fix-tests
add-job.yamlBackground job (Inngest/Vercel) + handler + retry + tests20 minscaffold-api, fix-tests
update-deps.yamlDependency update + test + fix breaking changes40 minfix-tests
docs-api.yamlGenerate OpenAPI + README + Postman collection15 min
perf-audit.yamlProfile endpoint → identify N+1 → patch → verify30 minfix-tests
security-scan.yamlSAST + dep audit + secret scan → fix findings20 minfix-tests
release-prep.yamlChangelog + version bump + tag + deploy verify10 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-tests Routine amplifies gaps; build tests first.
  • Non-Claude Code users: Cursor/Windsurf lack native Routine equivalent (Composer templates not composable).

Tool Crucible Rating

DimensionRating (1–5)Notes
Overall5Routines are the 2026 moat; prompt engineering is dead
Ease of Use3YAML learning curve; debugging Routine logic non-trivial
Value5Compounding: each Routine pays off forever
Support2Zero 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.