Skip to content

Surface stale worktree age and size in list/cleanup #144

@chubes4

Description

@chubes4

Problem

Old clean worktrees are easy to forget. The current cleanup surface can identify candidates, but DMC should make age and stale lifecycle state visible enough that hundreds of stale directories do not accumulate silently.

Proposed solution

Add age/staleness reporting to workspace worktree listing and cleanup.

Useful fields:

  • created_at from DMC metadata when available.
  • last_touched_at from metadata, git activity, or filesystem mtime.
  • age_days.
  • stale_reason such as older_than_threshold, merged_pr, closed_pr, missing_metadata, dirty, unpushed_commits.
  • estimated_size_bytes.

CLI behavior

Add filters/sorting such as:

wp datamachine-code workspace worktree list --stale --format=json
wp datamachine-code workspace worktree cleanup --dry-run --older-than=14d --sort=size
wp datamachine-code workspace worktree cleanup --dry-run --only=stale

Acceptance criteria

  • List output can show stale worktrees without running destructive cleanup.
  • Cleanup output can sort candidates by age and by size.
  • Worktrees with missing metadata are not silently ignored; they get a remediation hint.
  • Human output includes a top-N summary: biggest stale worktrees and oldest stale worktrees.
  • JSON output includes age and size fields for automation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions