원클릭으로
adding-commands
How to add new CLI commands to flow. Use when creating a new subcommand, adding flags, or modifying the command tree.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
How to add new CLI commands to flow. Use when creating a new subcommand, adding flags, or modifying the command tree.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
| name | adding-commands |
| description | How to add new CLI commands to flow. Use when creating a new subcommand, adding flags, or modifying the command tree. |
All commands live in internal/cmd/ and use cobra. Follow the existing pattern exactly.
Each command gets its own file: internal/cmd/<name>.go.
Every command follows this structure:
package cmd
import (
"github.com/milldr/flow/internal/ui"
"github.com/milldr/flow/internal/workspace"
"github.com/spf13/cobra"
)
func newXxxCmd(svc *workspace.Service) *cobra.Command {
return &cobra.Command{
Use: "xxx <workspace>",
Short: "One-line description",
Args: cobra.ExactArgs(1),
Example: ` flow xxx calm-delta`,
RunE: func(cmd *cobra.Command, args []string) error {
// 1. Resolve workspace
id, st, err := resolveWorkspace(svc, args[0])
if err != nil {
return err
}
// 2. Business logic (often wrapped in spinner)
name := workspaceDisplayName(id, st)
err = ui.RunWithSpinner("Doing thing: "+name, func(report func(string)) error {
// call svc methods here
return nil
})
if err != nil {
return err
}
// 3. Success output
ui.Success("Done: " + name)
return nil
},
}
}
Register the command in internal/cmd/root.go inside newRootCmd():
root.AddCommand(newXxxCmd(svc))
The svc (*workspace.Service) is the only dependency passed to commands. It provides access to config, git runner, and all workspace operations.
These are defined in internal/cmd/resolve.go:
resolveWorkspace(svc, idOrName) — resolves by ID or name, handles ambiguity with interactive prompt. Returns (id, *state.State, error).workspaceDisplayName(id, st) — returns name if set, otherwise ID.Add flags to the command, not globally:
func newXxxCmd(svc *workspace.Service) *cobra.Command {
var myFlag bool
cmd := &cobra.Command{
// ...
}
cmd.Flags().BoolVarP(&myFlag, "flag-name", "f", false, "Description")
return cmd
}
internal/ui/ — never fmt.Print* directlyui.Success(), ui.Warning(), ui.Error(), ui.Info() for prefixed messagesui.Code() to style inline commandsui.RunWithSpinner()Flow workspace management — commands, state format, rendering, and PRs. Load this skill at the start of every session.
How to create pull requests for this project. Use when opening a PR on GitHub.
How to create Claude Code skills for this project. Use when adding new skills, creating SKILL.md files, or setting up skill directories.
Testing conventions and patterns for this project. Use when writing tests, creating mocks, or understanding the test infrastructure.
How to update documentation for this project. Covers updating the root README, creating and updating VHS tape recordings, running gendocs, and the make commands that tie it together.
How to write PRDs for this project. Use when creating a new product requirement document, planning a feature, or adding to docs/prd/.