Skip to content

team-telnyx/ai / providers/claude/plugins/telnyx-platform/skills/telnyx-twilio-migration

telnyx-twilio-migration

Unverified

Migrate from Twilio to Telnyx. Orchestrates a complete 6-phase migration: discovery, planning, setup, code migration, validation, and cleanup. Covers voice (TwiML to TeXML, Call Control API), messaging, WebRTC, SIP trunking, verify, fax, video, IoT, number lookup, and porting. Includes automated scanners, validation scripts, and integration tests.

FileKindSize
SKILL.mdskill md43.3 KB
references/account-setup-guide.mdmarkdown17.8 KB
references/error-code-mapping.mdmarkdown11.0 KB
references/fax-migration.mdmarkdown14.7 KB
references/iot-migration.mdmarkdown17.9 KB
references/lookup-migration.mdmarkdown14.3 KB
references/messaging-migration.mdmarkdown36.5 KB
references/mobile-sdk-migration.mdmarkdown38.6 KB
references/number-porting.mdmarkdown17.0 KB
references/numbers-migration.mdmarkdown21.1 KB
references/product-mapping.mdmarkdown6.7 KB
references/sdk-api-details/10dlc.mdmarkdown9.8 KB
references/sdk-api-details/ai-assistants.mdmarkdown5.8 KB
references/sdk-api-details/messaging.mdmarkdown16.1 KB
references/sdk-api-details/numbers.mdmarkdown10.1 KB
references/sdk-api-details/voice.mdmarkdown9.6 KB
references/sip-trunking-migration.mdmarkdown18.1 KB
references/texml-verbs.mdmarkdown43.7 KB
references/unsupported-products.mdmarkdown3.5 KB
references/verify-migration.mdmarkdown18.4 KB
references/video-migration.mdmarkdown20.6 KB
references/voice-migration.mdmarkdown37.2 KB
references/webhook-migration.mdmarkdown20.3 KB
references/webrtc-migration.mdmarkdown50.0 KB
scripts/lint-telnyx-correctness.shexecutablescript31.4 KB
scripts/migration-state.shexecutablescript7.3 KB
scripts/post-test-diagnostic.shexecutablescript18.9 KB
scripts/preflight-check.shexecutablescript13.4 KB
scripts/run-discovery.shexecutablescript7.7 KB
scripts/run-validation.shexecutablescript13.1 KB
scripts/scan-twilio-deep.pyexecutablescript64.8 KB
scripts/scan-twilio-usage.shexecutablescript29.1 KB
scripts/test-migration/smoke-test.shexecutablescript10.0 KB
scripts/test-migration/test-fax.shexecutablescript8.7 KB
scripts/test-migration/test-lookup.shexecutablescript5.5 KB
scripts/test-migration/test-messaging.shexecutablescript18.8 KB
scripts/test-migration/test-sip.shexecutablescript29.6 KB
scripts/test-migration/test-verify.shexecutablescript13.6 KB
scripts/test-migration/test-voice.shexecutablescript22.4 KB
scripts/test-migration/test-webhooks-local.pyexecutablescript9.7 KB
scripts/test-migration/test-webrtc.shexecutablescript24.0 KB
scripts/test-migration/webhook-receiver.pyexecutablescript11.8 KB
scripts/validate-migration.shexecutablescript31.1 KB
scripts/validate-texml.shexecutablescript61.4 KB
sdk-reference/curl/10dlc.mdmarkdown25.8 KB
sdk-reference/curl/account-access.mdmarkdown15.6 KB
sdk-reference/curl/account-management.mdmarkdown9.5 KB
sdk-reference/curl/account-notifications.mdmarkdown11.0 KB
sdk-reference/curl/account-reports.mdmarkdown45.5 KB
sdk-reference/curl/account.mdmarkdown8.1 KB
sdk-reference/curl/ai-assistants.mdmarkdown34.3 KB
sdk-reference/curl/ai-inference.mdmarkdown34.5 KB
sdk-reference/curl/fax.mdmarkdown19.8 KB
sdk-reference/curl/iot.mdmarkdown49.4 KB
sdk-reference/curl/messaging-hosted.mdmarkdown23.3 KB
sdk-reference/curl/messaging-profiles.mdmarkdown14.2 KB
sdk-reference/curl/messaging.mdmarkdown29.1 KB
sdk-reference/curl/missions.mdmarkdown23.5 KB
sdk-reference/curl/networking.mdmarkdown39.8 KB
sdk-reference/curl/numbers-compliance.mdmarkdown30.2 KB
sdk-reference/curl/numbers-config.mdmarkdown29.7 KB
sdk-reference/curl/numbers-services.mdmarkdown12.6 KB
sdk-reference/curl/numbers.mdmarkdown24.0 KB
sdk-reference/curl/oauth.mdmarkdown15.6 KB
sdk-reference/curl/porting-in.mdmarkdown35.1 KB
sdk-reference/curl/porting-out.mdmarkdown9.8 KB
sdk-reference/curl/sip-integrations.mdmarkdown27.5 KB
sdk-reference/curl/sip.mdmarkdown47.6 KB
sdk-reference/curl/storage.mdmarkdown4.2 KB
sdk-reference/curl/texml.mdmarkdown31.4 KB
sdk-reference/curl/verify.mdmarkdown13.2 KB
sdk-reference/curl/video.mdmarkdown17.2 KB
sdk-reference/curl/voice-advanced.mdmarkdown32.8 KB
sdk-reference/curl/voice-conferencing.mdmarkdown41.6 KB
sdk-reference/curl/voice-gather.mdmarkdown14.7 KB
sdk-reference/curl/voice-media.mdmarkdown17.8 KB
sdk-reference/curl/voice-streaming.mdmarkdown13.3 KB
sdk-reference/curl/voice.mdmarkdown37.6 KB
sdk-reference/curl/webrtc.mdmarkdown6.5 KB
sdk-reference/go/10dlc.mdmarkdown29.0 KB
sdk-reference/go/account-access.mdmarkdown17.0 KB
sdk-reference/go/account-management.mdmarkdown9.9 KB
sdk-reference/go/account-notifications.mdmarkdown12.4 KB
sdk-reference/go/account-reports.mdmarkdown31.5 KB
sdk-reference/go/account.mdmarkdown9.1 KB
sdk-reference/go/ai-assistants.mdmarkdown37.7 KB
sdk-reference/go/ai-inference.mdmarkdown27.1 KB
sdk-reference/go/fax.mdmarkdown20.2 KB
sdk-reference/go/iot.mdmarkdown51.3 KB
sdk-reference/go/messaging-hosted.mdmarkdown24.5 KB
sdk-reference/go/messaging-profiles.mdmarkdown15.2 KB
sdk-reference/go/messaging.mdmarkdown30.1 KB
sdk-reference/go/missions.mdmarkdown26.9 KB
sdk-reference/go/networking.mdmarkdown42.5 KB
sdk-reference/go/numbers-compliance.mdmarkdown28.2 KB
sdk-reference/go/numbers-config.mdmarkdown29.5 KB
sdk-reference/go/numbers-services.mdmarkdown14.1 KB
sdk-reference/go/numbers.mdmarkdown26.7 KB
sdk-reference/go/oauth.mdmarkdown11.7 KB
sdk-reference/go/porting-in.mdmarkdown41.1 KB
sdk-reference/go/porting-out.mdmarkdown10.9 KB
sdk-reference/go/sip-integrations.mdmarkdown32.3 KB
sdk-reference/go/sip.mdmarkdown49.1 KB
sdk-reference/go/storage.mdmarkdown4.8 KB
sdk-reference/go/texml.mdmarkdown35.7 KB
sdk-reference/go/verify.mdmarkdown14.4 KB
sdk-reference/go/video.mdmarkdown18.6 KB
sdk-reference/go/voice-advanced.mdmarkdown33.2 KB
sdk-reference/go/voice-conferencing.mdmarkdown42.3 KB
sdk-reference/go/voice-gather.mdmarkdown14.5 KB
sdk-reference/go/voice-media.mdmarkdown18.1 KB
sdk-reference/go/voice-streaming.mdmarkdown13.5 KB
sdk-reference/go/voice.mdmarkdown39.2 KB
sdk-reference/go/webrtc.mdmarkdown7.5 KB
sdk-reference/java/10dlc.mdmarkdown31.3 KB
sdk-reference/java/account-access.mdmarkdown18.5 KB
sdk-reference/java/account-management.mdmarkdown11.1 KB
sdk-reference/java/account-notifications.mdmarkdown14.3 KB
sdk-reference/java/account-reports.mdmarkdown36.5 KB
sdk-reference/java/account.mdmarkdown10.3 KB
sdk-reference/java/ai-assistants.mdmarkdown39.2 KB
sdk-reference/java/ai-inference.mdmarkdown30.7 KB
sdk-reference/java/fax.mdmarkdown21.5 KB
sdk-reference/java/iot.mdmarkdown57.5 KB
sdk-reference/java/messaging-hosted.mdmarkdown28.4 KB
sdk-reference/java/messaging-profiles.mdmarkdown15.7 KB
sdk-reference/java/messaging.mdmarkdown32.2 KB
sdk-reference/java/missions.mdmarkdown31.6 KB
sdk-reference/java/networking.mdmarkdown47.1 KB
sdk-reference/java/numbers-compliance.mdmarkdown31.1 KB
sdk-reference/java/numbers-config.mdmarkdown32.2 KB
sdk-reference/java/numbers-services.mdmarkdown15.9 KB
sdk-reference/java/numbers.mdmarkdown28.4 KB
sdk-reference/java/oauth.mdmarkdown13.0 KB
sdk-reference/java/porting-in.mdmarkdown46.2 KB
sdk-reference/java/porting-out.mdmarkdown11.9 KB
sdk-reference/java/sip-integrations.mdmarkdown38.1 KB
sdk-reference/java/sip.mdmarkdown51.9 KB
sdk-reference/java/storage.mdmarkdown5.7 KB
sdk-reference/java/texml.mdmarkdown41.3 KB
sdk-reference/java/verify.mdmarkdown16.0 KB
sdk-reference/java/video.mdmarkdown20.3 KB
sdk-reference/java/voice-advanced.mdmarkdown35.0 KB
sdk-reference/java/voice-conferencing.mdmarkdown46.0 KB
sdk-reference/java/voice-gather.mdmarkdown16.1 KB
sdk-reference/java/voice-media.mdmarkdown19.5 KB
sdk-reference/java/voice-streaming.mdmarkdown14.7 KB
sdk-reference/java/voice.mdmarkdown40.8 KB
sdk-reference/java/webrtc.mdmarkdown8.5 KB
sdk-reference/javascript/10dlc.mdmarkdown28.5 KB
sdk-reference/javascript/account-access.mdmarkdown15.9 KB
sdk-reference/javascript/account-management.mdmarkdown9.6 KB
sdk-reference/javascript/account-notifications.mdmarkdown11.7 KB
sdk-reference/javascript/account-reports.mdmarkdown29.3 KB
sdk-reference/javascript/account.mdmarkdown8.7 KB
sdk-reference/javascript/ai-assistants.mdmarkdown37.5 KB
sdk-reference/javascript/ai-inference.mdmarkdown24.4 KB
sdk-reference/javascript/fax.mdmarkdown19.9 KB
sdk-reference/javascript/iot.mdmarkdown47.4 KB
sdk-reference/javascript/messaging-hosted.mdmarkdown22.4 KB
sdk-reference/javascript/messaging-profiles.mdmarkdown14.8 KB
sdk-reference/javascript/messaging.mdmarkdown29.7 KB
sdk-reference/javascript/missions.mdmarkdown23.8 KB
sdk-reference/javascript/networking.mdmarkdown39.3 KB
sdk-reference/javascript/numbers-compliance.mdmarkdown25.9 KB
sdk-reference/javascript/numbers-config.mdmarkdown28.3 KB
sdk-reference/javascript/numbers-services.mdmarkdown13.0 KB
sdk-reference/javascript/numbers.mdmarkdown26.1 KB
sdk-reference/javascript/oauth.mdmarkdown10.8 KB
sdk-reference/javascript/porting-in.mdmarkdown37.4 KB
sdk-reference/javascript/porting-out.mdmarkdown10.2 KB
sdk-reference/javascript/sip-integrations.mdmarkdown28.5 KB
sdk-reference/javascript/sip.mdmarkdown47.4 KB
sdk-reference/javascript/storage.mdmarkdown4.5 KB
sdk-reference/javascript/texml.mdmarkdown31.9 KB
sdk-reference/javascript/verify.mdmarkdown13.3 KB
sdk-reference/javascript/video.mdmarkdown17.2 KB
sdk-reference/javascript/voice-advanced.mdmarkdown32.6 KB
sdk-reference/javascript/voice-conferencing.mdmarkdown40.4 KB
sdk-reference/javascript/voice-gather.mdmarkdown14.3 KB
sdk-reference/javascript/voice-media.mdmarkdown17.8 KB
sdk-reference/javascript/voice-streaming.mdmarkdown13.4 KB
sdk-reference/javascript/voice.mdmarkdown39.4 KB
sdk-reference/javascript/webrtc.mdmarkdown7.2 KB
sdk-reference/python/10dlc.mdmarkdown28.5 KB
sdk-reference/python/account-access.mdmarkdown15.0 KB
sdk-reference/python/account-management.mdmarkdown9.1 KB
sdk-reference/python/account-notifications.mdmarkdown10.9 KB
sdk-reference/python/account-reports.mdmarkdown28.1 KB
sdk-reference/python/account.mdmarkdown8.1 KB
sdk-reference/python/ai-assistants.mdmarkdown37.3 KB
sdk-reference/python/ai-inference.mdmarkdown23.4 KB
sdk-reference/python/fax.mdmarkdown19.5 KB
sdk-reference/python/iot.mdmarkdown45.3 KB
sdk-reference/python/messaging-hosted.mdmarkdown21.7 KB
sdk-reference/python/messaging-profiles.mdmarkdown14.1 KB
sdk-reference/python/messaging.mdmarkdown29.4 KB
sdk-reference/python/missions.mdmarkdown23.2 KB
sdk-reference/python/networking.mdmarkdown37.1 KB
sdk-reference/python/numbers-compliance.mdmarkdown24.6 KB

