gomponents/SKILL.md
Guide for working with gomponents, a pure Go HTML component library. Use this skill when reading or writing gomponents code, or when building HTML views in Go applications.
npx skillsauth add maragudk/skills gomponentsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
gomponents is a pure Go HTML component library that treats HTML elements as composable Go values. Everything is built on the Node interface, making HTML construction type-safe and composable.
Use this skill when:
Everything in gomponents implements the Node interface:
type Node interface {
Render(w io.Writer) error
}
El(name string, children ...Node) - Create custom HTML elementsAttr(name string, value ...string) - Create custom attributesMost standard HTML5 elements and attributes are available as functions in the html package:
Div(), Span(), P(), A(), etc.Class(), ID(), Href(), Src(), etc.Note: nil Nodes are ignored during rendering, so it's safe to pass nil nodes to elements.
Text(string) - HTML-escaped text contentTextf(format string, args...) - Formatted, escaped textRaw(string) - Unescaped HTMLRawf(format string, args...) - Formatted, unescaped contentGroup([]Node) - Combine multiple nodesMap[T]([]T, func(T) Node) - Transform slices into node sequencesIf(condition bool, node Node) - Conditional renderingIff(condition bool, func() Node) - Lazy conditional rendering (deferred evaluation)Contrary to common Go idioms, dot imports are recommended for gomponents to achieve DSL-like syntax:
import (
. "maragu.dev/gomponents"
. "maragu.dev/gomponents/html"
. "maragu.dev/gomponents/components"
)
This allows writing clean, HTML-like code:
Div(Class("container"),
H1(Text("Hello World")),
P(Text("Welcome to gomponents")),
)
maragu.dev/gomponents - Core interface and helper functionsmaragu.dev/gomponents/html - All HTML5 elements and attributesmaragu.dev/gomponents/http - HTTP helpers for rendering components as responsesmaragu.dev/gomponents/components - Higher-level utilities (HTML5 document structure, dynamic classes)func UserCard(name, email string) Node {
return Div(Class("user-card"),
H2(Text(name)),
P(Text(email)),
)
}
func Alert(message string, isError bool) Node {
return Div(
If(isError, Class("error")),
If(!isError, Class("info")),
P(Text(message)),
)
}
Use If when the node is always safe to evaluate. Use Iff when the node might be nil and shouldn't be evaluated unless the condition is true.
func UserProfile(user *User) Node {
return Div(
H1(Text(user.Name)),
// Use Iff to avoid nil pointer dereference when user.Avatar is nil
Iff(user.Avatar != nil, func() Node {
return Img(Src(user.Avatar.URL))
}),
)
}
Use Group to group multiple nodes without wrapping them in a parent element:
func FormFields(required bool) Node {
return Group{
Label(For("email"), Text("Email")),
Input(Type("email"), ID("email")),
If(required, Span(Class("required"), Text("*"))),
}
}
func TodoList(todos []Todo) Node {
return Ul(Class("todo-list"),
Map(todos, func(t Todo) Node {
return Li(Text(t.Title))
}),
)
}
func Page(title string, body Node) Node {
return HTML5(HTML5Props{
Title: title,
Language: "en",
Head: []Node{
Link(Rel("stylesheet"), Href("/styles.css")),
},
Body: []Node{body},
})
}
import ghttp "maragu.dev/gomponents/http"
func HomeHandler(w http.ResponseWriter, r *http.Request) (Node, error) {
return Page("My App",
Div(Class("container"),
H1(Text("Hello, World!")),
),
), nil
}
// In main:
http.HandleFunc("/", ghttp.Adapt(HomeHandler))
The http package provides:
Handler type - function signature that returns (Node, error)Adapt(Handler) - converts Handler to http.HandlerFuncStatusCode() int interfacedevelopment
Guide for using git worktrees to parallelize development with coding agents. Use this skill when the user requests to work in a new worktree or wants to work on a separate feature in isolation (e.g., "Work in a new worktree", "Create a worktree for feature X").
development
Guide for working with SQL queries, in particular for SQLite. Use this skill when writing SQL queries, analyzing database schemas, designing migrations, or working with SQLite-related code.
tools
Guide for saving a web page for offline use using the monolith CLI. Use this when instructed to save a web page.
development
# Observable Plot Skill Observable Plot is a JavaScript library for exploratory data visualization. It's built on D3 and provides a concise, declarative API for creating charts. ## Installation ```bash npm install @observablehq/plot ``` Or via CDN: ```html <script type="module"> import * as Plot from "https://cdn.jsdelivr.net/npm/@observablehq/[email protected]/+esm"; </script> ``` ## Core Concepts ### Plot.plot(options) The main function that renders a visualization. Returns an SVG or HTML figure