Skip to content

Squad state destroyed when .squad/ is gitignored and agents switch branches #643

@seligj95

Description

@seligj95

Problem

When .squad/ is in .gitignore (common when using Squad in a repo you do not own), agent-triggered git checkout commands silently destroy all Squad state files (dashboards, agent history, decisions, orchestration logs).

Root Cause

.squad/ files are untracked. Git does not preserve untracked files during branch switches. Agents that run git checkout <branch> in the main worktree — instead of git worktree add — cause the deletion.

How We Hit This

We used Squad to triage a 78-issue backlog in Azure/azure-cli. Since we cannot commit .squad/ to that repo, we gitignored it. During live validation, an agent ran git checkout fix/ssl-branch in the main worktree. All .squad/ files were wiped — dashboards, agent charters, history, logs. This happened twice in one session.

Suggested Improvements

  1. Detect gitignored .squad/ at init — If .squad/ matches a .gitignore rule, warn the user: "⚠️ .squad/ is gitignored. State will not survive branch switches. Consider using --external-state or committing .squad/."

  2. Enforce worktree usage in agent prompts — The coordinator already instructs agents to use git worktree add, but there is no enforcement. Consider adding a pre-flight check or a git hook that prevents git checkout when .squad/ is untracked.

  3. Support external state directory — For "contributor" scenarios (using Squad in repos you do not own), allow .squad/ state to live outside the repo, e.g. ~/.squad/projects/<repo-name>/. This would be immune to checkout/worktree issues.

  4. Auto-backup before risky git ops — Before any branch switch, snapshot .squad/ to a temp location. Restore if files are missing after the operation.

Environment

  • Squad v0.9.1
  • Copilot CLI
  • macOS, Azure/azure-cli repo
  • .squad/ in .gitignore

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggo:needs-researchNeeds investigationsquadSquad triage inbox — Lead will assign to a membersquad:eecomAssigned to EECOM (Core Dev)squad:fidoAssigned to FIDO (Quality Owner)

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions