widget-creator
БесплатноБез исполняемых скриптовНе проверенStep-by-step guide for creating new widgets in the Hex1b TUI library. Use when implementing new widgets from scratch, including widget records, nodes…
Об этом скилле
Widget Creator Skill
This skill provides a comprehensive step-by-step guide for AI coding agents to create new widgets in the Hex1b TUI library. Widgets are the building blocks of Hex1b applications, following a declarative pattern inspired by React.
Overview
Creating a widget in Hex1b involves several coordinated files:
| File | Purpose |
|---|---|
src/Hex1b/Widgets/{Name}Widget.cs |
Immutable widget record (describes what to render) |
src/Hex1b/Nodes/{Name}Node.cs |
Mutable node class (manages state, renders) |
src/Hex1b/{Name}Extensions.cs |
Fluent API extension methods |
src/Hex1b/Theming/{Name}Theme.cs |
Theme elements (colors, characters) |
tests/Hex1b.Tests/{Name}NodeTests.cs |
Unit tests |
Step-by-Step Process
Step 1: Define the Widget Record
Widgets are immutable record types that describe the desired UI. They capture configuration and event handlers but contain no rendering logic.
Location: src/Hex1b/Widgets/{Name}Widget.cs
Key principles:
- Use primary constructor parameters for required data
- Use
internalproperties withinitfor optional configuration - Event handlers use
Func<TEventArgs, Task>?pattern - Provide sync and async overloads for event handlers using
this with { }pattern - Implement
Reconcile()to create/update the corresponding node - Implement
GetExpectedNodeType()to return the node type
Template:
using Hex1b.Events;
using Hex1b.Nodes;
namespace Hex1b.Widgets;
/// <summary>
/// Brief description of what the widget does.
/// </summary>
/// <param name="PrimaryProperty">Description of the main property.</param>
public sealed record MyWidget(string PrimaryProperty) : Hex1bWidget
{
/// <summary>
/// ActionId for the activate action. Use "WidgetName.ActionName" naming
/// convention (PascalCase, omit "Widget" suffix from the widget name).
/// Define one static readonly ActionId per rebindable action.
/// </summary>
public static readonly ActionId Activate = new($"{nameof(MyWidget)}.{nameof(Activate)}");
/// <summary>
/// Optional configuration property.
/// </summary>
internal bool SomeOption { get; init; }
/// <summary>
/// Event handler for some action.
/// </summary>
internal Func<MyEventArgs, Task>? ActionHandler { get; init; }
/// <summary>
/// Sets a synchronous action handler.
/// </summary>
public MyWidget OnAction(Action<MyEventArgs> handler)
=> this with { ActionHandler = args => { handler(args); return Task.CompletedTask; } };
/// <summary>
/// Sets an asynchronous action handler.
/// </summary>
public MyWidget OnAction(Func<MyEventArgs, Task> handler)
=> this with { ActionHandler = handler };
internal override Hex1bNode Reconcile(Hex1bNode? existingNode, ReconcileContext context)
{
var node = existingNode as MyNode ?? new MyNode();
// Mark dirty if properties changed
if (node.PrimaryProperty != PrimaryProperty || node.SomeOption != SomeOption)
{
node.MarkDirty();
}
node.PrimaryProperty = PrimaryProperty;
node.SomeOption = SomeOption;
node.SourceWidget = this;
// Convert typed event handler to internal handler if needed
if (ActionHandler != null)
{
node.ActionCallback = async ctx =>
{
var args = new MyEventArgs(this, node, ctx);
await ActionHandler(args);
};
}
else
{
node.ActionCallback = null;
}
return node;
}
internal override Type GetExpectedNodeType() => typeof(MyNode);
}
Step 2: Create Event Args (if needed)
If your widget has event handlers, create a typed event args class.
Location: src/Hex1b/Events/{Name}EventArgs.cs
Template:
using Hex1b.Input;
using Hex1b.Widgets;
namespace Hex1b.Events;
/// <summary>
/// Event arguments for MyWidget actions.
/// </summary>
public sealed class MyEventArgs
{
/// <summary>
/// The widget that raised the event.
/// </summary>
public MyWidget Widget { get; }
/// <summary>
/// The node that raised the event.
/// </summary>
public MyNode Node { get; }
/// <summary>
/// The input binding context.
/// </summary>
public InputBindingActionContext Context { get; }
internal MyEventArgs(MyWidget widget, MyNode node, InputBindingActionContext context)
{
Widget = widget;
Node = node;
Context = context;
}
}
Step 3: Create the Node Class
Nodes are mutable classes that hold render state and perform actual rendering. They receive updates during reconciliation and implement layout and rendering.
Location: src/Hex1b/Nodes/{Name}Node.cs
Key principles:
- Properties are mutable (set from widget during reconciliation)
- Track
Установить widget-creator в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл widget-creator?
Step-by-step guide for creating new widgets in the Hex1b TUI library. Use when implementing new widgets from scratch, including widget records, nodes, extension methods, theming, reconciliation, and tests.
Как установить скилл widget-creator?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл widget-creator запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic