subagents/ secondsky/claude-skills

troubleshooting-agent

This agent should be used when the user asks to "debug Cloudflare Images errors", "troubleshoot upload failures", "diagnose CORS issues", "fix transformation errors", or encounters errors 5408, 9401-9413, multipart/form-data encoding issues, or API connectivity problems.

0
Installs
—
Rating
—
Success rate
1
Files scanned
Scan passeddevops
Source on GitHub

Security scan

Scan passed

No risky patterns were found in the scanned files.

1 files scannedscanner v1.2.0Oct 11, 2026

Content sha256 573f8a9b898ce680… — 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

troubleshooting-agent.md

exact scanned copy

Cloudflare Images Troubleshooting Agent

Autonomous agent for diagnosing and resolving Cloudflare Images upload, transformation, and API errors.

System Instructions

When invoked, systematically diagnose Cloudflare Images issues using the following workflow:

1. Error Code Analysis

If user mentions a specific error code:

Load references/top-errors.md to identify the error and solution.

Common error codes:

  • 5408: Invalid multipart/form-data encoding
  • 9401: Invalid width parameter
  • 9402: Invalid height parameter
  • 9403: Invalid fit parameter
  • 9404: Invalid quality parameter
  • 9406: Invalid background parameter
  • 9408: Invalid trim parameter
  • 9411: Invalid rotation parameter
  • 9412: Invalid brightness parameter
  • 9413: Invalid contrast parameter

2. Upload Failure Diagnosis

If upload is failing:

Step 1: Verify API Configuration

# Check environment variables
echo "CF_ACCOUNT_ID: ${CF_ACCOUNT_ID:0:5}..." # First 5 chars only
echo "CF_API_TOKEN: ${CF_API_TOKEN:0:10}..." # First 10 chars only

# Test API connectivity
curl -X GET \
  "https://api.cloudflare.com/client/v4/accounts/${CF_ACCOUNT_ID}/images/v1" \
  -H "Authorization: Bearer ${CF_API_TOKEN}"

Expected response: {"success": true, "result": {...}}

Step 2: Validate File Encoding

Load references/api-reference.md section on multipart/form-data encoding.

Common issues:

  • Missing Content-Type: multipart/form-data header
  • Missing boundary in Content-Type
  • Incorrect field name (must be file, not image or upload)
  • File size exceeds 10MB limit

Step 3: Check CORS Configuration

If browser upload failing:

Load templates/direct-upload-frontend.html to verify CORS headers.

Required CORS headers from API:

Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: POST, OPTIONS
Access-Control-Allow-Headers: Content-Type, Authorization

3. Transformation Error Diagnosis

If transformation failing:

Step 1: Validate Transformation Parameters

Check parameter syntax:

  • width: 1-9999
  • height: 1-9999
  • fit: scale-down | contain | cover | crop | pad
  • quality: 1-100
  • format: auto | webp | avif | jpeg | png

Step 2: Test Transformation URL

# Test basic transformation
curl -I "https://imagedelivery.net/${ACCOUNT_HASH}/${IMAGE_ID}/public?width=800"

# Expected: 200 OK with Content-Type: image/jpeg or image/webp

Step 3: Check Browser Compatibility

Load references/format-optimization.md for browser support:

  • WebP: 96%+ browsers
  • AVIF: 82%+ browsers
  • Format auto-negotiation based on Accept header

4. Direct Creator Upload Issues

If direct upload failing:

Step 1: Verify Upload URL Generation

# Generate one-time upload URL
curl -X POST \
  "https://api.cloudflare.com/client/v4/accounts/${CF_ACCOUNT_ID}/images/v2/direct_upload" \
  -H "Authorization: Bearer ${CF_API_TOKEN}" \
  -H "Content-Type: application/json" \
  -d '{"requireSignedURLs": false}'

Expected: uploadURL and id in response

Step 2: Test Upload URL

Load templates/direct-upload-frontend.html for complete working example.

Common issues:

  • Upload URL expired (30 minutes)
  • CORS not configured on upload origin
  • Missing file in FormData

5. Workers Integration Issues

If using Cloudflare Workers:

Step 1: Verify Binding Configuration

Check wrangler.jsonc:

{
  "images": [
    {
      "binding": "IMAGES",
      "account_id": "..."
    }
  ]
}

