# SquadBuilderExtensions Methods

- Package: [CommunityToolkit.Aspire.Hosting.Squad](/reference/api/csharp/communitytoolkit.aspire.hosting.squad.md)
- Type: [SquadBuilderExtensions](/reference/api/csharp/communitytoolkit.aspire.hosting.squad/squadbuilderextensions.md)
- Kind: `Methods`
- Members: `1`

Provides fluent extension methods for adding and configuring Squad AI-agent team resources in an Aspire `Hosting.IDistributedApplicationBuilder`.

<a id="addsquad"></a>
<a id="addsquad-idistributedapplicationbuilder-string-string"></a>

## AddSquad(IDistributedApplicationBuilder, string, string?)

- Name: `AddSquad(IDistributedApplicationBuilder, string, string?)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<SquadResource>`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/d479e13473b1d29d06b974f144a0049289a3cb5c/src/CommunityToolkit.Aspire.Hosting.Squad/SquadBuilderExtensions.cs#L53-L197)

Adds a Squad AI-agent team to the distributed application. The lifecycle hook discovers agents from `.squad/team.md` (or the default roster when the file does not exist), publishes `Spawning` to `Active` state transitions visible in the Aspire dashboard, and injects a custom `squad://` descriptor that downstream services can consume as metadata. The Squad resource is a logical dashboard/resource-graph entry; it does not start a server process by itself.

```csharp
public static class SquadBuilderExtensions
{
    public static IResourceBuilder<SquadResource> AddSquad(
        this IDistributedApplicationBuilder builder,
        string name,
        string? teamRoot = null)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IDistributedApplicationBuilder`)
  The `Hosting.IDistributedApplicationBuilder` to add the resource to.
- `name` (`string`)
  The Aspire resource name.
- `teamRoot` (`string?`) `optional`
  Absolute path to the workspace root - the directory that contains the `.squad/` folder. Defaults to `Directory.GetCurrentDirectory` when not specified.

## Returns

`IResourceBuilder<SquadResource>` -- An `ApplicationModel.IResourceBuilder`1` for further configuration.

## Examples

```csharp
var builder = DistributedApplication.CreateBuilder(args);

var squad = builder.AddSquad("research-squad",
    teamRoot: @"C:\repos\my-project");

builder.AddProject<Projects.IncidentWorkflow>("workflow")
    .WithReference(squad);

builder.Build().Run();
```

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.
