Skip to content

Disk space pre-flight check before creating worktrees #71

Description

@that-github-user

Problem

thinktank run --attempts 10 creates 10 full copies of the repository as git worktrees. For a 1 GB repo, this consumes 10 GB of disk space with no warning. The user discovers the problem only when the disk fills up and git starts failing with cryptic errors.

There is currently no disk space check before worktrees are created.

Steps to Reproduce

  1. Have a large repo (e.g., 500 MB+)
  2. Run thinktank run "fix this bug" --attempts 8
  3. Disk fills up mid-run; worktrees fail to create; error messages are from git, not thinktank

Proposed Solution

Before creating worktrees, check available disk space:

  1. Measure the size of the current repo directory
  2. Estimate required space: repo_size × N × 1.1 (10% buffer)
  3. Check available space on the filesystem
  4. If insufficient, abort with a clear message:
✗ Insufficient disk space for 5 worktrees
  Repo size:       1.2 GB
  Required:        6.6 GB (5 × 1.2 GB + 10% buffer)
  Available:       3.1 GB
  
  Try reducing --attempts (current: 5) or freeing up disk space.
  Use --no-space-check to skip this check.

Acceptance Criteria

  • Before worktree creation, thinktank checks available disk space
  • Estimate is based on actual repo size (using du or equivalent)
  • If estimated space exceeds available space, run is aborted with a clear, actionable error
  • Error message suggests reducing --attempts or freeing disk space
  • --no-space-check flag skips the check for users who know what they're doing
  • Check handles edge cases: symlinked directories, network filesystems (fall back gracefully if check is unreliable)
  • Works on macOS, Linux, and Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions