Automated summary
Provides project-specific frontend context for the Megahub IDE: Vite build modes, Blockly, Web Bluetooth, CSS tokens, and component structure.
Strengths
- Documents the three build modes (dev, bt, web) and runtime access via VITE_MODE
- Enforces VS Code Dark theme tokens instead of hardcoded colors and sizes
- Maps the file structure and Web Components (Blockly, BLE, Lua preview, logs)
- Points to the blockly skill for block authoring and Lua generators
Limitations
- Highly specific to Megahub and not reusable for another frontend
- Web Bluetooth only works in Chrome, Edge, and Opera
- Does not cover testing or deployment beyond build modes
Use it when modifying the Megahub frontend: components, styles, BLE client, Blockly, or Vite configuration.
Avoid it for firmware, backend work, or generic frontend advice outside this project.
Security analysis
SafeThis skill is purely informational documentation for frontend development context. It declares no tools and contains no commands, scripts, or instructions that could execute destructive, exfiltrating, or unsafe actions. All content is descriptive guidance about project structure, CSS tokens, and UI patterns.
No concerns found
How this analysis is madeExamples
Add a new sidebar panel as a Web Component under /frontend/src/components/, using Shadow DOM and the existing --vscode-* theme tokens instead of hardcoded colors.Why isn't Web Bluetooth available in dev mode? Explain the dev, bt, and web build modes and how import.meta.env.VITE_MODE is used at runtime.Update the project manager dialog in /frontend/src/components/files/ to show an autostart badge, reusing theme.css spacing and color tokens rather than adding new CSS values.name: frontend description: Frontend development context for the Megahub project. Use when working on the web-based IDE, Vite build system, Blockly visual programming, Web Bluetooth API integration, JavaScript frontend code, CSS/styles, UI components, or anything in the /frontend/ directory.
Frontend Development — Megahub IDE
Tech Stack
- Vite — build tool and dev server
- Blockly 12.3.1 — visual programming editor; custom blocks in
/frontend/src/components/blockly/— seeblocklyskill for block authoring, Lua generators, and BLOCKS.md generation - Vanilla JS — no framework (intentionally lightweight for ESP32 flash size)
- Web Bluetooth API — browser BLE, Chrome/Edge/Opera only
- Prism.js — Lua syntax highlighting in the preview panel
- Web Components — all sidebar panels are custom elements with Shadow DOM
Build Modes
| Mode | Description |
|------|-------------|
| dev | Hot reload, localStorage for persistence, no BLE |
| bt | Production BLE mode, deployed to GitHub Pages |
| web | WiFi/HTTP mode, served from firmware WebServer |
Mode is available at runtime as import.meta.env.VITE_MODE.
File Structure
frontend/
index.html Main entry point (HTML skeleton)
src/
index.js App controller, event wiring, all Application.* methods
bleclient.js BLE protocol client (fragmentation, streaming, events)
theme.css CSS design tokens (all --vscode-* variables)
styles.css Global styles, layout grid, all UI component CSS
components/
blockly/ Blockly editor + custom block definitions
files/ Project manager dialog (list/create/delete/autostart)
logger/ Terminal-style log output (max 50 entries)
luapreview/ Syntax-highlighted Lua code preview
portstatus/ Real-time LEGO port status cards
ui/ show_value block output display
btdevicelist/ Bluetooth Classic device list + discovery
sidebar-toggle/ Mobile sidebar toggle button
VS Code Dark Theme System
All design tokens are CSS custom properties defined in theme.css. Always use these — never hardcode colors or sizes.
Key Color Tokens
--vscode-bg-primary: #1e1e1e /* Main background */
--vscode-bg-secondary: #252526 /* Panels, cards, sidebar */
--vscode-bg-elevated: #2d2d30 /* Hover states */
--vscode-bg-input: #3c3c3c /* Form inputs */
--vscode-text-primary: #cccccc /* Main text */
--vscode-text-secondary: #858585 /* Muted text, breadcrumb items */
--vscode-text-tertiary: #6a6a6a /* Very muted (separators) */
--vscode-text-bright: #ffffff /* Headings, active labels */
--vscode-accent-blue: #007acc /* Focus borders */
--vscode-accent-blue-dark: #0078d4 /* Primary buttons, status bar */
--vscode-accent-blue-hover: #1177bb
--vscode-accent-teal: #4ec9b0 /* Success, connected state */
--vscode-accent-yellow: #dcdcaa /* Warning, connecting state */
--color-success: #4ec9b0
--color-error: #f48771
--color-error-bg: #5a1d1d
--color-warning: #dcdcaa
--vscode-border-light: #3c3c3c
--vscode-border-medium: #3e3e42
Key Spacing / Sizing Tokens
--spacing-xs: 0.25rem --spacing-sm: 0.5rem
--spacing-md: 0.75rem --spacing-lg: 1rem
--spacing-xl: 1.25rem --spacing-2xl: 1.5rem
--transition-fast: 0.15s ease
--transition-medium: 0.3s ease
--header-height: 3rem
--z-modal: 1100 --z-tooltip: 2000
Application Mode System
Three modes, switched via Application.setMode(mode):
| Mode | View shown |
|------|-----------|
| btconnect | Welcome screen + connect button |
| management | Project list (files component) |
| editor | Blockly editor + sidebar controls |
Visibility Mechanism
dynamicvisibility class (all modes):
// setMode() sets display:block/none on elements with class dynamicvisibility
// Elements also have class visible-{mode} to declare when they appear
// e.g. class="dynamicvisibility visible-editor visible-management"
⚠ setMode() always sets display: block — do NOT use dynamicvisibility for elements that need display: flex or display: grid.
body.dataset.mode (CSS-based, for flex/grid elements):
// setMode() also sets document.body.dataset.mode = mode
// Use CSS selectors: body[data-mode="editor"] .my-element { display: flex }
// Used by: header breadcrumb, back button
Layout Grid
┌──────────────────────────────────────┐ ← header (3rem)
│ [←] Megahub IDE / project [toggle] │
├──────────────────┬───────────────────┤ ← 1fr
│ │ sidebar buttons │
│ Blockly / │ ─────────────────│
│ Files / │ accordion panels │
│ Welcome │ lua / ports / │
│ │ ui / btdevices │
├──────────────────┴───────────────────┤ ← footer (8–12rem)
│ Logger (terminal output) │
├──────────────────────────────────────┤ ← statusbar (20px)
│ ● Connected to Megahub IDE │
└──────────────────────────────────────┘
Desktop (≥1512px): 75/25 content/sidebar split. Mobile: sidebar is a slide-in overlay.
Existing UI Patterns (use these, don't reinvent)
Notifications (Toast)
showNotification('success' | 'error' | 'warning' | 'info', title, message, durationMs)
// duration 0 = no auto-dismiss
// Returns the notification element (for manual dismissal)
Confirmation Dialog
const confirmed = await showConfirmDialog(title, message, {
confirmText: 'Delete', // default: 'Confirm'
cancelText: 'Cancel',
destructive: true // red confirm button (default: true)
});
Top Progress Bar
Progress.show() // indeterminate shimmer sweep
Progress.hide()
// Used for: project list load, file open, file save
BLE Connection Modal
ConnectionModal.show() // resets all steps to pending
ConnectionModal.setStep(stepId) // marks previous steps done, current active
ConnectionModal.setAllDone() // all checkmarks
ConnectionModal.setError(stepId, message) // marks step red, shows error text
ConnectionModal.hide()
// stepIds: 'requesting' | 'connecting' | 'services' | 'notifications' | 'mtu' | 'ready'
VS Code Status Bar
StatusBar.setConnecting()
StatusBar.setConnected(deviceName)
StatusBar.setDisconnected()
StatusBar.setMessage(text) // right-side info text
StatusBar.clearMessage()
Sidebar Icon Buttons
.sidebar-icon-btn /* base */
.sidebar-icon-btn-primary /* blue background (Execute) */
.sidebar-icon-btn-danger /* red background (Stop) */
.sidebar-icon-btn-save /* neutral, turns blue on hover */
.sidebar-icon-btn-toggle /* teal when aria-pressed="true" */
.sidebar-icon-btn.btn-loading /* spins the SVG icon */
BLE Client Architecture (bleclient.js)
Connection Flow
connect(onProgress?)
→ navigator.bluetooth.requestDevice() [requires user gesture]
→ _setupGattConnection(onProgress?)
→ gatt.connect()
→ getPrimaryService()
→ getCharacteristic() × 4
→ startNotifications() × 3
→ sleep(200) ← CRITICAL: BLE stack propagation delay
→ waitForMTU(2000)
→ testControlChannel()
→ emits onProgress callbacks at each step
Message Protocol
- 5-byte fragment header: type, messageId, fragmentNum(2), flags
- MTU: default 23 bytes, negotiated up to 517 bytes
- Fragmentation: automatic for all requests/responses
- Streaming protocol: for large file uploads (chunks + ACK window)
Event System
bleClient.addEventListener(APP_EVENT_TYPE_*, callback)
bleClient.removeAllEventListeners()
// Event types: LOG, PORTSTATUS, COMMAND, BTCLASSICDEVICES
File Upload
await bleClient.uploadFileStreaming(projectId, filename, content, onProgress?)
// Sliding window: 8 chunks in flight, waits for ACK before advancing
Animation Principles
All animations must be purposeful — each one communicates meaning:
| Use case | Animation | Timing |
|----------|-----------|--------|
| State transitions | CSS transition | var(--transition-fast) = 0.15s ease |
| Indeterminate loading | Shimmer sweep (progress bar) | 1.4s linear infinite |
| Spinner (waiting) | Rotate 360° | 0.8s linear infinite |
| Step completion | Scale 0→1 + opacity | 0.15s ease-out (one-shot) |
| Status dot state change | Color transition | 0.3s ease |
| Connecting pulse | Opacity 1→0.3→1 | 1s ease-in-out infinite |
Always wrap looping animations in:
@media (prefers-reduced-motion: reduce) {
/* replace animation with instant state */
}
Component Pattern (Web Components)
All sidebar panels are custom elements with Shadow DOM:
class MyComponent extends HTMLElement {
connectedCallback() {
const shadow = this.attachShadow({ mode: 'open' });
const sheet = new CSSStyleSheet();
sheet.replaceSync(styleSheet); // import from style.css
shadow.adoptedStyleSheets = [sheet];
shadow.innerHTML = template; // import from component.html
}
}
customElements.define('custom-my-component', MyComponent);
Accordion behavior: dispatch accordion-expand / accordion-collapse custom events. Parent (initSidebarAccordion() in index.js) collapses all others on expand.
Important Constraints
- Bundle size: Keep JS small — it's embedded in 4MB ESP32 flash
- No framework: No React/Vue/Angular — intentional
- Shadow DOM: Component styles are isolated;
theme.cssvariables are inherited through the shadow boundary - Web Bluetooth: User gesture required for
requestDevice()— never call without a click handler - Supported browsers: Chrome, Edge, Opera only — Firefox/Safari don't support Web Bluetooth
From the file to a first result
The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.
View the source and supporting filesThis download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.
1. Download the file
Download SKILL.mdFrom the root of a test project, save the file as .skill-downloads/frontend-development-megahub-ide-mse7in5n/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.
Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.
mkdir -p '.skill-downloads/frontend-development-megahub-ide-mse7in5n' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/frontend-development-megahub-ide-mse7in5n/download' --output '.skill-downloads/frontend-development-megahub-ide-mse7in5n/SKILL.md.part' && mv '.skill-downloads/frontend-development-megahub-ide-mse7in5n/SKILL.md.part' '.skill-downloads/frontend-development-megahub-ide-mse7in5n/SKILL.md'2. Check prerequisites
Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.
No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.
The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.
3. Load the skill
After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.
Claude Code
test -f '.skill-downloads/frontend-development-megahub-ide-mse7in5n/SKILL.md' && test -s '.skill-downloads/frontend-development-megahub-ide-mse7in5n/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/frontend' && cp -R '.skill-downloads/frontend-development-megahub-ide-mse7in5n' '.claude/skills/frontend'OpenSkills
OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.
Official OpenSkills installationopenskills install './.skill-downloads/frontend-development-megahub-ide-mse7in5n'openskills read 'frontend-development-megahub-ide-mse7in5n'Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.
For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.
openskills syncManual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.
4. Try a first task
Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:
Read .skill-downloads/frontend-development-megahub-ide-mse7in5n/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.
React Hook Form Best Practices
Development
Master React Hook Form: avoid anti-patterns, manage subscriptions, and handle reset, dirty state, and controlled inputs correctly.
Emotion to Mantine Migration
Development
Migrate Emotion styled-components to Mantine components with style props and CSS modules. Use when converting .styled.tsx files or removing @emotion imports.
Scope Creep Detector
Development
Analyzes git diffs against a stated intent to detect scope creep, unrelated files, broad PRs, and oversized changes, then suggests keep, split, or justify actions.