# Verb functions

URL: /code/file-conventions/verb-functions · Id: `page:code/file-conventions/verb-functions`

> A Verb function file holds the Function behind one Verb, bound by its file name with no registration.

A file named `[Noun].[verb].ts` in `nouns/` holds the [Function](/business/nouns/function) behind one [Verb](/business/nouns/verb). The file name binds it; nothing registers it.

```text
nouns/
├── Lease.mdx
└── Lease.renew.ts        runs Lease.renew
```

## Reference
TypeScript with one default export. `.sb/types/` declares the [Noun](/business/nouns/noun), each Verb's input type and `$` globally, so the file needs no import.

| Export | Type | Holds |
| --- | --- | --- |
| `default` | `(thing: Noun, input: NounVerbInput, $: $) => Promise<Output>` | The Function: the record, the Verb's typed input, and the client acting as this Function's [Worker](/business/nouns/worker) |

The input type is named for the Noun and Verb: `renew` on `Lease` takes `LeaseRenewInput`, compiled from the Verb's entry in the [Nouns](/code/file-conventions/nouns#verb-inputs) file.

The kind is read from the code. `$.Noun.verb()` calls are code, `` $`…` `` is one model call, an [Agent](/business/nouns/agent)'s tag such as `` rae`…` `` is agentic, and a person's tag is a human [Task](/business/nouns/task). The caller never sees which ran.

## Examples
### Minimal
```ts title="nouns/Lease.renew.ts"
export default async (lease: Lease, input: LeaseRenewInput, $: $) => {
  const end = new Date(lease.endsOn)
  end.setMonth(end.getMonth() + input.months)
  return $.Lease.update({ id: lease.$id, endsOn: end.toISOString().slice(0, 10) })
}
```

### Leaseline
Leaseline declares a `Lease` Noun whose `renew` Verb takes `months` and an optional `increase` (the [Nouns](/code/file-conventions/nouns) file declares them). [Renewal](/business/nouns/renewal) extends the end date by the term and raises the rent within the increase the manager allows.

```ts title="nouns/Lease.renew.ts"
export default async (lease: Lease, input: LeaseRenewInput, $: $) => {
  const end = new Date(lease.endsOn)
  end.setMonth(end.getMonth() + input.months)
  const rent = lease.rent && { ...lease.rent, amount: Math.round(lease.rent.amount * (1 + (input.increase ?? 0))) }
  return $.Lease.update({ id: lease.$id, endsOn: end.toISOString().slice(0, 10), rent })
}
```

The Function never sets `status`, and `update` takes no `status` input. When the [Action](/business/nouns/action) succeeds, the Verb's [Event](/business/nouns/event), `Lease.renewed`, moves the record to `renewed`.

## What it builds
The [SoftwareBuilder](/code/builders/software) compiles the file into one Function [Version](/business/nouns/version) for the Verb.

- a `Function` with `kind` read from the code
- each call returns one [Action](/business/nouns/action) pinned to that Function Version, with input, output and cost
- the Verb's [Event](/business/nouns/event), `Lease.renewed`, when the Action succeeds

## Good to know
- Without the file, the Verb runs its inherited or default Function.
- A Verb has one body. This file and a [Workflow](/business/nouns/workflow) on the same Verb fail the parse check together.
- [Functions](/code/platform/functions) cover cascades, durable steps and agentic kinds.