.do
Business

teams

Team collaboration and management

teams

Team collaboration with member management, roles, permissions, shared resources, team spaces, and communication channels for organized teamwork.

Overview

The teams primitive provides comprehensive team management including team creation, member roles, permission assignments, resource sharing, team spaces, and collaboration tools.

Parent Primitive: organizations - Multi-tenant organization management

SDK Object Mapping

This primitive integrates with the user SDK object for team membership and permissions:

import { user, teams, on, send } from 'sdk.do'

// USER - Team membership (user is one of 8 core SDK objects)
const myTeams = await user.teams()
const isMember = await user.inTeam('team-123')
const teamRole = await user.role('team-123')

// Create team
const team = await teams.create({
  name: 'Engineering',
  organizationId: user.currentOrganization().id,
  members: [user.id],
})

// Team events via ON (on is one of 8 core SDK objects)
on($.Team.memberAdded, async ({ team, member }) => {
  await send($.Email.send, {
    to: member.email,
    template: 'team-welcome',
    data: { teamName: team.name },
  })
})

// Team-scoped permissions
const canManageProjects = await user.can('manage-projects', { teamId: 'team-123' })

Quick Example

import { teams } from 'sdk.do'

// Create team
const team = await teams.create({
  name: 'Engineering',
  description: 'Engineering team',
  organizationId: 'org-123',
  visibility: 'private',
})

console.log(`Team ID: ${team.id}`)

// Add members
await teams.addMember(team.id, {
  userId: 'user-123',
  role: 'lead',
})

await teams.addMembers(team.id, [
  { userId: 'user-456', role: 'member' },
  { userId: 'user-789', role: 'member' },
])

// List members
const members = await teams.listMembers(team.id)

members.forEach((member) => {
  console.log(`${member.user.name}: ${member.role}`)
  console.log(`  Joined: ${member.joinedAt}`)
})

// Update member role
await teams.updateMember(team.id, 'user-456', {
  role: 'senior',
})

// Remove member
await teams.removeMember(team.id, 'user-789')

// Team roles
await teams.defineRole(team.id, {
  name: 'Tech Lead',
  permissions: ['manage_members', 'manage_projects', 'approve_code', 'deploy_production'],
})

// Assign custom role
await teams.assignRole(team.id, 'user-123', 'Tech Lead')

// Team permissions
await teams.setPermissions(team.id, {
  'user-123': ['read', 'write', 'admin'],
  'user-456': ['read', 'write'],
  'role:member': ['read'],
})

// Check permission
const canDeploy = await teams.hasPermission(team.id, 'user-123', 'deploy_production')

// Shared resources
await teams.shareResource(team.id, {
  type: 'project',
  id: 'project-123',
  permissions: ['read', 'write'],
})

await teams.shareResource(team.id, {
  type: 'repository',
  id: 'repo-456',
  permissions: ['read', 'write', 'admin'],
})

// List shared resources
const resources = await teams.listResources(team.id)

resources.forEach((resource) => {
  console.log(`${resource.type}: ${resource.name}`)
  console.log(`  Permissions: ${resource.permissions.join(', ')}`)
})

// Team spaces
await teams.createSpace(team.id, {
  name: 'Documentation',
  type: 'wiki',
  visibility: 'team',
})

await teams.createSpace(team.id, {
  name: 'Code Reviews',
  type: 'discussion',
  visibility: 'team',
})

// Communication channels
await teams.createChannel(team.id, {
  name: 'general',
  description: 'General team discussion',
  type: 'chat',
})

await teams.createChannel(team.id, {
  name: 'announcements',
  description: 'Team announcements',
  type: 'announcement',
  restricted: true,
})

// Send team message
await teams.sendMessage(team.id, {
  channel: 'general',
  content: 'Team meeting at 2 PM',
  mentionAll: true,
})

// Team settings
await teams.setSettings(team.id, {
  defaultPermissions: ['read'],
  requireApproval: true,
  allowGuests: false,
  notificationsEnabled: true,
})

// Sub-teams
const frontend = await teams.createSubTeam(team.id, {
  name: 'Frontend',
  members: ['user-123', 'user-456'],
})

const backend = await teams.createSubTeam(team.id, {
  name: 'Backend',
  members: ['user-456', 'user-789'],
})

