golang-cli

Create, modify, and audit Go command-line applications using Cobra and Viper.

1|Updated Apr 4, 2026
One-click install
npx skills add https://github.com/Jylhis/claude-marketplace --skill golang-cli-jylhis
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: golang-cli
Source: https://github.com/Jylhis/claude-marketplace/tree/main/plugins/golang-dev/skills/golang-cli
Command: npx skills add https://github.com/Jylhis/claude-marketplace --skill golang-cli-jylhis

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes assets (resource) components.

What problem does it solve?

Developers need clear guidance to create, extend, and review Go command‑line applications, ensuring proper command structures, flag handling, configuration, versioning, I/O, signal handling, and testing.

Core Features & Use Cases

  • Command Architecture: Templates for root and subcommands using Cobra.
  • Flag Management: Persistent and local flag patterns with Viper binding and validation.
  • Configuration Layering: Automatic environment, config file, and defaults handling.
  • Version & Build Info: ldflags‑based version embedding.
  • Testing & CI: Patterns for unit testing commands and CI linting with golangci‑lint.
  • Signal Handling: Graceful shutdown via signal.NotifyContext.
  • Shell Completion: Automatic generation of bash, zsh, fish, and PowerShell completions.

Quick Start

Ask the skill to generate a new Cobra root command for a Go CLI named “myapp”.

Frequently Asked Questions about golang-cli

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I build a Go CLI application with Cobra and Viper?

To build a Go CLI application with Cobra and Viper, you structure root and subcommands, bind flags, handle configuration layering with defaults and environments, and implement testing. This provides a robust command architecture and flag management.

What is the best way to manage configuration layering in a Go command-line tool?

Managing configuration layering in a Go command-line tool involves automatically handling defaults, config files, and environment variables. Binding persistent and local flags with Viper ensures configuration is validated and applied correctly across commands.

How do I add shell completion to my Go command-line application?

Adding shell completion to your Go command-line application is done by automatically generating completion scripts for bash, zsh, fish, and PowerShell. Using Cobra's built-in generation features provides native autocomplete functionality for users.

How do I embed version and build info into a Go CLI binary?

Embedding version and build info into a Go CLI binary requires using ldflags during the build process. Passing version variables at compile time injects build metadata directly into the command-line application for version tracking.

Do I need golangci-lint to test my Go command-line application?

You do not need golangci-lint to test your Go command-line application, but it is an optional dependency for CI linting. Using it alongside unit testing patterns ensures your Go CLI commands pass quality checks in continuous integration.

How do I handle graceful shutdown in a Go CLI tool?

Handling graceful shutdown in a Go CLI tool is implemented using signal.NotifyContext. This mechanism intercepts OS interrupt signals, allowing your command-line application to clean up resources and exit safely.