Skip to content

feat(cli): add session prune command for cleanup#12631

Open
dzianisv wants to merge 1 commit intoanomalyco:devfrom
dzianisv:feat/session-prune
Open

feat(cli): add session prune command for cleanup#12631
dzianisv wants to merge 1 commit intoanomalyco:devfrom
dzianisv:feat/session-prune

Conversation

@dzianisv
Copy link

@dzianisv dzianisv commented Feb 7, 2026

Summary

Adds opencode session prune <duration> command to delete old sessions and free disk space.

After heavy usage, the ~/.local/share/opencode/storage/ directory can grow to 10+ GB with thousands of old sessions. This command provides a safe way to clean up old data.

Features

  • Duration format: 1d, 7d, 2w, 1m (days/hours/weeks/months)
  • --dry-run: Preview what would be deleted without making changes
  • --force/-f: Skip confirmation prompt
  • --all/-a: Prune sessions from all projects (not just current)
  • --logs: Also prune old log files
  • --snapshots: Also prune orphaned snapshot directories

Usage Examples

# Preview cleanup of sessions older than 7 days
opencode session prune 7d --dry-run

# Clean up sessions older than 1 month with logs
opencode session prune 1m --logs

# Clean up everything older than 2 weeks, including orphaned snapshots
opencode session prune 2w --logs --snapshots --force

Output

Shows a summary of sessions to be deleted with age, estimated space savings, and asks for confirmation before proceeding.

Testing

Tested manually with --dry-run on a storage directory with 400+ sessions.

Adds 'opencode session prune <duration>' command to delete old sessions
and free disk space. Features:

- Duration format: 1d, 7d, 2w, 1m (days/hours/weeks/months)
- --dry-run: preview what would be deleted
- --force/-f: skip confirmation prompt
- --all/-a: prune all projects (not just current)
- --logs: also prune old log files
- --snapshots: also prune orphaned snapshot directories

Shows estimated space savings before deletion and confirms with user.
@github-actions
Copy link
Contributor

github-actions bot commented Feb 7, 2026

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 7, 2026

The following comment was made by an LLM, it may be inaccurate:

No duplicate PRs found

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant