# =========================================
# CLINE RULES — A11Y TABLE CHECKER PROJECT
# =========================================

## GENERAL BEHAVIOR

- Never stop mid-task.
- Always complete all requested files.
- Never ask unnecessary confirmation questions.
- If implementation is partially complete, continue automatically.
- Prefer modifying existing files instead of creating duplicates.
- Always verify imports and references after edits.
- Never remove working functionality unless explicitly requested.
- Never generate placeholder implementations.
- Always generate production-ready code.

# =========================================
# WINDOWS COMPATIBILITY
# =========================================

- Use Windows-safe paths.
- Avoid Linux-only commands.
- Use relative paths.
- Never use bash-specific syntax unless requested.
- Avoid shell chaining operators that fail on Windows.
- Prefer Node.js scripts over shell commands.

# =========================================
# CHROME EXTENSION RULES
# =========================================

- Maintain Manifest V3 compatibility.
- Never break existing content_scripts.
- Never remove required permissions.
- Preserve popup functionality.
- Preserve service worker functionality.
- Verify manifest.json after edits.
- Ensure all referenced JS/CSS files exist.
- Ensure all popup references are valid.
- Ensure all executeScript calls are valid.
- Ensure injected functions exist on window scope.

# =========================================
# FILE VERIFICATION
# =========================================

Before completing ANY task:

1. Verify all referenced files exist.
2. Verify manifest paths are valid.
3. Verify no missing imports.
4. Verify no duplicate listeners.
5. Verify no duplicate tooltip systems.
6. Verify all functions are reachable.
7. Verify no syntax errors.
8. Verify all modules load correctly.
9. Verify all event listeners are cleaned up.
10. Verify extension can reload without errors.

# =========================================
# PERFORMANCE RULES
# =========================================

- Avoid duplicate DOM scans.
- Avoid duplicate event listeners.
- Reuse tooltip instances.
- Avoid memory leaks.
- Use MutationObserver carefully.
- Remove listeners during cleanup.
- Use event delegation when possible.

# =========================================
# TABLE ENGINE ARCHITECTURE
# =========================================

Keep architecture modular:

parser.js
- table matrix parsing
- rowspan handling
- colspan handling

mapping.js
- header association engine
- headers/id mapping
- scope mapping

audit.js
- WCAG checks
- accessibility analysis

overlay.js
- highlights
- hover overlays
- tooltips

panel.js
- side panel UI
- issue rendering

export.js
- CSV export
- JSON export
- report generation

content.js
- initialization
- orchestration

# =========================================
# TOOLTIP RULES
# =========================================

- Only ONE tooltip system allowed.
- Never create duplicate floating tooltips.
- Reuse global tooltip instance.
- Tooltip must cleanup on disable.
- Tooltip must hide on ESC.

# =========================================
# EXTENSION TOGGLE RULES
# =========================================

When extension is disabled:

- Remove all toolbars
- Remove all overlays
- Remove all highlights
- Remove all tooltips
- Remove all listeners
- Stop hover processing
- Stop keyboard navigation
- Remove MutationObservers

# =========================================
# DEBUGGING RULES
# =========================================

After every major edit:

- Check browser console errors.
- Check manifest validity.
- Check popup loads.
- Check content script loads.
- Check extension reloads correctly.

# =========================================
# UI RULES
# =========================================

- Maintain accessible UI.
- Buttons must support keyboard interaction.
- ESC must close overlays/panels.
- Use ARIA labels where appropriate.
- Preserve WCAG compatibility.

# =========================================
# TASK COMPLETION RULE
# =========================================

A task is NOT complete until:

- All requested files exist
- All functionality works
- No missing references exist
- No placeholder code exists
- No TODO comments remain
- Extension reloads successfully
- No console errors exist

Never scan node_modules.
Never scan dist.
Never recursively scan entire workspace unless required.