go-scripting
Skill0 starsChanged 6 months agoMITView on GitHub
Use when writing a new Go CLI tool or script, declaring a kong-based subcommand tree, choosing a logger (slog+tint), working with collections via stdlib iter or slices, or adding tables and spinners to CLI output. Trigger on 'write a Go CLI', 'build a Go script', 'kong subcommand', 'cobra vs kong', 'which Go logger', 'slog vs zerolog', 'Go iter', 'iter.Seq', 'samber lo', 'Go stdlib vs lo', 'scaffold Go tool', 'Go CLI table', 'Go spinner', 'go-pretty'.
In this repository11 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- attack-architectureSkill
- convention-engineeringSkill
- harness-routerSkill
- paper-vettingSkill
- skill-builderSkill
- skill-cli-authoringSkill
- slock-epic-protocolSkill
- taskfile-authoringSkill
- work-cliSkill
The file
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 66
Use slog: Don't introduce a third-party logger.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Go Scripting
Opinionated guide for small Go CLIs and scripts. Prescribes a narrow, modern stack so you don't re-litigate the same choices on every new tool.
When to use
- Writing a new Go CLI tool, even a one-file script.
- Adding a subcommand to an existing kong-based CLI.
- Deciding which logger, CLI framework, or collection helper to use.
- Adding tables, spinners, or progress output.
When NOT to use
- Go library code — this guide is for CLIs and scripts.
- Go web services — framework-specific guides fit better.
- Shell territory (one grep, one curl): write a shell script.
- Agent-facing command contracts for CLIs inside skills — use
skill-cli-authoringfirst, then return here for Go implementation details.
Stack (at a glance)
| Layer | Pick | Why |
| CLI router | alecthomas/kong | Declarative struct-tag parsing; the whole CLI is visible in one type |
| Logger | stdlib slog + lmittmann/tint | Stdlib + tiny color handler; modern, swappable |
| Collections | stdlib slices / maps / cmp + iter (Go 1.23+) | Stdlib + range-over-func covers most lodash territory |
| Tables | jedib0t/go-pretty | Rich, actively maintained, Unicode-aware |
| Spinner | charmbracelet/huh/spinner or briandowns/spinner | Pick one per tool; don't mix |
| Last-resort helpers | samber/lo | Only for specific helpers stdlib+iter can't provide |
See references for the full rationale.
Decision: Go vs shell
Go when you need any of:
- Structured config, JSON parsing, or typed values.
- Multiple subcommands.
- Cross-platform (no bash assumptions).
- Real error handling.
- Tests.
Shell when the whole thing is a sequence of ~5 commands a POSIX sh can
run in 30 lines.
Scale tiers
| Tier | Shape | Stack |
| Script | One main.go, ≤200 LOC, 0–1 flag | stdlib flag; stdlib slog if you log at all |
| Tool | Multiple subcommands, cmd/ layout, ≤1000 LOC | kong + slog+tint |
| CLI | Production-grade, config, releases, tests | kong + slog+tint, optionally go-pretty + spinner |
Skip kong below Tier 2 — stdlib flag is enough for a 2-flag script.
Skip go-pretty/spinner unless you have row-oriented data or long-running
operations.
Non-negotiables
- Use slog. Don't introduce a third-party logger. If you think you
need zerolog, read
references/logging.md. - Use kong for new tools. cobra is acceptable only when the codebase is already on it. Mixing routers across one project is worse than either.
- Ship
--verbose,--no-color, and respectNO_COLOR. Users expect these flags. - Exit codes:
0success,1runtime error,2usage error. - Never
log.Fataloros.Exitfrom library code. Exit from main only. - Stdlib collections first.
slices.Containsbeforelo.Contains.iter.Seqbeforelo.Mapchains. samber/lo is a last resort. - Gate all visual output (colors, spinners, tables) on
term.IsTerminal && NO_COLOR == "". Piped or CI output must be plain.
Common mistakes
- Reaching for kong on a 50-line script. Use stdlib
flag. - Using
fmt.Printlnas your logger. Use slog. panicas error handling. Return errors; exit from main.- Importing samber/lo for a single Filter. Use stdlib slices or a loop.
- Materializing a slice when
iter.Seqsuffices. Return the iterator. - Spinners in CI logs. Detect the terminal and suppress.
- Emitting a table when
--jsonwas passed. Respect the flag. - Keeping timestamps in CLI output. Strip them — the shell prefix is enough.
- Designing the command surface only after coding structs. For skill-local
CLIs, settle examples, JSON shape, safety class, and smoke checks with
skill-cli-authoringfirst.
References
| File | Use For |
references/logging.md | zerolog vs slog+tint tradeoffs; Setup boilerplate; idioms |
references/kong-patterns.md | Declarative struct shape, nested subcommands, global flags, exit codes, TTY |
references/collections.md | stdlib slices/maps/cmp; Go 1.23 iter; when samber/lo earns its keep |
references/progress-output.md | Tables (go-pretty), spinners, progress bars, TTY gating |
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

