You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add CONTEXT FOR AGENTS sections to all CLI help screens
Adds after_help blocks to every command and subcommand in the CLI,
giving LLM agents workflow context, argument syntax, and navigation
hints when they invoke --help.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: src/cli.rs
+166Lines changed: 166 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,21 @@ use clap::{Args, Parser, Subcommand};
4
4
#[command(name = "chv")]
5
5
#[command(about = "ClickHouse version manager", long_about = None)]
6
6
#[command(version)]
7
+
#[command(after_help = "\
8
+
CONTEXT FOR AGENTS:
9
+
chv is a CLI to work with local ClickHouse and ClickHouse Cloud.
10
+
11
+
Two main workflows:
12
+
1. Local: Install and interact with versions of ClickHouse to develop locally.
13
+
2. Cloud: Manage ClickHouse Cloud infrastructure and push local work to cloud.
14
+
15
+
You can install the ClickHouse Agent Skills for best practices on using ClikHouse:
16
+
17
+
`npx skills add clickhouse/agent-skills`
18
+
19
+
Typical local workflow: `chv install stable && chv use stable && chv run server`.
20
+
21
+
Use `chv <command> --help` to get more context for specific commands.")]
7
22
pubstructCli{
8
23
#[command(subcommand)]
9
24
pubcommand:Commands,
@@ -12,40 +27,91 @@ pub struct Cli {
12
27
#[derive(Subcommand)]
13
28
pubenumCommands{
14
29
/// Install a ClickHouse version
30
+
#[command(after_help = "\
31
+
CONTEXT FOR AGENTS:
32
+
Downloads a ClickHouse binary to ~/.clickhouse/versions/{version}/.
33
+
Accepts version specs: \"stable\", \"lts\", partial like \"25.12\", or exact like \"25.12.5.44\".
34
+
Optionally set as default with `chv use <version>`.
35
+
`chv use <version>` will auto-install if the version is missing and set as default.
36
+
Related: `chv list --available` to see downloadable versions.")]
15
37
Install{
16
38
/// Version to install (e.g., 25.1.2.3, 25.1, stable, lts)
17
39
version:String,
18
40
},
19
41
20
42
/// List installed versions
43
+
#[command(after_help = "\
44
+
CONTEXT FOR AGENTS:
45
+
Without flags: shows locally installed versions (exact version strings).
46
+
With --available: shows versions available for download from GitHub releases.
47
+
Use the exact version strings from this output with `chv remove` or `chv use`.
48
+
Related: `chv install <version>` to install, `chv which` to see current default.")]
21
49
List{
22
50
/// List versions available for download
23
51
#[arg(long)]
24
52
available:bool,
25
53
},
26
54
27
55
/// Set the default version
56
+
#[command(after_help = "\
57
+
CONTEXT FOR AGENTS:
58
+
Sets the default ClickHouse version used by `chv run` commands.
59
+
Accepts version specs: \"stable\", \"lts\", partial like \"25.12\", or exact like \"25.12.5.44\".
60
+
Auto-installs the version if not already present.
61
+
Related: `chv which` to verify, `chv run server` to start.")]
28
62
Use{
29
63
/// Version to use as default
30
64
version:String,
31
65
},
32
66
33
67
/// Remove an installed version
68
+
#[command(after_help = "\
69
+
CONTEXT FOR AGENTS:
70
+
Removes an installed ClickHouse version from ~/.clickhouse/versions/.
71
+
Takes an exact version string as shown by `chv list` (e.g., \"25.12.5.44\").
72
+
Does NOT accept keywords like \"stable\" — use the exact version number.
73
+
Related: `chv list` to see installed versions.")]
34
74
Remove{
35
75
/// Version to remove
36
76
version:String,
37
77
},
38
78
39
79
/// Show the current default version
80
+
#[command(after_help = "\
81
+
CONTEXT FOR AGENTS:
82
+
Shows the current default version and binary path. No arguments needed.
83
+
Use this to verify which version is active before running commands.
84
+
Related: `chv use <version>` to change the default.")]
40
85
Which,
41
86
42
87
/// Initialize a project-local ClickHouse configuration
88
+
#[command(after_help = "\
89
+
CONTEXT FOR AGENTS:
90
+
Creates a .clickhouse/ directory in the current working directory.
91
+
Auto-called by `chv run server`, so rarely needed manually.
92
+
Project data is scoped by version in .clickhouse/{version}/.
93
+
Related: `chv run server` to start a server with project-local data.")]
43
94
Init,
44
95
45
96
/// Run ClickHouse commands
97
+
#[command(after_help = "\
98
+
CONTEXT FOR AGENTS:
99
+
Used for interacting with ClickHouse (local and Cloud).
100
+
Gateway to server/client/local subcommands. Requires a default version set via `chv use`.
101
+
Shortcut: `chv run --sql 'SELECT 1'` runs a query via clickhouse-local without subcommands to test things that don't need persistence.
102
+
Pass extra ClickHouse args after -- (e.g., `chv run server -- --http_port=9000`).
103
+
Related: `chv use <version>` to set default, `chv which` to check current version.")]
46
104
Run(RunArgs),
47
105
48
106
/// ClickHouse Cloud API commands
107
+
#[command(after_help = "\
108
+
CONTEXT FOR AGENTS:
109
+
Used for managing ClickHouse Cloud infrastructure.
110
+
Gateway to org/service/backup subcommands for ClickHouse Cloud.
111
+
Requires credentials via env vars CLICKHOUSE_CLOUD_API_KEY + CLICKHOUSE_CLOUD_API_SECRET, or via --api-key and --api-secret flags. Verify auth with `chv cloud org list`.
112
+
Add --json to any cloud command for machine-readable output.
113
+
Typical workflow: `cloud org list` → get org ID → `cloud service list` → manage services.
114
+
Related: `chv cloud org list` to start.")]
49
115
Cloud(CloudArgs),
50
116
}
51
117
@@ -62,20 +128,40 @@ pub struct RunArgs {
62
128
#[derive(Subcommand)]
63
129
pubenumRunCommands{
64
130
/// Run clickhouse-server
131
+
#[command(after_help = "\
132
+
CONTEXT FOR AGENTS:
133
+
Starts clickhouse-server with project-local data in .clickhouse/{version}/.
134
+
Auto-initializes the data directory on first run. Replaces the current process (exec).
135
+
Pass extra clickhouse-server args after -- (e.g., `chv run server -- --http_port=9000`).
136
+
Data persists in .clickhouse/{version}/ between runs.
137
+
Related: `chv run client` to connect, `chv use <version>` to change version.")]
0 commit comments