scripts/scan-twilio-usage.sh

View on GitHub
#!/usr/bin/env bash
# scan-twilio-usage.sh — Grep-based Twilio codebase scanner
# Outputs structured JSON describing Twilio SDK usage, products, env vars,
# config files, TwiML templates, webhook handlers, and API URLs.
#
# Usage: ./scan-twilio-usage.sh <project-root>

set -euo pipefail

# Requires bash 4+ for associative arrays (declare -A)
if [ "${BASH_VERSINFO[0]}" -lt 4 ]; then
  echo "Error: This script requires bash 4+. You have bash ${BASH_VERSION}." >&2
  echo "  macOS: brew install bash (then use /opt/homebrew/bin/bash or /usr/local/bin/bash)" >&2
  echo "  Linux: bash 4+ is standard" >&2
  exit 1
fi

# ---------------------------------------------------------------------------
# Helpers
# ---------------------------------------------------------------------------

usage() {
  echo "Usage: $0 <project-root>" >&2
  exit 1
}

log() {
  echo "[scan] $*" >&2
}

# Escape a string for safe embedding inside a JSON string value.
json_escape() {
  local s="$1"
  s="${s//\\/\\\\}"
  s="${s//\"/\\\"}"
  s="${s//$'\n'/\\n}"
  s="${s//$'\r'/}"
  s="${s//$'\t'/\\t}"
  printf '%s' "$s"
}

