library/specializations/cli-mcp-development/skills/cobra-scaffolder/SKILL.md
Generate Cobra/Viper-based Go CLI applications with persistent flags, subcommands, and configuration management. Creates production-ready Go CLI with modern patterns.
npx skillsauth add a5c-ai/babysitter cobra-scaffolderInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Generate a complete Cobra CLI application with Viper configuration, proper Go module structure, and best practices.
Invoke this skill when you need to:
| Parameter | Type | Required | Description | |-----------|------|----------|-------------| | projectName | string | Yes | Name of the CLI project (kebab-case) | | modulePath | string | Yes | Go module path (e.g., github.com/user/project) | | description | string | Yes | Short description of the CLI | | commands | array | No | List of commands to scaffold | | useViper | boolean | No | Integrate Viper config (default: true) | | useCobra | boolean | No | Use cobra-cli generator patterns (default: true) |
{
"commands": [
{
"name": "serve",
"description": "Start the server",
"persistentFlags": [
{ "name": "config", "shorthand": "c", "type": "string", "usage": "config file path" }
],
"flags": [
{ "name": "port", "shorthand": "p", "type": "int", "default": 8080, "usage": "port to listen on" }
],
"subcommands": ["start", "stop", "status"]
}
]
}
<projectName>/
├── go.mod
├── go.sum
├── main.go
├── README.md
├── .goreleaser.yaml
├── cmd/
│ ├── root.go # Root command with Viper
│ ├── serve.go # Serve command
│ ├── version.go # Version command
│ └── completion.go # Completion command
├── internal/
│ ├── config/
│ │ └── config.go # Configuration structures
│ ├── server/
│ │ └── server.go # Server implementation
│ └── logger/
│ └── logger.go # Logging setup
├── pkg/
│ └── utils/
│ └── helpers.go # Public utilities
└── tests/
└── cmd/
└── root_test.go
package cmd
import (
"fmt"
"os"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
var cfgFile string
var rootCmd = &cobra.Command{
Use: "<projectName>",
Short: "<description>",
Long: `<long description>`,
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
return initConfig()
},
}
func Execute() {
if err := rootCmd.Execute(); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}
func init() {
rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "",
"config file (default is $HOME/.<projectName>.yaml)")
rootCmd.PersistentFlags().BoolP("verbose", "v", false, "verbose output")
viper.BindPFlag("verbose", rootCmd.PersistentFlags().Lookup("verbose"))
}
func initConfig() error {
if cfgFile != "" {
viper.SetConfigFile(cfgFile)
} else {
home, err := os.UserHomeDir()
cobra.CheckErr(err)
viper.AddConfigPath(home)
viper.SetConfigType("yaml")
viper.SetConfigName(".<projectName>")
}
viper.AutomaticEnv()
viper.SetEnvPrefix("<PROJECT_NAME>")
if err := viper.ReadInConfig(); err == nil {
fmt.Fprintln(os.Stderr, "Using config file:", viper.ConfigFileUsed())
}
return nil
}
package cmd
import (
"fmt"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
var serveCmd = &cobra.Command{
Use: "serve",
Short: "Start the server",
Long: `Start the server with the specified configuration.`,
RunE: func(cmd *cobra.Command, args []string) error {
port := viper.GetInt("port")
host := viper.GetString("host")
fmt.Printf("Starting server on %s:%d\n", host, port)
return nil
},
}
func init() {
rootCmd.AddCommand(serveCmd)
serveCmd.Flags().IntP("port", "p", 8080, "port to listen on")
serveCmd.Flags().String("host", "localhost", "host to bind to")
viper.BindPFlag("port", serveCmd.Flags().Lookup("port"))
viper.BindPFlag("host", serveCmd.Flags().Lookup("host"))
}
module github.com/user/<projectName>
go 1.21
require (
github.com/spf13/cobra v1.8.0
github.com/spf13/viper v1.18.0
)
development
Model documentation skill for generating model cards following Google's model card framework.
development
MLflow integration skill for experiment tracking, model registry, and artifact management. Enables LLMs to log experiments, compare runs, manage model lifecycle, and retrieve artifacts through the MLflow API.
data-ai
LIME-based local explanation skill for individual predictions across tabular, text, and image data.
devops
Kubeflow Pipelines skill for ML workflow orchestration, component management, and Kubernetes-native ML.