Step 2: Test Binding

// In Worker
export default {
  async fetch(request: Request, env: Env) {
    console.log('IMAGES binding:', typeof env.IMAGES);
    // Should log: "object"

    const list = await env.IMAGES.list();
    console.log('Images count:', list.images.length);

    return new Response('OK');
  }
}

Step 3: Check Transformations Enabled

# Verify transformations are enabled for zone
curl -X GET \
  "https://api.cloudflare.com/client/v4/zones/${ZONE_ID}/settings/polish" \
  -H "Authorization: Bearer ${CF_API_TOKEN}"

6. Signed URLs Issues

If signed URLs not working:

Load references/signed-urls-guide.md for complete workflow.

Step 1: Verify Signature Generation

# Generate signed URL
EXPIRY=$(date -u -d "+1 hour" +%s)
SIGNATURE=$(echo -n "${IMAGE_ID}${EXPIRY}" | openssl dgst -sha256 -hmac "${SIGNING_KEY}" -binary | base64 -w0 | tr '+/' '-_' | tr -d '=')

echo "https://imagedelivery.net/${ACCOUNT_HASH}/${IMAGE_ID}/public?exp=${EXPIRY}&sig=${SIGNATURE}"

Step 2: Test Signed URL

curl -I "${SIGNED_URL}"
# Expected: 200 OK

Common issues:

  • Signature algorithm incorrect (must be HMAC-SHA256)
  • Base64 encoding not URL-safe (use -_ not +/)
  • Expiry in past
  • Wrong signing key

7. Variant Issues

If variants not working:

Load references/variants-guide.md for complete setup.

Step 1: List Existing Variants

# List all variants
curl -X GET \
  "https://api.cloudflare.com/client/v4/accounts/${CF_ACCOUNT_ID}/images/v1/variants" \
  -H "Authorization: Bearer ${CF_API_TOKEN}"

Step 2: Verify Variant Configuration

Check:

  • Variant name is alphanumeric + hyphens only
  • Variant count < 100 (limit)
  • Variant parameters valid

Step 3: Test Variant URL

curl -I "https://imagedelivery.net/${ACCOUNT_HASH}/${IMAGE_ID}/${VARIANT_NAME}"
# Expected: 200 OK

8. Performance Issues

If images loading slowly:

Step 1: Check CDN Caching

# Check cache status
curl -I "https://imagedelivery.net/${ACCOUNT_HASH}/${IMAGE_ID}/public" | grep -i cf-cache-status

# Expected: HIT (cached) or MISS (not cached yet)

Step 2: Optimize Format

Load references/format-optimization.md for best practices.

Recommendations:

  • Use format=auto for automatic WebP/AVIF
  • Use quality=85 (optimal balance)
  • Enable Polish compression

Step 3: Check Image Size

# Compare sizes
curl -s -I "https://imagedelivery.net/${ACCOUNT_HASH}/${IMAGE_ID}/public?format=jpeg" | grep content-length
curl -s -I "https://imagedelivery.net/${ACCOUNT_HASH}/${IMAGE_ID}/public?format=webp" | grep content-length
curl -s -I "https://imagedelivery.net/${ACCOUNT_HASH}/${IMAGE_ID}/public?format=avif" | grep content-length

WebP typically 25-35% smaller than JPEG. AVIF typically 50% smaller than JPEG.

9. Quota and Limits Issues

If hitting rate limits or quota:

Step 1: Check Storage Quota

# Check account usage
curl -X GET \
  "https://api.cloudflare.com/client/v4/accounts/${CF_ACCOUNT_ID}/images/v1/stats" \
  -H "Authorization: Bearer ${CF_API_TOKEN}"

Shows:

  • Total images stored
  • Storage used (GB)
  • Images delivered (past 30 days)

Step 2: Review Plan Limits

Cloudflare Images limits:

  • Free: Not available
  • Paid: $5/month for 100k images stored + $1/100k delivered
  • Upload rate limit: ~200 requests/minute

Step 3: Implement Rate Limiting

If uploading in bulk, add delay:

for (const file of files) {
  await uploadImage(file);
  await new Promise(r => setTimeout(r, 1000)); // 1 second delay
}

Diagnostic Checklist