// Team hierarchy
const hierarchy = await teams.getHierarchy(team.id)

console.log(`Team: ${hierarchy.name}`)
hierarchy.subteams.forEach((sub) => {
  console.log(`  - ${sub.name}: ${sub.memberCount} members`)
})

// Team invitations
const invitation = await teams.invite(team.id, {
  email: '[email protected]',
  role: 'member',
  message: 'Welcome to the team!',
})

console.log(`Invitation URL: ${invitation.url}`)

// Team statistics
const stats = await teams.getStats(team.id, {
  timeRange: { last: '30d' },
})

console.log(`Active members: ${stats.activeMembers}`)
console.log(`Projects: ${stats.projects}`)
console.log(`Messages: ${stats.messages}`)
console.log(`Commits: ${stats.commits}`)

// Team activity
const activity = await teams.getActivity(team.id, {
  limit: 20,
})

activity.forEach((item) => {
  console.log(`${item.user.name} ${item.action} at ${item.timestamp}`)
})

// Team calendar
await teams.createEvent(team.id, {
  title: 'Sprint Planning',
  start: new Date('2024-12-25T10:00:00Z'),
  end: new Date('2024-12-25T12:00:00Z'),
  attendees: ['user-123', 'user-456'],
  location: 'Conference Room A',
})

// Team tasks
await teams.createTask(team.id, {
  title: 'Implement user authentication',
  assignee: 'user-123',
  dueDate: new Date('2024-12-31'),
  priority: 'high',
  labels: ['feature', 'security'],
})

// Team milestones
await teams.createMilestone(team.id, {
  name: 'Q1 Release',
  dueDate: new Date('2024-03-31'),
  goals: ['Complete authentication system', 'Deploy to production', 'Achieve 95% test coverage'],
})

// Team retrospectives
await teams.createRetrospective(team.id, {
  title: 'Sprint 23 Retrospective',
  date: new Date(),
  went_well: ['Good collaboration', 'Fast delivery'],
  to_improve: ['Better code review process', 'More automated tests'],
  action_items: ['Setup automated code review checks', 'Add integration test suite'],
})

// Team metrics
const metrics = await teams.getMetrics(team.id, {
  timeRange: { last: '90d' },
  metrics: ['velocity', 'cycle_time', 'throughput'],
})

console.log(`Velocity: ${metrics.velocity}`)
console.log(`Cycle time: ${metrics.cycleTime} days`)
console.log(`Throughput: ${metrics.throughput} items/week`)

// Team onboarding
await teams.setOnboarding(team.id, {
  checklist: ['Complete security training', 'Setup development environment', 'Review codebase architecture', 'Join team channels'],
  documents: ['Engineering handbook', 'Code style guide', 'Deployment guide'],
})

// Archive team
await teams.archive(team.id, {
  reason: 'Project completed',
  preserveData: true,
})

// Restore team
await teams.restore(team.id)

// Delete team
await teams.delete(team.id, {
  transferResources: 'org-123',
  notifyMembers: true,
})

// Team notifications
on(teams.memberJoined, async (team, member) => {
  console.log(`${member.user.name} joined ${team.name}`)
  await sendWelcomeMessage(team.id, member.userId)
})

on(teams.resourceShared, async (team, resource) => {
  console.log(`New resource shared: ${resource.name}`)
  await notifyTeamMembers(team.id, `New resource: ${resource.name}`)
})

Core Capabilities

  • Member Management - Add, remove, update members
  • Roles & Permissions - Flexible role definitions
  • Resource Sharing - Shared projects and assets
  • Team Spaces - Dedicated collaboration areas
  • Communication - Built-in chat and channels

Access Methods

SDK

TypeScript/JavaScript library for teams

await teams.create({ name: 'Engineering', organizationId: 'org-123' })

SDK Documentation

CLI

Command-line tool for team operations

do team create Engineering --org org-123

CLI Documentation

API

REST/RPC endpoints for team management

curl -X POST https://api.do/v1/teams -d '{"name":"Engineering","organizationId":"org-123"}'

API Documentation

MCP

Model Context Protocol for AI-driven teams

Create a new team named Engineering in organization org-123

MCP Documentation

Parent Primitive

Child Primitives

  • projects - Project management within teams
  • user - User authentication and team membership (SDK object mapping)
  • users - User management
  • on - Team event handlers