Skip to content

Commit fdea783

Browse files
michael-websterwebsterclaude
authored
Remove auto-snapshot from sidecar setup (#297)
* Remove auto-snapshot from sidecar setup, instruct agents to snapshot explicitly Setup now prints a prompt to run chunk sidecar snapshot create after verifying the sidecar works. The sidecar skill is updated to make snapshotting a required explicit step after validation is confirmed, using --remote --sidecar-id <id> for verification. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Remove unused sidecarSetupSnapshot function after setup flow refactor The auto-snapshot step was removed from sidecar setup in favor of an explicit user-driven snapshot workflow; the helper function was left behind and caught by the linter. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: webster <michael@webster.fyi> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 3862ff4 commit fdea783

2 files changed

Lines changed: 12 additions & 63 deletions

File tree

internal/cmd/sidecar.go

Lines changed: 6 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -691,8 +691,8 @@ func newSidecarSnapshotGetCmd() *cobra.Command {
691691
}
692692

693693
func newSidecarSetupCmd() *cobra.Command {
694-
var sidecarID, orgID, name, identityFile, snapshotName, dir string
695-
var skipSync, skipSnapshot, force bool
694+
var sidecarID, orgID, name, identityFile, dir string
695+
var skipSync, force bool
696696

697697
cmd := &cobra.Command{
698698
Use: "setup",
@@ -753,10 +753,10 @@ Example:
753753
if provider == "" {
754754
provider = defaultProvider
755755
}
756-
var scDisplayName, workspace string
756+
var workspace string
757757
if sidecarID == "" {
758758
var resolveErr error
759-
sidecarID, scDisplayName, workspace, resolveErr = sidecarSetupResolveSidecar(cmd.Context(), client, orgID, name, provider, status, streams)
759+
sidecarID, _, workspace, resolveErr = sidecarSetupResolveSidecar(cmd.Context(), client, orgID, name, provider, status, streams)
760760
if resolveErr != nil {
761761
return resolveErr
762762
}
@@ -779,29 +779,8 @@ Example:
779779
return err
780780
}
781781

782-
// Step 6: Create snapshot.
783-
if !skipSnapshot {
784-
snap, err := sidecarSetupSnapshot(cmd.Context(), client, sidecarID, scDisplayName, snapshotName, status)
785-
if err != nil {
786-
return err
787-
}
788-
789-
// Step 7: Record snapshot, persist image to config, clear active sidecar.
790-
if saveErr := sidecar.SaveActiveSnapshot(sidecar.ActiveSnapshot{ID: snap.ID, Name: snap.Name}); saveErr != nil {
791-
streams.ErrPrintf("warning: could not save active snapshot: %v\n", saveErr)
792-
}
793-
if cfg.Validation == nil {
794-
cfg.Validation = &config.ValidationConfig{}
795-
}
796-
cfg.Validation.SidecarImage = snap.ID
797-
if saveErr := config.SaveProjectConfig(dir, cfg); saveErr != nil {
798-
streams.ErrPrintf("warning: could not save snapshot ID to project config: %v\n", saveErr)
799-
}
800-
if clearErr := sidecar.ClearActive(); clearErr != nil {
801-
streams.ErrPrintf("warning: could not clear active sidecar: %v\n", clearErr)
802-
}
803-
status(iostream.LevelDone, fmt.Sprintf("Snapshot ID saved. Create a new sidecar from this snapshot with: chunk sidecar create --image %s", snap.ID))
804-
}
782+
streams.ErrPrintf("\nSetup complete. Verify the sidecar is working correctly, then snapshot it:\n")
783+
streams.ErrPrintf(" chunk sidecar snapshot create --name <snapshot-name>\n\n")
805784

806785
return nil
807786
},
@@ -812,9 +791,7 @@ Example:
812791
cmd.Flags().StringVar(&orgID, "org-id", "", "Organization ID (used when creating a new sidecar)")
813792
cmd.Flags().StringVar(&name, "name", "", "Sidecar name (used when creating a new sidecar)")
814793
cmd.Flags().StringVar(&identityFile, "identity-file", "", "SSH identity file")
815-
cmd.Flags().StringVar(&snapshotName, "snapshot-name", "", "Snapshot name (defaults to <sidecar-name>-setup)")
816794
cmd.Flags().BoolVar(&skipSync, "skip-sync", false, "Skip syncing files to the sidecar")
817-
cmd.Flags().BoolVar(&skipSnapshot, "skip-snapshot", false, "Skip creating a snapshot after install")
818795
cmd.Flags().BoolVar(&force, "force", false, "Re-detect environment even if cached in .chunk/config.json")
819796

820797
return cmd
@@ -979,29 +956,3 @@ func sidecarSetupRunSetup(
979956
}
980957
return nil
981958
}
982-
983-
func sidecarSetupSnapshot(
984-
ctx context.Context,
985-
client *circleci.Client,
986-
sidecarID, scDisplayName, snapshotName string,
987-
status iostream.StatusFunc,
988-
) (*circleci.Snapshot, error) {
989-
if snapshotName == "" {
990-
if scDisplayName != "" {
991-
snapshotName = scDisplayName + "-setup"
992-
} else {
993-
snapshotName = sidecarID[:min(len(sidecarID), 8)] + "-setup"
994-
}
995-
}
996-
status(iostream.LevelStep, fmt.Sprintf("Creating snapshot %q...", snapshotName))
997-
snap, err := client.CreateSnapshot(ctx, sidecarID, snapshotName)
998-
if err != nil {
999-
return nil, &userError{
1000-
msg: "Could not create the snapshot.",
1001-
suggestion: "Check your network connection and try again.",
1002-
err: err,
1003-
}
1004-
}
1005-
status(iostream.LevelDone, fmt.Sprintf("Snapshot created: %s (%s)", snap.Name, snap.ID))
1006-
return snap, nil
1007-
}

skills/chunk-sidecar/SKILL.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,12 @@ Run `chunk sidecar current`. Three cases:
3939

4040
## Step 3: One-time setup
4141

42-
Skip this step unless the user explicitly asks to "prep the sidecar", "snapshot it", "set up the environment", or similar. This is a one-time flow that produces a reusable snapshot so future sessions boot fast.
43-
44-
1. `chunk sidecar env` — detects the tech stack and emits a JSON environment spec.
45-
2. Review the spec with the user.
46-
3. `chunk sidecar env | chunk sidecar build --tag <image-tag>` — writes `Dockerfile.test` and builds an image.
47-
4. `chunk sidecar create --name <name> --image <image-tag>` — creates a sidecar from that image.
48-
5. Install any extra deps over SSH: `chunk sidecar ssh -- bash -c "<install commands>"`.
49-
6. `chunk sidecar snapshot create --name <checkpoint-name>` — captures the configured state and returns a snapshot ID.
42+
Skip this step unless the user explicitly asks to "prep the sidecar", "set up the environment", or similar. This is a one-time flow that produces a reusable snapshot so future sessions boot fast.
43+
44+
1. `chunk sidecar setup --dir . --name <name>` — detects the stack, syncs files, and runs install steps on the sidecar. Prompts to create a sidecar if none is active.
45+
2. Verify the sidecar is working correctly by running a validate command against it directly: `chunk validate --remote --sidecar-id <sidecar-id>`. Use the exact sidecar ID from step 1.
46+
3. Once confirmed working, snapshot the sidecar: `chunk sidecar snapshot create --name <snapshot-name>`. This captures the configured state and returns a snapshot ID. **Always snapshot after confirming the sidecar is working — do not skip this step.**
47+
4. Record the snapshot ID in `.chunk/config.json` under `validation.sidecarImage` so future sidecars boot from it: `chunk config set validation.sidecarImage <snapshot-id>`.
5048

5149
Future sessions boot from the snapshot: `chunk sidecar create --name <new-name> --image <snapshot-id>`.
5250

0 commit comments

Comments
 (0)