The twenty CLI's esbuild only externalizes `twenty-client-sdk/{core,metadata}`
when bundling user logic functions and front components. Everything else is
inlined, including `twenty-sdk/define` — which transitively imports `zod` (and
all ~80 locales) and `@sniptt/guards`. Result: a 30-line `defineLogicFunction`
handler compiles to ~1.25 MB of .mjs + ~3.3 MB of .map per file.
`twenty-sdk/define` is an authoring surface: its `defineXxx` helpers only run
build-time validation, and manifest extraction already imports the real module
directly (via `manifest-extract-config-from-file.ts`, unchanged). At runtime,
the server just reads `default.config.handler` / `default.config.component` —
the validation result wrapper and zod schemas are dead weight.
This change adds a zero-dependency runtime stub that passes the config through
untouched, then aliases `twenty-sdk/define` → `twenty-sdk/define-runtime-stub`
in the app-bundle esbuild configs only. Build-time manifest extraction still
uses the real, validating module.
Result on a representative app (twenty-eng, 31 logic functions):
- logic-function .mjs: 1.26 MB → 332 KB (-75%)
- .mjs.map: 3.3 MB → 744 KB (-77%)
Front components still ship ~2 MB because `twenty-sdk/front-component` has the
same zod/sniptt pull-through — that's a follow-up with a different shape
(front-component helpers have real runtime behavior that the host injects, so
a blanket stub doesn't apply).
A CLI and SDK to develop, build, and publish applications that extend Twenty CRM.
Quick start
The recommended way to start is with create-twenty-app:
npx create-twenty-app@latest my-app
cd my-app
yarn twenty dev
Documentation
Full documentation is available at docs.twenty.com/developers/extend/apps:
- Getting Started — scaffolding, local server, authentication, dev mode
- Building Apps — entity definitions, API clients, testing, CLI reference
- Publishing — deploy, npm publish, marketplace
Manual installation
If you are adding twenty-sdk to an existing project instead of using create-twenty-app:
yarn add twenty-sdk twenty-client-sdk
Then add a twenty script to your package.json:
{
"scripts": {
"twenty": "twenty"
}
}
Run yarn twenty help to see all available commands.
Configuration
The CLI stores credentials per remote in ~/.twenty/config.json. Run yarn twenty remote add to configure a remote, or yarn twenty remote list to see existing ones.
Troubleshooting
- Auth errors: run
yarn twenty remote addto re-authenticate. - Typings out of date: restart
yarn twenty devto refresh the client and types. - Not seeing changes in dev: make sure dev mode is running (
yarn twenty dev).
Contributing
Development setup
git clone https://github.com/twentyhq/twenty.git
cd twenty
yarn install
Development mode
npx nx run twenty-sdk:dev
Production build
npx nx run twenty-sdk:build
Running the CLI locally
npx nx run twenty-sdk:start -- <command>