CLI Command Creator
When to Use This Skill
Invoke this skill when the user:
- Asks to "create a command", "add a command", or "implement a command" for the CLI
- Mentions adding new CLI functionality (e.g., "create me a command that publishes collections")
- Uses the slash command /cli-command-create
Create a new CLI command for the Prolific CLI from start to finish.
Arguments
Arguments may be provided via $ARGUMENTS or gathered interactively.
Expected arguments:
ticket- Jira ticket number (e.g., DCP-2154)resource- Resource name (e.g., collection, study, workspace)command- Command name (e.g., list, get, create, update)command-type- Optional: LIST | VIEW | CREATE | UPDATE | ACTION (will infer if not provided)
If arguments are missing or $ARGUMENTS is empty, use the AskUserQuestion tool to gather them:
- First ask for the Jira ticket number (e.g., "DCP-2154")
- Then ask for the resource name (e.g., "collection", "study", "workspace")
- Then ask for the command name (e.g., "list", "get", "create", "publish")
- Finally ask for the command type with options: LIST, VIEW, CREATE, UPDATE, ACTION (or let Claude infer from the command name)
Phase 1: Gather Requirements
1.1 Understand the API Contract
Ask the user to provide ONE of:
- Bruno file path - e.g.,
path/to/request.bru - Inline API contract - endpoint, request/response examples, error codes
Also ask if they have any acceptance criteria (optional):
- Feature requirements or user stories
- Expected behavior descriptions
- Edge cases to handle
1.2 Determine Command Type
If not provided, infer from command name:
list→ LIST (paginated results, multiple renderers)get,view→ VIEW (single resource, one renderer)create→ CREATE (accepts template file)update→ UPDATE (modifies existing resource)- Other → ACTION (state transitions, operations)
1.3 Identify Required Flags
Based on command type, confirm which flags are needed:
| Flag | LIST | VIEW | CREATE | UPDATE | ACTION |
|---|---|---|---|---|---|
--workspace / -w |
Often | Often | Often | Often | Rare |
--non-interactive / -n |
Yes | No | No | No | No |
--csv / -c |
Yes | No | No | No | No |
--json |
Optional | Optional | No | No | No |
--limit / --offset |
Yes | No | No | No | No |
--web / -W |
No | Yes | No | No | No |
--template / -t |
No | No | Yes | Yes | No |
Ask user to confirm or add custom flags.
1.4 Present Plan Summary
Before proceeding, present:
- Files to create/modify
- Implementation approach
- Test strategy
Ask for explicit approval before Phase 2.
Phase 2: Implement
2.1 Model Layer
Create/update model/{resource}.go:
- Struct with JSON tags matching API response
- For LIST commands: implement
FilterValue(),Title(),Description()for bubbletea
2.2 Client Layer
- Add response type to
client/responses.go - Add method signature to
APIinterface inclient/client.go - Implement method on
Clientstruct
2.3 Command Layer
- Create parent command
cmd/{resource}/{resource}.go(if new resource) - Create
cmd/{resource}/{command}.go:- Options struct
New{Command}Command(client client.API, w io.Writer) *cobra.Command- Flag definitions
- RunE implementation with dependency injection
2.4 UI Layer
LIST commands:
- Create
ui/{resource}/list.gowith:ListStrategyinterfaceInteractiveRenderer(bubbletea)NonInteractiveRenderer(table)CsvRenderer- Optional:
JSONRenderer
VIEW commands:
- Create
ui/{resource}/view.gowith singleRender{Resource}()function
2.5 Wire Up
Add command to cmd/root.go:
rootCmd.AddCommand({resource}.New{Resource}Command(c, os.Stdout))
2.6 Generate Mocks
Run: make test-gen-mock
2.7 Tests
Create cmd/{resource}/{command}_test.go:
- Use
gomockwithmock_client.NewMockAPI(ctrl) - Test success cases
- Test error handling
- Remember:
defer ctrl.Finish()andwriter.Flush()
For LIST commands only: Create ui/{resource}/list_test.go
Phase 3: Verify
- Run
make build- ensure it compiles - Run
make test- ensure all tests pass - Run
make lint- ensure no lint errors - Manual smoke test (if user has
PROLIFIC_TOKENset)
Report results and any issues found.
Reference Patterns
| Pattern | Reference File |
|---|---|
| LIST command | cmd/collection/list.go |
| LIST renderers | ui/collection/list.go |
| VIEW command | cmd/project/view.go |
| CREATE command | cmd/project/create.go |
| UPDATE command | cmd/credentials/update.go |
| ACTION command | cmd/study/transition.go |
| Parent command | cmd/collection/collection.go |
| Model | model/collection.go |
| Client method | client/client.go:GetCollections |
| Test pattern | cmd/workspace/list_test.go |
$ARGUMENTS
Converted and distributed by TomeVault — claim your Tome and manage your conversions.