| name | workers-runtime-validator |
| description | Automatically validates Cloudflare Workers runtime compatibility during development, preventing Node.js API usage and ensuring proper Workers patterns |
| triggers | ["import statements","file creation","code changes","deployment preparation"] |
Workers Runtime Validator SKILL
Activation Patterns
This SKILL automatically activates when:
- New
.ts or .js files are created in Workers projects
- Import statements are added or modified
- Code changes include potential runtime violations
- Before deployment commands are executed
- When
process.env, require(), or Node.js APIs are detected
Expertise Provided
Runtime Compatibility Validation
- Forbidden API Detection: Identifies Node.js built-ins that don't exist in Workers
- Environment Access: Ensures proper
env parameter usage vs process.env
- Module System: Validates ES modules usage (no
require())
- Async Patterns: Ensures all I/O operations are async
- Package Compatibility: Checks npm packages for Node.js dependencies
Specific Checks Performed
❌ Critical Violations (Will Break in Production)
import fs from 'fs';
import { Buffer } from 'buffer';
const secret = process.env.API_KEY;
const data = require('./module');
✅ Correct Workers Patterns
import { z } from 'zod';
const secret = env.API_KEY;
const hash = await crypto.subtle.digest();
Integration Points
Complementary to Existing Components
- workers-runtime-guardian agent: Handles deep runtime analysis, SKILL provides immediate validation
- es-deploy command: SKILL prevents deployment failures by catching issues early
- validate command: SKILL provides continuous validation between explicit checks
Escalation Triggers
- Complex runtime compatibility questions →
workers-runtime-guardian agent
- Package dependency analysis →
edge-performance-oracle agent
- Migration from Node.js to Workers →
cloudflare-architecture-strategist agent
Validation Rules
P1 - Critical (Must Fix Immediately)
- Node.js Built-ins:
fs, path, os, crypto, process, buffer
- CommonJS Usage:
require(), module.exports
- Process Access:
process.env, process.exit()
- Synchronous I/O: Any blocking I/O operations
P2 - Important (Should Fix)
- Package Dependencies: npm packages with Node.js dependencies
- Missing Async: I/O operations without await
- Buffer Usage: Using Node.js Buffer instead of Uint8Array
P3 - Best Practices
- TypeScript Env Interface: Missing or incorrect Env type definition
- Web API Usage: Not using modern Web APIs when available
Remediation Examples
Fixing Node.js API Usage
import crypto from 'crypto';
const hash = crypto.createHash('sha256');
const encoder = new TextEncoder();
const hash = await crypto.subtle.digest('SHA-256', encoder.encode(data));
Fixing Environment Access
const apiKey = process.env.API_KEY;
export default {
async fetch(request: Request, env: Env) {
const apiKey = env.API_KEY;
}
}
Fixing Module System
const utils = require('./utils');
import { utils } from './utils';
MCP Server Integration
When Cloudflare MCP server is available:
- Query latest Workers runtime API documentation
- Check for deprecated APIs before suggesting fixes
- Get current compatibility information for new features
Benefits
Immediate Impact
- Prevents Runtime Failures: Catches issues before deployment
- Reduces Debugging Time: Immediate feedback on violations
- Educates Developers: Clear explanations of Workers vs Node.js differences
Long-term Value
- Consistent Code Quality: Ensures all code follows Workers patterns
- Faster Development: No need to wait for deployment to discover issues
- Better Developer Experience: Real-time guidance during coding
Usage Examples
During Code Creation
During Refactoring
Before Deployment
This SKILL ensures Workers runtime compatibility by providing immediate, autonomous validation of code patterns, preventing common migration mistakes and runtime failures.