version-badge-pattern
БесплатноБез исполняемых скриптовНе проверенVersion badge UI showing build version, git commit, and changelog in a tooltip. Use when adding version visibility for support or debugging. Works with React…
от laurigates★ 61 звезда на GitHubОб этом скилле
Version Badge Pattern
A reusable UI pattern for displaying application version with build metadata and recent changes.
When to Use This Skill
| Use this skill when... | Use alternative when... |
|---|---|
| Adding version display to app header/footer | Just need version in package.json |
| Want tooltip with changelog info | Only need static version text |
| Need accessible, keyboard-navigable version info | Building a non-interactive display |
| Implementing across React/Vue/Svelte | Using server-rendered only (no JS) |
Pattern Overview
A trigger (v1.43.0|004ddd9) stays visible in the header; hover or focus opens a tooltip with build information and recent changes. Layout diagram: REFERENCE.md.
Data Flow
CHANGELOG.md → parse-changelog.mjs → ENV_VAR → Component
package.json version ─────────────────────┘
git commit SHA ───────────────────────────┘
Build Script
Create scripts/parse-changelog.mjs:
#!/usr/bin/env node
/**
* parse-changelog.mjs
* Parses CHANGELOG.md for version badge tooltip
*
* Output: JSON array of versions with their changes
* Usage: node scripts/parse-changelog.mjs
*/
import { readFileSync, existsSync } from 'fs';
import { fileURLToPath } from 'url';
import { dirname, join } from 'path';
const __dirname = dirname(fileURLToPath(import.meta.url));
const CHANGELOG_PATH = join(__dirname, '..', 'CHANGELOG.md');
const MAX_VERSIONS = 2;
const MAX_FEATURES = 3;
const MAX_OTHER = 2;
const CHANGE_TYPES = {
feat: { icon: 'sparkles', label: 'Feature' },
fix: { icon: 'bug', label: 'Bug Fix' },
perf: { icon: 'zap', label: 'Performance' },
breaking: { icon: 'warning', label: 'Breaking' },
refactor: { icon: 'recycle', label: 'Refactor' },
docs: { icon: 'book', label: 'Documentation' },
};
function parseChangelog() {
if (!existsSync(CHANGELOG_PATH)) {
console.log(JSON.stringify([]));
return;
}
const content = readFileSync(CHANGELOG_PATH, 'utf-8');
const lines = content.split('\n');
const versions = [];
let currentVersion = null;
for (const line of lines) {
const versionMatch = line.match(/^## \[?(\d+\.\d+\.\d+)\]?/);
if (versionMatch) {
if (currentVersion) {
versions.push(currentVersion);
}
if (versions.length >= MAX_VERSIONS) break;
currentVersion = {
version: versionMatch[1],
features: [],
fixes: [],
other: [],
};
continue;
}
if (!currentVersion) continue;
const changeMatch = line.match(/^\* \*\*(\w+):\*?\*? (.+)$/);
if (changeMatch) {
const [, type, description] = changeMatch;
const changeType = CHANGE_TYPES[type.toLowerCase()] || CHANGE_TYPES.refactor;
const entry = {
type: type.toLowerCase(),
icon: changeType.icon,
description: description.trim(),
};
if (type.toLowerCase() === 'feat' && currentVersion.features.length < MAX_FEATURES) {
currentVersion.features.push(entry);
} else if (type.toLowerCase() === 'fix' && currentVersion.fixes.length < MAX_OTHER) {
currentVersion.fixes.push(entry);
} else if (currentVersion.other.length < MAX_OTHER) {
currentVersion.other.push(entry);
}
}
}
if (currentVersion) {
versions.push(currentVersion);
}
console.log(JSON.stringify(versions.slice(0, MAX_VERSIONS)));
}
parseChangelog();
React + Tailwind + shadcn/ui Implementation
Component: components/version-badge.tsx
'use client';
import { useMemo } from 'react';
import {
Tooltip,
TooltipContent,
TooltipProvider,
TooltipTrigger,
} from '@/components/ui/tooltip';
import { cn } from '@/lib/utils';
interface BuildInfo {
version: string;
commit: string;
branch: string;
buildTime: string;
}
interface ChangeEntry {
type: string;
icon: string;
description: string;
}
interface VersionEntry {
version: string;
features: ChangeEntry[];
fixes: ChangeEntry[];
other: ChangeEntry[];
}
const ICON_MAP: Record<string, string> = {
sparkles: '✨',
bug: '🐛',
zap: '⚡',
warning: '⚠️',
recycle: '♻️',
book: '📖',
};
function getIcon(iconName: string): string {
return ICON_MAP[iconName] || '•';
}
export function VersionBadge() {
const buildInfo = useMemo<BuildInfo | null>(() => {
try {
const raw = process.env.NEXT_PUBLIC_BUILD_INFO;
return raw ? JSON.parse(raw) : null;
} catch {
return null;
}
}, []);
const changelog = useMemo<VersionEntry[]>(() => {
try {
const raw = process.env.NEXT_PUBLIC_CHANGELOG;
return raw ? JSON.parse(raw) : [];
} catch {
return [];
}
}, []);
if (!buildInfo?.version || buildInfo.version === 'dev') {
return null;
}
const shortCommit = buildInfo.commit?.slice(0, 7) || 'unknown';
const formattedDate = buildInfo.buildTime
? new Date(buildInfo.buildTime).toLocaleString('en-US', {
Установить version-badge-pattern в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
ReadWriteEditGrepGlobTodoWriteВложенные файлы
FAQ
Что делает скилл version-badge-pattern?
Version badge UI showing build version, git commit, and changelog in a tooltip. Use when adding version visibility for support or debugging. Works with React, Vue, Svelte, and JS.
Как установить скилл version-badge-pattern?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл version-badge-pattern запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
от Anthropicacademy-guide
Stop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
от Anthropicinternal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
от Anthropicskill-development
This skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…
от Anthropic