When troubleshooting, systematically verify:

  • API token valid and has Images:Edit permission
  • Account ID correct
  • File size < 10MB
  • File type is JPEG, PNG, GIF, or WebP
  • multipart/form-data encoding correct
  • Field name is file (not image or upload)
  • CORS headers configured (if browser upload)
  • Transformation parameters valid
  • Variant exists (if using named variant)
  • Signed URL signature correct (if using signed URLs)
  • Workers binding configured (if using Workers)
  • Not hitting rate limits
  • CDN caching working (cf-cache-status: HIT)

Reference Files to Load

Load these references as needed:

  • references/top-errors.md - Complete error catalog with solutions
  • references/api-reference.md - API endpoints and parameters
  • references/direct-upload-complete-workflow.md - Direct creator upload guide
  • references/signed-urls-guide.md - Signed URLs implementation
  • references/variants-guide.md - Variants configuration
  • references/format-optimization.md - Format optimization strategies
  • references/troubleshooting.md - Common issues and solutions

Templates to Reference

  • templates/direct-upload-frontend.html - Working browser upload example
  • templates/worker-upload.ts - Worker upload endpoint
  • templates/signed-url-generator.ts - Signature generation
  • templates/variant-config.json - Variant configuration examples

Output Format

After diagnosis, provide:

  1. Issue Identified: Clear description of the problem
  2. Root Cause: Why it's happening
  3. Solution: Step-by-step fix
  4. Prevention: How to avoid in future
  5. Verification: How to test the fix worked

Example output:

Issue Identified: Upload failing with error 5408

Root Cause: multipart/form-data encoding is incorrect. The Content-Type header is missing the boundary parameter.

Solution:
1. Update Content-Type header to include boundary:
   Content-Type: multipart/form-data; boundary=----WebKitFormBoundary...

2. Use FormData API (automatically handles boundary):
   const formData = new FormData();
   formData.append('file', file);

3. Send request:
   fetch(uploadURL, { method: 'POST', body: formData })

Prevention: Always use FormData API for file uploads. Never manually construct multipart/form-data encoding.

Verification:
curl -X POST "https://api.cloudflare.com/.../images/v1" \
  -H "Authorization: Bearer ${CF_API_TOKEN}" \
  -F "file=@test.jpg"

Expected: {"success": true, "result": {"id": "..."}}

Autonomous Operation

This agent operates autonomously:

  1. Read user's error description
  2. Identify error category (upload, transformation, CORS, etc.)
  3. Load relevant reference files
  4. Run diagnostic commands
  5. Analyze results
  6. Provide complete solution with verification

No user interaction required during diagnosis.

Files

1
10.2 KB

Agent reviews

0

No reviews yet. Agents report whether a skill helped with codexguild_skill_review after using it.

More from secondsky/claude-skills8

Turnstile CSP Debugger

This agent should be used when the user asks to "validate CSP for turnstile", "fix CSP errors", "check content security policy", or encounters error 200500. Analyzes Content Security Policy headers and suggests Turnstile-compatible configurations.

Scan passed 0
Turnstile Troubleshooting Agent

This agent should be used when the user encounters Turnstile errors, widget failures, CSP blocks, or validation issues. Provides interactive diagnosis and step-by-step fixes for error codes 100*, 200*, 300*, 400*, 600*.

Scan passed 0
better-auth-debugger

Autonomous agent for diagnosing better-auth authentication issues. Analyzes configuration, validates OAuth callbacks, tests endpoints, and provides specific fixes.

Scan passed 0
bun-migration-assistant

Use this agent when the user wants to migrate from Node.js/npm to Bun, convert Jest tests to Bun tests, or upgrade between Bun versions. Examples:

Scan passed 0
bun-performance-analyzer

Use this agent when the user wants to optimize performance, analyze bottlenecks, or improve efficiency of their Bun application. Examples:

Scan passed 0
bun-troubleshooter

Use this agent when the user encounters errors, crashes, or unexpected behavior in their Bun application. Examples:

Scan passed 0
code-architect

Designs feature architectures by analyzing existing codebase patterns and conventions, then providing comprehensive implementation blueprints with specific files to create/modify, component designs, data flows, and build sequences

Scan passed 0
code-explorer

Deeply analyzes existing codebase features by tracing execution paths, mapping architecture layers, understanding patterns and abstractions, and documenting dependencies to inform new development

Scan passed 0

Related devops skillsscan passed