|
1 | | -= How to use the chunk CLI |
| 1 | += How to use the Chunk CLI |
2 | 2 | :page-platform: Cloud |
3 | | -:page-description: How to use the chunk CLI to generate AI review prompts, run validations, manage Chunk sidecars, and install AI agent skills. |
| 3 | +:page-description: How to use the `chunk` CLI to generate AI review prompts, run validations, manage Chunk sidecars, and install AI agent skills. |
4 | 4 | :experimental: |
5 | 5 |
|
6 | 6 | This page describes how to use the main features of the `chunk` CLI. |
@@ -62,7 +62,7 @@ You can customize this behavior with the following flags: |
62 | 62 | -- |
63 | 63 |
|
64 | 64 | [#run-validation] |
65 | | -== Validate your changes |
| 65 | +== Validate your changes locally |
66 | 66 |
|
67 | 67 | The `chunk validate` command runs the commands configured in your project's `.chunk/config.json`. Use it to verify your changes pass all quality checks before pushing. |
68 | 68 |
|
@@ -105,20 +105,85 @@ The following flags are available: |
105 | 105 | -- |
106 | 106 |
|
107 | 107 | [#run-validation-in-a-sidecar] |
108 | | -=== Validate in a Chunk sidecar |
| 108 | +[badge="Preview"] |
| 109 | +== Validate in a Chunk sidecar |
109 | 110 |
|
110 | 111 | CAUTION: Chunk sidecars are available in preview if you are on a paid plan. The product is in its early stages and you may encounter bugs, unexpected behavior, or incomplete features. If you have feedback, you can share it on our link:https://discord.com/invite/circleci[Discord]. When the feature is made generally available, there will be a cost associated with access and usage. |
111 | 112 |
|
112 | | -To validate in a CircleCI Cloud environment instead of locally, pass a Chunk sidecar ID: |
| 113 | +Chunk sidecars let you validate your changes in a CircleCI Cloud environment instead of locally. This ensures your code runs against the same environment your CI pipeline uses. |
| 114 | + |
| 115 | +Follow these steps to validate in a Chunk sidecar: |
| 116 | + |
| 117 | +=== 1. Authenticate with CircleCI |
| 118 | + |
| 119 | +Before creating a Chunk sidecar, authenticate with CircleCI: |
| 120 | + |
| 121 | +[source,console] |
| 122 | +---- |
| 123 | +$ chunk auth set circleci |
| 124 | +---- |
| 125 | + |
| 126 | +Enter your CircleCI personal API token when prompted. Generate a token from your link:https://app.circleci.com/settings/user/tokens[User Settings, window=_blank] in the CircleCI web app. |
| 127 | + |
| 128 | +=== 2. Create a Chunk sidecar |
| 129 | + |
| 130 | +Create a new Chunk sidecar environment: |
| 131 | + |
| 132 | +[source,console] |
| 133 | +---- |
| 134 | +$ chunk sidecar create --name <name> |
| 135 | +---- |
| 136 | + |
| 137 | +Replace `<name>` with a descriptive name for your sidecar. The command auto-detects your tech stack, generates a Dockerfile, and provisions a cloud environment. When ready, it prints the Chunk sidecar ID. Copy this ID for use in the validation step. |
| 138 | + |
| 139 | +=== 3. Sync your local files to the sidecar |
| 140 | + |
| 141 | +Sync your local project files to the Chunk sidecar: |
| 142 | + |
| 143 | +[source,console] |
| 144 | +---- |
| 145 | +$ chunk sidecar sync |
| 146 | +---- |
| 147 | + |
| 148 | +This copies your current working directory to the remote environment. |
| 149 | + |
| 150 | +=== 4. Run validation in the sidecar |
| 151 | + |
| 152 | +Run your validation commands in the Chunk sidecar: |
113 | 153 |
|
114 | 154 | [source,console] |
115 | 155 | ---- |
116 | 156 | $ chunk validate --sidecar-id <sidecar-id> |
117 | 157 | ---- |
118 | 158 |
|
119 | | -To get a Chunk sidecar ID, run `chunk sidecar create` and copy the ID printed when the environment is ready, or run `chunk sidecar list` to retrieve the ID of an existing Chunk sidecar. See the <<manage-sidecars>> section for details. |
| 159 | +Replace `<sidecar-id>` with the ID from step 2. The command executes all configured validation commands from your `.chunk/config.json` in the remote environment. |
| 160 | + |
| 161 | +=== 5. (Optional) SSH into the sidecar for debugging |
| 162 | + |
| 163 | +If validation fails and you need to investigate, SSH into the Chunk sidecar: |
| 164 | + |
| 165 | +[source,console] |
| 166 | +---- |
| 167 | +$ chunk sidecar ssh |
| 168 | +---- |
| 169 | + |
| 170 | +This opens an interactive shell in the remote environment. |
| 171 | + |
| 172 | +=== 6. (Optional) Snapshot the sidecar for reuse |
| 173 | + |
| 174 | +After configuring a Chunk sidecar successfully, capture its state as a snapshot for faster future sessions: |
| 175 | + |
| 176 | +[source,console] |
| 177 | +---- |
| 178 | +$ chunk sidecar snapshot create --name <snapshot-name> |
| 179 | +---- |
| 180 | + |
| 181 | +The command prints a snapshot ID. Use this ID to create new sidecars with `chunk sidecar create --name <name> --image <snapshot-id>`. |
| 182 | + |
| 183 | +For more details on managing Chunk sidecars, see the <<manage-sidecars>> section. |
120 | 184 |
|
121 | 185 | [#manage-sidecars] |
| 186 | +[badge="Preview"] |
122 | 187 | == Manage Chunk sidecars |
123 | 188 |
|
124 | 189 | CAUTION: Chunk sidecars are available in preview if you are on a paid plan. The product is in its early stages and you may encounter bugs, unexpected behavior, or incomplete features. If you have feedback, you can share it on our link:https://discord.com/invite/circleci[Discord]. When the feature is made generally available, there will be a cost associated with access and usage. |
@@ -194,6 +259,67 @@ $ chunk sidecar sync |
194 | 259 | $ chunk sidecar exec <command> |
195 | 260 | ---- |
196 | 261 |
|
| 262 | +[#trigger-chunk-tasks] |
| 263 | +== Trigger Chunk tasks |
| 264 | + |
| 265 | +The `chunk task` command triggers a xref:guides:toolkit:chunk-setup-and-overview.adoc[Chunk Task] in CircleCI Cloud from your terminal, instead of opening the Chunk task drawer in the CircleCI web app. |
| 266 | + |
| 267 | +[#configure-task-runs] |
| 268 | +=== Configure task runs |
| 269 | + |
| 270 | +Before you can trigger a task run, set up `.chunk/run.json` for the repository. This file records the CircleCI project to run the task against. |
| 271 | + |
| 272 | +From your project directory: |
| 273 | + |
| 274 | +[source,console] |
| 275 | +---- |
| 276 | +$ chunk task config |
| 277 | +---- |
| 278 | + |
| 279 | +The command fetches your CircleCI projects and prompts you to select the project to use. It then saves the selection to `.chunk/run.json`. Pass `--force` (or `-f`) to overwrite an existing configuration without confirmation. |
| 280 | + |
| 281 | +[#trigger-a-task-run] |
| 282 | +=== Trigger a task run |
| 283 | + |
| 284 | +After you have configured the repository, trigger a task run with `chunk task run`: |
| 285 | + |
| 286 | +[source,console] |
| 287 | +---- |
| 288 | +$ chunk task run --definition <name-or-uuid> --prompt "<prompt text>" |
| 289 | +---- |
| 290 | + |
| 291 | +Replace `<name-or-uuid>` with the name or UUID of the Chunk task definition you want to run, and `<prompt text>` with the instructions to send to the task. Both flags are required. |
| 292 | + |
| 293 | +The command prints the run ID and pipeline ID when the task is triggered. |
| 294 | + |
| 295 | +The following flags are available: |
| 296 | + |
| 297 | +[.table-scroll] |
| 298 | +-- |
| 299 | +[cols=2*, options="header"] |
| 300 | +|=== |
| 301 | +|Flag |Description |
| 302 | + |
| 303 | +|`--definition <name-or-uuid>` |
| 304 | +|Required. Name or UUID of the Chunk task definition to run. |
| 305 | + |
| 306 | +|`--prompt <text>` |
| 307 | +|Required. Prompt text to send to the task. |
| 308 | + |
| 309 | +|`--branch <branch>` |
| 310 | +|Override the branch the task checks out. |
| 311 | + |
| 312 | +|`--new-branch` |
| 313 | +|Create a new branch for the task run. |
| 314 | + |
| 315 | +|`--no-pipeline-as-tool` |
| 316 | +|Disable running the pipeline as a tool. |
| 317 | + |
| 318 | +|`--json` |
| 319 | +|Print the response as JSON. |
| 320 | +|=== |
| 321 | +-- |
| 322 | + |
197 | 323 | [#install-skills] |
198 | 324 | == Install AI agent skills |
199 | 325 |
|
@@ -287,3 +413,4 @@ Supported keys: |
287 | 413 | == Next steps |
288 | 414 |
|
289 | 415 | * xref:guides:toolkit:chunk-setup-and-overview.adoc[Set up Chunk in the CircleCI Web App] |
| 416 | +* link:https://github.com/CircleCI-Public/chunk-cli/blob/main/docs/CLI.md[View the full command list in the Chunk CLI repository, window=_blank] |
0 commit comments