# Introduction (/docs/codegen)



`@kysoql/codegen` reads Salesforce metadata and generates the TypeScript schema Kysoql uses to validate queries.

That schema reflects your org. Custom fields, relationship names, field capabilities, picklist values, and supported object features can all affect what TypeScript allows you to build.

## Install [#install]

For the usual CLI workflow, keep codegen as a development dependency and core as an application dependency:

<Tabs items="[&#x22;npm&#x22;, &#x22;yarn&#x22;, &#x22;pnpm&#x22;, &#x22;bun&#x22;]" defaultIndex="2">
  <Tab value="npm">
    ```bash
    npm install @kysoql/core
    npm install --save-dev @kysoql/codegen
    ```
  </Tab>

  <Tab value="yarn">
    ```bash
    yarn add @kysoql/core
    yarn add --dev @kysoql/codegen
    ```
  </Tab>

  <Tab value="pnpm">
    ```bash
    pnpm add @kysoql/core
    pnpm add -D @kysoql/codegen
    ```
  </Tab>

  <Tab value="bun">
    ```bash
    bun add @kysoql/core
    bun add --dev @kysoql/codegen
    ```
  </Tab>
</Tabs>

Install `@kysoql/codegen` as a normal dependency only when your runtime code calls its library API.

## Configure generation [#configure-generation]

A small config is enough to choose the objects you want:

```ts title="kysoql.config.ts"
import { defineConfig } from "@kysoql/codegen";

export default defineConfig({
  objects: ["Account", "Contact", "User"],
  schemaName: "SalesforceSchema",
});
```

The generator also needs a Salesforce session provider through config `auth` or the `--auth` CLI option. See [configuration](/docs/codegen/configuration) for a complete example.

Run:

```bash
pnpm exec kysoql generate
```

If the project has a `src` directory, the default output is `src/kysoql/salesforce.generated.ts`. Otherwise the generated file is written to `kysoql/salesforce.generated.ts`.

## Keep the schema focused when you need to [#keep-the-schema-focused-when-you-need-to]

By default, selected objects keep all described fields. For very large objects, [field filtering](/docs/codegen/field-filtering) lets you generate an exact include or exclude set without pretending that the omitted fields no longer exist in Salesforce.

Continue with [schema generation](/docs/codegen/schema-generation) for CLI and library workflows.
