Skip to content

squad init: agent invisible when CWD is inside a parent git repo #374

Closed

Description

@bradygaster

Problem

When running squad init in a directory that is a subdirectory of a parent git repository, the Squad agent (.github/agents/squad.agent.md) is created at the CWD but is invisible to copilot --agent squad.

Root cause: Copilot resolves .github/agents/ relative to git rev-parse --show-toplevel (the git root), not relative to CWD. If CWD is inside a parent git repo, the git root points to the parent directory — where the agent file doesn't exist.

Reproduction:

  1. Accidentally run git init in a parent directory (e.g., C:\src\)
  2. mkdir child && cd child
  3. squad init
  4. copilot --agent squad → No such agent: squad

The agent file exists at child/.github/agents/squad.agent.md but copilot looks at parent/.github/agents/ — wrong path.

Fix

Added detectParentGitRepo() to packages/squad-cli/src/cli/core/init.ts:

  • Compares CWD to git rev-parse --show-toplevel
  • If they differ, warns the user and auto-runs git init to create a proper repo boundary
  • Gracefully handles no-git environments (catch block, no crash)

Commit: a9eee03 on dev

Activity

  1. bradygaster commented on Mar 13, 2026

    @bradygaster
    CollaboratorAuthor

    Fixed in commit a9eee03 on dev branch. \detectParentGitRepo()\ added to \packages/squad-cli/src/cli/core/init.ts\ — detects parent git repos during \squad init\ and auto-runs \git init\ to create a proper repo boundary.

  2. added a commit that references this issue on Mar 16, 2026
    0024771
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

    release:nextTargeted for next release

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions