struere dev
Watch files and sync to Convex on change
The dev command is your primary development workflow. It loads all resource definitions from your project, syncs them to the Convex backend in the development environment, and watches for file changes to re-sync automatically.
Usage
npx struere dev
Options
| Flag | Description |
|---|---|
--force |
Skip the destructive sync confirmation prompt. By default, dev warns you if the sync would delete remote resources not present locally. |
How It Works
The dev command follows this flow:
- Auto-init — If no
struere.jsonexists, runs the initialization flow - Auto-login — If not authenticated, opens a browser for OAuth
- Load resources — Reads all files from
agents/,entity-types/,roles/,triggers/, andtools/directories - Build sync payload — Assembles all resources into a single payload via
extractSyncPayload() - Sync to Convex — Sends the payload to the
syncOrganizationmutation - Watch for changes — Uses chokidar to monitor all resource directories
- Re-sync on change — When any file is added, modified, or deleted, reloads and re-syncs
Sync Payload
The CLI assembles all your local definitions into a single sync payload:
{
agents: [...],
entityTypes: [...],
roles: [...],
triggers: [...]
}
Each resource is upserted by its slug or name, so both new resources and updates are handled transparently.
Sync HTTP Request
Under the hood, the CLI sends the payload to Convex via an HTTP mutation:
POST /api/mutation
Authorization: Bearer {token}
Content-Type: application/json
{
"path": "sync:syncOrganization",
"args": {
"agents": [...],
"entityTypes": [...],
"roles": [...],
"triggers": [...]
}
}
Environment
The dev command always syncs to the development environment. All entity types, roles, agent configurations, and triggers are scoped to development. This ensures your changes do not affect production data or behavior.
To deploy to production, use struere deploy.
File Watching
The CLI watches the following directories for changes:
agents/— Agent definition filesentity-types/— Entity type schema filesroles/— Role definition filestriggers/— Trigger definition filestools/— Custom tool definition filesevals/— Eval suite definition files
When a file is added, modified, or deleted, the CLI:
- Reloads all resources from disk
- Builds a fresh sync payload
- Sends the full payload to Convex
This means the sync is always a complete snapshot of your local state, not incremental changes.
Example Workflow
npx struere dev
With the dev command running, open a separate terminal and create resources:
npx struere add agent scheduler
The dev process will detect the new file and sync it automatically. Edit the generated agents/scheduler.ts file and save — the changes will sync within seconds.
Convex Sync Functions
The backend processes the sync payload through these functions:
| Function | Purpose |
|---|---|
syncOrganization |
Bulk upsert all resources (agents, entity types, roles, triggers) |
getSyncState |
Return current remote state for comparison |
The sync helpers upsert resources by slug, creating new records or updating existing ones as needed.
Troubleshooting
If the sync fails, the CLI will display the error message from Convex. Common issues include:
- Invalid schema — Entity type schemas must be valid JSON Schema objects
- Duplicate slugs — Each resource type must have unique slugs within an organization
- Authentication expired — Re-run
struere loginto refresh your token