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

# Flow Generator

> Generate a @Flow class extending FlowBase

Generates a `@Flow` class with all lifecycle stage methods: `pre`, `execute`, `post`, `finalize`, and `error`.

## Usage

```bash theme={"theme":{"light":"snazzy-light","dark":"dark-plus"}}
nx g @frontmcp/nx:flow audit-log --project crm
```

## Options

| Option      | Type     | Default | Description                                  |
| ----------- | -------- | ------- | -------------------------------------------- |
| `name`      | `string` | —       | **Required.** The name of the flow           |
| `project`   | `string` | —       | **Required.** The project to add the flow to |
| `directory` | `string` | —       | Subdirectory within `src/flows/`             |

## Generated Code

```ts theme={"theme":{"light":"snazzy-light","dark":"dark-plus"}}
import { Flow, FlowBase } from '@frontmcp/sdk';

@Flow({
  name: 'audit-log',
  description: 'TODO: describe what this flow does',
  plan: {
    steps: ['pre', 'execute', 'post', 'finalize'],
  },
})
export default class AuditLogFlow extends FlowBase {
  async pre(): Promise<void> {
    // TODO: pre-processing logic
  }

  async execute(): Promise<void> {
    // TODO: main execution logic
  }

  async post(): Promise<void> {
    // TODO: post-processing logic
  }

  async finalize(): Promise<void> {
    // TODO: finalization logic
  }

  async error(err: Error): Promise<void> {
    // TODO: error handling logic
    throw err;
  }
}
```

See the [Flows guide](/frontmcp/servers/flows) for lifecycle details and hook integration.
