panel-base-advanced
できること
このスキルは、AIエージェントがプレーンTypeScriptで、完全なダッシュボードのパネルのベースクラスを作る方法を示します。サイズ変更のハンドル、保存されたレイアウト、エラーのカウントダウン、適切な後片付けを備えたパネルがほしい開発者向けです。
使う場面
- ✓再読み込み後も、サイズとレイアウトを覚えているダッシュボードのパネルがほしいとき。
- ✓パネルがエラーのカウントダウンを表示し、指数バックオフで再試行すべきとき。
- ✓タイマーとリスナーを取り除く、きれいな破棄の処理がパネルに必要なとき。
スキルのリンク
https://github.com/HKUDS/AgentPilot/blob/main/openspace/legacy/v1/showcase/skills/panel-base-advanced/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“TypeScriptで、サイズを覚え、エラー時に再試行のカウントダウンを表示し、削除されたときに後片付けをするダッシュボードのパネルのベースクラスを作ってください。”
毎週5つの新しいスキル。1分で読めます。
仕組み
エージェントは、ヘッダー、内容の領域、2つのサイズ変更のハンドルを持つPanelクラスを作ります。レイアウトはlocalStorageに保存し、失敗した取得は遅延を増やしながら再試行し、エラーのカウントダウンを表示します。destroyメソッドでタイマーを消去します。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
Resilient Panel — Unified Pattern (v2)
Create dashboard panel components using vanilla TypeScript (no framework, no JSX).
Each panel is a class extending a Panel base class and optionally wraps its data source with a CircuitBreaker.
Architecture Overview
Panel (base class)
├── element: HTMLElement (.panel)
│ ├── header: HTMLElement (.panel-header)
│ │ ├── headerLeft (.panel-header-left)
│ │ │ ├── title (.panel-title)
│ │ │ └── newBadge (.panel-new-badge) [optional, via setNewBadge()]
│ │ ├── statusBadge (.panel-data-badge) [optional, via setDataBadge()]
│ │ └── countEl (.panel-count) [optional]
│ ├── content: HTMLElement (.panel-content)
│ ├── resizeHandleRow (.panel-resize-handle-row) [bottom edge]
│ └── resizeHandleCol (.panel-resize-handle-col) [right edge]
Resilience layers (choose what you need)
| Layer | File | When to use |
|---|---|---|
| isFetching guard | Panel base class |
Always — prevents concurrent duplicate requests |
| Exponential-backoff retry | Panel.fetchWithRetry() |
When you own the fetch call and want per-request retry before surfacing an error |
| Error countdown in showError() | Panel base class |
Automatic retry countdown rendered inside the error state UI |
| CircuitBreaker | src/utils/circuit-breaker.ts |
When a service may fail repeatedly; stops hammering the API and serves stale cache instead |
| localStorage persistence | Panel.saveMap() / loadMap() |
When you want grid-span (not pixel size) state to survive page reloads |
Wrapping an existing service call with CircuitBreaker is a one-liner:
// Before const data = await fetchStockQuotes(); // After — adds caching + cooldown with zero refactor const data = await breaker.execute(() => fetchStockQuotes(), []);
File 1 — src/components/Panel.ts
Authoritative implementation. Use this verbatim; do not revert to the older
saveState()/loadState()width/height approach.
export interface PanelOptions {
id: string;
title: string;
showCount?: boolean;
className?: string;
}
export class Panel {
protected element: HTMLElement;
protected content: HTMLElement;
protected header: HTMLElement;
protected headerLeft: HTMLElement;
protected countEl: HTMLElement | null = null;
protected statusBadge: HTMLElement | null = null;
protected newBadge: HTMLElement | null = null;
protected panelId: string;
private _fetching = false;
private _countdownInterval: ReturnType<typeof setInterval> | null = null;
private _resizeListeners: Array<{ target: EventTarget; type: string; fn: EventListenerOrEventListenerObject }> = [];
// Retry state (used by fetchWithRetry)
protected retryAttempts = 0;
protected retryDelay = 1000; // ms; doubles each attempt
private maxRetries = 3;
constructor(options: PanelOptions) {
this.panelId = options.id;
this.element = document.createElement('div');
this.element.className = `panel${options.className ? ' ' + options.className : ''}`;
this.element.dataset.panel = options.id;
// Header
this.header = document.createElement('div');
this.header.className = 'panel-header';
this.headerLeft = document.createElement('div');
this.headerLeft.className = 'panel-header-left';
const title = document.createElement('span');
title.className = 'panel-title';
title.textContent = options.title;
this.headerLeft.appendChild(title);
this.header.appendChild(this.headerLeft);
// Count badge (optional)
if (options.showCount) {
this.countEl = document.createElement('span');
this.countEl.className = 'panel-count';
this.countEl.textContent = '0';
this.header.appendChild(this.countEl);
}
// Content area
this.content = document.createElement('div');
this.content.className = 'panel-content';
this.content.id = `${options.id}Content`;
// Dual resize handles
const resizeHandleRow = document.createElement('div');
resizeHandleRow.className = 'panel-resize-handle-row';
const resizeHandleCol = document.createElement('div');
resizeHandleCol.className = 'panel-resize-handle-col';
this.element.appendChild(this.header);
this.element.appendChild(this.content);
this.element.appendChild(resizeHandleRow);
this.element.appendChild(resizeHandleCol);
this._initResizeHandles(resizeHandleRow, resizeHandleCol);
this.sh
よくある質問
destroyメソッドは何をしますか?
タイマーとイベントハンドラーを消去するので、取り除かれたパネルが動き続けないとスキルは述べています。
再試行はどのように動きますか?
指数バックオフを使うので、再試行のたびに待ち時間が前回より長くなります。
レイアウトはどこに保存されますか?
レイアウトの状態はlocalStorageに保存され、そのブラウザーで次に読み込んだときも残ります。
詳細
作者による元の説明
Unified guide for authoring dashboard panel components in vanilla TypeScript — covers the authoritative Panel base class (grid-span persistence, dual resize handles, radar loading animation, exponential-backoff error countdown, data/new badge helpers, full destroy() cleanup), localStorage state via loadMap/saveMap, exponential-backoff retry, and CircuitBreaker integration. Shows how to wrap any existing fetchX() service call with CircuitBreaker.execute() as a one-liner and clarifies when each resilience layer is appropriate.
repo: HKUDS/AgentPilot
人気
- GitHubのスター
- 7.8k
- ランキング
- #13062
- ライセンス
- MIT
- 更新日
- 2026/11/1
コメント
- …
このリポジトリの他のスキル
agentpilot
7.8kエージェントが、作業を準備し、変更案を提案してテストし、評価するAgentPilotのループを実行することで、プロジェクトを段階的に改善できるよう支援します。
openspace
7.8kエージェントが、スキルを保存し取り出すツールであるOpenSpaceをセットアップし、MCPを通じてAIアプリに接続できるよう支援します。
rsi-arena
7.8kエージェントが、AIMEやTerminal-Benchなどの標準的なAIベンチマークテストをセットアップして実行し、異なる改善方法を比較できるよう支援します。
experiment-guide
7.8kエージェントが、プログラムを改善する方法を調べる間に、小さな実験を計画し、その結果を読み、発見を記録できるよう支援します。
似ているスキル
angular-developer
280kエージェントがAngularのコードを作成し、プロジェクト構成についてアドバイスできるようにします。新しいプロジェクトの開始、コード部品の作成、パフォーマンスやアクセシビリティの改善に役立ちます。
frontend-a11y
280kエージェントが Web インターフェースを誰にとっても使いやすくするよう支援します。スクリーンリーダーやキーボード操作に対応し、サイトやアプリが適切に動作するようにします。
frontend-patterns
280kエージェントがフロントエンド開発の最新パターンを適用できるようにします。React と Next.js において、パフォーマンスの最適化、状態管理、ベストプラクティスの遵守を行います。