# ---------------------------------------------------------------------------
# Arguments
# ---------------------------------------------------------------------------

if [[ $# -lt 1 ]]; then
  usage
fi

PROJECT_ROOT="$1"

if [[ ! -d "$PROJECT_ROOT" ]]; then
  echo "Error: directory '$PROJECT_ROOT' does not exist." >&2
  exit 1
fi

# Resolve to absolute path
PROJECT_ROOT="$(cd "$PROJECT_ROOT" && pwd)"

# ---------------------------------------------------------------------------
# Exclude directories (passed to grep via --exclude-dir)
# ---------------------------------------------------------------------------

EXCLUDE_DIRS=(
  node_modules .git vendor __pycache__ venv .venv
  dist build .next .nuxt coverage .tox
)

EXCLUDE_ARGS=()
for d in "${EXCLUDE_DIRS[@]}"; do
  EXCLUDE_ARGS+=(--exclude-dir="$d")
done
# Exclude minified/bundled files (can cause grep OOM and produce false positives)
EXCLUDE_ARGS+=(--exclude='*.min.js' --exclude='*.min.css' --exclude='*.bundle.js' --exclude='*.chunk.js')
# Exclude lock files (contain Twilio version strings but aren't source code)
EXCLUDE_ARGS+=(--exclude='package-lock.json' --exclude='yarn.lock' --exclude='pnpm-lock.yaml' --exclude='Gemfile.lock' --exclude='Pipfile.lock' --exclude='poetry.lock' --exclude='go.sum')

# ---------------------------------------------------------------------------
# State — associative arrays / arrays collected during the scan
# ---------------------------------------------------------------------------

# NOTE: associative arrays MUST be initialized with =() so that `${#ARR[@]}`
# is safe under `set -u` even when no entries are added (clean/empty scan).
declare -A LANG_SET=()       # languages_detected  (key=lang, value=1)
declare -A PRODUCT_SET=()    # products_used        (key=product, value=1)

# Per-file info stored as parallel indexed arrays
declare -a FILE_PATHS=()     # relative paths
declare -a FILE_LANGS=()     # language per file
declare -a FILE_PRODUCTS=()  # comma-separated products per file
declare -a FILE_PATTERNS=()  # comma-separated matched patterns per file

declare -a ENV_NAMES=()      # env var names
declare -a ENV_FILES=()      # comma-separated files per env var
declare -A ENV_MAP=()        # name -> comma-separated files

declare -a CFG_PATHS=()      # config file relative paths
declare -a CFG_TYPES=()      # config types (pip, npm, gem, ...)
declare -a CFG_LINES=()      # matching line content

declare -a TWIML_FILES=()    # TwiML template paths

declare -a WH_PATHS=()       # webhook handler file paths
declare -a WH_PATTERNS=()    # webhook matched pattern

declare -a API_URLS=()       # unique API URLs found
declare -a API_URL_FILES=()  # comma-separated files per URL
declare -A API_URL_MAP       # url -> comma-separated files

# ---------------------------------------------------------------------------
# Scanning helpers
# ---------------------------------------------------------------------------

# run_grep <label> <extra-grep-args...>
# Runs grep -rn inside PROJECT_ROOT with standard excludes and returns
# matching lines (path:lineno:content). Returns 0 even if nothing matched.
run_grep() {
  grep -rn "${EXCLUDE_ARGS[@]}" "$@" "$PROJECT_ROOT" 2>/dev/null || true
}

# Detect language from file extension
detect_language() {
  local f="$1"
  case "$f" in
    *.py)                     echo "python" ;;
    *.js|*.mjs|*.cjs)        echo "javascript" ;;
    *.ts|*.tsx)               echo "typescript" ;;
    *.go)                     echo "go" ;;
    *.rb)                     echo "ruby" ;;
    *.java)                   echo "java" ;;
    *.php)                    echo "php" ;;
    *.cs)                     echo "csharp" ;;
    *.sh|*.bash)              echo "shell" ;;
    *.xml)                    echo "xml" ;;
    *.json)                   echo "json" ;;
    *.yml|*.yaml)             echo "yaml" ;;
    *.env|*.env.*)            echo "env" ;;
    *.toml)                   echo "toml" ;;
    *.cfg)                    echo "config" ;;
    *.txt)                    echo "text" ;;
    *.swift)                  echo "swift" ;;
    *.kt|*.kts)               echo "kotlin" ;;
    *.dart)                   echo "dart" ;;
    *.gradle)                 echo "groovy" ;;
    *.csproj)                 echo "xml" ;;
    *)                        echo "unknown" ;;
  esac
}

