The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
---
title: Syncing & recovery
description: Which command to use when, how to read the sync output, and a recovery ladder for when local metadata drifts — before reaching a full reset.
---
import { PageBanner } from "/snippets/page-banner.mdx"
## Overview
Local app development revolves around **syncing**: the CLI rebuilds your manifest and the server applies only the difference between it and the metadata already in your workspace. This page covers which command to reach for, how to read what a sync changed, and what to do — in order — when local state looks inconsistent.
## Which command, when
<Note>
For day-to-day local iteration you almost always want `twenty app dev`.
Deploying and publishing are for shipping releases, **not** for the local
loop.
</Note>
| You want to… | Command | Notes |
| ------------------------------------------ | ------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------- |
| Iterate locally with live sync | `twenty app dev` | Watches your files and syncs on every change. |
| Sync once and exit (CI, scripts, hooks) | `twenty app apply` | One build + sync, then exits. Add `--yes` to skip the destructive-change confirmation. |
| Preview changes **without applying them** | `twenty app plan` | Builds locally and prints the diff; does not change the workspace. |
| Sync without deleting anything | `twenty app apply --no-prune` | Creates and updates only: entities that exist in the workspace but not in your source are left alone. Also accepted by `plan` and `dev`. |
| Prune the workspace Custom application | `twenty app apply --prune` | That app keeps entities missing from source unless you pass `--prune`. Also accepted by `plan` and `dev`. |
| Regenerate local source from the workspace | `twenty app pull` | **Experimental.** Restores define files, translations and stored dependencies. See below. |
| Remove the app from the workspace | `twenty app uninstall` | Add `--yes` to skip the prompt. |
| Ship a tarball to a server | `twenty app publish --private` | Requires a **strictly higher** `package.json` version — see [Publishing](/developers/extend/apps/operations/publishing). |
| Publish to the marketplace (npm) | `twenty app publish` | — |
| Install / upgrade a deployed version | `twenty app install` | Installs the version currently deployed. |
### Local sync does not need a version bump
The strictly-increasing `version` rule (`VERSION_ALREADY_EXISTS` on deploy, `APP_ALREADY_INSTALLED` / `CANNOT_DOWNGRADE_APPLICATION` on install) applies to **`twenty app publish` / `twenty app install`** — the release path. `twenty app dev` syncs your manifest in place and never requires a version change, so you don't need to touch `package.json` to iterate. If you find yourself bumping the version to test a local change, you're using the release path when you want the dev loop.
## Reading the sync output
Every sync prints the metadata changes it applied (or would apply, with `plan`), Terraform-style — one block per entity with its attributes, then a summary line:
```text filename="Terminal"
# objectMetadata "rocket" will be created
+ icon = "IconRocket"
+ labelSingular = "Rocket"
+ ...
# fieldMetadata "launchedAt" will be updated
~ isNullable = false -> true
Plan: 2 to add, 1 to change, 1 to destroy.
✓ Synced My App (4 files)
```
This is your first diagnostic: it tells you exactly which objects, fields, and layouts changed, so you can confirm a sync did what you expected before checking the UI.
Destructive changes (`to destroy`) are listed with what they drop (e.g. `objectMetadata "auditNote" — drops the table and all its rows`) and require interactive confirmation, or `--yes` in scripts.
A sync deletes every entity your app owns that your source no longer declares. When a plan contains destroys it says so and points at `--no-prune` (formerly `--no-delete`, which still works), which makes the sync additive: creates and updates are applied, nothing missing from your source is deleted, and the settings component and uninstall hook bindings of the app stay as they are when your source does not declare them. Use it when your source is intentionally partial, for example while adopting an app that was built in the UI. The workspace Custom application is the exception: since pull cannot export everything it owns yet, its sync is additive unless you pass `--prune`. Servers released before this change still delete by default, so pass `--no-prune` when applying the Custom application to one.
When a sync fails on a single entity, the error names the offending entity and its `universalIdentifier`, for example:
```text
Migration action 'create' for 'fieldMetadata' (universalIdentifier: 2020...4337) failed
```
Use that identifier to find the entity in your manifest (and, if needed, in the workspace) instead of guessing which one conflicts.
## Previewing changes (plan)
`twenty app plan` builds your manifest, asks the server for the migration plan, and prints it — **without applying anything**. It's the safe way to answer "what would this sync change?" before committing to it.
```bash filename="Terminal"
twenty app plan
```
```text filename="Terminal"
Building manifest...
Computing metadata plan (read-only, nothing will be applied)...
# fieldMetadata "crewCapacity" will be created
+ ...
Plan: 1 to add, 1 to change, 0 to destroy.
✓ Plan complete for My App — no changes were applied
```
A plan:
- **Does not change the workspace**, no metadata migration, application record update, or default role/tab changes. It builds a local snapshot but does not regenerate the API client.
- Returns the **same diff** a real sync would apply, so you can review created/updated/deleted entities up front.
- Is useful before a risky change, when reviewing an AI-generated change, or in a script that should fail if an unexpected change is about to land.
<Note>
A plan only previews **metadata** changes. It also works for an app that was
never synced: the server evaluates the manifest against an empty application,
so the plan lists everything your source would create.
</Note>
## Pulling an installed app back to source
<Warning>
`twenty app pull` is **experimental**. It covers only part of an application
today, its output shape may change between releases, and it overwrites the
files that define the entities it pulls. It restores published translations
into `locales/`, keeping the entries whose source strings are not in your tree
yet in `locales/compiled/` so that a push does not lose them. Commit your work
before running it, and review the diff.
</Warning>
`twenty app pull` is the inverse of `apply`: it reads an application out of the workspace and restores its define files, translations and stored dependency files.
```bash
twenty app pull --remote dev
twenty app pull --path ./workspace-app --yes --no-input
```
Inside an app, pull reads its local `defineApplication()` identifier and retrieves that application. Outside an app, it asks for a directory and confirmation, creates a local project for the selected workspace's custom application, installs dependencies with Yarn, then pulls the definitions. The new project includes package and configuration files, without the initializer's demo entities.
Use `--path` to select an existing app or a new or empty directory. Noninteractive creation requires `--path` and `--yes`; pull refuses to overwrite an unrelated nonempty directory. Creating a project does not register an application or change the workspace. An existing SDK project without an application definition also pulls the custom application. There is no `--universal-identifier` option.
If dependency installation fails for a new project, the scaffold is kept. Run `yarn install` inside it, then retry pull. Existing projects do not install dependencies automatically. If their application identifier cannot be read, pull reports that error instead of creating another app. Add `--verbose` to expand the coverage sections of the report, which then name up to 20 identifiers per metadata type instead of only the totals.
**What it writes:**
- the application config;
- stored `package.json` and `yarn.lock` dependency files, at the project root;
- objects, with their fields inline;
- fields your app added to objects it does not own;
- authored indexes;
- permission flags your app declares, as `definePermissionFlag()` files;
- roles, with their object permissions, field permissions, row-level permission predicates and groups, and permission flags inline. Your app's default role is written with `defineApplicationRole()`. An object or field permission whose identifier is the one the build derives is written without it. When the default role is not one of your app's own roles, as for the workspace Custom application, the application config keeps `defaultRoleUniversalIdentifier` instead;
- views, with their fields, field groups, filters, filter groups, sorts and groups inline;
- view fields your app added to views it does not own, as standalone `defineViewField()` files;
- page layouts, with their tabs and widgets inline;
- tabs your app added to page layouts it does not own, as standalone `definePageLayoutTab()` files;
- navigation menu items, as `defineNavigationMenuItem()` files, folders included;
- widgets your app added to tabs it does not own, as standalone `definePageLayoutWidget()` files;
- workflows, as `defineWorkflow()` files, when their stored version is the one the last sync wrote. For the workspace Custom application, it is the active version, whether a sync or the workflow builder published it, and apply publishes a changed definition as a new version, as described in [Workflows](/developers/extend/apps/logic/workflows#workflows-of-the-workspace-custom-application);
- skills, as `defineSkill()` files;
- agents, as `defineAgent()` files, with their triggers and the role your app binds them to;
- validation rules, as `defineValidationRule()` files with their expression as a string;
- published translations, as `locales/<locale>.json` for the strings pull can read back from the pulled metadata and source, and `locales/compiled/<locale>.json` for the rest.
Each entity goes to the file that already defines it, so a second pull rewrites only what changed on the server. A file is also rewritten when it uses a different define function than pull would write, for example a role that became or stopped being the default role. New entities are placed beside existing files of their kind, and a generated name that would land on an unrelated file is qualified rather than overwriting it.
**Dependency files.** When the stored `package.json` or `yarn.lock` changes, pull replaces the local file and reports any overwritten local edits. If the remote file has not changed since the previous pull, local edits are kept. A missing remote file does not delete its local counterpart. When the exported package omits `twenty-sdk`, as the workspace Custom application does, pull retains your local SDK dependency so CLI commands can still load the project. Dependency files, metadata and the baseline are written together and rolled back together if a write fails.
Run `yarn install` after pulling dependency changes. Pull installs dependencies only when creating a new project, before restoring the remote files; it does not reinstall them after replacing `package.json` or `yarn.lock`. Pull does not regenerate the typed client. Run `twenty app generate-client` when you need updated workspace types.
**What it does not write:**
- **Not exported yet** — command menu items and settings menu items, logic functions and front components, connection providers, application variables, public assets, timeline activity types, and the stored source of your functions.
- **Derived by the engine** — system fields, default relations, default views and backing indexes, and the default page layouts of each object. The server rebuilds them on apply. An object may still point its label identifier at one of them, as junction objects created in the UI do; the pointer is written and the build resolves it without adding a field.
- **Placed on a default or foreign view** — filters, filter groups, sorts, groups and field groups added to an engine default view, or to a view owned by another application, have no source form yet and are reported. View fields added there are written as standalone files, since the view's identifier is known.
- **Placed on a default or foreign page layout** — tabs and widgets added to an engine default page layout, or to one owned by another application, are written as standalone `definePageLayoutTab()` and `definePageLayoutWidget()` files, since the identifier they attach to is known.
- **Widgets the export cannot carry yet** — on any layout, including your own, a widget of the deprecated `VIEW` type, a widget showing one of your app's own front components or command menu items, or a widget without a position for its tab's layout mode is reported, and the layout or tab is written without it.
- **Workflows the export cannot carry yet** — a workflow changed in the workflow builder since the last sync, a system or private workflow, one with a Code or chat message step, which application workflows don't support, and one calling another app's workflow action are reported and left in place. The workspace custom application is the exception for the first and last cases: the builder publishes its workflows too, and they may call any app's actions, so they are pulled. One of its workflows is reported instead when it has no active version, or when its active version uses settings a definition can't express. Email and calendar steps are pulled: an account shared with the workspace is written as its `connectedAccountHandle`, while a member's private account and variables are kept as they are. The workflow is reported instead when a step's account is archived, can no longer run the step, or shares its address with an older account, since applying the handle would pick another account.
- **Agents the export cannot carry yet** — an agent on more than one role, or bound to a role pull does not write, is reported and left in place.
- **Validation rules the export cannot carry yet** — a rule with no expression or message, such as an unfinished draft from Settings, or one that reads a field deleted from the workspace, is reported and left in place.
- **Workspace runtime state**, record attachments, email attachments, member and API-key role assignments, webhooks, per-user navigation and navigation items pinned to a record, all excluded by design, including for the workspace Custom application.
- **Owned by another application** — reported, never pulled.
The report at the end of a pull lists all of it, grouped by kind and reason. Everything it names as not written is still in your workspace, so push a pulled tree back with `twenty app apply --no-prune` until the missing kinds are covered. The workspace Custom application already applies this way by default. A pruning apply (the default for other apps, `--prune` for the Custom application) would delete them, and `twenty app plan` lists exactly which.
**Workspace-local state.** An entity deactivated in the workspace is written as an active definition, and the overrides the workspace made on an entity, such as a renamed label, are not written. The report lists those rows under "Written without their workspace-local state". Applying the tree back to the same workspace leaves that state untouched; another workspace gets the entity active and without the overrides.
**The base file.** Pull records what it pulled in `.twenty/cli/pull-base.json`, which is gitignored and per checkout. That file is what a later pull compares against to leave untouched the files whose entity did not change, and to delete the file of an entity that is gone from the workspace. A checkout without it simply writes everything and deletes nothing.
## Recovery ladder
When local metadata looks wrong, escalate in this order and stop as soon as you're unblocked. Each step is more disruptive than the last.
1. **Re-sync.** Run `twenty app apply` again. Syncs are idempotent — re-running a clean manifest is safe and often resolves a transient hiccup.
2. **Preview the plan.** Run `twenty app plan` to see exactly what the next sync intends to change, without applying it.
3. **Read the named error.** If a sync fails, note the metadata type and `universalIdentifier` in the message (see above) and locate that entity in your manifest. A conflict usually points to a duplicated or re-used identifier.
4. **Uninstall and reinstall.** `twenty app uninstall`, then sync again (`twenty app dev`). This rebuilds the app's metadata from a clean slate while keeping the rest of your workspace intact.
5. **Full reset (last resort).** For a CLI-managed local environment, run `twenty local reset`, then `twenty local start` and reconnect before syncing again. For a source checkout, reset and re-seed its development database instead.
<Warning>
Resetting your local environment or repository development database deletes
**all** data in your local instance, every workspace, record, and app. Only
use it once the earlier steps have failed.
</Warning>
<Note>
Hit a metadata error? Please [open an
issue](https://github.com/twentyhq/twenty/issues/new/choose) and include the
failing migration message (with its metadata type and `universalIdentifier`),
the `Metadata changes` output from the sync, and the commands you ran.
</Note>
## Avoid concurrent syncs on one workspace
Syncing applies metadata migrations. Running several sync, deploy, or install operations against the **same workspace at the same time** — for example, multiple terminals or AI agents iterating in parallel — can interleave those migrations and leave metadata in a partially-applied state.
The server serializes syncs per workspace to prevent this, but you should still funnel sensitive metadata operations through a **single** process rather than firing them concurrently. If you orchestrate development with multiple agents, route their sync/deploy/install calls through one queue so only one runs at a time.
## Telling failures apart
When something goes wrong, the metadata diff and named errors let you place the failure:
- **Manifest build error** — the CLI fails before syncing (`MANIFEST_BUILD_FAILED`, `TYPECHECK_FAILED`); fix your app source.
- **Registration ownership error** — the sync is refused because the app's `universalIdentifier` belongs to another workspace, or to no workspace at all; see [Registration ownership](/developers/extend/apps/operations/publishing#registration-ownership).
- **Sync / migration error** — the build succeeds but applying the diff fails, naming the entity and `universalIdentifier`; fix the conflicting metadata.
- **Dependencies size error** — the sync or install fails because the app's production `dependencies` are too large to install as a runtime layer (`LOGIC_FUNCTION_DEPENDENCIES_SIZE_EXCEEDED`); move packages your logic functions do not import at runtime (UI libraries, dev tooling) to `devDependencies`.
- **Deferred migration in progress** — the sync is refused because a background data model migration from an earlier sync is still running (`DEFERRED_WORKSPACE_MIGRATION_ACTIONS_IN_PROGRESS`); wait for it to finish, then sync again.
- **App code runtime error** — the sync succeeds but your logic functions or components misbehave at runtime; check [function logs](/developers/extend/apps/operations/cli).
- **Local instance state** — none of the above and the workspace still looks wrong; work down the recovery ladder.
<PageBanner illustration="card-page-sync-recovery" />