Index of every page on this site: llms.txt
All skills
meza avatar

/charm-tui

@982e21e
by mezameza/skills2 stars
Run it yourself

Design, build, refactor, and review Go terminal interfaces using Bubble Tea, Bubbles, Lip Gloss, and Bubblebook. Use whenever work involves Charm TUI components, message routing, focus, terminal layout, styling, component stories, or UI tests. Teaches one native v2 architecture with a coordinating root, reusable components, and isolated Bubblebook stories. Does not cover unrelated Charm services or authorize a v1 migration.

Use this Skill: https://skilld.dev/gh/meza/skills/charm-tui

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

referencesperformance.md

≈1.4k tokens on demand. Your agent reads this file only when SKILL.md points to it.

Rendering performance

Read this guide when investigating or changing rendering time, allocation, list measurement, or caching. Preserve the ownership boundaries in SKILL.md. For delivery gates, read CI and delivery.

Measure a representative interaction

First reproduce the problem with controlled data: a long result list, expanded markdown, a large highlighted diff, or repeated narrow/wide resize. Record the data size, viewport, theme, and operation. Compare the same scenario after the change.

For a project that has a BenchmarkResultsRender benchmark in internal/ui/search, run from its module root:

go test ./internal/ui/search -run '^$' -bench '^BenchmarkResultsRender$' -benchmem -count=5
go test ./internal/ui/search -run '^$' -bench '^BenchmarkResultsRender$' -cpuprofile cpu.out -memprofile mem.out
go tool pprof -top cpu.out
go tool pprof -alloc_space -top mem.out

Replace the package and benchmark with the real project names. These commands produce local diagnostic files; keep them outside published source artifacts. Inspect time and allocations together: fewer allocations do not establish a faster user interaction. A render benchmark also excludes backend latency and root routing unless it explicitly exercises them. The Go documentation explains benchmark measurement and profiling.

Measure cold rendering separately from repeated rendering, scrolling, and resize. A warm-cache benchmark alone can conceal a costly invalidation path. Keep fixture construction outside the timed section unless construction is the operation being measured.

Ask only for the layout information you need

An exact total height may require wrapping every item. A boolean overflow check can stop as soon as the accumulated height exceeds the available rows.

Caller needs Suitable computation Cost implication
Whether a scrollbar or overflow hint is needed Stop after proving overflow Avoids measuring the unseen tail
Exact scrollbar thumb size Exact total height, reused while valid May require all items
The visible page Render visible items and necessary overscan Cost follows viewport rather than collection size
A changed width Recalculate width-dependent wrapping Old height and render caches are invalid

For an existing list abstraction, reuse its bounded query or viewport support. Do not add another general list framework. Crush supplies a concrete example: its TotalHeight measures every item, while Overflows answers the cheaper question. It also memoizes theme-dependent syntax styles and lexer selection. These names belong to Crush, not Bubbles' public list API. Crush's render-path guidance shows why this distinction matters.

For long lists, prepare syntax-highlighting configuration once for a resolved theme. Reuse the selected lexer for unchanged language inputs according to the library's concurrency contract. Do not recreate a Chroma style and repeat lexer discovery for every visible row on every frame. Content tokenization still needs to change when the content changes.

Make cache dependencies visible

Cache only a measured expensive operation. The following local excerpt shows a single-entry cache around a pure markdown renderer. The application supplies renderMarkdown; its output depends only on the arguments listed here. This is an example of cache ownership, not an instruction to build a cache library.

type markdownKey struct {
    body          string
    width         int
    themeRevision uint64
    expanded      bool
}

type markdownCache struct {
    valid   bool
    key     markdownKey
    content string
}

func (cache *markdownCache) Render(
    body string,
    width int,
    themeRevision uint64,
    expanded bool,
    renderMarkdown func(string, int, uint64, bool) string,
) string {
    key := markdownKey{
        body: body, width: max(0, width),
        themeRevision: themeRevision, expanded: expanded,
    }
    if !cache.valid || cache.key != key {
        cache.content = renderMarkdown(
            key.body, key.width, key.themeRevision, key.expanded,
        )
        cache.key = key
        cache.valid = true
    }
    return cache.content
}

The renderer supplied to this cache must remain the same function for the cache's lifetime. Its theme revision identifies immutable resolved styles. If output also depends on selection, search highlighting, color profile, language, or terminal features, add those dependencies or keep that decoration outside the cached layer. A revision token works only when every relevant change advances it. The explicit validity flag prevents a zero-value key from being mistaken for a populated entry.

This cache belongs to one component and is used on the UI goroutine. It retains one body and rendered result; an unbounded map would retain every historical width and content combination. Verify a hit with identical inputs and a miss for each changing dependency. Also compare cached and uncached output for the same state.

During rapid resize, width changes invalidate wrapping repeatedly. If profiling still shows unacceptable work, consider the project's existing strategy for deferring expensive exact scrollbar calculation until resize settles. Preserve usable content and correct final geometry. Incremental prewarming and temporary scrollbar suppression are advanced responses to evidence, not baseline requirements for every component.

Source: SKILL.md on GitHub

No rule matched.

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No alerts2mo3 checks · Risk SAFE
  • Gen Agent Trust Hub2mo

    The Charm TUI skill provides architectural guidance and practical examples for building terminal user interfaces in Go using the Bubble Tea ecosystem. It promotes best practices like component isolation, deterministic rendering, and comprehensive testing. No malicious code, data exfiltration, or obfuscation patterns were detected.

  • Socket2mo

    No alerts

  • Snyk2mo

    Risk: LOW · No issues

Signed by skilld at 982e21e. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 4 weeks ago.

Activeupdated 3 months ago

README badge

README badge for meza/skills/charm-tui