> ## 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.

# Agent Generator

> Generate an @Agent class

Generates an `@Agent` class with LLM configuration and optional tool references.

## Usage

```bash theme={"theme":{"light":"snazzy-light","dark":"dark-plus"}}
nx g @frontmcp/nx:agent researcher --project crm
nx g @frontmcp/nx:agent researcher --project crm --model claude-sonnet-4-5-20250514 --tools web_search,summarize
```

## Options

| Option | Type | Default | Description |
| - | - | - | - |
| `name` | `string` | — | **Required.** The name of the agent |
| `project` | `string` | — | **Required.** The project to add the agent to |
| `model` | `string` | `gpt-4` | The LLM model name |
| `tools` | `string` | — | Comma-separated tool names to reference |
| `directory` | `string` | — | Subdirectory within `src/agents/` |

## Generated Code

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

import WebSearchTool from '../tools/web-search.tool';
import SummarizeTool from '../tools/summarize.tool';

@Agent({
  name: 'researcher',
  description: 'TODO: describe what this agent does',
  llm: {
    provider: 'anthropic',
    model: 'claude-sonnet-4-5-20250514',
    apiKey: { env: 'ANTHROPIC_API_KEY' },
  },
  inputSchema: {
    task: z.string().describe('TODO: describe the task the agent should perform'),
  },
  tools: [WebSearchTool, SummarizeTool],
  systemInstructions: 'TODO: define system instructions for this agent',
})
export default class ResearcherAgent extends AgentContext {
  async execute(input: { task: string }) {
    // The default implementation runs the LLM loop with the agent's tools.
    return super.execute(input);
  }
}
```

* The LLM provider follows the model name: models starting with `claude` use `anthropic` and read `ANTHROPIC_API_KEY`; everything else uses `openai` and reads `OPENAI_API_KEY`. Set the variable in the environment that runs the server.
* Each name in `--tools` becomes an import of `../tools/<name>.tool` (relative to the agent file) and a class reference in `tools`. Names are de-duplicated, so `--tools search,search` imports the tool once. Generate the tools first with the [tool generator](/frontmcp/nx-plugin/generators/tool) so the imports resolve.


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