원클릭으로
javascript-author
Write vanilla JavaScript for Web Components with functional core, imperative shell. Use when creating JavaScript files, building interactive components, or writing any client-side code.
메뉴
Write vanilla JavaScript for Web Components with functional core, imperative shell. Use when creating JavaScript files, building interactive components, or writing any client-side code.
Define and use custom HTML elements. Use when creating new components, defining custom tags, or using project-specific elements beyond standard HTML5.
Modern CSS organization with native @import, @layer cascade control, CSS nesting, design tokens, and element-focused selectors. AUTO-INVOKED when editing .css files.
Enforce structured git workflow with conventional commits, feature branches, semver versioning, and work logging. Use for all code changes to prevent work loss and maintain history.
INVOKE FIRST before any code work. Validates git workflow (branch, issue, worklog) and checks approach. Use at START of every task and END before completing. Prevents skipped steps.
Use consistent Lucide icons with the <icon-wc> component. Use when adding icons to pages, buttons, or UI elements.
Umbrella coordinator for image handling. Coordinates responsive-images, placeholder-images, and automation scripts. Use when adding images to any page, optimizing existing images, or setting up image pipelines.
| name | javascript-author |
| description | Write vanilla JavaScript for Web Components with functional core, imperative shell. Use when creating JavaScript files, building interactive components, or writing any client-side code. |
| allowed-tools | Read, Write, Edit, Glob, Grep |
Write modern vanilla JavaScript following functional core with imperative shell architecture.
| Principle | Description |
|---|---|
| Functional Core | Pure functions, getters, computed values - no side effects |
| Imperative Shell | DOM manipulation, event handlers, side effects in lifecycle hooks |
| Dependency Injection | Import templates, styles, i18n from separate files |
| Named Exports Only | No default exports - explicit named exports |
| JSDoc Documentation | Document classes, public methods, and events |
components/
└── my-component/
├── my-component.js # Main component class
├── my-component-template.js # Template function
├── my-component-styles.js # CSS-in-JS styles
└── my-component-i18n.js # Translations object
import { template } from './my-component-template.js';
import { styles } from './my-component-styles.js';
import { translations } from './my-component-i18n.js';
/**
* my-component: Brief description of component purpose
*
* @attr {string} lang - Language code
* @attr {string} value - Current value
* @fires my-component:update - Fired when state changes
*/
import { VBElement } from '../../lib/vb-element.js';
import { registerComponent } from '../../lib/bundle-registry.js';
class MyComponent extends VBElement {
static get observedAttributes() {
return ['lang', 'value'];
}
// FUNCTIONAL CORE - Pure getters
get lang() {
return this.getAttribute('lang') ||
this.closest('[lang]')?.getAttribute('lang') ||
document.documentElement.lang ||
'en';
}
// IMPERATIVE SHELL - Side effects
setup() {
// Initialize component, query children, bind listeners
// Use this.listen(target, event, handler) for auto-cleanup
// Return false to abort upgrade
}
teardown() {
// Component-specific cleanup (clear timers, disconnect observers)
// Event listeners registered via this.listen() are auto-cleaned
}
attributeChangedCallback(name, oldValue, newValue) {
if (oldValue !== newValue) {
// React to attribute changes
}
}
}
customElements.define('my-component', MyComponent);
export { MyComponent };
| Rule | Requirement |
|---|---|
no-var | Use const or let only |
prefer-const | Use const when variable is never reassigned |
prefer-template | Use template literals for string concatenation |
eqeqeq | Use === and !== only |
camelcase | Use camelCase for variables and functions |
object-shorthand | Use { foo } not { foo: foo } |
| Named exports | No default exports |
| Context | Convention | Example |
|---|---|---|
| Variables/Functions | camelCase | handleClick, userName |
| Classes | PascalCase | MyComponent, UserService |
| Custom Elements | kebab-case | <my-component>, <user-card> |
| Events | kebab-case | 'user-updated', 'form-submit' |
| CSS Classes | kebab-case | .card-header, .nav-item |
When authoring JavaScript, consider invoking these related skills:
| Code Pattern | Invoke Skill | Why |
|---|---|---|
class X extends VBElement | custom-elements | Full Web Component lifecycle, VBElement base class |
fetch() or API calls | api-client | Retry logic, error handling, caching patterns |
| Component state, reactivity | state-management | Observable patterns, undo/redo, sync strategies |
localStorage, IndexedDB | data-storage | Persistence patterns, offline-first |
| Error handling | error-handling | Error boundaries, global handlers, reporting |
If your JavaScript file defines a custom element (extends VBElement), also invoke:
If your code uses fetch() or makes network requests: