agentleFS
gh-xjgh-xj/agent-repo-kit/skills/go-scripting/SKILL.md

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'.

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
  1. Very specific:

    Use slog: Don't introduce a third-party logger.

    line 66

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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-authoring first, then return here for Go implementation details.

Stack (at a glance)

LayerPickWhy
CLI routeralecthomas/kongDeclarative struct-tag parsing; the whole CLI is visible in one type
Loggerstdlib slog + lmittmann/tintStdlib + tiny color handler; modern, swappable
Collectionsstdlib slices / maps / cmp + iter (Go 1.23+)Stdlib + range-over-func covers most lodash territory
Tablesjedib0t/go-prettyRich, actively maintained, Unicode-aware
Spinnercharmbracelet/huh/spinner or briandowns/spinnerPick one per tool; don't mix
Last-resort helperssamber/loOnly 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

TierShapeStack
ScriptOne main.go, ≤200 LOC, 0–1 flagstdlib flag; stdlib slog if you log at all
ToolMultiple subcommands, cmd/ layout, ≤1000 LOCkong + slog+tint
CLIProduction-grade, config, releases, testskong + 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 respect NO_COLOR. Users expect these flags.
  • Exit codes: 0 success, 1 runtime error, 2 usage error.
  • Never log.Fatal or os.Exit from library code. Exit from main only.
  • Stdlib collections first. slices.Contains before lo.Contains. iter.Seq before lo.Map chains. 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.Println as your logger. Use slog.
  • panic as 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.Seq suffices. Return the iterator.
  • Spinners in CI logs. Detect the terminal and suppress.
  • Emitting a table when --json was 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-authoring first.

References

FileUse For
references/logging.mdzerolog vs slog+tint tradeoffs; Setup boilerplate; idioms
references/kong-patterns.mdDeclarative struct shape, nested subcommands, global flags, exit codes, TTY
references/collections.mdstdlib slices/maps/cmp; Go 1.23 iter; when samber/lo earns its keep
references/progress-output.mdTables (go-pretty), spinners, progress bars, TTY gating

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.