| name | vfloat-file-structure |
| description | Enforce the unified file structure for VFloat composables and modules. This skill ensures a consistent layout where the main logic is prioritized at the top, followed by internal helpers, and finally public types/interfaces. Use this when creating new composables, refactoring existing ones, or during code cleanup. |
VFloat File Structure
This skill defines the "Gold Standard" for file organization in the VFloat repository. It prioritizes the public API and main logic at the top of the file to improve "scannability" and developer experience.
When to use this Skill
- When creating any new composable in
src/composables/.
- When refactoring "shallow" or "deep" modules to align with project standards.
- When performing a polish pass on existing files.
- When the user asks to "fix the structure" or "normalize the file layout."
The Blueprint: Standard Order
All VFloat files (especially composables) must follow this exact sequence:
- Imports: Third-party first (Vue, etc.), then internal VFloat modules.
- Internal Module Constants/Types: Simple, non-exported types or constants needed by the main logic.
- 📌 Main Section: The primary exported function (e.g.,
useClick, useFloating).
- 📌 Helpers Section: (Optional) Module-level private functions or logic blocks.
- 📌 Types Section: All exported interfaces (
UseXOptions, UseXContext, etc.).
1. Visual Markers (Banners)
Use consistent divider widths and emoji markers.
Main Section Banners
Width: // + 85 = (Total 87 characters).
Sub-section Banners (Inside Functions)
Width: // + 85 = (Total 87 characters). Used to group logical blocks inside a large function.
2. The Composable Anatomy
When writing the main exported function, follow this internal flow:
- JSDoc: Comprehensive description with
@param, @returns, and at least one @example.
- Options Destructuring: Destructure all options at the top with sensible defaults.
- Internal State: Reactive and non-reactive state variables.
- Derived State:
computed properties and helper booleans.
- Logic / Event Handlers: The "meat" of the behavior.
- Wiring (Watchers/Listeners):
watch, watchPostEffect, and useEventListener calls.
- Return Statement: Only if the composable returns an object (often interaction composables return
void).
3. Section Detail: 📌 Types
The Types section at the bottom should include:
UseXContext: If a specific context shape is required.
UseXOptions: The configuration interface.
UseXReturn: If the function returns more than just a cleanup.
export interface UseClickOptions { ... }
Examples
Reference Implementation
Always refer to use-click.ts as the master template for this structure.
Checklist for Validation