> tdz-debugger
Quickly diagnose and fix JavaScript Temporal Dead Zone (TDZ) / 'Cannot access X before initialization' errors.
curl "https://skillshub.wtf/tippyentertainment/skills/tdz-debugger?format=md"Provided by TippyEntertainment
https://github.com/tippyentertainment/skills.git
Purpose
This skill is for one specific class of problems:
ReferenceError: Cannot access 'X' before initialization
(TDZ issues caused bylet/const/class, bundlers, or circular imports).
Use this skill whenever I mention:
- “TDZ”, “temporal dead zone”. Goal: fast, concrete fixes in the actual codebase, not generic JS theory.
Inputs you should ask for
Before proposing changes, ask for:
- Error + stack trace
- At least one full stack trace pointing to source (sourcemaps enabled).
- Relevant files
- The modules/functions mentioned in the stack (imports + top of file).
- Tooling
- Bundler (Vite/Webpack/Rollup), test runner (Jest/Vitest), Node/browser target.
If something is missing, ask targeted follow‑ups instead of guessing.
Inputs you should ask for
Before proposing changes, ask for:
- Error + stack trace
- At least one full stack trace pointing to source (sourcemaps enabled).
- Relevant files
- The modules/functions mentioned in the stack (imports + top of file).
- Tooling
- Bundler (Vite/Webpack/Rollup), test runner (Jest/Vitest), Node/browser target.
If something is missing, ask targeted follow‑ups instead of guessing.
How to think about TDZ
- TDZ happens when a
let/const/classbinding is touched between scope entry and its declaration line.
Common root causes:
- Variable/function/class used before its declaration in the same file.
- Circular module imports (A imports B, B imports A, with top‑level execution).
- Exported constants that depend on other exports defined later in the same module.
Required answer format
Always answer TDZ questions using this structure:
-
Issue
- Short description of what is failing and in which context (dev build, prod build, tests).
- The specific TDZ cause (for example, “circular import between
store.tsandroutes.ts”, or “schemaused before declaration”).
-
File/Line
- File name(s) and approximate line/region where the problem manifests and where the fix should be applied.
-
Fix
- Minimal, concrete code changes to remove the TDZ, such as:
- Re‑ordering declarations.
- Breaking circular imports by extracting shared pieces.
- Moving imports/usages inside functions or factories.
- Minimal, concrete code changes to remove the TDZ, such as:
-
Result
- Briefly state how the change removes the TDZ and what behavior to expect afterward.
Fixing strategy
- Identify the binding
- Classify the pattern
- Same‑file ordering vs circular imports vs exported constant ordering.
- Propose the smallest change that breaks the TDZ
- Prefer:
- Moving declarations above use.
- Extracting shared code into a separate module to break cycles.
- Lazy imports inside functions for rarely used paths.
- Prefer:
- Show before/after code
- Only for affected snippets, minimal and copy‑paste‑ready.
- e.g., “Re‑run
npm run buildand load/app; TDZ error should be gone. If a new symbol appears, send that stack trace next.”
Constraints
- Don’t respond with pure theory; always tie explanations to actual files and imports.
- Don’t recommend disabling minification or code‑splitting as a final fix; that’s only for temporary debugging.
- Don’t propose massive refactors; default to the smallest structural change that fixes the issue.
Example prompts this skill should handle
- “TDZ again: Cannot access 'schema' before initialization in
src/routes/app.tsx.” - “Vite prod build: Cannot access 'ce' before initialization, stack trace attached.”
- “Jest tests fail with TDZ errors after I split my store into multiple files.”
- “How do I fix this TDZ in a circular import between
store.tsandroutes.ts?”
> related_skills --same-repo
> worldclass-tailwind-v4-visual-design
A top-tier product/UI designer skill that uses Tailwind v4 plus Google Gemini Nano Banana image models to craft visually stunning, “award‑winning” marketing sites and apps with strong art direction, motion, and systems thinking.
> wasm-spa-autofix-react-imports
Meticulously detect and fix missing React/TSX imports, undefined components, and bundler runtime errors in the WASM SPA build/preview pipeline. Ensures JSX components, icons, and hooks are properly imported or defined before running the browser preview, so the runtime safety-net rarely triggers.
> vite-webcontainer-developer
Debug and auto-fix Vite projects running inside WebContainers: resolve mount/root issues, alias/path errors, missing scripts, and other common dev-time problems so the app boots cleanly.
> vite-config-react19-spa-expert
Diagnose and fix Vite + React 19 configuration issues for TypeScript SPA and WASM preview builds. Specializes in React 19’s JSX runtime, @vitejs/plugin-react, path aliases, SPA routing, and dev-server behavior so the app and in-browser preview bundle cleanly without manual trial-and-error.