docs/agi/skills/inheritance-debugging/SKILL.md
# Skill: inheritance-debugging ## Scope Debug constructor inheritance issues where subclass properties are accessed before initialization. **Does:** - Diagnose "undefined is not iterable" and NaN calculation errors - Fix super() initialization order problems - Add fallback defaults in render methods - Verify fixes with incremental testing **Does Not:** - Cover general JavaScript debugging - Handle non-inheritance related bugs ## Context In jsgui3 controls, a common pattern is: 1. Base class
npx skillsauth add metabench/jsgui3-html docs/agi/skills/inheritance-debuggingInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Debug constructor inheritance issues where subclass properties are accessed before initialization.
Does:
Does Not:
In jsgui3 controls, a common pattern is:
compose() or render()super(spec) then sets its own propertiesThis manifests as:
undefined is not iterable when destructuring this._propertyNaN calculations using undefined numeric propertiesLook for this constructor structure:
class Child extends Parent {
constructor(spec) {
super(spec); // ← Parent calls render() here
this._my_property = spec.value || 'default'; // ← Too late!
}
}
Create a debug script to test with abstract: true:
const control = new MyControl({
context,
abstract: true, // Skips compose/render
...options
});
console.log('Properties:', control._my_property);
If it works with abstract: true but fails without, this confirms the timing issue.
In every method that uses subclass properties, add defaults:
// Before (breaks during super())
render() {
const [min, max] = this._range; // undefined error
const gap = this._gap; // NaN
}
// After (safe)
render() {
const range = this._range || [-10, 10]; // Fallback
const [min, max] = range;
const gap = this._gap !== undefined ? this._gap : 0.1;
}
In the subclass constructor, re-render after setting properties:
constructor(spec) {
super(spec); // Renders with defaults
this._my_property = spec.value || 'default';
// Re-render now that properties are set
if (!spec.abstract && !spec.el && this._svg) {
this.render_chart();
}
}
Use browser testing to visually confirm the fix:
1. Start demo server
2. Navigate to demo page
3. Inspect rendered elements for correct attributes
4. Check console for errors
5. Screenshot for documentation
Ensure all tests pass after the fix:
npx mocha test/controls/<control>.test.js --reporter min
Problem: Bar rects had y and height but missing x and width.
Root Cause: super(spec) called compose_chart() → render_chart() → render_bars(), which used this._bar_gap before it was set.
Fix: Added fallback in render_bars():
const bar_gap = this._bar_gap !== undefined ? this._bar_gap : 0.1;
const group_gap = this._group_gap !== undefined ? this._group_gap : 0.2;
Result: 35 chart tests passing, bars render correctly.
abstract: true worksabstract: true workstools
# Skill: ui-pick-prompting ## Scope Use the ui-pick tool to present structured choices to the user. **Does:** - Show GUI picker with options. - Wait for user selection. - Return structured result (selection, cancelled, etc.). **Does Not:** - Handle complex multi-step wizards. - Manage state between prompts. ## Inputs - Options array (strings or objects with label/value/description). - Theme (optional): `wlilo` (dark) or `bright` (light). ## Procedure ### Via HTTP (Current Session) ```power
development
# Skill: typescript-types ## Scope Create and maintain TypeScript declaration files (.d.ts) for jsgui3-html components. **Does:** - Generate .d.ts files for controls and modules - Define interfaces for specs, params, and return types - Update package.json exports for TypeScript consumers - Maintain backward compatibility with JavaScript users **Does Not:** - Convert source files to TypeScript - Add runtime type checking - Handle complex generic patterns ## Inputs - File or module to type (e.
development
# Skill: theme-system-integration ## Scope Add theme support to existing controls or integrate theming into new features. **Does:** - Define params schemas for controls - Register variants in the variant registry - Integrate `resolve_params` for merge priority - Add CSS variable hooks and data attributes - Test theme inheritance and override behavior **Does Not:** - Create controls from scratch (see jsgui3-control-creation skill) - Handle runtime theme switching animations ## Inputs - Contro
testing
# Skill: session-discipline ## Scope Maintain structured notes across agent sessions to ensure continuity and knowledge transfer. **Does:** - Initialize session folders with standard structure. - Track active work, findings, and follow-ups. - Enable future agents to resume work seamlessly. **Does Not:** - Persist state between AI context windows (that's the purpose of the docs). - Replace version control (still commit changes). ## Session Structure Each session lives in `docs/sessions/<date