cli-creator-skill 0.1.0__tar.gz → 0.1.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- cli_creator_skill-0.1.2/CHANGELOG.md +17 -0
- {cli_creator_skill-0.1.0 → cli_creator_skill-0.1.2}/PKG-INFO +7 -17
- {cli_creator_skill-0.1.0 → cli_creator_skill-0.1.2}/README.md +6 -16
- {cli_creator_skill-0.1.0 → cli_creator_skill-0.1.2}/pyproject.toml +1 -1
- cli_creator_skill-0.1.2/skills/cli-creator/SKILL.md +266 -0
- cli_creator_skill-0.1.2/skills/cli-creator/references/creation-playbook.md +214 -0
- cli_creator_skill-0.1.2/skills/cli-creator/references/pitfalls-and-solutions.md +360 -0
- cli_creator_skill-0.1.2/skills/cli-creator/references/review-rubric.md +227 -0
- cli_creator_skill-0.1.2/skills/cli-creator/references/technical-best-practices.md +247 -0
- {cli_creator_skill-0.1.0 → cli_creator_skill-0.1.2}/src/cli_creator_skill/__init__.py +1 -1
- cli_creator_skill-0.1.0/CHANGELOG.md +0 -7
- cli_creator_skill-0.1.0/skills/cli-creator/SKILL.md +0 -288
- cli_creator_skill-0.1.0/skills/cli-creator/references/creation-playbook.md +0 -267
- cli_creator_skill-0.1.0/skills/cli-creator/references/pitfalls-and-solutions.md +0 -319
- cli_creator_skill-0.1.0/skills/cli-creator/references/review-rubric.md +0 -217
- {cli_creator_skill-0.1.0 → cli_creator_skill-0.1.2}/.gitignore +0 -0
- {cli_creator_skill-0.1.0 → cli_creator_skill-0.1.2}/LICENSE +0 -0
- {cli_creator_skill-0.1.0 → cli_creator_skill-0.1.2}/NOTICE.md +0 -0
- {cli_creator_skill-0.1.0 → cli_creator_skill-0.1.2}/src/cli_creator_skill/__main__.py +0 -0
- {cli_creator_skill-0.1.0 → cli_creator_skill-0.1.2}/src/cli_creator_skill/installer.py +0 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.1.2
|
|
4
|
+
|
|
5
|
+
- Broaden the skill for command-first, configuration-driven, hybrid, and performance-oriented CLIs.
|
|
6
|
+
- Add technical best practices for Typer/Click, config precedence, Rich rendering, cache, errors, packaging, and LLM-enabled CLIs.
|
|
7
|
+
- Add audit guidance for machine-readable diagnostics, cache status metadata, and release-copy drift.
|
|
8
|
+
|
|
9
|
+
## 0.1.1
|
|
10
|
+
|
|
11
|
+
- Remove public release setup details from README.
|
|
12
|
+
|
|
13
|
+
## 0.1.0
|
|
14
|
+
|
|
15
|
+
- Initial release of the `cli-creator` skill.
|
|
16
|
+
- Add installable PyPI package with `cli-creator-skill install`.
|
|
17
|
+
- Add creation playbook, pitfalls reference, and review rubric.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cli-creator-skill
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.2
|
|
4
4
|
Summary: Installable cli-creator agent skill for designing and auditing Python CLI tools.
|
|
5
5
|
Project-URL: Homepage, https://github.com/AdvancingTitans/cli-creator-skill
|
|
6
6
|
Project-URL: Repository, https://github.com/AdvancingTitans/cli-creator-skill
|
|
@@ -56,25 +56,13 @@ Install to a custom directory:
|
|
|
56
56
|
cli-creator-skill install --target ~/.agents/skills
|
|
57
57
|
```
|
|
58
58
|
|
|
59
|
-
##
|
|
59
|
+
## Release
|
|
60
60
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
Configure a pending publisher on PyPI with these exact values:
|
|
64
|
-
|
|
65
|
-
```text
|
|
66
|
-
PyPI project name: cli-creator-skill
|
|
67
|
-
Owner: AdvancingTitans
|
|
68
|
-
Repository name: cli-creator-skill
|
|
69
|
-
Workflow name: publish.yml
|
|
70
|
-
Environment name: pypi
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
After the pending publisher is configured, publishing is:
|
|
61
|
+
Maintainers can publish a new version by updating `pyproject.toml`, committing the change, and pushing a version tag:
|
|
74
62
|
|
|
75
63
|
```bash
|
|
76
|
-
git tag v0.1.
|
|
77
|
-
git push origin v0.1.
|
|
64
|
+
git tag v0.1.2
|
|
65
|
+
git push origin v0.1.2
|
|
78
66
|
```
|
|
79
67
|
|
|
80
68
|
## What This Skill Helps With
|
|
@@ -85,6 +73,7 @@ git push origin v0.1.0
|
|
|
85
73
|
- Build natural multi-turn CLI flows without making users feel like they are filling out a form.
|
|
86
74
|
- Add robust model provider configuration for OpenAI, Anthropic, Ark/OpenAI-compatible endpoints, and local models.
|
|
87
75
|
- Add cache, profile memory, diagnostics, and first-run setup flows.
|
|
76
|
+
- Audit machine-readable diagnostics, cache status metadata, package-data drift, and release-copy synchronization.
|
|
88
77
|
|
|
89
78
|
## Repository Structure
|
|
90
79
|
|
|
@@ -96,6 +85,7 @@ cli-creator-skill/
|
|
|
96
85
|
creation-playbook.md
|
|
97
86
|
pitfalls-and-solutions.md
|
|
98
87
|
review-rubric.md
|
|
88
|
+
technical-best-practices.md
|
|
99
89
|
src/cli_creator_skill/
|
|
100
90
|
installer.py
|
|
101
91
|
__main__.py
|
|
@@ -31,25 +31,13 @@ Install to a custom directory:
|
|
|
31
31
|
cli-creator-skill install --target ~/.agents/skills
|
|
32
32
|
```
|
|
33
33
|
|
|
34
|
-
##
|
|
34
|
+
## Release
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
Configure a pending publisher on PyPI with these exact values:
|
|
39
|
-
|
|
40
|
-
```text
|
|
41
|
-
PyPI project name: cli-creator-skill
|
|
42
|
-
Owner: AdvancingTitans
|
|
43
|
-
Repository name: cli-creator-skill
|
|
44
|
-
Workflow name: publish.yml
|
|
45
|
-
Environment name: pypi
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
After the pending publisher is configured, publishing is:
|
|
36
|
+
Maintainers can publish a new version by updating `pyproject.toml`, committing the change, and pushing a version tag:
|
|
49
37
|
|
|
50
38
|
```bash
|
|
51
|
-
git tag v0.1.
|
|
52
|
-
git push origin v0.1.
|
|
39
|
+
git tag v0.1.2
|
|
40
|
+
git push origin v0.1.2
|
|
53
41
|
```
|
|
54
42
|
|
|
55
43
|
## What This Skill Helps With
|
|
@@ -60,6 +48,7 @@ git push origin v0.1.0
|
|
|
60
48
|
- Build natural multi-turn CLI flows without making users feel like they are filling out a form.
|
|
61
49
|
- Add robust model provider configuration for OpenAI, Anthropic, Ark/OpenAI-compatible endpoints, and local models.
|
|
62
50
|
- Add cache, profile memory, diagnostics, and first-run setup flows.
|
|
51
|
+
- Audit machine-readable diagnostics, cache status metadata, package-data drift, and release-copy synchronization.
|
|
63
52
|
|
|
64
53
|
## Repository Structure
|
|
65
54
|
|
|
@@ -71,6 +60,7 @@ cli-creator-skill/
|
|
|
71
60
|
creation-playbook.md
|
|
72
61
|
pitfalls-and-solutions.md
|
|
73
62
|
review-rubric.md
|
|
63
|
+
technical-best-practices.md
|
|
74
64
|
src/cli_creator_skill/
|
|
75
65
|
installer.py
|
|
76
66
|
__main__.py
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: cli-creator
|
|
3
|
+
description: Use when designing, scaffolding, refactoring, or auditing Python CLI tools, including command-first CLIs, configuration-driven tools, performance-oriented utilities, interactive assistants, data pipelines, and LLM-enabled command line products.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# CLI Creator
|
|
7
|
+
|
|
8
|
+
Use this skill to create or review production-grade Python CLI tools. Apply it to Typer, Click, argparse, or hybrid CLIs, with special attention to command design, configuration, terminal UX, packaging, performance, testability, and long-term maintenance.
|
|
9
|
+
|
|
10
|
+
## Step 1: Learn And Extract Principles
|
|
11
|
+
|
|
12
|
+
Before designing or reviewing a non-trivial CLI, ground your judgment in these patterns:
|
|
13
|
+
|
|
14
|
+
- Typer: prefer type-hint-driven command definitions, automatic help, shell completion, and gradual growth from one command to command trees.
|
|
15
|
+
- uv: treat speed, cache behavior, installability, and cross-platform distribution as product features, not backend details.
|
|
16
|
+
- Ruff: provide a cohesive command surface, fast defaults, file discovery rules, config-file support, and explicit CLI overrides.
|
|
17
|
+
- Rich: standardize terminal rendering through one console layer; use tables, panels, progress, Markdown, and rich tracebacks intentionally.
|
|
18
|
+
- HTTPie: optimize syntax and output for humans; make common actions short, natural, colorized, and inspectable.
|
|
19
|
+
- Your own CLI experience: never hide model/provider/config failures behind empty results; make cache, profile memory, refresh semantics, delivery channels, and diagnostics observable.
|
|
20
|
+
|
|
21
|
+
## Core Philosophy
|
|
22
|
+
|
|
23
|
+
Build CLIs as durable products, not one-off scripts.
|
|
24
|
+
|
|
25
|
+
1. Design from the user's job, not the implementation mode. A CLI should make the next action obvious.
|
|
26
|
+
2. Keep command semantics stable. Names, flags, exit codes, config keys, and output modes are product contracts.
|
|
27
|
+
3. Make defaults useful and safe. Zero-config should do something helpful, or fail with a concrete fix.
|
|
28
|
+
4. Separate routing, domain logic, IO, config, persistence, rendering, and integrations.
|
|
29
|
+
5. Optimize both humans and automation. Rich output is for people; JSON/plain output is for scripts.
|
|
30
|
+
6. Treat performance as UX. Startup, help, cache hits, file discovery, and progress feedback matter.
|
|
31
|
+
7. Make state explainable. Config, cache, credentials, profiles, history, and remote auth must be inspectable and resettable.
|
|
32
|
+
8. Verify installability early. The command in README must be the command installed from PyPI, uv, pipx, Homebrew, or standalone binaries.
|
|
33
|
+
|
|
34
|
+
## CLI Type Selection
|
|
35
|
+
|
|
36
|
+
Classify the CLI before choosing architecture.
|
|
37
|
+
|
|
38
|
+
| CLI type | Examples | Primary design concern | Architecture bias |
|
|
39
|
+
|---|---|---|---|
|
|
40
|
+
| Command-first utility | `ruff check`, `uv pip install`, data query tools | Fast, scriptable, predictable | Thin CLI, service layer, strict exit codes, JSON option |
|
|
41
|
+
| Configuration-driven tool | linters, formatters, deploy tools | Config precedence, discovery, reproducibility | Settings loader, config schema, project root detection |
|
|
42
|
+
| Interactive assistant | setup wizards, research assistants, LLM tools | Natural flow, state, recovery | Flow/state machine, prompts, profile/cache memory |
|
|
43
|
+
| Hybrid CLI | `run`, `setup`, `doctor`, `config`, `export` | Friendly first run plus automation | Commands wrap reusable orchestration services |
|
|
44
|
+
| Performance-heavy CLI | scanners, batch processors, package tools | Startup, concurrency, cache, progress | Lazy imports, compiled hot paths when needed, bounded IO |
|
|
45
|
+
| Plugin/extensible CLI | cloud tools, delivery-channel frameworks | Stable extension contracts | Adapter registry, entry points, versioned plugin API |
|
|
46
|
+
|
|
47
|
+
Do not force an interactive assistant architecture onto a command-first tool. Do not force a single-command script structure onto a growing product.
|
|
48
|
+
|
|
49
|
+
## New CLI Creation Workflow
|
|
50
|
+
|
|
51
|
+
### 1. Determine The Product Shape
|
|
52
|
+
|
|
53
|
+
Ask and answer:
|
|
54
|
+
|
|
55
|
+
- Who runs this CLI, and under what pressure?
|
|
56
|
+
- Is the main value a command result, a generated file, a changed remote state, or a guided decision?
|
|
57
|
+
- Does the user need zero-config use, project config, global config, or credentials?
|
|
58
|
+
- Will it be used in terminals only, or also cron, CI, automations, and pipes?
|
|
59
|
+
- What should be cached, remembered, logged, or deliberately forgotten?
|
|
60
|
+
|
|
61
|
+
### 2. Design The Command Surface
|
|
62
|
+
|
|
63
|
+
Prefer a small stable command tree:
|
|
64
|
+
|
|
65
|
+
```text
|
|
66
|
+
my-cli run # main workflow
|
|
67
|
+
my-cli init # create project config or scaffold
|
|
68
|
+
my-cli config show # inspect config safely
|
|
69
|
+
my-cli config set # update config
|
|
70
|
+
my-cli doctor # diagnose environment
|
|
71
|
+
my-cli cache clear # clear derived state
|
|
72
|
+
my-cli completion # shell completion, if not provided by framework
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
For command-first tools, prefer verbs that match user intent:
|
|
76
|
+
|
|
77
|
+
```text
|
|
78
|
+
my-cli check PATH
|
|
79
|
+
my-cli format PATH
|
|
80
|
+
my-cli fetch QUERY --json
|
|
81
|
+
my-cli export ID --output result.md
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Rules:
|
|
85
|
+
|
|
86
|
+
- Use arguments for required domain objects.
|
|
87
|
+
- Use options for modifiers, output modes, and optional behavior.
|
|
88
|
+
- Provide `--json` or `--format json` for automation.
|
|
89
|
+
- Provide `--quiet`, `--verbose`, and `--debug` consistently.
|
|
90
|
+
- Avoid surprising network or mutation in commands that sound read-only.
|
|
91
|
+
|
|
92
|
+
### 3. Choose The Stack
|
|
93
|
+
|
|
94
|
+
Use Typer when type hints, async-ish orchestration, and Rich integration matter. Use Click when you need mature low-level control, custom contexts, or an existing Click ecosystem. Use argparse only for minimal standard-library scripts or dependency-sensitive tools.
|
|
95
|
+
|
|
96
|
+
Default Python stack:
|
|
97
|
+
|
|
98
|
+
- Typer or Click for command routing.
|
|
99
|
+
- Rich for terminal rendering and tracebacks.
|
|
100
|
+
- Pydantic v2 for domain models and validation.
|
|
101
|
+
- pydantic-settings for env/config loading.
|
|
102
|
+
- tomllib/tomli-w or `tomlkit` for project config.
|
|
103
|
+
- platformdirs for config/cache/data directories.
|
|
104
|
+
- httpx for HTTP with timeouts and retries.
|
|
105
|
+
- SQLite, diskcache, or sqlite-utils for durable local cache.
|
|
106
|
+
- loguru or stdlib logging with a single configured logger.
|
|
107
|
+
- pytest plus CliRunner or subprocess smoke tests.
|
|
108
|
+
- ruff for lint/format; uv for build, sync, and release workflows when available.
|
|
109
|
+
|
|
110
|
+
Add questionary only when prompts are core to the product. Add litellm/instructor only when LLM calls are genuinely needed.
|
|
111
|
+
|
|
112
|
+
### 4. Pick An Architecture Level
|
|
113
|
+
|
|
114
|
+
Choose the smallest architecture that will survive the next two releases:
|
|
115
|
+
|
|
116
|
+
- Single file: one or two commands, no config, no network, no long-term state.
|
|
117
|
+
- Small package: 3-8 commands, config, HTTP, output renderers, tests.
|
|
118
|
+
- Modular package: multiple workflows, cache, integrations, domain models, plugins.
|
|
119
|
+
- Plugin platform: stable extension API, third-party integrations, versioned contracts.
|
|
120
|
+
|
|
121
|
+
Never keep HTTP calls, prompt text, SQL, Rich tables, and Typer callbacks in the same module once the tool has real users.
|
|
122
|
+
|
|
123
|
+
### 5. Implement The Product Loop
|
|
124
|
+
|
|
125
|
+
For any workflow, make these explicit:
|
|
126
|
+
|
|
127
|
+
- Input collection.
|
|
128
|
+
- Validation.
|
|
129
|
+
- Execution.
|
|
130
|
+
- Rendering.
|
|
131
|
+
- Persistence.
|
|
132
|
+
- Exit code.
|
|
133
|
+
- Recovery hint.
|
|
134
|
+
|
|
135
|
+
For interactive flows, use a state object. For command-first flows, use request/result models.
|
|
136
|
+
|
|
137
|
+
### 6. Verify Before Shipping
|
|
138
|
+
|
|
139
|
+
Always verify:
|
|
140
|
+
|
|
141
|
+
- `my-cli --help`
|
|
142
|
+
- each top-level command `--help`
|
|
143
|
+
- clean install into a new venv
|
|
144
|
+
- missing config first run
|
|
145
|
+
- invalid config
|
|
146
|
+
- success path
|
|
147
|
+
- JSON/scriptable mode
|
|
148
|
+
- cache refresh and cache clear
|
|
149
|
+
- packaging metadata and console script
|
|
150
|
+
|
|
151
|
+
## Review Workflow
|
|
152
|
+
|
|
153
|
+
When auditing an existing CLI:
|
|
154
|
+
|
|
155
|
+
1. Inspect repository shape: package layout, command entry points, config files, tests, docs, CI.
|
|
156
|
+
2. Run help: `my-cli --help` and command-level help.
|
|
157
|
+
3. Trace one successful command from CLI callback to domain service to renderer.
|
|
158
|
+
4. Trace one failure path and inspect error quality.
|
|
159
|
+
5. Check configuration precedence: flags, env, project config, user config, defaults.
|
|
160
|
+
6. Check performance: startup imports, network timeouts, cache behavior, file discovery.
|
|
161
|
+
7. Check automation: exit codes, JSON output, non-TTY behavior.
|
|
162
|
+
8. Check packaging: Python version, dependencies, scripts, wheels, README commands.
|
|
163
|
+
9. Score with `references/review-rubric.md`.
|
|
164
|
+
10. Return findings first, then prioritized fixes.
|
|
165
|
+
|
|
166
|
+
## Common Pitfalls
|
|
167
|
+
|
|
168
|
+
Read `references/pitfalls-and-solutions.md` when implementing or auditing. Watch especially for:
|
|
169
|
+
|
|
170
|
+
- Command names that expose internals instead of user intent.
|
|
171
|
+
- Prompt-only workflows with no flags or non-TTY fallback.
|
|
172
|
+
- Config fields hidden behind a single "API key" setup.
|
|
173
|
+
- Undefined precedence between flags, env, local config, and global config.
|
|
174
|
+
- Slow `--help` caused by heavy imports or network probes.
|
|
175
|
+
- Pretty Rich output with no JSON mode.
|
|
176
|
+
- Cache failures stored as valid empty results.
|
|
177
|
+
- README install commands that do not match `[project.scripts]`.
|
|
178
|
+
- No `doctor` command for environment, auth, model, cache, and path issues.
|
|
179
|
+
|
|
180
|
+
## Recommended Structure
|
|
181
|
+
|
|
182
|
+
Use this as the default for a modern medium-sized CLI:
|
|
183
|
+
|
|
184
|
+
```text
|
|
185
|
+
my-cli/
|
|
186
|
+
pyproject.toml
|
|
187
|
+
README.md
|
|
188
|
+
CHANGELOG.md
|
|
189
|
+
.env.example
|
|
190
|
+
src/my_cli/
|
|
191
|
+
__init__.py
|
|
192
|
+
__main__.py
|
|
193
|
+
cli.py
|
|
194
|
+
console.py
|
|
195
|
+
errors.py
|
|
196
|
+
models.py
|
|
197
|
+
settings.py
|
|
198
|
+
config.py
|
|
199
|
+
paths.py
|
|
200
|
+
logging.py
|
|
201
|
+
app/
|
|
202
|
+
__init__.py
|
|
203
|
+
commands.py
|
|
204
|
+
workflows.py
|
|
205
|
+
services/
|
|
206
|
+
__init__.py
|
|
207
|
+
http.py
|
|
208
|
+
cache.py
|
|
209
|
+
domain.py
|
|
210
|
+
renderers/
|
|
211
|
+
__init__.py
|
|
212
|
+
terminal.py
|
|
213
|
+
json.py
|
|
214
|
+
markdown.py
|
|
215
|
+
integrations/
|
|
216
|
+
__init__.py
|
|
217
|
+
base.py
|
|
218
|
+
plugins/
|
|
219
|
+
__init__.py
|
|
220
|
+
registry.py
|
|
221
|
+
tests/
|
|
222
|
+
test_cli_help.py
|
|
223
|
+
test_config.py
|
|
224
|
+
test_errors.py
|
|
225
|
+
test_smoke.py
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
Read `references/creation-playbook.md` for scale-specific templates and implementation phases.
|
|
229
|
+
|
|
230
|
+
## Technical Best Practices
|
|
231
|
+
|
|
232
|
+
Read `references/technical-best-practices.md` when implementing:
|
|
233
|
+
|
|
234
|
+
- Typer callbacks, command groups, context objects, parameter validation, and completions.
|
|
235
|
+
- Config precedence with TOML, env vars, flags, and secrets.
|
|
236
|
+
- Rich rendering rules for tables, progress, panels, Markdown, and tracebacks.
|
|
237
|
+
- Cache, logs, error classes, exit codes, and JSON output.
|
|
238
|
+
- Packaging with `pyproject.toml`, uv, wheels, and CI.
|
|
239
|
+
|
|
240
|
+
## Output Expectations
|
|
241
|
+
|
|
242
|
+
For a new CLI, deliver:
|
|
243
|
+
|
|
244
|
+
- Product type decision.
|
|
245
|
+
- Command tree.
|
|
246
|
+
- Project structure.
|
|
247
|
+
- Core models and config schema.
|
|
248
|
+
- Main command implementation.
|
|
249
|
+
- Tests and smoke checks.
|
|
250
|
+
- README with real commands.
|
|
251
|
+
|
|
252
|
+
For a review, deliver:
|
|
253
|
+
|
|
254
|
+
- Findings ordered by severity.
|
|
255
|
+
- File/line references.
|
|
256
|
+
- Reproduction steps.
|
|
257
|
+
- Concrete fixes.
|
|
258
|
+
- Test gaps.
|
|
259
|
+
- Suggested migration sequence.
|
|
260
|
+
|
|
261
|
+
## References
|
|
262
|
+
|
|
263
|
+
- `references/pitfalls-and-solutions.md`
|
|
264
|
+
- `references/creation-playbook.md`
|
|
265
|
+
- `references/review-rubric.md`
|
|
266
|
+
- `references/technical-best-practices.md`
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
# CLI Creation Playbook
|
|
2
|
+
|
|
3
|
+
Use this playbook to build a modern Python CLI from zero.
|
|
4
|
+
|
|
5
|
+
## Phase 0: Requirements And Type Selection
|
|
6
|
+
|
|
7
|
+
Classify the CLI:
|
|
8
|
+
|
|
9
|
+
- Command-first: fast commands, stable flags, JSON output.
|
|
10
|
+
- Configuration-driven: config discovery, precedence, reproducibility.
|
|
11
|
+
- Interactive/hybrid: first-run wizard, prompts, state machine.
|
|
12
|
+
- Data/LLM: evidence, cache, provider verification, structured output.
|
|
13
|
+
- Performance-heavy: startup, concurrency, streaming, cache.
|
|
14
|
+
- Plugin-based: extension API and adapter contracts.
|
|
15
|
+
|
|
16
|
+
Write:
|
|
17
|
+
|
|
18
|
+
- one-sentence product promise
|
|
19
|
+
- main command examples
|
|
20
|
+
- non-goals for v1
|
|
21
|
+
- expected output forms
|
|
22
|
+
- failure/recovery model
|
|
23
|
+
|
|
24
|
+
## Phase 1: Command Design
|
|
25
|
+
|
|
26
|
+
Design examples before code.
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
my-cli --help
|
|
30
|
+
my-cli init
|
|
31
|
+
my-cli check .
|
|
32
|
+
my-cli fetch "query" --json
|
|
33
|
+
my-cli export result --output report.md
|
|
34
|
+
my-cli config show
|
|
35
|
+
my-cli doctor
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Rules:
|
|
39
|
+
|
|
40
|
+
- Required domain objects are arguments.
|
|
41
|
+
- Behavior modifiers are options.
|
|
42
|
+
- Mutating commands use clear verbs.
|
|
43
|
+
- Machine-readable output is explicit.
|
|
44
|
+
- Global options are consistent: `--config`, `--verbose`, `--quiet`, `--debug`, `--no-color`.
|
|
45
|
+
|
|
46
|
+
## Phase 2: Project Initialization
|
|
47
|
+
|
|
48
|
+
Recommended package layout:
|
|
49
|
+
|
|
50
|
+
```text
|
|
51
|
+
my-cli/
|
|
52
|
+
pyproject.toml
|
|
53
|
+
README.md
|
|
54
|
+
CHANGELOG.md
|
|
55
|
+
.env.example
|
|
56
|
+
src/my_cli/
|
|
57
|
+
__init__.py
|
|
58
|
+
__main__.py
|
|
59
|
+
cli.py
|
|
60
|
+
console.py
|
|
61
|
+
errors.py
|
|
62
|
+
settings.py
|
|
63
|
+
config.py
|
|
64
|
+
models.py
|
|
65
|
+
app/
|
|
66
|
+
services/
|
|
67
|
+
renderers/
|
|
68
|
+
tests/
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Recommended `pyproject.toml`:
|
|
72
|
+
|
|
73
|
+
```toml
|
|
74
|
+
[project]
|
|
75
|
+
name = "my-cli"
|
|
76
|
+
version = "0.1.0"
|
|
77
|
+
requires-python = ">=3.10"
|
|
78
|
+
readme = "README.md"
|
|
79
|
+
dependencies = [
|
|
80
|
+
"typer>=0.12",
|
|
81
|
+
"rich>=13",
|
|
82
|
+
"pydantic>=2",
|
|
83
|
+
"pydantic-settings>=2",
|
|
84
|
+
"platformdirs>=4",
|
|
85
|
+
"httpx>=0.27",
|
|
86
|
+
]
|
|
87
|
+
|
|
88
|
+
[project.scripts]
|
|
89
|
+
my-cli = "my_cli.cli:main"
|
|
90
|
+
|
|
91
|
+
[dependency-groups]
|
|
92
|
+
dev = ["pytest>=8", "ruff>=0.8"]
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Use `uv` for environment, build, and release workflows when available.
|
|
96
|
+
|
|
97
|
+
## Phase 3: Core Models And Boundaries
|
|
98
|
+
|
|
99
|
+
Define models early:
|
|
100
|
+
|
|
101
|
+
- `AppContext`: console, settings, logger, paths.
|
|
102
|
+
- `Settings`: validated config.
|
|
103
|
+
- `CommandRequest`: parsed input for a command.
|
|
104
|
+
- `CommandResult`: structured output and exit status.
|
|
105
|
+
- `CacheEntry`: key, status, payload, created_at, expires_at.
|
|
106
|
+
- `EvidenceItem`: source-backed data for data/LLM CLIs.
|
|
107
|
+
- `ProviderConfig`: provider/base URL/model/credential reference.
|
|
108
|
+
|
|
109
|
+
Boundaries:
|
|
110
|
+
|
|
111
|
+
- `cli.py`: Typer/Click only.
|
|
112
|
+
- `app/`: orchestration.
|
|
113
|
+
- `services/`: IO and domain operations.
|
|
114
|
+
- `renderers/`: terminal/JSON/Markdown.
|
|
115
|
+
- `config.py`: config discovery and precedence.
|
|
116
|
+
- `errors.py`: domain exceptions and exit mapping.
|
|
117
|
+
|
|
118
|
+
## Phase 4: Configuration
|
|
119
|
+
|
|
120
|
+
Implement precedence:
|
|
121
|
+
|
|
122
|
+
1. flags
|
|
123
|
+
2. env vars
|
|
124
|
+
3. project config
|
|
125
|
+
4. user config
|
|
126
|
+
5. defaults
|
|
127
|
+
|
|
128
|
+
Provide commands:
|
|
129
|
+
|
|
130
|
+
```text
|
|
131
|
+
my-cli config show
|
|
132
|
+
my-cli config path
|
|
133
|
+
my-cli config set KEY VALUE
|
|
134
|
+
my-cli config reset
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
For credentials:
|
|
138
|
+
|
|
139
|
+
- mask values in output
|
|
140
|
+
- prefer keychain or env refs for secrets
|
|
141
|
+
- never commit real `.env`
|
|
142
|
+
|
|
143
|
+
## Phase 5: Rendering And Output
|
|
144
|
+
|
|
145
|
+
Create a single console factory.
|
|
146
|
+
|
|
147
|
+
Human modes:
|
|
148
|
+
|
|
149
|
+
- tables for rows
|
|
150
|
+
- panels for summaries
|
|
151
|
+
- progress for long-running work
|
|
152
|
+
- Markdown for long generated text
|
|
153
|
+
|
|
154
|
+
Machine modes:
|
|
155
|
+
|
|
156
|
+
- JSON without Rich markup
|
|
157
|
+
- stable schema
|
|
158
|
+
- documented exit codes
|
|
159
|
+
|
|
160
|
+
## Phase 6: Cache, Logs, And Diagnostics
|
|
161
|
+
|
|
162
|
+
Add cache only with clear semantics:
|
|
163
|
+
|
|
164
|
+
- cache key includes query/input/config/schema/source
|
|
165
|
+
- cache status distinguishes failures from valid empty results
|
|
166
|
+
- `--refresh` bypasses or varies cache
|
|
167
|
+
- `cache clear` exists
|
|
168
|
+
|
|
169
|
+
Add `doctor` when the CLI has config, network, credentials, optional tools, model providers, or generated entry points.
|
|
170
|
+
|
|
171
|
+
## Phase 7: Interactive Or LLM Workflows
|
|
172
|
+
|
|
173
|
+
For interactive flows:
|
|
174
|
+
|
|
175
|
+
- one question at a time
|
|
176
|
+
- state object
|
|
177
|
+
- non-TTY fallback
|
|
178
|
+
- remembered profile with `profile show` and `profile clear`
|
|
179
|
+
|
|
180
|
+
For LLM flows:
|
|
181
|
+
|
|
182
|
+
- verify provider before workflow
|
|
183
|
+
- validate structured output
|
|
184
|
+
- separate facts from model inference
|
|
185
|
+
- retain evidence and prompt/model metadata
|
|
186
|
+
|
|
187
|
+
## Phase 8: Tests
|
|
188
|
+
|
|
189
|
+
Minimum tests:
|
|
190
|
+
|
|
191
|
+
- package import
|
|
192
|
+
- `--help`
|
|
193
|
+
- top-level command help
|
|
194
|
+
- config precedence
|
|
195
|
+
- errors and exit codes
|
|
196
|
+
- JSON validity
|
|
197
|
+
- cache hit/miss/refresh
|
|
198
|
+
- clean install smoke test
|
|
199
|
+
|
|
200
|
+
Use subprocess tests for installed command confidence.
|
|
201
|
+
|
|
202
|
+
## Phase 9: Release
|
|
203
|
+
|
|
204
|
+
Checklist:
|
|
205
|
+
|
|
206
|
+
- `README.md` has real install and usage commands
|
|
207
|
+
- `CHANGELOG.md` updated
|
|
208
|
+
- `pyproject.toml` metadata complete
|
|
209
|
+
- wheel/sdist build succeeds
|
|
210
|
+
- clean venv install succeeds
|
|
211
|
+
- no secrets in repo
|
|
212
|
+
- CI runs lint and tests
|
|
213
|
+
|
|
214
|
+
Use tag-driven releases when publishing to PyPI. Keep sensitive release setup out of public docs.
|