syncore-cli-codegen
Syncore CLI And Codegen
Use this skill when working on @syncore/cli, generated files, or the
developer loop inside a Syncore app.
Documentation Sources
Read these first:
packages/core/src/cli.tspackages/cli/src/index.tspackages/cli/AGENTS.mdREADME.mddocs/development.mddocs/architecture.md
Instructions
CLI Commands
The current CLI surface includes:
npx syncorejs initnpx syncorejs codegennpx syncorejs doctornpx syncorejs import --table <table> <file>npx syncorejs seed --table <table>npx syncorejs seed --table <table> --file <file>npx syncorejs migrate:statusnpx syncorejs migrate:generate [name]npx syncorejs migrate:applynpx syncorejs dev
init
syncorejs init scaffolds the standard project layout and supports templates
such as minimal, node, react-web, expo, electron, and next.
Core scaffold output is:
syncore.config.tssyncore/schema.tssyncore/functions/tasks.tssyncore/migrations/syncore/_generated/
Template-specific files are added on top of that. Current scaffolding does not
create a special syncore/crons.ts file.
codegen
syncorejs codegen scans syncore/functions/**/*.ts, finds exported query,
mutation, and action definitions, and generates:
syncore/_generated/api.tssyncore/_generated/functions.tssyncore/_generated/server.ts
The generated API must preserve end-to-end types by referencing function
definitions through createFunctionReferenceFor<typeof ...>(...).
Generated server helpers currently re-export action, mutation, query,
createFunctionReference, createFunctionReferenceFor, and v.
dev
syncorejs dev is the main local development loop. It can scaffold a missing
Syncore project, then bootstraps codegen and migration work, starts the
devtools hub and dashboard shell when available, and watches relevant project
inputs.
import And seed
Use import to load JSONL data into an explicit table and file path.
Use seed to load conventional sample data from syncore/seed.jsonl or
syncore/seed/<table>.jsonl, or from an explicit --file path.
Migrations
The CLI compares the current schema against a stored snapshot and renders SQL for safe changes.
Typical flow:
npx syncorejs migrate:status
npx syncorejs migrate:generate add_notes_table
npx syncorejs migrate:apply
migrate:generate accepts an optional name and falls back to auto.
Monorepo Constraint
Inside the Syncore repo, examples intentionally run codegen from CLI source or
from already-built workspace packages. Avoid changes that require unrelated
shared dist output to exist while parallel tasks are running.
Examples
Typical App Loop
npx syncorejs dev
npx syncorejs doctor
npx syncorejs import --table tasks sampleData.jsonl
npx syncorejs seed --table tasks
Generated API Pattern
Codegen should emit references shaped like this:
import { createFunctionReferenceFor } from "syncorejs";
import type { FunctionReferenceFor } from "syncorejs";
import {
create as tasks__create,
list as tasks__list
} from "../functions/tasks";
export const api = {
tasks: {
list: createFunctionReferenceFor<typeof tasks__list>("query", "tasks/list"),
create: createFunctionReferenceFor<typeof tasks__create>(
"mutation",
"tasks/create"
)
}
} as const;
Best Practices
- Treat codegen regressions as high-priority DX issues
- Keep generated files as outputs, never hand-maintained sources
- Preserve
createFunctionReferenceFor<typeof ...>in generated API files - Prefer
import typewhere generated code only needs type positions - Verify codegen changes with CLI tests and example integrations
- Keep the dev loop independent from workspace
distartifacts when examples are involved - Document
syncorejs devas the happy path unless the task is specifically about one-off commands
Common Pitfalls
- Breaking type flow by emitting looser generated reference types
- Requiring built CLI output during parallel example validation
- Fixing generated files manually instead of fixing the template source
- Treating migration SQL as unreviewed boilerplate
- Documenting scaffolded files that the current templates no longer create
References
packages/core/src/cli.tspackages/cli/src/index.tspackages/cli/AGENTS.mdREADME.mddocs/development.md