Agent skill

Golang CLI

by context-labs in context-labs/whip

Golang CLI development — command structure, flags, config layering, exit codes, I/O, signals, shell completion, validation, testing.

MITAuto-check passedDevelopment

Install Golang CLI

skills CLI
$ npx skills add context-labs/whip --skill golang-cli -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install context-labs/whip golang-cli --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/context-labs/whip.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agents/skills/golang-cli .claude/skills/golang-cli && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
golang-cli
GitHub stars
1.1k
Used in
3 other repos
Token cost
~2.5k tokens
SKILL.md length
912 words
Files
14 (incl. assets)
Skills in repo
40
Repo updated
First seen
Licence
MIT

At a glance

Golang CLI development — command structure, flags, config layering, exit codes, I/O, signals, shell completion, validation, testing.

  • Works in 4 steps: CLI flags (explicit user input) → Environment variables (deployment config) → Config file (persistent settings) → …
  • Reviewing a Go CLI
  • SKILL.md covers Quick Reference, Project Structure, Root Command Setup and Subcommands, plus 11 more sections
  • Runs Go scripts from its folder; calls go

What it does

Golang CLI is an agent skill from context-labs/whip. Golang CLI development — command structure, flags, config layering, exit codes, I/O, signals, shell completion, validation, testing. Use when building or reviewing a Go CLI or code using cobra, viper, urfave/cli. Cobra → golang-spf13-cobra; viper → golang-spf13-viper.

Its SKILL.md is about 2.5k tokens, which your agent loads only when the skill is triggered. The skill folder holds 16 other files, including assets (for example `evals/evals.json`). Compatibility notes: Designed for Claude Code, Codex or similar harness, and for projects using Golang.

It sits in Development. It works with Go and GitHub. The repository describes itself as: A fast coding-agent harness in Go. Tool-use loop, bubbletea TUI, provider-routable models with live catalog discovery, MCP support, background subagents. One binary, no runtime… The licence is MIT.

When your agent uses it

  • Reviewing a Go CLI
  • Code using cobra

Example prompts

  • “/golang-cli”

Requirements

  • Docker
  • Compatibility (from SKILL.md): Designed for Claude Code, Codex or similar harness, and for projects using Golang.
  • Pre-approved tools (allowed-tools): Read, Edit, Write, Glob, Grep, Bash(go:*), Bash(golangci-lint:*), Bash(git:*), Agent, AskUserQuestion

Workflow steps

4 steps, taken from the first numbered list in SKILL.md.

  1. CLI flags (explicit user input)
  2. Environment variables (deployment config)
  3. Config file (persistent settings)
  4. Defaults (set in code)

What it can do on your machine

Read from SKILL.md and the folder at commit 8876467. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves these tools, so the agent can use them without asking each time:

    • Read
    • Edit
    • Write
    • Glob
    • Grep
    • Bash(go:*)
    • Bash(golangci-lint:*)
    • Bash(git:*)
    • Agent
    • AskUserQuestion

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Ships script files (Go), which the agent can run.

    Shell commands in SKILL.md call:

    • go

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

  • Compatibility

    Designed for Claude Code, Codex or similar harness, and for projects using Golang.

    From compatibility in the SKILL.md frontmatter.

Context cost

Golang CLI loads about 2.5k tokens when it runs. Until then it costs about 71 tokens; SKILL.md has 912 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~71
When it runs · the whole SKILL.md, loaded when a task matches
~2.5k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from context-labs/whip at commit 8876467, republished under its MIT licence (© context-labs). 912 words, ~2,475 tokens.

