CLI application patterns and best practices
Provides CLI patterns for progress bars, interactive prompts, and colored output. Use when building Go CLI tools that need user feedback or terminal enhancements.
/plugin marketplace add pluginagentmarketplace/custom-plugin-go/plugin install go-development-assistant@pluginagentmarketplace-goThis skill inherits all available tools. When active, it can use any tool Claude has access to.
assets/cobra-template.goassets/config.yamlassets/schema.jsonreferences/GUIDE.mdreferences/PATTERNS.mdscripts/validate.pySupplementary CLI patterns and utilities.
Additional CLI patterns for argument parsing, progress indicators, and user interaction.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| feature | string | yes | - | Feature: "progress", "prompt", "color" |
var cmd = &cobra.Command{
Use: "process [file]",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
file := args[0]
if _, err := os.Stat(file); os.IsNotExist(err) {
return fmt.Errorf("file not found: %s", file)
}
return process(file)
},
}
func DownloadWithProgress(url, dest string) error {
resp, err := http.Get(url)
if err != nil {
return err
}
defer resp.Body.Close()
file, err := os.Create(dest)
if err != nil {
return err
}
defer file.Close()
bar := progressbar.DefaultBytes(resp.ContentLength, "downloading")
_, err = io.Copy(io.MultiWriter(file, bar), resp.Body)
return err
}
func ConfirmAction(message string) bool {
reader := bufio.NewReader(os.Stdin)
fmt.Printf("%s [y/N]: ", message)
input, _ := reader.ReadString('\n')
input = strings.TrimSpace(strings.ToLower(input))
return input == "y" || input == "yes"
}
import "github.com/fatih/color"
var (
successColor = color.New(color.FgGreen).SprintFunc()
errorColor = color.New(color.FgRed).SprintFunc()
warnColor = color.New(color.FgYellow).SprintFunc()
)
func PrintSuccess(msg string) {
fmt.Println(successColor("✓"), msg)
}
func PrintError(msg string) {
fmt.Fprintln(os.Stderr, errorColor("✗"), msg)
}
| Symptom | Cause | Fix |
|---|---|---|
| Colors not showing | No TTY | Check isatty |
| Input hangs | Stdin closed | Handle EOF |
Skill("go-cli")
This skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
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.