Architecture and package layout
How the codebase is organized, where the boundaries are, and why it is deterministic and offline-first.
The binary and its entry point
cmd/agore-skill/main.go is the only entry point. Its run function wires
an App (the process dependencies: writers, TTY state, env lookups, git
helpers, prompt hooks) into the cobra command tree and hands it to
charmbracelet/fang for execution and styling. Any returned error becomes
exit code 1; otherwise 0.
Package map
- cmd/agore-skillentry point: fang.Execute over the command tree
- main.go
- internal
- clisix cobra commands + the App dependency surface
- root.go
- configagore.yaml model, defaults, loader, validation
- workspaceskill discovery and git change filtering
- skillSKILL.md parser + embedded scaffold templates
- filefilterthe shared file funnel: hidden paths, dist/, .gitignore, skill.exclude
- inspecttoken estimation and the L1/L2/L3 analysis
- lintten deterministic rules and the Diagnostic type
- releasetag parsing, bundling, changelog, GitHub publisher
- uilipgloss theme and terminal renderers
The layering is one-directional: cli depends on all the others; the
domain packages (config, workspace, skill, filefilter, inspect,
lint, release) never import cli. ui is a leaf used by cli;
filefilter is a leaf shared by inspect and release, so what inspect
counts is what release publishes.
The dependency-injection core
Every effectful operation the CLI performs — reading git state, looking up
binaries on PATH, prompting in a TTY, running the GitHub publish — is a
field on the cli.App struct. NewApp() connects the real environment;
tests construct an App with fakes. This is why the CLI logic is testable
without touching the terminal or the network, and why the six commands have
no hidden global state.
Templates are embedded, not fetched
The three scaffolds (minimal, progressive, scripted) live in
internal/skill/templates/ and are compiled into the binary with
go:embed, rendered through Go's text/template with a small yaml helper
function that safely quotes values into frontmatter. A generated skill is
identical on every machine; create needs no network and no template
repository.
Deterministic, offline-first
The design choices that make output reproducible:
- The token estimator is pure arithmetic — ASCII at ¼ token, non-ASCII runes at 1.5 — so inspect and lint never depend on a model or a dictionary.
- Discovery sorts deterministically: the root skill first, then alphabetical by relative path; glob expansion order is normalized.
- Bundles pin timestamps (1980-01-01 UTC) and preserve file modes, so re-bundling identical content yields identical bytes and checksums.
- No runtime network calls except the GitHub publisher in a real release. Everything else — parsing, analysis, linting, bundling — works in a hermetic environment.
Testing posture
Each package carries table-driven tests; the lint package additionally asserts that all three embedded templates lint clean (0 errors, 0 warnings), which is the invariant the tutorials rely on. The release package tests tag parsing, exclusion matching and archive contents directly.
Related
- What each command does: CLI overview
- The analysis model: Progressive disclosure L1/L2/L3
- The contributor's deep dive on the same design: Deterministic offline-first design