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

# Configuration

> Overview of all AgentXP configuration options and how to apply them.

# Configuration

> Overview of all AgentXP configuration options and how to apply them.

Configure AgentXP by passing an options object directly to `withAgentXP()` in your `middleware.ts`. No separate config file is required.

```typescript middleware.ts theme={null}
import { withAgentXP } from '@reaganhsu/agentxp-next'

export default withAgentXP({
  detection: { /* ... */ },
  transform: { /* ... */ },
  permissions: { /* ... */ },
  llmsTxt: { /* ... */ },
  siteHeader: { /* ... */ },
})

export const config = {
  matcher: ['/((?!_next/static|_next/image|favicon.ico).*)'],
}
```

## Type-safe config with `defineConfig()`

For projects where you want to define configuration separately and get full TypeScript inference, import `defineConfig()` from `@reaganhsu/agentxp-core`:

```typescript agentxp.config.ts theme={null}
import { defineConfig } from '@reaganhsu/agentxp-core'

export default defineConfig({
  detection: { /* ... */ },
  transform: { /* ... */ },
  permissions: { /* ... */ },
})
```

Then spread it into `withAgentXP()`:

```typescript middleware.ts theme={null}
import { withAgentXP } from '@reaganhsu/agentxp-next'
import agentxpConfig from './agentxp.config'

export default withAgentXP({
  ...agentxpConfig,
  llmsTxt: {
    siteName: 'My App',
  },
})
```

<Note>
  `defineConfig()` is a zero-overhead identity function — it exists solely for TypeScript autocompletion and type-checking. It does not load, validate, or transform your config at runtime.
</Note>

## Configuration shape

The object passed to `withAgentXP()` accepts the following top-level keys:

| Key           | Type     | Description                                                    |
| ------------- | -------- | -------------------------------------------------------------- |
| `detection`   | `object` | Controls how AgentXP identifies AI agent requests              |
| `transform`   | `object` | Controls HTML-to-markdown conversion                           |
| `permissions` | `object` | Signals what agents are permitted to do with your content      |
| `llmsTxt`     | `object` | Configures the auto-generated `/llms.txt` index                |
| `siteHeader`  | `object` | Manual navigation context prepended to every markdown response |

## Complete example

```typescript middleware.ts theme={null}
import { withAgentXP } from '@reaganhsu/agentxp-next'

export default withAgentXP({
  detection: {
    signals: ['accept-header', 'user-agent'],
    customAgents: [
      { name: 'MyBot', pattern: /MyCustomBot\/\d+/i },
    ],
  },

  transform: {
    contentSelector: 'main',
    excludeSelectors: ['.chat-widget', '.cookie-banner', '#intercom-container'],
    maxTokens: 8000,
  },

  permissions: {
    aiTrain: false,
    aiInput: true,
    search: true,
  },

  llmsTxt: {
    siteName: 'My SaaS App',
    description: 'Project management tool for engineering teams',
    pages: [
      { path: '/', title: 'Home', section: 'Product' },
      { path: '/pricing', title: 'Pricing', section: 'Product' },
      { path: '/docs', title: 'Documentation', section: 'Documentation' },
      { path: '/blog', title: 'Blog', section: 'Resources' },
    ],
  },

  siteHeader: {
    name: 'My App',
    links: [
      { text: 'Docs', href: '/docs' },
      { text: 'Pricing', href: '/pricing' },
      { text: 'Blog', href: '/blog' },
    ],
  },
})

export const config = {
  matcher: ['/((?!_next/static|_next/image|favicon.ico).*)'],
}
```

## Configuration sections

<CardGroup cols={2}>
  <Card title="Detection" icon="radar" href="/docs/configuration/detection">
    Configure which signals AgentXP uses to identify AI agents.
  </Card>

  <Card title="Transform" icon="wand-magic-sparkles" href="/docs/configuration/transform">
    Control how HTML pages are converted to markdown.
  </Card>

  <Card title="Permissions" icon="shield-check" href="/docs/configuration/permissions">
    Signal what agents may do with your content.
  </Card>

  <Card title="llms.txt" icon="file-lines" href="/docs/configuration/llms-txt">
    Configure the auto-generated site index for AI agents.
  </Card>
</CardGroup>
