[PR #7263] feat(cli): add snapshot management commands #12324

Open
opened 2026-02-16 18:17:14 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/7263

State: open
Merged: No


Summary

The Snapshot directory can get very large. This is a simple command to delete it.
Its a known issue
Also relevent to #1126 #6845 #5617 #3182 #3176

This adds a new snapshot command to manage project snapshot directories with list and clear subcommands.

Changes

  • New command: opencode snapshot

    • opencode snapshot list - Lists all projects with snapshot sizes, sorted by size
    • opencode snapshot clear [project-id] - Clears specific snapshot
    • opencode snapshot clear - Clears all snapshots
  • Features:

    • Displays project ID, name, size, and last updated date
    • Safety features: --dry-run flag, confirmation prompts by default
    • --force flag to skip confirmation
    • Clear specific project or all projects
    • Error handling for missing projects
    • Success feedback showing space freed

Motivation

Snapshot directories can grow large . Users need a way to:

  • See which projects have snapshots and their sizes
  • Clean up old or unnecessary snapshots to free disk space
  • Manage snapshots per project

I have 8.1 GB across 14 projects.

image

Testing

# List all snapshots
opencode snapshot list

# Preview what would be deleted (dry-run)
opencode snapshot clear --dry-run

# Clear specific project
opencode snapshot clear <project-id>

# Clear all with confirmation
opencode snapshot clear

# Clear all without confirmation
opencode snapshot clear --force

Code Style

  • Follows project style guide (single functions, no destructuring, no else, const only)
  • Minimal changes: 2 lines in index.ts + new command file (260 lines)
  • All typechecks pass
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/7263 **State:** open **Merged:** No --- ## Summary The Snapshot directory can get very large. This is a simple command to delete it. Its a [known issue](https://x.com/marwanbz_/status/2009016262526161294) Also relevent to #1126 #6845 #5617 #3182 #3176 This adds a new `snapshot` command to manage project snapshot directories with list and clear subcommands. ## Changes - **New command**: `opencode snapshot` - `opencode snapshot list` - Lists all projects with snapshot sizes, sorted by size - `opencode snapshot clear [project-id]` - Clears specific snapshot - `opencode snapshot clear` - Clears all snapshots - **Features**: - Displays project ID, name, size, and last updated date - Safety features: `--dry-run` flag, confirmation prompts by default - `--force` flag to skip confirmation - Clear specific project or all projects - Error handling for missing projects - Success feedback showing space freed ## Motivation Snapshot directories can grow large . Users need a way to: - See which projects have snapshots and their sizes - Clean up old or unnecessary snapshots to free disk space - Manage snapshots per project I have 8.1 GB across 14 projects. <img width="800" height="389" alt="image" src="https://github.com/user-attachments/assets/969bdaa4-b2c0-46c9-82d6-595af7f58d17" /> ## Testing ```bash # List all snapshots opencode snapshot list # Preview what would be deleted (dry-run) opencode snapshot clear --dry-run # Clear specific project opencode snapshot clear <project-id> # Clear all with confirmation opencode snapshot clear # Clear all without confirmation opencode snapshot clear --force ``` ## Code Style - Follows project style guide (single functions, no destructuring, no else, const only) - Minimal changes: 2 lines in index.ts + new command file (260 lines) - All typechecks pass
yindo added the pull-request label 2026-02-16 18:17:14 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#12324