Validate wrangler.jsonc configuration, verify Cloudflare Images bindings, check environment variables, and test Workers integration. Ensures correct setup for using Cloudflare Images with Cloudflare Workers.
Validates Cloudflare Images configuration including wrangler.jsonc, environment variables, and API token permissions.
/plugin marketplace add secondsky/claude-skills/plugin install cloudflare-images@claude-skillsComprehensive validation of wrangler.jsonc, environment variables, and Cloudflare Images bindings for Workers integration.
When you run /validate-config, Claude will:
wrangler.jsonc exists and has valid JSON.env, .dev.vars)/validate-config
Run from your Cloudflare Worker project root (where wrangler.jsonc is located).
Run the following validation checks:
echo "š Checking project structure..."
if [ ! -f "wrangler.jsonc" ]; then
echo "ā wrangler.jsonc not found"
echo " Run: wrangler init"
exit 1
else
echo "ā
wrangler.jsonc found"
fi
echo ""
echo "š Validating wrangler.jsonc syntax..."
# Check if valid JSON (with comments allowed for JSONC)
if jq empty wrangler.jsonc 2>/dev/null; then
echo "ā
Valid JSON syntax"
else
# Try stripping comments and validating
if grep -v '^\s*//' wrangler.jsonc | jq empty 2>/dev/null; then
echo "ā
Valid JSONC syntax (with comments)"
else
echo "ā Invalid JSON syntax in wrangler.jsonc"
echo " Check for trailing commas, missing quotes, etc."
exit 1
fi
fi
echo ""
echo "š Checking images binding..."
BINDING_EXISTS=$(jq -r 'has("images")' wrangler.jsonc 2>/dev/null)
if [ "$BINDING_EXISTS" = "true" ]; then
echo "ā
images binding configured"
# Validate binding structure
BINDING_COUNT=$(jq -r '.images | length' wrangler.jsonc)
echo " Bindings configured: $BINDING_COUNT"
# Check each binding
for i in $(seq 0 $(($BINDING_COUNT - 1))); do
BINDING_NAME=$(jq -r ".images[$i].binding" wrangler.jsonc)
BINDING_ACCOUNT=$(jq -r ".images[$i].account_id" wrangler.jsonc)
if [ "$BINDING_NAME" != "null" ]; then
echo " ⢠Binding: $BINDING_NAME"
else
echo " ā ļø Binding $i missing 'binding' field (default: IMAGES)"
fi
if [ "$BINDING_ACCOUNT" != "null" ]; then
echo " Account: ${BINDING_ACCOUNT:0:8}..."
else
echo " ā ļø No account_id specified (will use account from wrangler auth)"
fi
done
else
echo "ā No images binding configured"
echo ""
echo " Add to wrangler.jsonc:"
echo ' {
"images": [
{
"binding": "IMAGES",
"account_id": "your_account_id"
}
]
}'
exit 1
fi
echo ""
echo "š Checking environment variables..."
# Check .env file
if [ -f ".env" ]; then
echo "ā
.env file found"
if grep -q "CF_ACCOUNT_ID" .env; then
ACCOUNT_ID=$(grep "CF_ACCOUNT_ID" .env | cut -d '=' -f2)
echo " CF_ACCOUNT_ID: ${ACCOUNT_ID:0:8}..."
else
echo " ā ļø CF_ACCOUNT_ID not set in .env"
fi
if grep -q "CF_API_TOKEN" .env; then
API_TOKEN=$(grep "CF_API_TOKEN" .env | cut -d '=' -f2)
echo " CF_API_TOKEN: ${API_TOKEN:0:10}..."
else
echo " ā ļø CF_API_TOKEN not set in .env"
fi
if grep -q "CF_ACCOUNT_HASH" .env; then
ACCOUNT_HASH=$(grep "CF_ACCOUNT_HASH" .env | cut -d '=' -f2)
echo " CF_ACCOUNT_HASH: $ACCOUNT_HASH"
else
echo " ā¹ļø CF_ACCOUNT_HASH not set (optional for delivery URLs)"
fi
else
echo "ā ļø .env file not found"
echo " Create .env with:"
echo " CF_ACCOUNT_ID=your_account_id"
echo " CF_API_TOKEN=your_api_token"
fi
# Check .dev.vars file (for wrangler dev)
echo ""
if [ -f ".dev.vars" ]; then
echo "ā
.dev.vars file found (for local development)"
else
echo "ā¹ļø .dev.vars not found (optional - for wrangler dev)"
echo " Create .dev.vars for local secrets"
fi
echo ""
echo "š Verifying account ID consistency..."
# Get account ID from wrangler.jsonc
WRANGLER_ACCOUNT=$(jq -r '.images[0].account_id // empty' wrangler.jsonc)
# Get account ID from .env
if [ -f ".env" ]; then
ENV_ACCOUNT=$(grep "CF_ACCOUNT_ID" .env | cut -d '=' -f2 | tr -d '"' | tr -d "'")
fi
if [ ! -z "$WRANGLER_ACCOUNT" ] && [ ! -z "$ENV_ACCOUNT" ]; then
if [ "$WRANGLER_ACCOUNT" = "$ENV_ACCOUNT" ]; then
echo "ā
Account IDs match"
echo " wrangler.jsonc: ${WRANGLER_ACCOUNT:0:8}..."
echo " .env: ${ENV_ACCOUNT:0:8}..."
else
echo "ā Account ID mismatch!"
echo " wrangler.jsonc: ${WRANGLER_ACCOUNT:0:8}..."
echo " .env: ${ENV_ACCOUNT:0:8}..."
echo " These should match for consistent behavior"
fi
elif [ -z "$WRANGLER_ACCOUNT" ]; then
echo "ā¹ļø No account_id in wrangler.jsonc (using default account)"
elif [ -z "$ENV_ACCOUNT" ]; then
echo "ā¹ļø CF_ACCOUNT_ID not set in .env"
fi
echo ""
echo "š Testing API token permissions..."
if [ -f ".env" ] && grep -q "CF_API_TOKEN" .env && grep -q "CF_ACCOUNT_ID" .env; then
source .env
# Test Images API access
IMAGES_TEST=$(curl -s \
"https://api.cloudflare.com/client/v4/accounts/${CF_ACCOUNT_ID}/images/v1?per_page=1" \
-H "Authorization: Bearer ${CF_API_TOKEN}")
IMAGES_SUCCESS=$(echo "$IMAGES_TEST" | jq -r '.success')
if [ "$IMAGES_SUCCESS" = "true" ]; then
echo "ā
API token has Images:Read permission"
# Test if can list variants (requires Edit permission)
VARIANTS_TEST=$(curl -s \
"https://api.cloudflare.com/client/v4/accounts/${CF_ACCOUNT_ID}/images/v1/variants" \
-H "Authorization: Bearer ${CF_API_TOKEN}")
VARIANTS_SUCCESS=$(echo "$VARIANTS_TEST" | jq -r '.success')
if [ "$VARIANTS_SUCCESS" = "true" ]; then
echo "ā
API token has Images:Edit permission"
else
echo "ā ļø API token missing Images:Edit permission"
echo " Required for uploads and variant management"
fi
else
echo "ā API token invalid or missing Images permissions"
ERRORS=$(echo "$IMAGES_TEST" | jq -r '.errors[].message')
echo " Error: $ERRORS"
fi
else
echo "ā ļø Cannot test API token (missing .env or credentials)"
fi
echo ""
echo "š¦ Checking TypeScript configuration..."
if [ -f "src/index.ts" ] || [ -f "src/worker.ts" ]; then
echo "ā
TypeScript Worker found"
# Check for proper Env interface
if grep -r "interface Env" src/ >/dev/null 2>&1; then
echo " ā
Env interface defined"
# Check if IMAGES binding is typed
if grep -r "IMAGES.*any\|IMAGES.*Fetcher" src/ >/dev/null 2>&1; then
echo " ā
IMAGES binding typed in Env interface"
else
echo " ā ļø IMAGES binding not found in Env interface"
echo ""
echo " Add to Env interface:"
echo " interface Env {"
echo " IMAGES: any; // Cloudflare Images binding"
echo " }"
fi
else
echo " ā ļø No Env interface found"
echo " Define Env interface for type safety"
fi
else
echo "ā¹ļø No TypeScript Worker found (using JavaScript)"
fi
echo ""
echo "šØ Checking transformation configuration..."
# Check if using zone-based transformations
if jq -e '.zone_id' wrangler.jsonc >/dev/null 2>&1; then
ZONE_ID=$(jq -r '.zone_id' wrangler.jsonc)
echo "ā
Zone ID configured: ${ZONE_ID:0:8}..."
# Could test Polish settings here if API token available
else
echo "ā¹ļø No zone_id configured"
echo " Zone-based transformations require zone_id in wrangler.jsonc"
echo " Cloudflare Images transformations work without zone"
fi
echo ""
echo "ā ļø Checking for common issues..."
ISSUES_FOUND=0
# Check 1: .gitignore includes sensitive files
if [ -f ".gitignore" ]; then
if grep -q ".env" .gitignore && grep -q ".dev.vars" .gitignore; then
echo "ā
.gitignore includes .env and .dev.vars"
else
echo "ā .gitignore missing .env or .dev.vars"
echo " Add to .gitignore:"
echo " .env"
echo " .dev.vars"
ISSUES_FOUND=$((ISSUES_FOUND + 1))
fi
fi
# Check 2: Node modules installed
if [ -f "package.json" ]; then
if [ -d "node_modules" ]; then
echo "ā
Node modules installed"
else
echo "ā ļø Node modules not installed"
echo " Run: npm install"
fi
fi
# Check 3: Wrangler version
if command -v wrangler >/dev/null 2>&1; then
WRANGLER_VERSION=$(wrangler --version | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')
echo "ā
Wrangler installed: v$WRANGLER_VERSION"
# Check if version is recent (3.x+)
MAJOR_VERSION=$(echo $WRANGLER_VERSION | cut -d '.' -f1)
if [ "$MAJOR_VERSION" -ge 3 ]; then
echo " ā
Using Wrangler 3.x (recommended)"
else
echo " ā ļø Using Wrangler $MAJOR_VERSION.x (upgrade to 3.x recommended)"
fi
else
echo "ā Wrangler not installed"
echo " Install: npm install -g wrangler"
ISSUES_FOUND=$((ISSUES_FOUND + 1))
fi
if [ "$ISSUES_FOUND" = 0 ]; then
echo ""
echo "ā
No common issues detected"
fi
echo ""
echo "========================================="
echo "Configuration Validation Complete"
echo "========================================="
echo ""
if [ "$BINDING_EXISTS" = "true" ] && [ "$IMAGES_SUCCESS" = "true" ]; then
echo "ā
Configuration is valid!"
echo ""
echo "Next steps:"
echo " 1. Deploy worker: wrangler deploy"
echo " 2. Test upload: See templates/worker-upload.ts"
echo " 3. Check health: /check-images"
echo " 4. Create variants: /generate-variant"
else
echo "ā ļø Configuration needs attention"
echo ""
echo "Required fixes:"
if [ "$BINDING_EXISTS" != "true" ]; then
echo " ⢠Add images binding to wrangler.jsonc"
fi
if [ "$IMAGES_SUCCESS" != "true" ]; then
echo " ⢠Verify CF_API_TOKEN has Images permissions"
fi
echo ""
echo "See references/setup-guide.md for complete setup instructions"
fi
echo ""
š Checking project structure...
ā
wrangler.jsonc found
š Validating wrangler.jsonc syntax...
ā
Valid JSONC syntax (with comments)
š Checking images binding...
ā
images binding configured
Bindings configured: 1
⢠Binding: IMAGES
Account: 1a2b3c4d...
š Checking environment variables...
ā
.env file found
CF_ACCOUNT_ID: 1a2b3c4d...
CF_API_TOKEN: abc123def4...
CF_ACCOUNT_HASH: Vi7wi5KSItxGFsWRG2Us6Q
ā
.dev.vars file found (for local development)
š Verifying account ID consistency...
ā
Account IDs match
wrangler.jsonc: 1a2b3c4d...
.env: 1a2b3c4d...
š Testing API token permissions...
ā
API token has Images:Read permission
ā
API token has Images:Edit permission
š¦ Checking TypeScript configuration...
ā
TypeScript Worker found
ā
Env interface defined
ā
IMAGES binding typed in Env interface
šØ Checking transformation configuration...
ā¹ļø No zone_id configured
Zone-based transformations require zone_id in wrangler.jsonc
Cloudflare Images transformations work without zone
ā ļø Checking for common issues...
ā
.gitignore includes .env and .dev.vars
ā
Node modules installed
ā
Wrangler installed: v3.91.0
ā
Using Wrangler 3.x (recommended)
ā
No common issues detected
=========================================
Configuration Validation Complete
=========================================
ā
Configuration is valid!
Next steps:
1. Deploy worker: wrangler deploy
2. Test upload: See templates/worker-upload.ts
3. Check health: /check-images
4. Create variants: /generate-variant
Solution: Initialize Worker project:
wrangler init my-project
cd my-project
Solution: Check wrangler.jsonc for:
Use a JSON validator or IDE with JSON support.
Solution: Add to wrangler.jsonc:
{
"name": "my-worker",
"main": "src/index.ts",
"images": [
{
"binding": "IMAGES",
"account_id": "your_account_id_here"
}
]
}
Solution: Ensure same account ID in both places:
wrangler.jsonc: images[0].account_id.env: CF_ACCOUNT_IDSolution: Create new API token with Images permissions:
.env: CF_API_TOKEN=new_token_hereSolution: Add to TypeScript Env interface:
interface Env {
IMAGES: any; // Cloudflare Images binding
// ... other bindings
}
export default {
async fetch(request: Request, env: Env, ctx: ExecutionContext) {
// env.IMAGES is now typed
}
}
/check-images - Test API connectivity and health/generate-variant - Create image variant interactivelyreferences/setup-guide.md - Initial setup instructionsreferences/api-reference.md - API documentationtemplates/worker-upload.ts - Complete Worker example