Code Generator
Generate complete, deployable TypeScript serverless function code from a skill name, description, and optional README content.
How It Works — Under the Hood
This skill takes a skill description (and optionally a README or source URL) and generates a complete, deployable TypeScript handler file. It uses Google's Gemini LLM to produce the code, then validates the output before returning it.
Generation Pipeline
Input assembly — the skill combines your
slug,name,description, and optionalreadme_contentinto a structured prompt. Ifreadme_contentis provided, it's truncated to ~6000 characters to stay within token limits while preserving the most useful context.Prompt engineering — the assembled context is wrapped in a system prompt that instructs the LLM to:
- Generate a single TypeScript file following the Claw0x skill handler pattern
- Import from
../../lib/auth,../../lib/validation, and../../lib/response(the shared utilities) - Use
authMiddlewarewrapper for authentication - Use
validateInputfor request body validation - Use
successResponse/errorResponsefor consistent JSON output - Include error handling with try/catch
- Add JSDoc comments explaining the skill's purpose
LLM generation — the prompt is sent to Gemini (currently
gemini-3.1-flash-lite-preview) with a temperature of 0.3 (low creativity, high consistency). The model generates the complete handler code.Structural validation — the generated code is checked for:
- Presence of required imports (
authMiddleware,validateInput, etc.) - A default export wrapping the handler with
authMiddleware - At least one
successResponsecall - At least one
errorResponsecall - No syntax-breaking patterns (unclosed brackets, missing semicolons)
If validation fails, the skill returns a 422 error instead of broken code.
- Presence of required imports (
Response — the validated code is returned along with metadata (line count, whether it includes a fallback path).
What the Generated Code Looks Like
Every generated handler follows this structure:
import { VercelRequest, VercelResponse } from '@vercel/node';
import { authMiddleware } from '../../lib/auth';
import { validateInput } from '../../lib/validation';
import { successResponse, errorResponse } from '../../lib/response';
async function handler(req: VercelRequest, res: VercelResponse) {
// Input validation
const validation = validateInput(req.body, { /* schema */ });
if (!validation.valid) {
return errorResponse(res, 'Invalid input', 400, validation.errors);
}
// Core logic
try {
const result = /* ... */;
return successResponse(res, result);
} catch (error) {
return errorResponse(res, 'Processing failed', 500);
}
}
export default authMiddleware(handler);
This pattern ensures every generated skill is immediately deployable on Vercel, has authentication, input validation, and consistent error handling out of the box.
When the LLM Adds a Fallback
If the skill description suggests it wraps an external API (detected via needs_upstream_api: true or keywords like "API", "upstream", "external"), the generator includes a deterministic fallback path — a simpler implementation that runs when the external API is unavailable. This follows the same dual-layer pattern used by the humanizer skill (LLM primary + regex fallback).
Limitations
- No runtime testing — the generated code is structurally validated but not executed. It may have logical bugs that only surface at runtime.
- Single-file only — generates one handler file. If your skill needs multiple files (e.g., a separate data file or config), you'll need to add those manually.
- TypeScript only — the generator targets the Claw0x/Vercel TypeScript stack. No Python, Go, or other language support.
Prerequisites
Requires a Claw0x API key. Sign up at claw0x.com and create a key in your dashboard. Set it as an environment variable:
export CLAW0X_API_KEY="your-api-key-here"
When to Use
- User says "generate code for this skill", "create a handler for", "scaffold a serverless function"
- Agent pipeline needs to auto-generate skill implementations from descriptions
- User provides a README or description and wants working backend code
- Bootstrapping a new skill quickly before customizing the logic
Input
| Field | Type | Required | Description |
|---|---|---|---|
input.slug |
string | yes | URL-safe skill identifier |
input.name |
string | yes | Human-readable skill name |
input.description |
string | no | What the skill does |
input.readme_content |
string | no | README text to guide code generation (max ~6000 chars used) |
input.source_url |
string | no | Source repository URL for context |
input.topics |
string[] | no | Tags/topics for the skill |
input.needs_upstream_api |
boolean | no | Whether the skill wraps an external API |
input.evaluation_details |
object | no | AI evaluation notes and build recommendations |
Output Fields
| Field | Type | Description |
|---|---|---|
code |
string | Complete TypeScript handler code, ready to deploy |
slug |
string | The skill slug |
lines |
number | Line count of generated code |
has_fallback |
boolean | Whether the code includes a deterministic fallback |
Error Codes
400— Missing requiredinput.slugorinput.name422— Generated code failed structural validation502— Upstream LLM API error (not billed)
Pricing
$0.01 per successful call. Failed calls and 5xx errors are never charged.