Multi-layer workflow for creating complete panel features by analyzing existing patterns and generating coordinated server routes, services, UI components, regi
复制下面这句话,粘贴给 Claude Code、Codex、Cursor 等 AI 编程工具,它会读取安装说明并在你确认后完成安装。
请阅读 https://ai.atlankj.com/install/asset/gh-create-full-stack-panel-feature-c5748b4d69cd ,按照其中的说明把「create-full-stack-panel-feature」安装到你(当前 AI 工具)中。执行前先告诉我将运行的命令和写入的位置,等我确认。
查看 AI 将读取的安装说明正在读取 GitHub 原文…
内容来自 GitHub 原始文件,由原作者维护。在 GitHub 查看
This skill guides you through creating a complete, pattern-consistent panel feature across all application layers: backend API routes, service logic, frontend components, registration, and styling.
Locate existing examples for each layer you need to implement:
# Find existing server routes
find . -name "*route*.js" -o -name "*routes*.js" | grep -E "(panel|dashboard)"
# Find service files
find . -name "*service*.js" | grep -E "(panel|dashboard)"
# Find UI components
find . -name "*.jsx" -o -name "*.tsx" | grep -i panel
# Find registration/config files
find . -name "*config*.js" -o -name "*registry*.js"
# Find styling files
find . -name "*.css" -o -name "*.scss" | grep -i panel
Read 1-2 representative examples from each layer to understand:
MetricsPanel, metrics-service.js)Example analysis checklist:
Server Route Pattern:
- ✓ Endpoint naming: /api/panels/{type}
- ✓ Authentication middleware
- ✓ Response format: { success, data, error }
Service Pattern:
- ✓ Export structure: class vs functions
- ✓ Data transformation logic
- ✓ Error propagation
Component Pattern:
- ✓ Props interface
- ✓ State management (hooks/class)
- ✓ Data fetching approach
- ✓ Loading/error states
Registration Pattern:
- ✓ Registry file location
- ✓ Registration format (array/object)
- ✓ Required metadata fields
Based on patterns, list the files you need to create:
Typical full-stack panel structure:
server/routes/system-health-route.js)server/services/system-health-service.js)client/components/SystemHealthPanel.jsx)client/config/panel-registry.js)client/styles/system-health-panel.css)types/system-health.ts)Before selecting templates in Step 4, determine the frontend framework in use:
# Check for React
grep -s "react" package.json | head -5
# Check for TypeScript without React (vanilla TS)
ls client/components/*.ts 2>/dev/null | head -3
ls client/panels/*.ts 2>/dev/null | head -3
# Check for a Panel base class (common in vanilla TS dashboards)
grep -r "class.*Panel" client/ --include="*.ts" -l | head -3
grep -r "extends Panel" client/ --include="*.ts" -l | head -3
Decision rule:
react or react-dom is present in package.json → use the React/JSX template (Step 4C-React)..ts files extending a Panel base class → use the Vanilla TS template (Step 4C-Vanilla).Generate files in dependency order (backend → frontend → registration):
// server/routes/{feature}-route.js
const express = require('express');
const router = express.Router();
const featureService = require('../services/{feature}-service');
router.get('/api/panels/{feature}', async (req, res) => {
try {
const data = await featureService.getData();
res.json({ success: true, data });
} catch (error) {
res.status(500).json({ success: false, error: error.message });
}
});
module.exports = router;
// server/services/{feature}-service.js
class FeatureService {
async getData() {
// Implementation following existing service patterns
// - Data fetching
// - Business logic
// - Data transformation
return processedData;
}
}
module.exports = new FeatureService();
Use this template only when React is confirmed in Step 3b.
// client/components/{Feature}Panel.jsx
import React, { useState, useEffect } from 'react';
import './styles/{feature}-panel.css';
const FeaturePanel = () => {
const [data, setData] = useState(null);
const [loading, setLoading] = useState(true);
const [error, setError] = useState(null);
useEffect(() => {
fetch('/api/panels/{feature}')
.then(res => res.json())
.then(result => {
setData(result.data);
setLoading(false);
})
.catch(err => {
setError(err.message);
setLoading(false);
});
}, []);
if (loading) return <div>Loading...</div>;
if (error) return <div>Error: {error}</div>;
return (
<div className="{feature}-panel">
{/* Render data following UI patterns */}
</div>
);
};
export default FeaturePanel;
Use this template when components extend a Panel base class (no React).
// client/panels/{Feature}Panel.ts
import { Panel } from '../core/Panel';
export class FeaturePanel extends Panel {
private intervalId: number | null = null;
constructor(id: string) {
super(id);
this.setTitle('Feature Display Name');
}
async onLoad(): Promise<void> {
if (this.isFetching) return;
this.isFetching = true;
try {
const res = await fetch('/api/panels/{feature}', {
headers: { Authorization: `Bearer ${localStorage.getItem('token') ?? ''}` }
});
if (!res.ok) throw new Error(`HTTP ${res.status}`);
const { data } = await res.json();
this.render(data);
} catch (err) {
this.showError(err instanceof Error ? err.message : String(err), () => this.onLoad());
} finally {
this.isFetching = false;
}
}
private render(data: unknown): void {
const container = document.createElement('div');
container.className = '{feature}-panel';
// Build DOM nodes from data instead of JSX:
// const item = document.createElement('p');
// item.textContent = String(data);
// container.appendChild(item);
this.setContent(container);
}
// Call this to start polling (optional)
startPolling(intervalMs = 60_000): void {
this.onLoad();
this.intervalId = window.setInterval(() => this.onLoad(), intervalMs);
}
destroy(): void {
if (this.intervalId !== null) clearInterval(this.intervalId);
super.destroy();
}
}
Key differences from React template:
Panel base class; uses setContent() / showError() / setTitle() / setCount() instead of React state.document.createElement / innerHTML instead of JSX.useState / useEffect; lifecycle is onLoad() + destroy()..ts, not .jsx/.tsx.React projects — import the component directly:
// client/config/panel-registry.js (update existing)
import FeaturePanel from '../components/FeaturePanel';
export const panels = [
// ... existing panels
{
id: '{feature}',
name: 'Feature Display Name',
component: FeaturePanel,
icon: 'icon-name',
category: 'appropriate-category'
}
];
Vanilla TS projects — register via factory:
// client/config/panel-registry.ts (update existing)
import { FeaturePanel } from '../panels/FeaturePanel';
export const panels = [
// ... existing panels
{
id: '{feature}',
name: 'Feature Display Name',
factory: (id: string) => new FeaturePanel(id),
icon: 'icon-name',
category: 'appropriate-category'
}
];
/* client/styles/{feature}-panel.css */
.{feature}-panel {
/* Follow existing panel styling conventions */
padding: 1rem;
border-radius: 4px;
}
.{feature}-panel__header {
/* Consistent header styling */
}
After creating all files, check:
Verify that:
# Server route is registered
grep -r "require.*{feature}-route" server/
# Component is imported in registry
grep -r "import.*{Feature}Panel" client/config/
# Styles are imported
grep -r "import.*{feature}-panel.css" client/
For simple features: May omit service layer if route logic is trivial
For complex features: May need additional files:
For TypeScript projects: Add .d.ts or .ts type definition files