add-command-simple

Scaffold a Cobra CLI command file with flags and root wiring.

10|14|Updated Feb 26, 2026
One-click install
npx skills add https://github.com/openkaiden/kdn --skill add-command-simple
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: add-command-simple
Source: https://github.com/openkaiden/kdn/tree/main/.agents/skills/add-command-simple
Command: npx skills add https://github.com/openkaiden/kdn --skill add-command-simple

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill helps you add a simple CLI command that outputs plain text (no JSON output support) to accelerate task automation in Go projects.

Core Features & Use Cases

  • Command scaffolding: generate a Cobra-based command file at pkg/cmd/<command>.go with standard Use, Short, Long, and Example fields.
  • Argument and flag patterns: supports required args, PreRun, RunE, and flag binding via BoolVarP/StringVarP, enabling consistent behavior.
  • Integration patterns: demonstrates how to wire the command into root.go and group categorization for help output.
  • Use Case: quickly add a new CLI action like "clean" or "validate" to streamline workflows in a workspace.

Quick Start

Create a new Cobra command file under pkg/cmd for your <command> and wire it into root.go to expose the command.

Frequently Asked Questions about add-command-simple

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

FAQPage Schema
How do I add a Cobra command to a Go CLI project?

To add a Cobra command to a Go CLI project, generate a command file under pkg/cmd with standard Use, Short, Long, and Example fields, then wire it into root.go. This scaffolding pattern supports PreRun, RunE, and flag binding for consistent behavior.

How do I scaffold a CLI command with plain text output in Golang?

Scaffold a CLI command with plain text output in Golang by creating a Cobra-based command file in a pkg/cmd structure. This process generates argument validation, flag binding via BoolVarP/StringVarP, and basic testing scaffolds for the new command.

Does this CLI command scaffolding support JSON output?

This CLI command scaffolding does not support JSON output, as it is designed specifically to generate commands that output plain text. It focuses on streamlining workspace workflows with simple text-based actions.

What is the best way to wire a new command into root.go for help output?

The best way to wire a new command into root.go for help output is to register the generated Cobra command file alongside group categorization. This integration pattern ensures the new CLI action appears correctly in the workspace help output.

Can I use flag binding with BoolVarP and StringVarP in Cobra command scaffolding?

Yes, you can use flag binding with BoolVarP and StringVarP in Cobra command scaffolding. The generated command file applies these patterns alongside required arguments and PreRun hooks to enable consistent CLI behavior.

Do I need a specific Go project structure to scaffold Cobra commands?

You need a Go project organized with a pkg/cmd command structure to scaffold Cobra commands effectively. This layout allows the generated command files to integrate seamlessly with root command registration and testing scaffolds.