Skip to content
Skillpedia
Websites & UI (frontend)7.8k Β· #13046

data-driven-panel

What it does

This skill shows the AI agent how to build a dashboard panel that loads and manages its own data. It is for developers who want panels that keep working when an API is flaky.

When to use it

  • βœ“When a dashboard panel must load its own data from an API.
  • βœ“When an API fails often and the panel should stop hammering it.
  • βœ“When you want caching and failure handling built into each panel.

Skill link

https://github.com/HKUDS/AgentPilot/blob/main/openspace/legacy/v1/showcase/skills/data-driven-panel/SKILL.md

Copy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.

How to use

The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.

Ready-to-paste message

Use this skill to help me: https://github.com/HKUDS/AgentPilot/blob/main/openspace/legacy/v1/showcase/skills/data-driven-panel/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
Want your AI to find skills like this on its own?Install the free Skillpedia MCP: one line, and it searches 15,000+ skills before each task.Install in 1 minute β†’

Example of what to ask your AI

β€œBuild a dashboard panel that fetches our sales numbers and falls back to cached data when the API is down.”

5 new skills a week. 1 minute to read.

How it works

The agent creates a base panel class with a header and content area. Each panel pairs with an internal data service that uses a circuit breaker and a cache, so repeated failures trigger a cooldown and the panel shows stored data.

Technical content (original SKILL.md)

Original text by the author, straight from GitHub.

Data-Driven Panel Pattern

Create dashboard panels that seamlessly integrate UI construction with resilient data fetching. Each panel is a self-contained component that manages its own data lifecycle.

Architecture Overview

Panel (base class)
β”œβ”€β”€ element: HTMLElement (outer container)
β”‚   β”œβ”€β”€ header (title, status indicators)
β”‚   └── content (data display area)
└── DataService (internal)
    β”œβ”€β”€ Circuit Breaker (failure handling)
    └── Caching layer

Implementation

1. Base Panel with Integrated Data Service

Create src/components/DataPanel.ts:

import { createCircuitBreaker } from '../utils/circuit-breaker';

export interface PanelOptions<T> {
  id: string;
  title: string;
  showCount?: boolean;
  className?: string;
  dataService: () => Promise<T>;
  defaultValue: T;
  serviceOptions?: {
    maxFailures?: number;
    cooldownMs?: number;
    cacheTtlMs?: number;
  };
}

export abstract class DataPanel<T> {
  protected element: HTMLElement;
  protected content: HTMLElement;
  private breaker: CircuitBreaker<T>;
  private refreshTimer: ReturnType<typeof setInterval> | null = null;

  constructor(protected options: PanelOptions<T>) {
    this.breaker = createCircuitBreaker<T>({
      name: options.id,
      maxFailures: options.serviceOptions?.maxFailures ?? 2,
      cooldownMs: options.serviceOptions?.cooldownMs ?? 300_000,
      cacheTtlMs: options.serviceOptions?.cacheTtlMs ?? 60_000,
    });

    this.element = document.createElement('div');
    this.element.className = `panel ${options.className || ''}`;
    this.element.dataset.panel = options.id;

    // Initialize UI
    this.initUI();
    this.fetchData();
  }

  private initUI(): void {
    // Header setup
    const header = document.createElement('div');
    header.className = 'panel-header';
    
    const title = document.createElement('span');
    title.className = 'panel-title';
    title.textContent = this.options.title;
    header.appendChild(title);

    // Content area
    this.content = document.createElement('div');
    this.content.className = 'panel-content';

    this.element.appendChild(header);
    this.element.appendChild(this.content);
    this.showLoading();
  }

  protected async fetchData(): Promise<void> {
    try {
      const data = await this.breaker.execute(
        this.options.dataService,
        this.options.defaultValue
      );
      this.render(data);
    } catch (err) {
      this.showError('Failed to load data', () => this.fetchData());
    }
  }

  protected abstract render(data: T): void;

  public showLoading(message = 'Loading...'): void {
    this.content.innerHTML = `<div class="loading">${message}</div>`;
  }

  public showError(message: string, retryHandler: () => void): void {
    this.content.innerHTML = `
      <div class="error">
        <p>${message}</p>
        <button class="retry-btn">Retry</button>
      </div>`;
    this.content.querySelector('.retry-btn')?.addEventListener('click', retryHandler);
  }

  public setAutoRefresh(intervalMs: number): void {
    this.refreshTimer = setInterval(() => this.fetchData(), intervalMs);
  }

  public destroy(): void {
    if (this.refreshTimer) clearInterval(this.refreshTimer);
    this.element.remove();
  }
}

2. Concrete Panel Implementation Example

import { DataPanel } from './DataPanel';

interface StockData {
  quotes: StockQuote[];
  updatedAt: string;
}

export class StockPanel extends DataPanel<StockData> {
  constructor() {
    super({
      id: 'stocks',
      title: 'Stock Market',
      dataService: fetchStockData,
      defaultValue: { quotes: [], updatedAt: new Date().toISOString() },
      serviceOptions: {
        cacheTtlMs: 30_000 // Refresh cache every 30 seconds
      }
    });
    this.setAutoRefresh(60_000); // Auto-refresh every minute
  }

  protected render(data: StockData): void {
    const html = data.quotes.map(quote => `
      <div class="stock-item">
        <span class="symbol">${quote.symbol}</span>
        <span class="price">$${quote.price?.toFixed(2) || 'β€”'}</span>
      </div>
    `).join('');
    
    this.content.innerHTML = `
      <div class="stock-list">
        ${html}
        <div class="updated">Updated: ${new Date(data.updatedAt).toLocaleTimeString()}</div>
      </div>`;
  }
}

3. Data Service Implementation

// src/services/stockService.ts
interface StockQuote {
  symbol: string;
  price: number | null;
}

export async function fetchStock
FAQ

What is a circuit breaker here?

It is a safety switch that pauses calls to a failing API for a cooldown period and serves cached data instead.

How are the panel's defaults set?

The skill sets default values for max failures, cooldown and cache time, which can be changed in the options.

Does the panel refresh on a timer?

The base class includes a refresh timer for updating the data.

Details

Original description by the author

Create dashboard panel components with integrated resilient data services, combining UI construction and data fetching into a unified pattern.

repo: HKUDS/AgentPilot

Popularity

GitHub stars
7.8k
Ranking position
#13046
License
MIT
Updated
11/1/2026

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills