Squad Documentation

repository·dev·Indexed 25 days ago

https://github.com/bradygaster/squad

A programmable multi-agent runtime for GitHub Copilot built on @github/copilot-sdk. Squad enables developers to deploy specialized, persistent AI agent teams (e.g., frontend, backend, tester) within a repository to assist with coordination and parallel execution under human oversight. The ecosystem includes @bradygaster/squad-cli for team management and an interactive REPL, and @bradygaster/squad-sdk for building custom agentic workflows, governance hook pipelines, and pluggable storage providers.

Tokens
245.8K
Snippets
734
Records
1.4K
Agent score
84%

What's inside Squad

  1. Overview of Squad Wave 2, 2.5, and 3 features

    dev

    Squad is currently in alpha. Recent roadmap completions include:

    Wave 2

    • Tiered response modes: Choose between Direct, Lightweight, Standard, and Full to manage agent spawn overhead.
    • Smart upgrade: Includes version-keyed migrations.
    • Skills Phase 1: Agents read SKILL.md files to inform their work.
    • Export CLI: Command-line interface for exporting squad configurations.

    Wave 2.5

    • GitHub Issues Mode: Automates the lifecycle from GitHub Issue to branch, PR, and merge.
    • PRD Mode: Decomposes a pasted specification into a backlog.
    • Human Team Members: Allows humans to be included in the roster alongside AI agents.

    Wave 3

    • Import CLI: Provides full portability by allowing you to export a squad and import it into a new project.
    • Skills Phase 2: Agents earn skills from real work, progressing through a confidence lifecycle: lowmediumhigh.
    • Progressive history summarization: Manages long-running context.
    • Lightweight spawn template: Optimized templates for agent spawning.
  2. Overview of Squad API Reference Documentation

    dev

    The Squad SDK documentation is transitioning to an auto-generated API reference system using TypeDoc and Markdown. This system is designed to provide a searchable, linkable, and canonical source for all exported symbols, including classes, interfaces, functions, and type aliases.

    Key components being documented include:

    • SquadState: Central architecture type for state management.
    • StorageProvider: The interface contract for state layer implementations.
    • AgentHandle: The interface defining operations available to agents in .squad/agents/.
    • SquadCoordinator: Core orchestration class.
    • Config Schemas: Definitions found in config/schema.ts and runtime/config.ts.
  3. Design Specification: Fixed Bottom Input Box

    dev

    The Squad CLI uses a fixed bottom input box design to provide a grounded user experience similar to Copilot or Claude. The input area is contained within a box using a rounded border style to distinguish it from the streaming message history.

    Key Design Features

    • Border Style: Uses borderStyle="round" (e.g., ╔═╗╚═╝) for a soft visual feel that matches the header.
    • Error Handling: Errors are not rendered inside the input box. Instead, they appear as system messages in the scrollback history above the input box, allowing users to see errors in context.
    • Terminal Compatibility: The layout is designed to be responsive across different terminal widths (40, 80, and 120 columns).
    • NO_COLOR Support: When NO_COLOR is detected, the UI degrades gracefully to a plain text format using separators (e.g., ─────── sq> [text] ───────).
  4. Key concepts in Streaming-chat

    dev

    The sample demonstrates several core Squad patterns:

    • Casting: Using CastingEngine to cast multiple agents and create individual sessions per agent.
    • Session Management: Using SquadClientWithPool to manage concurrent sessions with rate limiting.
    • Routing: Mapping user input to specific agents via keyword matching.
    • Streaming: Using StreamingPipeline to capture and display token-by-token output in real time.
    • Event Handling: Using EventBus to emit and subscribe to session lifecycle events.
  5. Understand the Squad initialization entry points

    dev

    Squad supports several ways to enter the initialization/onboarding flow depending on your current state:

    1. New Project: Running squad in a directory without a .squad/ folder will prompt you to run squad init.
    2. Scaffold Only: Running squad init (without a prompt) creates the .squad/ directory and an empty team.md roster, but requires a subsequent step to cast the team.
    3. Deferred Casting: Running squad init "<prompt>" creates the scaffold and a .init-prompt file. Running squad afterwards will trigger an automatic team cast.
    4. REPL Casting: If you enter the REPL with an empty roster, your first message can be used as the prompt to cast your team.
    5. Copilot Extension: Using the squad.agent.md template in Copilot provides a rich, two-phase casting flow (propose $\rightarrow$ confirm $\rightarrow$ create).
  6. Core concepts in hello-squad

    dev

    The sample demonstrates several key Squad SDK workflows:

    • Directory Resolution: Using resolveSquad() to find or create a .squad/ directory.
    • Themed Casting: Using the CastingEngine to create a team of agents from a specific universe system.
    • Agent Onboarding: Creating individual agent directories and initializing their charter and history files.
    • Deterministic Identities: Using the casting history system to ensure that casting the same configuration twice results in consistent agent names.
  7. Understand the three layers of Ralph execution

    dev

    Ralph (the Squad automation engine) can operate at three different levels of autonomy depending on your setup:

    1. In-session: Active loop triggered manually while you are at the keyboard (e.g., "Ralph, go"). This is ephemeral and lives only while the Copilot session is active.
    2. Local watchdog: A separate process running on your machine while you are away (e.g., squad watch --execute). It polls at a defined --interval.
    3. Cloud heartbeat: Fully unattended execution triggered by GitHub Actions events (e.g., squad-heartbeat.yml) in response to events like issue closures or PR merges.
  8. Understand the Tiered Memory model

    dev

    Squad uses a three-tier memory model to reduce agent spawn context costs by 20–55%. Instead of loading the entire history.md on every spawn, the system separates context into three distinct tiers based on relevance and lifetime:

    • 🔥 Hot (Current Session Context): Always loaded on every spawn. Contains the current task, active decisions, immediate blockers, and the last 3–5 actions. Size target: ~2–4KB.
    • ❄️ Cold (Summarized Cross-Session History): Loaded on demand. Contains summarized past sessions, cross-session decisions, and recurring patterns. It uses a 30-day rolling window. Size target: ~8–12KB.
    • 📚 Wiki (Durable Structured Knowledge): Loaded selectively/asynchronously. Contains authoritative reference material like ADRs, agent charters, and API contracts. Size target: variable.

    Note: This feature is currently Experimental and is implemented as a built-in skill at .copilot/skills/tiered-memory/SKILL.md.

  9. Manage agent collections with Squad Presets

    dev

    Presets are reusable, named bundles of agent charters (roles, expertise, and prompt styles) that you can apply to any Squad project. They define the shape of a team but do not capture casting state, skills, routing rules, decisions, or memory.

    Built-in presets are available by default, and you can save your own custom rosters to ~/.squad/presets/<name>/.

  10. Understand the Memory Governance Architecture

    dev

    Squad uses a tiered memory architecture to separate concerns between low-level persistence and high-level intelligence.

    • StorageProvider: A low-level abstraction for reading, writing, listing, and deleting bytes/blobs. It does not understand semantic meaning or retention policies.
    • SquadState: The structured surface for .squad/ data.
    • MemoryGovernanceProvider / MemoryStore: A high-level layer sitting above state and storage. It handles classification, policy enforcement, routing, retrieval, and promotion of memory entries.

    This architecture allows Squad to support local worktree memory (default) alongside optional external semantic providers like Copilot Memory.

  11. Understand the Platform Adapter abstraction

    dev

    The Platform Adapter allows Squad to interact with different source code hosting platforms (such as GitHub and Azure DevOps) using a unified interface. This abstraction ensures that Squad's triage and assignment logic remains consistent regardless of whether you are using GitHub or Azure DevOps.

    Key features include:

    • Zero-config detection: The platform is automatically detected by reading the origin git remote URL.
    • CLI-based interaction: Instead of managing OAuth tokens or PATs, the adapters wrap existing CLI tools (gh for GitHub, az for Azure DevOps), leveraging your existing local authentication.
  12. Learn about Squad SDK governance hooks

    dev

    The hook-governance sample demonstrates four specific types of deterministic hooks that enforce security and policy without relying on prompt instructions:

    • File-write guards: Blocks writes to prohibited paths (e.g., preventing writes to /etc/passwd) by defining allowed safe zones.
    • PII scrubbing: Automatically redacts personally identifiable information, such as email addresses, from tool output strings and nested objects.
    • Reviewer lockout: Prevents a specific agent from editing a file after a review rejection, while still allowing other agents access.
    • Ask-user rate limiting: Caps the number of times an agent can prompt the user within a single session.