> ## Documentation Index
> Fetch the complete documentation index at: https://trytilde.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# People as code

> Declare a team's users and groups with defineTeam, and grant them access to agents, in @trytilde/iac specs.

A spec can declare who belongs to a team, and who may see or change each agent. `tilde deploy` applies people in the same transaction as the agents.

## Declare a team

```ts tilde.config.ts theme={"system"}
import { defineTeam, group, user } from "@trytilde/iac";

export const team = defineTeam({
  team: "support",
  users: [
    user({ email: "ana@example.com", name: "Ana", login: { role: "admin" } }),
    user({ email: "ben@example.com", login: true }),
  ],
  groups: [group({ name: "on-call", members: ["ana@example.com", "ben@example.com"] })],
});
```

* A user is found by email, and joins the team as a member.
* `login: true` invites them to sign in, and keeps an existing member's role. `login: { role }` also sets their role.
* A group is found by name in the team, and created if it is missing. `members` lists emails.

## Grant access to an agent

`access` grants a user or group **visibility** (see the agent) or **ownership** (change it). `group("on-call")` or `user("ana@example.com")` names one declared elsewhere, or one that already exists.

```ts theme={"system"}
import { defineAgent, grant, group } from "@trytilde/iac";

export const triage = defineAgent({
  key: "triage",
  name: "Triage",
  access: [grant(group("on-call"), "ownership")],
});
```

In a monorepo, an agent can declare its own `users` and `groups` beside it. Tilde merges them with the team's by email and by name. Conflicting definitions fail preflight.

## Remove people

As everywhere in a spec, removal is explicit:

| Write | Effect |
| - | - |
| `user({ email, delete: true })` | Disables the user. Their history stays. |
| `user({ email, team: { delete: true } })` | Removes the user from the team. |
| `group({ name, delete: true })` | Deletes the group. |
| `members: [{ email, delete: true }]` | Removes a member from the group. |
| `grant(principal, plane, { delete: true })` | Revokes the grant. |

See [Organizations and teams](https://trytilde.ai/docs/deployment/organizations-and-teams.md) and [Resource access](https://trytilde.ai/docs/operator-access.md#resource-access) for what roles and grants allow.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.