Download SKILL.mdSave it as .claude/skills/golang-cli/SKILL.md (or your agent's skills folder). This skill also uses 13 other files; get the full folder from GitHub.
name
golang-cli
description
Golang CLI development — command structure, flags, config layering, exit codes, I/O, signals, shell completion, validation, testing. Use when building or reviewing a Go CLI or code using cobra, viper, urfave/cli. Cobra → `golang-spf13-cobra`; viper → `golang-spf13-viper`.
allowed-tools
Read, Edit, Write, Glob, Grep, Bash(go:*), Bash(golangci-lint:*), Bash(git:*), Agent, AskUserQuestion
compatibility
Designed for Claude Code, Codex or similar harness, and for projects using Golang.
user-invocable
true
license
MIT
metadata.author
samber
metadata.version
1.3.0
paths
**/*.go

Persona: You are a Go CLI engineer. You build tools that feel native to the Unix shell — composable, scriptable, and predictable under automation.

Modes:

  • Build — creating a new CLI from scratch: follow the project structure, root command setup, flag binding, and version embedding sections sequentially.
  • Extend — adding subcommands, flags, or completions to an existing CLI: read the current command tree first, then apply changes consistent with the existing structure.
  • Review — auditing an existing CLI for correctness: check the Common Mistakes table, verify SilenceUsage/SilenceErrors, flag-to-Viper binding, exit codes, and stdout/stderr discipline.

Go CLI Best Practices

Use Cobra + Viper as the default stack for Go CLI applications. Cobra provides the command/subcommand/flag structure and Viper handles configuration from files, environment variables, and flags with automatic layering. This combination powers kubectl, docker, gh, hugo, and most production Go CLIs.

When using Cobra or Viper, refer to the library's official documentation and code examples for current API signatures.

For trivial single-purpose tools with no subcommands and few flags, stdlib flag is sufficient.

Quick Reference

ConcernPackage / Tool
Commands & flagsgithub.com/spf13/cobra
Configurationgithub.com/spf13/viper
Flag parsinggithub.com/spf13/pflag (via Cobra)
Colored outputgithub.com/fatih/color
Table outputgithub.com/olekukonko/tablewriter
Interactive promptsgithub.com/charmbracelet/bubbletea
Version injectiongo build -ldflags
Distributiongoreleaser

Project Structure

Organize CLI commands in cmd/myapp/ with one file per command. Keep main.go minimal — it only calls Execute().

myapp/
├── cmd/
│   └── myapp/
│       ├── main.go              # package main, only calls Execute()
│       ├── root.go              # Root command + Viper init
│       ├── serve.go             # "serve" subcommand
│       ├── migrate.go           # "migrate" subcommand
│       └── version.go           # "version" subcommand
├── go.mod
└── go.sum

main.go should be minimal — see assets/examples/main.go.

Root Command Setup

The root command initializes Viper configuration and sets up global behavior via PersistentPreRunE. See assets/examples/root.go.

Key points:

  • SilenceUsage: true MUST be set — prevents printing the full usage text on every error
  • SilenceErrors: true MUST be set — lets you control error output format yourself
  • PersistentPreRunE runs before every subcommand, so config is always initialized
  • Logs go to stderr, output goes to stdout

Subcommands

Add subcommands by creating separate files in cmd/myapp/ and registering them in init(). See assets/examples/serve.go for a complete subcommand example including command groups.

Flags

See assets/examples/flags.go for all flag patterns:

Persistent vs Local
  • Persistent flags are inherited by all subcommands (e.g., --config)
  • Local flags only apply to the command they're defined on (e.g., --port)
Required Flags

Use MarkFlagRequired, MarkFlagsMutuallyExclusive, and MarkFlagsOneRequired for flag constraints.

Flag Validation with RegisterFlagCompletionFunc

Provide completion suggestions for flag values.

Always Bind Flags to Viper

This ensures viper.GetInt("port") returns the flag value, env var MYAPP_PORT, or config file value — whichever has highest precedence.

Argument Validation

Cobra provides built-in validators for positional arguments. See assets/examples/args.go for both built-in and custom validation examples.

ValidatorDescription
cobra.NoArgsFails if any args provided
cobra.ExactArgs(n)Requires exactly n args
cobra.MinimumNArgs(n)Requires at least n args
cobra.MaximumNArgs(n)Allows at most n args
cobra.RangeArgs(min, max)Requires between min and max
cobra.ExactValidArgs(n)Exactly n args, must be in ValidArgs

Configuration with Viper

Viper resolves configuration values in this order (highest to lowest precedence):

  1. CLI flags (explicit user input)
  2. Environment variables (deployment config)
  3. Config file (persistent settings)
  4. Defaults (set in code)

See assets/examples/config.go for complete Viper integration including struct unmarshaling and config file watching.

Example Config File (.myapp.yaml)
yaml
port: 8080
host: localhost
log-level: info
database:
  dsn: postgres://localhost:5432/myapp
  max-conn: 25

With the setup above, these are all equivalent:

  • Flag: --port 9090
  • Env var: MYAPP_PORT=9090
  • Config file: port: 9090

Version and Build Info

Version SHOULD be embedded at compile time using ldflags. See assets/examples/version.go for the version command and build instructions.

Show full SKILL.md (377 more words)Show less

Exit Codes

Exit codes MUST follow Unix conventions:

CodeMeaningWhen to Use
0SuccessOperation completed normally
1General errorRuntime failure
2Usage errorInvalid flags or arguments
64-78BSD sysexitsSpecific error categories
126Cannot executePermission denied
127Command not foundMissing dependency
128+NSignal NTerminated by signal (e.g., 130 = SIGINT)

See assets/examples/exit_codes.go for a pattern mapping errors to exit codes.

I/O Patterns

See assets/examples/output.go for all I/O patterns:

  • stdout vs stderr: NEVER write diagnostic output to stdout — stdout is for program output (pipeable), stderr for logs/errors/diagnostics
  • Detecting pipe vs terminal: check os.ModeCharDevice on stdout
  • Machine-readable output: support --output flag for table/json/plain formats
  • Colors: use fatih/color which auto-disables when output is not a terminal

Signal Handling

Signal handling MUST use signal.NotifyContext to propagate cancellation through context. See assets/examples/signal.go for graceful HTTP server shutdown.

Shell Completions

Cobra generates completions for bash, zsh, fish, and PowerShell automatically. See assets/examples/completion.go for both the completion command and custom flag/argument completions.

Testing CLI Commands

Test commands by executing them programmatically and capturing output. See assets/examples/cli_test.go.

Use cmd.OutOrStdout() and cmd.ErrOrStderr() in commands (instead of os.Stdout / os.Stderr) so output can be captured in tests.

Common Mistakes

MistakeFix
Writing to os.Stdout directlyTests can't capture output. Use cmd.OutOrStdout() which tests can redirect to a buffer
Calling os.Exit() inside RunECobra's error handling, deferred functions, and cleanup code never run. Return an error, let main() decide
Not binding flags to ViperFlags won't be configurable via env/config. Call viper.BindPFlag for every configurable flag
Missing viper.SetEnvPrefixPORT collides with other tools. Use a prefix (MYAPP_PORT) to namespace env vars
Logging to stdoutUnix pipes chain stdout — logs corrupt the data stream for the next program. Logs go to stderr
Printing usage on every errorFull help text on every error is noise. Set SilenceUsage: true, save full usage for --help
Config file requiredUsers without a config file get a crash. Ignore viper.ConfigFileNotFoundError — config should be optional
Not using PersistentPreRunEConfig initialization must happen before any subcommand. Use root's PersistentPreRunE
Hardcoded version stringVersion gets out of sync with tags. Inject via ldflags at build time from git tags
Not supporting --output formatScripts can't parse human-readable output. Add JSON/table/plain for machine consumption

See samber/cc-skills-golang@golang-project-layout, samber/cc-skills-golang@golang-dependency-injection, samber/cc-skills-golang@golang-testing, samber/cc-skills-golang@golang-design-patterns skills.

© context-labs, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 13 other files (assets) in .agents/skills/golang-cli of context-labs/whip.

  • SKILL.md
  • assets/examples/args.go
  • assets/examples/cli_test.go
  • assets/examples/completion.go
  • assets/examples/config.go
  • assets/examples/exit_codes.go
  • assets/examples/flags.go
  • assets/examples/main.go
  • assets/examples/output.go
  • assets/examples/root.go
  • assets/examples/serve.go
  • assets/examples/signal.go
  • assets/examples/version.go
  • evals/evals.json

Open the folder on GitHubat commit 8876467

Used in 3 other repositories

We found 4 copies of this SKILL.md (exact, near-identical or edited) in other folders, from 3 other GitHub owners. This page covers the copy in context-labs/whip, which our catalogue first saw on October 7, 2026.

Compare with similar skills

Golang CLI next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Golang CLI compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Golang CLI this skillcontext-labs/whip1.1k3 repos~2.5kAutomated safety check: PassMIT
Go-Redis Release Preparationredis/go-redis22k—~1.1kAutomated safety check: PassBSD-2-Clause
Machinistowainlewis/machinist4921 repos~761Automated safety check: PassMIT
Valgocohesivestack/valgo508—~2.4kAutomated safety check: PassMIT
Releaseyoanbernabeu/grepai1.9k—~918Automated safety check: PassMIT
Fix Gh Issuebeatlabs/harvester135—~783Automated safety check: PassApache-2.0

Similar skills

  • Official

    Prepares a go-redis release locally: picks the next semver, gathers merged PRs, writes the RELEASE-NOTES entry and bumps versions, without publishing.

    22k GitHub stars~1.1k tokensUpdated yesterday
    DevelopmentAuto-check passed
  • Machinist

    owainlewis/machinist

    Use Machinist to create, assign, and monitor software tasks.

    492 GitHub starsUsed in 1 repo~761 tokens
    DevelopmentAuto-check passed
  • Valgo

    cohesivestack/valgo

    Add, refactor, debug, review, explain, or migrate type-safe validation in consumer Go applications using github.com/cohesivestack/valgo.

    508 GitHub stars~2.4k tokensUpdated 1 mo ago
    DevelopmentAuto-check passed
  • Release

    yoanbernabeu/grepai

    Create a new release for grepai. An agent skill from yoanbernabeu/grepai.

    1.9k GitHub stars~918 tokensUpdated 17 days ago
    DevelopmentAuto-check passed
  • Fix Gh Issue

    beatlabs/harvester

    Fix a single GitHub issue end-to-end using wt. An agent skill from beatlabs/harvester.

    135 GitHub stars~783 tokensUpdated 6 days ago
    DevelopmentAuto-check passed
  • Release

    ggwhite/go-masker

    Release a new version of go-masker: update CHANGELOG.md from git log, create GitHub release.

    130 GitHub stars~938 tokensUpdated 3 mo ago
    DevelopmentAuto-check passed

More from context-labs/whip

All 40 skills in this repo
  • Golang Lint

    context-labs/whip

    Linting best practices and golangci-lint configuration for Go — running linters, configuring .golangci.yml, nolint suppressions, selecting linters.

    1.1k GitHub starsUsed in 2 repos~1.8k tokens
    Auto-check passed
  • Golang Project Layout

    context-labs/whip

    Golang project layouts and workspaces. An agent skill from context-labs/whip.

    1.1k GitHub starsUsed in 1 repo~1.8k tokens
    Auto-check passed
  • Golang Pkg Go Dev

    context-labs/whip

    Golang package/module docs via godig, a pkg.go.dev API client (CLI + MCP) — APIs, symbols, versions, importers, licenses, vulnerabilities.

    1.1k GitHub starsUsed in 2 repos~3k tokens
    Auto-check passed
  • Golang Stretchr Testify

    context-labs/whip

    Golang testing with stretchr/testify — assert, require, mock, suite: assertions, mock expectations, argument matchers, suite lifecycle, Eventually, JSONEq.

    1.1k GitHub starsUsed in 2 repos~1.8k tokens
    Auto-check passed
  • CI/CD with GitHub Actions for Golang — testing, linting, SAST, security scanning, coverage, Dependabot, Renovate, GoReleaser, release pipelines.

    1.1k GitHub stars~3.5k tokensUpdated 3 days ago
    Auto-check passed
  • Golang Data Structures

    context-labs/whip

    Golang data structures — slices/maps internals (capacity growth, preallocation, hash buckets), slices/maps packages, container/list/heap/ring, strings.Builder vs bytes.Buffer, generic collections…

    1.1k GitHub starsUsed in 1 repo~2.6k tokens
    Auto-check passed

Works with

Categories

Questions about Golang CLI

What does Golang CLI do?

Golang CLI development — command structure, flags, config layering, exit codes, I/O, signals, shell completion, validation, testing. Golang CLI is an agent skill from context-labs/whip. Golang CLI development — command structure, flags, config layering, exit codes, I/O, signals, shell completion, validation, testing.

When should I use Golang CLI?

Golang CLI fits situations like: reviewing a Go CLI; code using cobra.

How do I install Golang CLI in Claude Code?

Run `npx skills add context-labs/whip --skill golang-cli -a claude-code`. Or copy the skill folder (.agents/skills/golang-cli in context-labs/whip) into .claude/skills/golang-cli in your project. Claude Code loads it when a task matches its description.

How do I install Golang CLI in Codex?

Run `npx skills add context-labs/whip --skill golang-cli -a codex`. Or copy the skill folder (.agents/skills/golang-cli in context-labs/whip) into .agents/skills/golang-cli in your project. Codex loads it when a task matches its description.

Can I use Golang CLI in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add context-labs/whip --skill golang-cli -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/golang-cli, .gemini/skills/golang-cli, .github/skills/golang-cli and .opencode/skills/golang-cli in your project.

What does Golang CLI need to run?

Going by SKILL.md and its folder, Golang CLI needs Go for the scripts in its folder and the command-line tools its instructions call (go). Our summary lists: Docker. Its frontmatter pre-approves these tools: Read, Edit, Write, Glob, Grep, Bash(go:*), Bash(golangci-lint:*), Bash(git:*), Agent, AskUserQuestion. Compatibility (from SKILL.md): Designed for Claude Code, Codex or similar harness, and for projects using Golang..

Does Golang CLI access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Golang CLI safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Golang CLI use?

Golang CLI is published under the MIT licence (declared in SKILL.md). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Golang CLI use?

About 2.5k tokens (SKILL.md is roughly 9.9k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Golang CLI?

Skills that share tags, products or a category with Golang CLI: Go-Redis Release Preparation (redis/go-redis, 22k stars), Machinist (owainlewis/machinist, 492 stars), Valgo (cohesivestack/valgo, 508 stars) and Release (yoanbernabeu/grepai, 1.9k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Golang CLI?

context-labs (a GitHub organization) maintains it in context-labs/whip, which has 1,081 GitHub stars. The repository holds 40 skills in this directory. The repository was last updated on October 5, 2026.

Source: context-labs/whip on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.