Hello Squad: Your First Multi-Agent TypeScript App
Build a minimal Squad application that resolves a team directory, casts named agents from a fictional universe, onboards them, and tracks casting history.
Use this file to discover all available pages before exploring further.
The hello-squad sample is the recommended starting point for the Squad SDK. In under 100 lines of TypeScript it demonstrates the four core SDK primitives — directory resolution, agent casting, agent onboarding, and casting history — using a themed team drawn from The Usual Suspects universe. No GitHub token is required; everything runs locally in a temp directory.
Call resolveSquad(root) to locate an existing .squad/ directory or confirm it exists. The sample creates a fresh directory under os.tmpdir() so the demo never writes into your repository.
Pass a universe, teamSize, and requiredRoles array to CastingEngine.castTeam(). The engine assigns characters from the chosen universe to roles based on personality fit and returns typed CastMember objects.
For every cast member, call onboardAgent() to create an agent directory under .squad/agents/<name>/ containing two files: charter.md (role, project context, and personality) and history.md (an empty cast log ready for entries).
Iterate the CastMember[] array to render a formatted table showing each agent’s name, role, and personality trait. This is the human-readable summary of the cast.
for (const m of team) { const name = m.name.padEnd(11); const role = m.role.padEnd(16); const personality = m.personality.slice(0, 40).padEnd(40); console.log(` │ ${name} │ ${role} │ ${personality} │`);}
5
Track casting history
Create a CastingHistory instance and call recordCast() after each cast. Then cast the same config a second time and verify that agent names are identical — the casting system is deterministic, so names persist across runs and can be used as stable identifiers.
const history = new CastingHistory();history.recordCast(team, config);const team2 = engine.castTeam(config);history.recordCast(team2, config);const match = team.every((m, i) => m.name === team2[i].name);// → true: names are deterministic across casts
Searches root for a .squad/ directory and returns the absolute path if found, or null if the directory doesn’t exist. Use this to locate an existing team workspace rather than constructing the path manually.
Selects characters from the named universe and assigns them to the requested roles. Returns a CastMember[] array where each member has name, displayName, role, personality, and backstory fields. The assignment is deterministic: the same config always produces the same names.
🎬 hello-squad — Squad SDK beginner sample──────────────────────────────────────────────────────────── Step 1 — Resolve .squad/ directory────────────────────────────────────────────────────────────✅ Created demo .squad/ at: /tmp/hello-squad-demo/.squad resolveSquad() → /tmp/hello-squad-demo/.squad──────────────────────────────────────────────────────────── Step 2 — Cast a team from "The Usual Suspects"──────────────────────────────────────────────────────────── Universe: The Usual Suspects Team size: 4 🎭 Keyser — Lead Personality: Quietly commanding; sees the whole board before anyone else. Backstory: ...──────────────────────────────────────────────────────────── Step 3 — Onboard agents──────────────────────────────────────────────────────────── ✅ Keyser — Lead Dir: /tmp/hello-squad-demo/.squad/agents/keyser Charter: /tmp/hello-squad-demo/.squad/agents/keyser/charter.md History: /tmp/hello-squad-demo/.squad/agents/keyser/history.md ✅ McManus — Developer ✅ Fenster — Tester ✅ Verbal — Scribe──────────────────────────────────────────────────────────── Step 4 — Team roster──────────────────────────────────────────────────────────── ┌─────────────┬──────────────────┬──────────────────────────────────────────┐ │ Name │ Role │ Personality │ ├─────────────┼──────────────────┼──────────────────────────────────────────┤ │ Keyser │ lead │ Quietly commanding; sees the whole bo... │ │ McManus │ developer │ Bold and improvisational; figures it ... │ │ Fenster │ tester │ Paranoid attention to detail; spots ... │ │ Verbal │ scribe │ Quietly observant; captures everything ... │ └─────────────┴──────────────────┴──────────────────────────────────────────┘──────────────────────────────────────────────────────────── Step 5 — Casting history (persistent names)──────────────────────────────────────────────────────────── Casting records: 2 Cast #1 names: Keyser, McManus, Fenster, Verbal Cast #2 names: Keyser, McManus, Fenster, Verbal Names match across casts: ✅ Yes Serialized history version: 1 Records in history: 2 Keyser appeared in 2 cast(s)──────────────────────────────────────────────────────────── Done! 🎉────────────────────────────────────────────────────────────
Exact Personality and Backstory text comes from the universe definition inside the SDK. If you swap universe: 'usual-suspects' for another universe, you’ll see different character names and traits while all five steps remain identical.