# Map a matched pattern to zero or more products (space-separated)
pattern_to_products() {
  local pat="$1"
  local products=""
  # WebRTC (mobile + browser SDKs) — check before voice to avoid false categorization
  if echo "$pat" | grep -qiE 'TwilioVoiceSDK|import TwilioVoice|TVOCall|TVOCallInvite|TVOCallDelegate|com\.twilio\.voice|com\.twilio:voice-android|@twilio/voice-react-native|twilio_voice|Twilio\.Device|@twilio/voice-sdk|twilio-client|new Device\('; then
    products="$products webrtc"
  fi
  # Voice (server-side API/SDK — excludes mobile SDK patterns to avoid double-tagging)
  if echo "$pat" | grep -qiE 'twiml|VoiceResponse|CallResource|VoiceGrant|\.calls\.create|\.calls\.list'; then
    # Skip if already tagged as webrtc (mobile SDK patterns)
    if ! echo "$products" | grep -q 'webrtc'; then
      products="$products voice"
    fi
  fi
  # Messaging
  if echo "$pat" | grep -qiE 'Messages\.create|MessageResource|messaging'; then
    products="$products messaging"
  fi
  # Video
  if echo "$pat" | grep -qiE 'twilio-video|VideoGrant|Room'; then
    products="$products video"
  fi
  # Verify
  if echo "$pat" | grep -qiE 'twilio/rest/verify|VerificationResource|verify'; then
    products="$products verify"
  fi
  # Fax
  if echo "$pat" | grep -qiE 'twilio/rest/fax|FaxResource|fax'; then
    products="$products fax"
  fi
  # Lookup
  if echo "$pat" | grep -qiE 'twilio/rest/lookups|PhoneNumber|lookups'; then
    products="$products lookup"
  fi
  # TeXML (TwiML)
  if echo "$pat" | grep -qiE 'twilio/twiml|texml'; then
    products="$products texml"
  fi
  # Webhook validation
  if echo "$pat" | grep -qiE 'RequestValidator|validateRequest|X-Twilio-Signature'; then
    products="$products webhook-validation"
  fi
  # SIP trunking
  if echo "$pat" | grep -qiE 'trunking|TrunkingGrant|SipGrant'; then
    products="$products sip"
  fi
  # IoT / Wireless
  if echo "$pat" | grep -qiE 'wireless|supersim|SuperSim|SimResource|fleet\.create'; then
    products="$products iot"
  fi
  # Conversations
  if echo "$pat" | grep -qiE 'conversations\.v1|ConversationResource'; then
    products="$products conversations"
  fi
  # Notify
  if echo "$pat" | grep -qiE 'notify\.v1|NotificationResource'; then
    products="$products notify"
  fi
  # Proxy
  if echo "$pat" | grep -qiE 'proxy\.v1|ProxyService'; then
    products="$products proxy"
  fi
  # Autopilot
  if echo "$pat" | grep -qiE 'autopilot\.v1|AutopilotTask'; then
    products="$products autopilot"
  fi
  # TaskRouter
  if echo "$pat" | grep -qiE 'taskrouter|TaskRouterWorker|WorkflowResource'; then
    products="$products taskrouter"
  fi
  # Studio
  if echo "$pat" | grep -qiE 'studio\.v2|studio\.v1|flow\.create'; then
    products="$products studio"
  fi
  # Flex
  if echo "$pat" | grep -qiE 'flex\.v1|FlexFlow|@twilio/flex-ui|@twilio/flex-plugin|twilio-flex'; then
    products="$products flex"
  fi
  # Pay
  if echo "$pat" | grep -qiE '\.pay\b|PayResource|payments\.create|<Pay>'; then
    products="$products pay"
  fi
  echo "$products"
}

# Register a file hit: record_file <rel_path> <language> <product> <pattern>
# Accumulates products and patterns for files already seen.
declare -A FILE_INDEX  # rel_path -> index into FILE_* arrays

