Skip to content

squadrant projection emit ignores the worktree it is run from — writes into the main checkout's CLAUDE.md and injects unrelated skill content #717

Description

@tu11aa

Reported by a crew working in an isolated worktree on 2026-08-22. The crew caught it, reverted, and escalated rather than filing.

What happened

A crew running in its own worktree (/Users/q3labsadmin/me/squadrant/.worktrees/squadrant-docs) ran:

squadrant projection emit --scope project --project squadrant

Two defects fired:

  1. It ignored the worktree cwd. Instead of emitting into the worktree it was invoked from, it wrote directly into the main checkout at /Users/q3labsadmin/me/squadrant/CLAUDE.md — a tracked file in the captain's own working tree, outside the crew's sandbox.

  2. The project-scope payload was wildly oversized. It injected roughly 1665 lines of unrelated skill content (add-pick-crew-rule, etc.) into that file. For reference, the committed CLAUDE.md is 80 lines.

The crew reverted immediately with git checkout -- CLAUDE.md. Captain verified afterwards:

$ git status --porcelain            # (empty — clean)
$ wc -l CLAUDE.md                   # 80
$ git diff HEAD -- CLAUDE.md GEMINI.md AGENTS.md   # (empty)

No data was lost. But nothing about the command warned that it was writing outside the caller's tree.

Why this matters

Worktree isolation is the guarantee that lets crews run in parallel without stepping on each other or on the captain. A command that silently escapes that boundary and rewrites a tracked file in the captain's checkout breaks the same invariant as the 2026-08-18 daemon-hijack class. Here it hit a file that is supposed to be generated, so a careless crew could easily have committed the 1665-line version instead of reverting it.

Expected

  • projection emit should resolve its target from the cwd it was invoked in (respecting git rev-parse --show-toplevel in a linked worktree), never the repo's main checkout.
  • Project-scope emission should not pull in skill content that is not project-scoped — the size blowup suggests a scope-resolution bug independent of the worktree issue.

Also found in the same run

GEMINI.md in this repo was missing its closing <!-- squadrant:end --> marker, which made emit fail with Corrupted squadrant markers. The crew patched it. Worth a guard: emit should report which file has unbalanced markers rather than failing generically.

Related

#662 (no way to opt a project out of projection) is a different concern — that is about unrelated repos; this is about escaping the worktree within the correct repo.

Environment

squadrant 0.18.1, develop @ 7a72e9a, macOS.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions