Generate Cobra/Viper-based Go CLI applications with persistent flags, subcommands, and configuration management. Creates production-ready Go CLI with modern patterns.
Generates production-ready Go CLI applications with Cobra/Viper, including commands, flags, and configuration management.
npx claudepluginhub a5c-ai/babysitterThis skill is limited to using the following tools:
README.mdGenerate 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
)
Activates when the user asks about AI prompts, needs prompt templates, wants to search for prompts, or mentions prompts.chat. Use for discovering, retrieving, and improving prompts.
Search, retrieve, and install Agent Skills from the prompts.chat registry using MCP tools. Use when the user asks to find skills, browse skill catalogs, install a skill for Claude, or extend Claude's capabilities with reusable AI agent components.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.