record_file() {
  local rel="$1" lang="$2" product="$3" pattern="$4"
  if [[ -n "$lang" && "$lang" != "unknown" ]]; then
    LANG_SET["$lang"]=1
  fi
  if [[ -n "$product" ]]; then
    PRODUCT_SET["$product"]=1
  fi

  if [[ -v FILE_INDEX["$rel"] ]]; then
    local idx="${FILE_INDEX[$rel]}"
    # Append product if not already listed
    if [[ -n "$product" ]] && ! echo ",${FILE_PRODUCTS[$idx]}," | grep -q ",$product,"; then
      FILE_PRODUCTS[$idx]="${FILE_PRODUCTS[$idx]},$product"
    fi
    # Append pattern if not already listed
    local escaped_pattern
    escaped_pattern="$(json_escape "$pattern")"
    if ! echo "||${FILE_PATTERNS[$idx]}||" | grep -qF "||$escaped_pattern||"; then
      FILE_PATTERNS[$idx]="${FILE_PATTERNS[$idx]}||$escaped_pattern"
    fi
  else
    local idx=${#FILE_PATHS[@]}
    FILE_INDEX["$rel"]=$idx
    FILE_PATHS+=("$rel")
    FILE_LANGS+=("$lang")
    FILE_PRODUCTS+=("$product")
    FILE_PATTERNS+=("$(json_escape "$pattern")")
  fi
}

# ---------------------------------------------------------------------------
# 1. SDK imports
# ---------------------------------------------------------------------------

log "Scanning SDK imports..."

SDK_PATTERNS=(
  # Python
  'from twilio'
  'import twilio'
  # JavaScript / TypeScript
  "require('twilio')"
  'require("twilio")'
  "from 'twilio'"
  'from "twilio"'
  # Go
  'github.com/twilio/twilio-go'
  # Ruby
  "require 'twilio-ruby'"
  'require "twilio-ruby"'
  "gem 'twilio-ruby'"
  # Java
  'import com.twilio'
  'com.twilio.'
  # PHP
  'use Twilio\\'
  'Twilio\\'
  # C# / .NET
  'using Twilio'
  'Twilio.'
  # curl
  'api.twilio.com'
  # iOS (Swift)
  'TwilioVoiceSDK'
  'import TwilioVoice'
  # Android (Kotlin/Java)
  'com.twilio.voice'
  'com.twilio:voice-android'
  # React Native
  '@twilio/voice-react-native'
  # Flutter (Dart)
  'twilio_voice'
  # Browser WebRTC
  'Twilio.Device'
  '@twilio/voice-sdk'
  'twilio-client'
)

# Also catch JS/TS `import ... twilio` via regex
SDK_REGEX_PATTERNS=(
  'import.*twilio'
)

for pat in "${SDK_PATTERNS[@]}"; do
  while IFS= read -r line; do
    [[ -z "$line" ]] && continue
    filepath="${line%%:*}"
    rest="${line#*:}"
    content="${rest#*:}"
    rel="${filepath#"$PROJECT_ROOT"/}"
    lang="$(detect_language "$rel")"
    trimmed="$(echo "$content" | sed 's/^[[:space:]]*//' | sed 's/[[:space:]]*$//')"
    products="$(pattern_to_products "$trimmed")"
    if [[ -z "$products" ]]; then
      # Generic SDK import — no specific product
      record_file "$rel" "$lang" "" "$trimmed"
    else
      for p in $products; do
        record_file "$rel" "$lang" "$p" "$trimmed"
      done
    fi
  done < <(run_grep -F "$pat")
done

for pat in "${SDK_REGEX_PATTERNS[@]}"; do
  while IFS= read -r line; do
    [[ -z "$line" ]] && continue
    filepath="${line%%:*}"
    rest="${line#*:}"
    content="${rest#*:}"
    rel="${filepath#"$PROJECT_ROOT"/}"
    lang="$(detect_language "$rel")"
    trimmed="$(echo "$content" | sed 's/^[[:space:]]*//' | sed 's/[[:space:]]*$//')"
    products="$(pattern_to_products "$trimmed")"
    if [[ -z "$products" ]]; then
      record_file "$rel" "$lang" "" "$trimmed"
    else
      for p in $products; do
        record_file "$rel" "$lang" "$p" "$trimmed"
      done
    fi
  done < <(run_grep -E "$pat")
done

# ---------------------------------------------------------------------------
# 2. Product-specific patterns (deeper detection)
# ---------------------------------------------------------------------------

log "Scanning product-specific patterns..."

PRODUCT_PATTERNS_FIXED=(
  'VoiceResponse:voice'
  'CallResource:voice'
  'MessageResource:messaging'
  'VideoGrant:video'
  'twilio-video:video'
  'VerificationResource:verify'
  'FaxResource:fax'
  'RequestValidator:webhook-validation'
  'validateRequest:webhook-validation'
  # Mobile WebRTC SDKs
  'TwilioVoiceSDK:webrtc'
  'TVOCall:webrtc'
  'TVOCallInvite:webrtc'
  'TVOCallDelegate:webrtc'
  # Browser WebRTC
  'Twilio.Device:webrtc'
  '@twilio/voice-sdk:webrtc'
  'twilio-client:webrtc'
  # SIP trunking
  'TrunkingGrant:sip'
  'SipGrant:sip'
  # IoT / Wireless
  'SuperSim:iot'
  'SimResource:iot'
  # Conversations
  'ConversationResource:conversations'
  # Notify
  'NotificationResource:notify'
  # Proxy
  'ProxyService:proxy'
  # Autopilot
  'AutopilotTask:autopilot'
  # TaskRouter
  'TaskRouterWorker:taskrouter'
  'WorkflowResource:taskrouter'
)

for entry in "${PRODUCT_PATTERNS_FIXED[@]}"; do
  pat="${entry%%:*}"
  product="${entry#*:}"
  while IFS= read -r line; do
    [[ -z "$line" ]] && continue
    filepath="${line%%:*}"
    rest="${line#*:}"
    content="${rest#*:}"
    rel="${filepath#"$PROJECT_ROOT"/}"
    lang="$(detect_language "$rel")"
    trimmed="$(echo "$content" | sed 's/^[[:space:]]*//' | sed 's/[[:space:]]*$//')"
    record_file "$rel" "$lang" "$product" "$trimmed"
  done < <(run_grep -F "$pat")
done

# Case-insensitive regex patterns for common method calls
PRODUCT_PATTERNS_REGEX=(
  'messages\.create:messaging'
  'messages\.list:messaging'
  '\.calls\.create:voice'
  '\.calls\.list:voice'
  'verify\.v2:verify'
  'verifications\.create:verify'
  'verification_checks:verify'
  '\.fax\.:fax'
  'faxes\.create:fax'
  'lookups\.v1:lookup'
  'lookups\.v2:lookup'
  'phone_numbers\.fetch:lookup'
  'twiml\.voice:voice'
  'twiml\.messaging:messaging'
  'VoiceGrant:voice'
  'SipGrant:voice'
  # SIP trunking
  'twilio\.rest\.trunking:sip'
  'trunking\.v1:sip'
  'trunk\.create:sip'
  # IoT / Wireless / Super SIM
  'twilio\.rest\.wireless:iot'
  'twilio\.rest\.supersim:iot'
  'wireless\.v1:iot'
  'supersim\.v1:iot'
  'sim\.create:iot'
  'fleet\.create:iot'
  # Conversations
  'twilio\.rest\.conversations:conversations'
  'conversations\.v1:conversations'
  'conversation\.create:conversations'
  # Sync
  'twilio\.rest\.sync:sync'
  'sync\.v1:sync'
  # Notify
  'twilio\.rest\.notify:notify'
  'notify\.v1:notify'
  # Proxy
  'twilio\.rest\.proxy:proxy'
  'proxy\.v1:proxy'
  # Autopilot
  'twilio\.rest\.autopilot:autopilot'
  'autopilot\.v1:autopilot'
  # TaskRouter
  'twilio\.rest\.taskrouter:taskrouter'
  'taskrouter\.v1:taskrouter'
  # Studio
  'twilio\.rest\.studio:studio'
  'studio\.v2:studio'
  'flow\.create:studio'
  # Flex
  'twilio\.rest\.flex:flex'
  'flex\.v1:flex'
  'FlexFlow:flex'
  '@twilio/flex-ui:flex'
  '@twilio/flex-plugin:flex'
  # Pay
  'twilio\.rest\.pay:pay'
  'payments\.create:pay'
  # Mobile WebRTC SDKs
  'com\.twilio\.voice\.:webrtc'
  'com\.twilio:voice-android:webrtc'
  '@twilio/voice-react-native:webrtc'
  'twilio_voice:webrtc'
  'import TwilioVoice:webrtc'
  # Browser WebRTC SDKs
  'new Device\(:webrtc'
  'Twilio\.Device:webrtc'
  '@twilio/voice-sdk:webrtc'
  'twilio-client:webrtc'
)

for entry in "${PRODUCT_PATTERNS_REGEX[@]}"; do
  pat="${entry%%:*}"
  product="${entry#*:}"
  while IFS= read -r line; do
    [[ -z "$line" ]] && continue
    filepath="${line%%:*}"
    rest="${line#*:}"
    content="${rest#*:}"
    rel="${filepath#"$PROJECT_ROOT"/}"
    lang="$(detect_language "$rel")"
    trimmed="$(echo "$content" | sed 's/^[[:space:]]*//' | sed 's/[[:space:]]*$//')"
    record_file "$rel" "$lang" "$product" "$trimmed"
  done < <(run_grep -iE "$pat")
done

# ---------------------------------------------------------------------------
# 3. Environment variables
# ---------------------------------------------------------------------------

log "Scanning environment variables..."

ENV_VAR_NAMES=(
  TWILIO_ACCOUNT_SID
  TWILIO_AUTH_TOKEN
  TWILIO_API_KEY
  TWILIO_API_KEY_SECRET
  TWILIO_API_KEY_SID
  TWILIO_PHONE_NUMBER
  TWILIO_FROM_NUMBER
  TWILIO_NUMBER
  TWILIO_TWIML_APP_SID
  TWILIO_MESSAGING_SERVICE_SID
  TWILIO_VERIFY_SERVICE_SID
)

for varname in "${ENV_VAR_NAMES[@]}"; do
  while IFS= read -r line; do
    [[ -z "$line" ]] && continue
    filepath="${line%%:*}"
    rel="${filepath#"$PROJECT_ROOT"/}"
    if [[ -v ENV_MAP["$varname"] ]]; then
      if ! echo ",${ENV_MAP[$varname]}," | grep -q ",$rel,"; then
        ENV_MAP["$varname"]="${ENV_MAP[$varname]},$rel"
      fi
    else
      ENV_MAP["$varname"]="$rel"
    fi
  done < <(run_grep -F "$varname")
done

for varname in "${!ENV_MAP[@]}"; do
  ENV_NAMES+=("$varname")
  ENV_FILES+=("${ENV_MAP[$varname]}")
done

# ---------------------------------------------------------------------------
# 4. API URLs
# ---------------------------------------------------------------------------

log "Scanning API URLs..."

API_URL_LIST=(
  api.twilio.com
  verify.twilio.com
  messaging.twilio.com
  video.twilio.com
  trunking.twilio.com
  lookups.twilio.com
  fax.twilio.com
)

for url in "${API_URL_LIST[@]}"; do
  while IFS= read -r line; do
    [[ -z "$line" ]] && continue
    filepath="${line%%:*}"
    rel="${filepath#"$PROJECT_ROOT"/}"
    if [[ -v API_URL_MAP["$url"] ]]; then
      if ! echo ",${API_URL_MAP[$url]}," | grep -q ",$rel,"; then
        API_URL_MAP["$url"]="${API_URL_MAP[$url]},$rel"
      fi
    else
      API_URL_MAP["$url"]="$rel"
    fi
  done < <(run_grep -F "$url")
done

for url in "${!API_URL_MAP[@]}"; do
  API_URLS+=("$url")
  API_URL_FILES+=("${API_URL_MAP[$url]}")
done

# ---------------------------------------------------------------------------
# 5. Config / dependency files
# ---------------------------------------------------------------------------

log "Scanning config files..."

CONFIG_FILES=(
  "requirements.txt:pip"
  "package.json:npm"
  "Gemfile:gem"
  "go.mod:gomod"
  "pom.xml:maven"
  "build.gradle:gradle"
  "composer.json:composer"
  "Pipfile:pipenv"
  "setup.py:setuptools"
  "setup.cfg:setuptools"
  "pyproject.toml:pyproject"
  "requirements-to-freeze.txt:pip"
  "Podfile:cocoapods"
  "pubspec.yaml:pub"
)

# shellcheck disable=SC2034  # reserved for future C#/.NET dependency scanning
CSPROJ_PATTERN="*.csproj:nuget"

# Scan known config filenames
for entry in "${CONFIG_FILES[@]}"; do
  filename="${entry%%:*}"
  cfgtype="${entry#*:}"
  while IFS= read -r line; do
    [[ -z "$line" ]] && continue
    filepath="${line%%:*}"
    rest="${line#*:}"
    content="${rest#*:}"
    rel="${filepath#"$PROJECT_ROOT"/}"
    trimmed="$(echo "$content" | sed 's/^[[:space:]]*//' | sed 's/[[:space:]]*$//')"
    CFG_PATHS+=("$rel")
    CFG_TYPES+=("$cfgtype")
    CFG_LINES+=("$(json_escape "$trimmed")")
  done < <(run_grep -F "twilio" --include="$filename")
done

# Scan *.csproj files
while IFS= read -r line; do
  [[ -z "$line" ]] && continue
  filepath="${line%%:*}"
  rest="${line#*:}"
  content="${rest#*:}"
  rel="${filepath#"$PROJECT_ROOT"/}"
  trimmed="$(echo "$content" | sed 's/^[[:space:]]*//' | sed 's/[[:space:]]*$//')"
  CFG_PATHS+=("$rel")
  CFG_TYPES+=("nuget")
  CFG_LINES+=("$(json_escape "$trimmed")")
done < <(run_grep -F "Twilio" --include="*.csproj")

# ---------------------------------------------------------------------------
# 6. TwiML files — XML files containing <Response> with voice verbs
# ---------------------------------------------------------------------------

log "Scanning TwiML files..."

TWIML_VERBS='<Say>|<Play>|<Dial>|<Gather>|<Record>|<Hangup>|<Redirect>|<Pause>|<Enqueue>'

while IFS= read -r line; do
  [[ -z "$line" ]] && continue
  filepath="${line%%:*}"
  rel="${filepath#"$PROJECT_ROOT"/}"
  # Verify the file also contains <Response>
  if grep -q '<Response>' "$filepath" 2>/dev/null; then
    # Deduplicate
    local_found=0
    for existing in "${TWIML_FILES[@]+"${TWIML_FILES[@]}"}"; do
      if [[ "$existing" == "$rel" ]]; then
        local_found=1
        break
      fi
    done
    if [[ $local_found -eq 0 ]]; then
      TWIML_FILES+=("$rel")
    fi
  fi
done < <(run_grep -E "$TWIML_VERBS" --include="*.xml")

# ---------------------------------------------------------------------------
# 7. Webhook validation handlers
# ---------------------------------------------------------------------------

log "Scanning webhook handlers..."

WH_TERMS=(
  "RequestValidator"             # Python/Node/Ruby/PHP SDK validator class
  "validateRequest"              # method call on RequestValidator
  "X-Twilio-Signature"           # header name (any casing)
  "twilio.webhook"               # Express middleware (Node)
  "Twilio.webhook"               # same, capitalised import
  "Twilio::Security"             # Ruby namespace housing RequestValidator
  "validate_twilio_request"      # common Rails before_action / Flask decorator name
)

for term in "${WH_TERMS[@]}"; do
  while IFS= read -r line; do
    [[ -z "$line" ]] && continue
    filepath="${line%%:*}"
    rel="${filepath#"$PROJECT_ROOT"/}"
    # Deduplicate by rel+term
    dup=0
    for i in "${!WH_PATHS[@]}"; do
      if [[ "${WH_PATHS[$i]}" == "$rel" && "${WH_PATTERNS[$i]}" == "$term" ]]; then
        dup=1
        break
      fi
    done
    if [[ $dup -eq 0 ]]; then
      WH_PATHS+=("$rel")
      WH_PATTERNS+=("$term")
    fi
  done < <(run_grep -F "$term")
done

# ---------------------------------------------------------------------------
# 8. Config/deployment files with TWILIO_ references
# ---------------------------------------------------------------------------

log "Scanning config and deployment files for TWILIO_ references..."

declare -a DEPLOY_PATHS=()
declare -a DEPLOY_TYPES=()

DEPLOY_PATTERNS=(
  ".env:env"
  ".env.example:env"
  ".env.local:env"
  ".env.production:env"
  ".env.development:env"
  "docker-compose.yml:docker"
  "docker-compose.yaml:docker"
  "Dockerfile:docker"
  "app.json:heroku"
  "app.yaml:gae"
  "serverless.yml:serverless"
  "serverless.yaml:serverless"
  "terraform.tfvars:terraform"
  "variables.tf:terraform"
  "*.tf:terraform"
  ".github/workflows/*.yml:ci"
  ".github/workflows/*.yaml:ci"
  ".circleci/config.yml:ci"
  ".gitlab-ci.yml:ci"
  "Procfile:procfile"
  "render.yaml:render"
  "fly.toml:fly"
  "vercel.json:vercel"
  "netlify.toml:netlify"
)

for entry in "${DEPLOY_PATTERNS[@]}"; do
  filename="${entry%%:*}"
  dtype="${entry#*:}"
  while IFS= read -r line; do
    [[ -z "$line" ]] && continue
    filepath="${line%%:*}"
    rel="${filepath#"$PROJECT_ROOT"/}"
    # Deduplicate
    dup=0
    for existing in "${DEPLOY_PATHS[@]+"${DEPLOY_PATHS[@]}"}"; do
      if [[ "$existing" == "$rel" ]]; then
        dup=1
        break
      fi
    done
    if [[ $dup -eq 0 ]]; then
      DEPLOY_PATHS+=("$rel")
      DEPLOY_TYPES+=("$dtype")
    fi
  done < <(run_grep -iE "TWILIO_|twilio" --include="$filename")
done

# ---------------------------------------------------------------------------
# 9. Test mocks (detect test files mocking Twilio)
# ---------------------------------------------------------------------------

log "Scanning for test mocks..."

declare -a MOCK_PATHS=()

MOCK_PATTERNS_REGEX=(
  'mock.*twilio'
  '@patch.*twilio'
  'jest\.mock.*twilio'
  'stub.*twilio'
  'fake.*twilio'
  'nock.*twilio'
  'sinon.*twilio'
  'WebMock.*twilio'
  'VCR.*twilio'
)

for pat in "${MOCK_PATTERNS_REGEX[@]}"; do
  while IFS= read -r line; do
    [[ -z "$line" ]] && continue
    filepath="${line%%:*}"
    rel="${filepath#"$PROJECT_ROOT"/}"
    # Deduplicate
    dup=0
    for existing in "${MOCK_PATHS[@]+"${MOCK_PATHS[@]}"}"; do
      if [[ "$existing" == "$rel" ]]; then
        dup=1
        break
      fi
    done
    if [[ $dup -eq 0 ]]; then
      MOCK_PATHS+=("$rel")
    fi
  done < <(run_grep -iE "$pat")
done

# ---------------------------------------------------------------------------
# Build JSON output
# ---------------------------------------------------------------------------

log "Building JSON output..."

SCAN_TIME="$(date -u +"%Y-%m-%dT%H:%M:%SZ")"

# --- languages_detected ---
lang_json=""
for lang in "${!LANG_SET[@]}"; do
  [[ -n "$lang_json" ]] && lang_json="$lang_json, "
  lang_json="$lang_json\"$lang\""
done

# --- products_used ---
prod_json=""
for prod in "${!PRODUCT_SET[@]}"; do
  [[ -n "$prod_json" ]] && prod_json="$prod_json, "
  prod_json="$prod_json\"$prod\""
done

# --- files array ---
files_json=""
for i in "${!FILE_PATHS[@]}"; do
  [[ -n "$files_json" ]] && files_json="$files_json,"
  rel="$(json_escape "${FILE_PATHS[$i]}")"
  lang="${FILE_LANGS[$i]}"
  # Build products array from comma-separated
  prods_arr=""
  IFS=',' read -ra plist <<< "${FILE_PRODUCTS[$i]}"
  for p in "${plist[@]}"; do
    p="$(echo "$p" | sed 's/^[[:space:]]*//' | sed 's/[[:space:]]*$//')"
    [[ -z "$p" ]] && continue
    [[ -n "$prods_arr" ]] && prods_arr="$prods_arr, "
    prods_arr="$prods_arr\"$p\""
  done
  # Build patterns array from ||-separated
  pats_arr=""
  IFS=$'\x1f' read -ra patlist <<< "${FILE_PATTERNS[$i]//'||'/$'\x1f'}"
  for pt in "${patlist[@]}"; do
    [[ -z "$pt" ]] && continue
    [[ -n "$pats_arr" ]] && pats_arr="$pats_arr, "
    pats_arr="$pats_arr\"$pt\""
  done
  files_json="$files_json
    {
      \"path\": \"$rel\",
      \"language\": \"$lang\",
      \"products\": [$prods_arr],
      \"patterns_matched\": [$pats_arr]
    }"
done

# --- env_vars array ---
env_json=""
for i in "${!ENV_NAMES[@]}"; do
  [[ -n "$env_json" ]] && env_json="$env_json,"
  name="${ENV_NAMES[$i]}"
  files_list=""
  IFS=',' read -ra elist <<< "${ENV_FILES[$i]}"
  for ef in "${elist[@]}"; do
    ef="$(echo "$ef" | sed 's/^[[:space:]]*//' | sed 's/[[:space:]]*$//')"
    [[ -z "$ef" ]] && continue
    [[ -n "$files_list" ]] && files_list="$files_list, "
    files_list="$files_list\"$(json_escape "$ef")\""
  done
  env_json="$env_json
    {
      \"name\": \"$name\",
      \"files\": [$files_list]
    }"
done

# --- config_files array ---
cfg_json=""
for i in "${!CFG_PATHS[@]}"; do
  [[ -n "$cfg_json" ]] && cfg_json="$cfg_json,"
  cfg_json="$cfg_json
    {
      \"path\": \"$(json_escape "${CFG_PATHS[$i]}")\",
      \"type\": \"${CFG_TYPES[$i]}\",
      \"line\": \"${CFG_LINES[$i]}\"
    }"
done

# --- twiml_files array ---
twiml_json=""
for tf in "${TWIML_FILES[@]+"${TWIML_FILES[@]}"}"; do
  [[ -n "$twiml_json" ]] && twiml_json="$twiml_json, "
  twiml_json="$twiml_json\"$(json_escape "$tf")\""
done

# --- webhook_handlers array ---
wh_json=""
for i in "${!WH_PATHS[@]}"; do
  [[ -n "$wh_json" ]] && wh_json="$wh_json,"
  wh_json="$wh_json
    {
      \"path\": \"$(json_escape "${WH_PATHS[$i]}")\",
      \"pattern\": \"$(json_escape "${WH_PATTERNS[$i]}")\"
    }"
done

# --- api_urls array ---
api_json=""
for i in "${!API_URLS[@]}"; do
  [[ -n "$api_json" ]] && api_json="$api_json,"
  url="${API_URLS[$i]}"
  files_list=""
  IFS=',' read -ra alist <<< "${API_URL_FILES[$i]}"
  for af in "${alist[@]}"; do
    af="$(echo "$af" | sed 's/^[[:space:]]*//' | sed 's/[[:space:]]*$//')"
    [[ -z "$af" ]] && continue
    [[ -n "$files_list" ]] && files_list="$files_list, "
    files_list="$files_list\"$(json_escape "$af")\""
  done
  api_json="$api_json
    {
      \"url\": \"$url\",
      \"files\": [$files_list]
    }"
done

# --- summary ---
# Use (( ${#ARR[@]} > 0 )) for "array has elements" — safe under `set -u` for
# declared arrays and avoids shellcheck SC2199 (array concatenation in [[ ]]).
total_files=${#FILE_PATHS[@]}
total_products=${#PRODUCT_SET[@]}
total_languages=${#LANG_SET[@]}
has_webhook="false"
(( ${#WH_PATHS[@]} > 0 )) && has_webhook="true"
has_twiml="false"
(( ${#TWIML_FILES[@]} > 0 )) && has_twiml="true"
has_env="false"
(( ${#ENV_NAMES[@]} > 0 )) && has_env="true"
has_deploy="false"
(( ${#DEPLOY_PATHS[@]} > 0 )) && has_deploy="true"
has_mocks="false"
(( ${#MOCK_PATHS[@]} > 0 )) && has_mocks="true"

# --- deploy_files array ---
deploy_json=""
for i in "${!DEPLOY_PATHS[@]}"; do
  [[ -n "$deploy_json" ]] && deploy_json="$deploy_json,"
  deploy_json="$deploy_json
    {
      \"path\": \"$(json_escape "${DEPLOY_PATHS[$i]}")\",
      \"type\": \"${DEPLOY_TYPES[$i]}\"
    }"
done

# --- test_mocks array ---
mock_json=""
for mf in "${MOCK_PATHS[@]+"${MOCK_PATHS[@]}"}"; do
  [[ -n "$mock_json" ]] && mock_json="$mock_json, "
  mock_json="$mock_json\"$(json_escape "$mf")\""
done

# ---------------------------------------------------------------------------
# Print final JSON to stdout
# ---------------------------------------------------------------------------

cat <<ENDJSON
{
  "scan_version": "1.0.0",
  "project_root": "$(json_escape "$PROJECT_ROOT")",
  "scan_time": "$SCAN_TIME",
  "languages_detected": [$lang_json],
  "products_used": [$prod_json],
  "files": [${files_json}
  ],
  "env_vars": [${env_json}
  ],
  "config_files": [${cfg_json}
  ],
  "twiml_files": [${twiml_json}],
  "webhook_handlers": [${wh_json}
  ],
  "api_urls": [${api_json}
  ],
  "deploy_files": [${deploy_json}
  ],
  "test_mocks": [${mock_json}],
  "summary": {
    "total_files": $total_files,
    "total_products": $total_products,
    "total_languages": $total_languages,
    "has_webhook_validation": $has_webhook,
    "has_twiml": $has_twiml,
    "has_env_vars": $has_env,
    "has_deploy_config": $has_deploy,
    "has_test_mocks": $has_mocks
  },
  "notes": [
    "Standard TWILIO_* env vars are scanned above. Also search for non-standard names that may contain Twilio SIDs or phone numbers (e.g., ACCOUNT_SID, SMS_FROM, PHONE_NUMBER)."
  ]
}
ENDJSON

log "Scan complete. Found $total_files files, $total_products products, $total_languages languages."
finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the workStars: 322kUpdated Claude CodeCodexVerifiedInstall
systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixesStars: 322kUpdated Claude CodeCodexVerifiedInstall
test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation codeStars: 322kUpdated Claude CodeCodexVerifiedInstall
skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.Stars: 198kUpdated Claude CodeCodexVerifiedInstall