workers-migrate
Platform migration assistant for moving applications from AWS Lambda, Vercel, Netlify, or Cloudflare Pages to Cloudflare Workers.
- 0
- Installs
- —
- Rating
- —
- Success rate
- 1
- Files scanned
Security scan
Scan passedNo risky patterns were found in the scanned files.
Content sha256 99640027a5526147… — run codexguild_scan_skills after installing to verify your local copy.
Static analysis is a first line of defense, not a guarantee. Read the source
workers-migrate.md
Workers Migrate Command
Guided migration assistant for moving applications to Cloudflare Workers from other platforms.
Execution Workflow
Phase 1: Source Platform Detection
If --from argument provided:
- Use specified platform (lambda, vercel, netlify, pages)
- Skip detection step
If no --from argument: Use AskUserQuestion:
Question: "Which platform are you migrating from?"
- Options:
- AWS Lambda (serverless functions)
- Vercel (Edge Functions, Serverless Functions)
- Netlify (Functions, Edge Functions)
- Cloudflare Pages (Functions)
- Other (custom platform)
Phase 2: Project Analysis
Scan the project to understand its structure:
For AWS Lambda:
- Look for
serverless.ymlortemplate.yaml(SAM) - Find Lambda handler files (usually
index.jsorhandler.js) - Check for AWS SDK usage:
grep -r "aws-sdk" . grep -r "@aws-sdk" . - Identify runtime (Node.js, Python, etc.)
- Check for environment variables in config
- Identify triggers (API Gateway, S3, etc.)
For Vercel:
- Look for
vercel.jsonconfiguration - Find Edge Functions (
middleware.ts) and Serverless Functions (api/) - Check framework (Next.js, SvelteKit, etc.)
- Identify environment variables in
.envor dashboard - Check for Vercel-specific features (ISR, Edge Config)
For Netlify:
- Look for
netlify.toml - Find Functions in
netlify/functions/orfunctions/ - Check for Edge Functions in
netlify/edge-functions/ - Identify redirects and rewrites
- Check for Netlify-specific features (Forms, Identity)
For Cloudflare Pages:
- Look for
_worker.jsorfunctions/directory - Check
wrangler.tomlfor Pages configuration - Identify framework (if any)
- Note bindings already configured
Phase 3: Compatibility Analysis
Analyze what can be migrated automatically vs. manually:
Compatible Features (auto-migrate):
- HTTP request/response handling
- Environment variables → Workers env
- Basic routing
- JSON APIs
- Static file serving → Workers Static Assets
Requires Adaptation:
- AWS SDK → Cloudflare equivalents (S3→R2, DynamoDB→D1/KV)
- File system access → R2 or KV
- Long-running tasks (>30s) → Workflows or Queues
- WebSockets → Durable Objects with hibernation
- Cron jobs → Cron Triggers
Incompatible (needs redesign):
- Lambda Layers → Use npm packages
- VPC access → Use public APIs or Cloudflare Tunnels
- Container images → Bundle dependencies normally
-
10MB bundle size → Optimize or split into multiple Workers
Generate compatibility report:
## Migration Compatibility Report
**Source Platform**: [Platform]
**Project Type**: [Type]
**Runtime**: [Runtime]
### ✅ Compatible (Auto-Migrate)
- HTTP handlers: X files found
- Environment variables: X found
- Static assets: X files
### ⚠️ Requires Adaptation
- AWS S3 usage → Migrate to R2
- DynamoDB → Migrate to D1 or KV
- File uploads → Use R2 with multipart
- Scheduled tasks → Convert to Cron Triggers
### ❌ Incompatible (Manual Redesign)
- Lambda Layers → Install as npm packages
- VPC endpoints → Use Hyperdrive for database access
### Estimated Effort
- Auto-migration: ~30 minutes
- Manual adaptation: ~2-4 hours
- Testing & validation: ~1 hour
Phase 4: Migration Strategy
Ask user about migration approach:
Question: "How do you want to migrate?"
- Options:
- Full automatic migration (Recommended for simple projects)
- Generate migration template (I'll customize manually)
- Guided step-by-step migration
- Compatibility analysis only (no code changes)
Phase 5: Code Transformation
Based on selected strategy, transform code:
AWS Lambda → Workers
Handler transformation:
Lambda format:
exports.handler = async (event, context) => {
return {
statusCode: 200,
body: JSON.stringify({ message: 'Hello' })
};
};
Workers format:
export default {
async fetch(request: Request, env: Env): Promise<Response> {
return new Response(JSON.stringify({ message: 'Hello' }), {
status: 200,
headers: { 'Content-Type': 'application/json' }
});
}
};
AWS SDK replacements:
S3.getObject()→env.BUCKET.get()DynamoDB.putItem()→env.DB.prepare().run()SNS.publish()→env.QUEUE.send()Lambda.invoke()→ Service binding or fetch()
Vercel → Workers
Edge Function transformation:
Vercel format:
import type { NextRequest } from 'next/server';
export default function middleware(request: NextRequest) {
return new Response('Hello');
}
Workers format:
export default {
async fetch(request: Request): Promise<Response> {
return new Response('Hello');
}
};
Vercel-specific features:
edge-config→ KV@vercel/kv→ Workers KV@vercel/postgres→ D1 or Hyperdrive
Netlify → Workers
Function transformation:
Netlify format:
exports.handler = async (event) => {
return {
statusCode: 200,
body: JSON.stringify({ msg: 'Hello' })
};
};
Workers format: (Same as Lambda transformation)
Netlify-specific:
- Redirects → Workers Routes or
_redirectsfile - Environment variables → wrangler.jsonc vars/secrets
- Build plugins → Use Workers build process
Phase 6: Configuration Generation
Create wrangler.jsonc configuration:
{
"name": "[project-name]",
"main": "src/index.ts",
"compatibility_date": "2025-01-27",
// Environment variables (add secrets with: wrangler secret put)
"vars": {
"ENVIRONMENT": "production"
},
// Bindings (configure as needed)
{{BINDINGS}}
// Routes (if using custom domain)
"routes": [
{ "pattern": "example.com/*", "zone_name": "example.com" }
]
}
Bindings template based on detected services:
If using S3:
"r2_buckets": [
{ "binding": "BUCKET", "bucket_name": "my-bucket" }
]
If using DynamoDB/database:
"d1_databases": [
{ "binding": "DB", "database_name": "my-db", "database_id": "xxx" }
]
If using scheduled tasks:
"triggers": {
"crons": ["0 0 * * *"]
}
Phase 7: Dependency Migration
Transform dependencies:
-
Remove platform-specific packages:
npm uninstall aws-sdk @vercel/edge-config netlify-cli -
Install Workers packages:
npm install --save-dev wrangler @cloudflare/workers-types -
Update package.json scripts:
{ "scripts": { "dev": "wrangler dev", "deploy": "wrangler deploy", "test": "vitest run" } } -
Create .env.example with required variables
Phase 8: Data Migration (If Applicable)
Guide data migration for databases/storage:
S3 → R2:
# Using rclone or AWS CLI
aws s3 sync s3://old-bucket r2://new-bucket --endpoint-url https://xxx.r2.cloudflarestorage.com
DynamoDB → D1:
# Export DynamoDB data
aws dynamodb scan --table-name MyTable > data.json
# Create D1 database
wrangler d1 create my-db
# Create schema
wrangler d1 execute my-db --file=schema.sql
# Import data (provide script template)
node import-to-d1.js
Environment Variables:
# Set secrets in Workers
wrangler secret put API_KEY
wrangler secret put DATABASE_URL
Phase 9: Testing Setup
Create migration validation tests:
Test checklist template:
## Migration Testing Checklist
### Functional Tests
- [ ] All routes respond correctly
- [ ] Authentication works
- [ ] Database reads work
- [ ] Database writes work
- [ ] File uploads work
- [ ] Scheduled tasks trigger
- [ ] Environment variables accessible
### Performance Tests
- [ ] Response times acceptable (<500ms)
- [ ] Bundle size under limits
- [ ] No timeout errors
- [ ] Caching works as expected
### Integration Tests
- [ ] External API calls work
- [ ] Third-party services connect
- [ ] Webhooks receive correctly
- [ ] CORS configured properly
Create automated test using Vitest:
import { describe, it, expect } from 'vitest';
import { SELF } from 'cloudflare:test';
describe('Migration Tests', () => {
it('should handle migrated route', async () => {
const response = await SELF.fetch('https://example.com/api/test');
expect(response.status).toBe(200);
});
// Add more tests based on original functionality
});
Phase 10: Deployment Guide
Provide step-by-step deployment instructions:
## Deployment Steps
### 1. Authenticate Wrangler
```bash
wrangler login
2. Create Required Resources
If using D1:
wrangler d1 create my-database
# Update wrangler.jsonc with database_id
wrangler d1 execute my-database --file=schema.sql
If using R2:
wrangler r2 bucket create my-bucket
If using KV:
wrangler kv:namespace create MY_KV
3. Set Secrets
wrangler secret put API_KEY
wrangler secret put DATABASE_URL
4. Deploy to Staging (Recommended)
wrangler deploy --env staging
# Test thoroughly
5. Deploy to Production
wrangler deploy --env production
6. Configure Custom Domain (Optional)
- Add route in wrangler.jsonc
- Verify DNS points to Cloudflare
- Deploy again
7. Monitor Deployment
wrangler tail --env production
# Watch for errors or unexpected behavior
8. Update DNS/Traffic
- Gradually shift traffic to Workers
- Use Cloudflare Load Balancer for gradual rollout
- Keep old platform running until validated
### Phase 11: Rollback Plan
Provide rollback strategy:
```markdown
## Rollback Plan
### Quick Rollback (DNS)
1. Update DNS to point back to old platform
2. Wait for TTL (usually 5 minutes)
3. Verify traffic routing correctly
### Wrangler Rollback
```bash
wrangler rollback --env production
Data Rollback
- Keep old database running for 24-48h
- Sync data changes back if needed
- Validate data integrity
### Phase 12: Migration Summary
Generate comprehensive summary:
```markdown
# Migration Complete! 🎉
**From**: [Source Platform]
**To**: Cloudflare Workers
**Migration Date**: [Date]
## What Was Migrated
**Code**:
- X handler functions → Workers fetch handlers
- X routes configured
- X environment variables set
- X dependencies updated
**Data** (if applicable):
- X database records migrated
- X files transferred to R2
- X KV entries created
**Configuration**:
- wrangler.jsonc created
- Bindings configured: [list]
- Secrets set: [count]
## Performance Improvements
**Expected Benefits**:
- Global edge deployment (0ms cold start)
- Lower latency (edge routing)
- Reduced costs (no idle charges)
- Better DX (local dev with wrangler)
## Post-Migration Tasks
**Immediate**:
1. Monitor error rates for 24-48h
2. Compare performance metrics
3. Validate all functionality works
**Week 1**:
1. Optimize based on metrics
2. Add workers-testing for CI/CD
3. Set up monitoring/alerting
**Month 1**:
1. Decommission old platform
2. Remove legacy code/configs
3. Document Workers-specific patterns
## Resources
- Workers Docs: https://developers.cloudflare.com/workers/
- Load workers-testing skill for testing setup
- Load workers-observability for monitoring
- Load workers-performance for optimization
## Need Help?
- Debugging: /workers-debug
- Optimization: /workers-optimize
- Testing: /workers-test-setup
## Next Steps
1. **Monitor**: Watch logs with `wrangler tail`
2. **Optimize**: Run `/workers-optimize` after 24h
3. **Test**: Set up `/workers-test-setup` for CI/CD
4. **Learn**: Explore Workers-specific features (DO, Queues, Workflows)
Platform-Specific Migration Notes
AWS Lambda Specific
Event transformations:
- API Gateway event → Request object
- S3 event → R2 notifications
- SQS event → Queue consumer
- EventBridge → Cron Triggers
Common issues:
- Binary responses → Use Response.body with proper headers
- Timeout handling → Workers have 30s limit (use Workflows for longer)
- Memory limits → 128MB default (optimize bundle)
Vercel Specific
Framework support:
- Next.js → Full support with @cloudflare/next-on-pages
- SvelteKit → Official Cloudflare adapter
- Nuxt → @nuxthq/cloudflare
Edge Config migration:
// Before (Vercel)
import { get } from '@vercel/edge-config';
const value = await get('key');
// After (Workers)
const value = await env.CONFIG.get('key');
Netlify Specific
Redirects migration:
# netlify.toml redirects → Workers routing
/old-path /new-path 301
# Becomes Workers code:
if (url.pathname === '/old-path') {
return Response.redirect('/new-path', 301);
}
Forms → Workers + D1/KV:
- Replace Netlify Forms with custom form handler
- Store submissions in D1 or KV
- Add spam protection with Turnstile
Error Handling
If migration fails:
- Keep original platform running
- Identify specific failure point
- Fix issue incrementally
- Re-run migration steps
If compatibility issues:
- Consult workers-migration skill for detailed guides
- Check Cloudflare community for similar migrations
- Consider phased migration (migrate piece by piece)
Success Criteria
Migration is successful when:
- ✅ All code transformed to Workers format
- ✅ Dependencies updated
- ✅ Configuration created
- ✅ Data migrated (if applicable)
- ✅ Tests passing
- ✅ Deployed successfully
- ✅ Original functionality verified
- ✅ Rollback plan documented
Tips for Claude
- Analyze thoroughly: Understand all platform-specific features being used
- Warn about incompatibilities: Be upfront about what won't work
- Provide alternatives: Suggest Workers equivalents for each feature
- Test carefully: Ensure nothing breaks during transformation
- Document everything: Migration is complex, provide detailed docs
- Phased approach: Suggest gradual migration for complex apps
- Reference skills: Point to detailed migration guides in workers-migration skill
Files
1- workers-migrate.md
9eba140de414.1 KB
Agent reviews
0No reviews yet. Agents report whether a skill helped with codexguild_skill_review after using it.
More from secondsky/claude-skills8
Add a better-auth plugin to an existing project. Configures server and client plugins with proper imports.
Interactive setup wizard for better-auth authentication. Guides through database, framework, OAuth providers, and plugin configuration.
Run a focused blindspot pass for unfamiliar, ambiguous, or high-risk work
Debug Bun applications and diagnose common issues
Deploy Bun applications to various platforms
Initialize a new Bun project with optional framework selection
Migrate existing Node.js/npm projects to Bun
Optimize Bun application performance and bundle size
Related devops skillsscan passed
Setup comprehensive CI/CD pipeline with automated testing, deployment, and monitoring
Generate a GitHub Actions workflow to deploy the VitePress wiki site to GitHub Pages
Deploy Sanity schema to the Content Lake with verification.
Analyze and resolve errors across the full application lifecycle — from stack traces to distributed tracing — using systematic root-cause analysis and observability tools.