cf-worker-modular-architecture

cf-worker-modular-architecture is a skill for Claude Code, Codex from humanerd-drew/opencode-drewgent. It costs 48 tokens per session (1,862 once invoked), scanned A, original, MIT.

A software architecture guide for organising Cloudflare Workers into a router, controllers, computation logic, utilities, and shared data. It describes a repeatable way to split large Worker files.

In plain words
What is it for?
Use it when a Worker has grown large or serves several API areas, and you need to separate responsibilities while checking each change during development.
Why use it?
It helps prevent request handling, business logic, and shared utilities from becoming tangled in one file.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it when a Worker has grown large or serves several API areas, and you need to separate responsibilities while checking each change during development.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/humanerd-drew/opencode-drewgent/cf-worker-modular-architecture
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add humanerd-drew/opencode-drewgent --skill cf-worker-modular-architecture
Clone the repo
git clone --depth 1 https://github.com/humanerd-drew/opencode-drewgent

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for cf-worker-modular-architecture

README.md
[![agentmods](https://agentmods.dev/badge/skills/humanerd-drew/opencode-drewgent/cf-worker-modular-architecture/github.svg)](https://agentmods.dev/skills/humanerd-drew/opencode-drewgent/cf-worker-modular-architecture)
Your own site
<a href="https://agentmods.dev/skills/humanerd-drew/opencode-drewgent/cf-worker-modular-architecture"><img src="https://agentmods.dev/badge/skills/humanerd-drew/opencode-drewgent/cf-worker-modular-architecture/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for cf-worker-modular-architecture

Your own site · 80×15
<a href="https://agentmods.dev/skills/humanerd-drew/opencode-drewgent/cf-worker-modular-architecture"><img src="https://agentmods.dev/badge/skills/humanerd-drew/opencode-drewgent/cf-worker-modular-architecture.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 48 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,862 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00048 $0.01862
Opus 5.5 $0.00019 $0.00745
Sonnet 5.5 $0.00010 $0.00372
Haiku 4.5 $0.00005 $0.00186

Measured 2mo ago against content hash cf483e1745fc, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

cf-worker-modular-architecture scanned grade A with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

- One change at a time — make the change, watch for wrangler auto-reload, verify with curl, then proceed.
skills/software-development/cf-worker-modular-architecture/SKILL.md · 145 lines

How it starts

The opening of the file, as written. The whole thing — 145 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Cloudflare Worker Modular Architecture

When a Worker grows beyond 300-500 lines, refactor into: Router → Controllers → Engine → Utilities

Workflow Protocol

  • Never commit without user review. Stage changes (git add -A) and present the diff or summary. Wait for explicit approval before git commit.
  • Run npm run dev and verify the app works after each batch of changes.
  • One change at a time — make the change, watch for wrangler auto-reload, verify with curl, then proceed.
  • When dev server crashes (port conflict / SQLITE_BUSY): kill old process, clear .wrangler/state/v3/d1/, restart.

Layers

  • worker.ts (router, ~100-200 lines): URL matching → dispatch to controller. No business logic.
  • controllers/: export handle*(request, env, url): Promise<Response>. Single responsibility.
  • engine/ or analysis/: Pure computation, no HTTP, deterministic.
  • utils/: Shared helpers (llm, crypto, cors, email)
  • data/: Static JSON master data

Key Rules

Controller Pattern

  • All controllers share the same signature (request, env, url): Promise<Response>
  • Export individual handler functions, not class instances
  • Import shared utilities from ../utils/

External API Isolation (PDC Principle)

  • Never recalculate what an external API already provides. Pipe it through and transform format only.
  • Example: PersonalDateCalculator returns tenGods, daewoon.direction, wolun[]. Use those values directly rather than recalculating from raw pillars.
  • The external API is the single source of truth for core domain calculations. Your engine should only compute what the API doesn't provide.
  • Pitfall: Duplicating calculation logic creates maintenance burden and subtle drift when the external API gets bug fixes.

LLM Caller Consolidation

  • Don't duplicate LLM call logic across controllers. One utils/llm.ts with:
    • callDeepSeek() — primary
    • callNvidiaWithFallback() — 3-key fallback (NIM_KEY → FALLBACK → FALLBACK_2)
    • callLLMJson() — DeepSeek → NVIDIA + JSON extraction
    • 28s per-key timeout to stay under Cloudflare's 30s wall limit
  • Each LLM endpoint (report generation, polish, analysis) builds its own system prompt but calls through the same utility.

Read the full file on GitHub · 145 lines

Files

What ships with it

2 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2mo ago First seen · 145 lines · 48 tokens per session scan A cf483e1745fc

Subscribe to this mod's changes

cf-worker-modular-architecture is a skill published in the GitHub repository humanerd-drew/opencode-drewgent (3 stars, last pushed 3mo ago), licensed MIT. It adds 48 tokens to every session and 1,862 once invoked, about $0.0002 per session on Opus 5.5. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.

Related

cf-worker-modular-architecture compared with skills from other repositories

cf-worker-modular-architecture next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
cf-worker-modular-architecturehumanerd-drew/opencode-drewgentSkill33mo agoMITA48Claude Code, Codex
architecture-paradigm-microservicesathola/claude-night-marketSkill348yesterdayMITA33Claude Code
architecture-paradigm-serverlessathola/claude-night-marketSkill348yesterdayMITA37Claude Code
release-itciembor/agent-rules-booksSkill3.2k1mo agoMITA34Claude Code, Codex
terraform-infrastructuresoulcodex/agenticSkill107d agoMITA96Claude Code, Codex
health-check-endpointssoulcodex/agenticSkill107d agoMITA58Claude Code, Codex
serverless-architecturesoulcodex/agenticSkill107d agoMITA62Claude Code, Codex