원클릭으로
cli-patterns
Cobra commands in cmd/ package, flag conventions
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Cobra commands in cmd/ package, flag conventions
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
| name | cli-patterns |
| description | Cobra commands in cmd/ package, flag conventions |
| domain | architecture |
| confidence | high |
| source | hyoka/cmd/*.go |
Hyoka's CLI is built with Cobra, a popular Go CLI framework. Commands are organized in the cmd/ package with consistent flag naming and help text patterns.
Each command is a Cobra command object:
// cmd/run.go
var runCmd = &cobra.Command{
Use: "run",
Short: "Run evaluation",
Long: "Run an evaluation with prompts and configs.",
Args: cobra.NoArgs, // Positional arguments check
RunE: func(cmd *cobra.Command, args []string) error {
// Retrieve flags
promptID, _ := cmd.Flags().GetString("prompt-id")
config, _ := cmd.Flags().GetString("config")
// Validate
if promptID == "" && config == "" {
return fmt.Errorf("either --prompt-id or --config required")
}
// Execute
return run(promptID, config)
},
}
func init() {
rootCmd.AddCommand(runCmd)
runCmd.Flags().StringP("prompt-id", "", "", "Single prompt ID")
runCmd.Flags().StringP("config", "", "", "Config (comma-sep for multiple)")
}
--log-level, --max-files, --prompt-id (not --logLevel, --maxfiles)-v for --verbose)--*-timeout for duration limits (e.g., --gen-timeout)--skip-* for skipping phases (e.g., --skip-review)--*-file for file paths (e.g., --log-file)String flags:
cmd.Flags().StringP("config", "", "", "Config name")
Comma-separated lists:
cmd.Flags().String("tags", "", "Comma-separated tags (must quote: \"auth,crud\")")
// Parsed as: strings.Split(value, ",")
Boolean flags:
cmd.Flags().Bool("dry-run", false, "Show what would run without executing")
Numeric flags:
cmd.Flags().Int("max-files", 50, "Max files per eval")
cmd.Flags().Duration("gen-timeout", 600*time.Second, "Generation timeout")
Keep help text brief but actionable:
// Good
--config Config name or comma-sep list
--prompt-id Single prompt ID (e.g., identity-dp-python-default-credential)
--service Azure service (e.g., identity, key-vault)
--dry-run List matching prompts without executing
// Bad (too verbose, no examples)
--prompt-id The prompt identifier
--config The configuration to use
RunE: func(cmd *cobra.Command, args []string) error {
// 1. Get flags
promptID, _ := cmd.Flags().GetString("prompt-id")
config, _ := cmd.Flags().GetString("config")
// 2. Validate
if promptID == "" {
return fmt.Errorf("--prompt-id required")
}
// 3. Execute
ctx := context.Background()
return executeEval(ctx, promptID, config)
}
run — Execute evaluationlist — List available promptsvalidate — Validate prompt schemacheck-env — Check environment (Copilot SDK, Go version)clean — Clean orphaned sessionsserve — Start local web server for resultsReturn errors from RunE. Cobra catches them and prints with exit code 1:
RunE: func(cmd *cobra.Command, args []string) error {
result, err := runEval(...)
if err != nil {
slog.Error("Evaluation failed", "error", err)
return err // Cobra handles exit
}
return nil
}
--log-level flagRunE, let Cobra printRunE: func(cmd *cobra.Command, args []string) error {
config, _ := cmd.Flags().GetString("config")
allConfigs, _ := cmd.Flags().GetBool("all-configs")
if config == "" && !allConfigs {
return fmt.Errorf("either --config or --all-configs required")
}
if config != "" && allConfigs {
return fmt.Errorf("cannot use both --config and --all-configs")
}
return runWithConfig(config, allConfigs)
}
hyoka/cmd/root.gohyoka/cmd/*.gohyoka/cmd/common.go (if shared parsing logic)-a if context unclear)How to write comprehensive architectural proposals that drive alignment before code is written
How the eval engine works: generate → grade → review → report
Record final outcomes to history.md, not intermediate requests or reversed decisions
Tone enforcement patterns for external-facing community responses
Team initialization flow (Phase 1 proposal + Phase 2 creation)
Core conventions and patterns for this codebase