Cloudflare workers migration
Skill ComeOnOliver/skillshub/skills/secondsky/claude-skills/cloudflare-workers-migration
π§ The right skill, one API call. AI agent skills registry with token-efficient skill resolution. 5,000+ skills from 500+ top repos.
npx -y skills add ComeOnOliver/skillshub --skill cloudflare-workers-migrationAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
What its author says it does
Copied from the file, not written here
Migrate to Cloudflare Workers from AWS Lambda, Vercel, Express, and Node.js. Use when porting existing applications to the edge, adapting serverless functions, or resolving Node.js API compatibility issues.
The file declares its own license as MIT. That is the authorβs claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.
SKILL.md
5.2 KB, ~1.3k tokens by cl100k_base, as published. Nobody here has run it
Workers Migration Guide
Migrate existing applications to Cloudflare Workers from various platforms.
Migration Decision Tree
What are you migrating from?
βββ AWS Lambda
β βββ Node.js handler? β Lambda adapter pattern
β βββ Python? β Consider Python Workers
β βββ Container/custom runtime? β May need rewrite
βββ Vercel/Next.js
β βββ API routes? β Minimal changes with adapter
β βββ Full Next.js app? β Use OpenNext adapter
β βββ Middleware? β Direct Workers equivalent
βββ Express/Node.js
β βββ Simple API? β Hono (similar API)
β βββ Complex middleware? β Gradual migration
β βββ Heavy node: usage? β Compatibility layer
βββ Other Edge (Deno Deploy, Fastly)
βββ Standard Web APIs? β Minimal changes
βββ Platform-specific? β Targeted rewrites
Platform Comparison
| Feature | Workers | Lambda | Vercel | Express |
|---|---|---|---|---|
| Cold Start | ~0ms | 100-500ms | 10-100ms | N/A |
| CPU Limit | 50ms/10ms | 15 min | 10s | None |
| Memory | 128MB | 10GB | 1GB | System |
| Max Response | 6MB (stream unlimited) | 6MB | 4.5MB | None |
| Global Edge | 300+ PoPs | Regional | ~20 PoPs | Manual |
| Node.js APIs | Partial | Full | Full | Full |
Top 10 Migration Errors
| Error | From | Cause | Solution |
|---|---|---|---|
fs is not defined | Lambda/Express | File system access | Use KV/R2 for storage |
Buffer is not defined | Node.js | Node.js globals | Import from node:buffer |
process.env undefined | All | Env access pattern | Use env parameter |
setTimeout not returning | Lambda | Async patterns | Use ctx.waitUntil() |
require() not found | Express | CommonJS | Convert to ESM imports |
Exceeded CPU time | All | Long computation | Chunk or use DO |
body already consumed | Express | Request body | Clone before read |
Headers not iterable | Lambda | Headers API | Use Headers constructor |
crypto.randomBytes | Node.js | Node crypto | Use crypto.getRandomValues |
Cannot find module | All | Missing polyfill | Check Workers compatibility |
Quick Migration Patterns
AWS Lambda Handler
// Before: AWS Lambda
export const handler = async (event, context) => {
const body = JSON.parse(event.body);
return {
statusCode: 200,
body: JSON.stringify({ message: 'Hello' }),
};
};
// After: Cloudflare Workers
export default {
async fetch(request: Request, env: Env): Promise<Response> {
const body = await request.json();
return Response.json({ message: 'Hello' });
},
};
Express Middleware
// Before: Express
app.use((req, res, next) => {
if (!req.headers.authorization) {
return res.status(401).json({ error: 'Unauthorized' });
}
next();
});
// After: Hono Middleware
app.use('*', async (c, next) => {
if (!c.req.header('Authorization')) {
return c.json({ error: 'Unauthorized' }, 401);
}
await next();
});
Environment Variables
// Before: Node.js
const apiKey = process.env.API_KEY;
// After: Workers
export default {
async fetch(request: Request, env: Env): Promise<Response> {
const apiKey = env.API_KEY;
// ...
},
};
Node.js Compatibility
Workers support many Node.js APIs via compatibility flags:
// wrangler.jsonc
{
"compatibility_flags": ["nodejs_compat_v2"],
"compatibility_date": "2024-12-01"
}
Supported with nodejs_compat_v2:
crypto(most methods)buffer(Buffer class)util(promisify, types)stream(Readable, Writable)events(EventEmitter)path(all methods)string_decoderassert
Not Supported (need alternatives):
fsβ Use R2/KVchild_processβ Not possibleclusterβ Not applicabledgramβ Not supportednetβ Use fetch/WebSockettlsβ Handled by platform
When to Load References
| Reference | Load When |
|---|---|
references/lambda-migration.md | Migrating AWS Lambda functions |
references/vercel-migration.md | Migrating from Vercel/Next.js |
references/express-migration.md | Migrating Express/Node.js apps |
references/node-compatibility.md | Node.js API compatibility issues |
Migration Checklist
- Analyze Dependencies: Check for unsupported Node.js APIs
- Convert to ESM: Replace require() with import
- Update Env Access: Use env parameter instead of process.env
- Replace File System: Use R2/KV for storage
- Handle Async: Use ctx.waitUntil() for background tasks
- Test Locally: Verify with wrangler dev
- Performance Test: Ensure CPU limits aren't exceeded
See Also
workers-runtime-apis- Available APIs in Workersworkers-performance- Optimization techniquescloudflare-worker-base- Basic Workers setup
What ships with it
108.4 KB alongside SKILL.md, 5 of them executable
GitHub clipped this repositoryβs file list, so this is at least 9 files and may be more.
references/
- express-migration.md13.1 KB
- lambda-migration.md11.4 KB
- node-compatibility.md11.1 KB
- vercel-migration.md11.8 KB
scripts/
- analyze-migration.shruns13.6 KB
templates/
- express-adapter.tsruns11.8 KB
- lambda-adapter.tsruns10.4 KB
- node-compat.tsruns12.6 KB
- vercel-adapter.tsruns12.6 KB