Agent skill

Evolving The Data Model

by TriliumNext in TriliumNext/Trilium

A skill your agent uses when adding a DB migration or a new column/field to a Becca entity in Trilium ("add a migration", "new column on notes/attributes", "ALTER TABLE", "add a field to…

AGPL-3.0Auto-check passedDatabases

Install Evolving The Data Model

skills CLI
$ npx skills add TriliumNext/Trilium --skill evolving-the-data-model -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install TriliumNext/Trilium evolving-the-data-model --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/TriliumNext/Trilium.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.claude/skills/evolving-the-data-model .claude/skills/evolving-the-data-model && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
evolving-the-data-model
GitHub stars
38k
Token cost
~2.1k tokens
SKILL.md length
759 words
Files
6 (incl. references, assets)
Skills in repo
22
Repo updated
First seen
Licence
AGPL-3.0

At a glance

A skill your agent uses when adding a DB migration or a new column/field to a Becca entity in Trilium ("add a migration", "new column on notes/attributes", "ALTER TABLE", "add a field to…

  • Works in 2 steps: schema.sql parity. Fresh installs run… → becca_loader positional misalignment.…
  • Adding a DB migration
  • SKILL.md covers Migrations are not dated .sql…, The two un-guarded hazards…, Decision: what are you doing? and Recipe: add a migration (SQL), plus 3 more sections
  • Runs TypeScript scripts from its folder; calls pnpm

What it does

Evolving The Data Model is an agent skill from TriliumNext/Trilium. Use when adding a DB migration or a new column/field to a Becca entity in Trilium ("add a migration", "new column on notes/attributes", "ALTER TABLE", "add a field to BNote/BAttribute/BBranch", schema change). Migrations are NOT dated .sql files — they are integer-versioned entries in the DESCENDING MIGRATIONS array in packages/trilium-core/src/migrations/migrations.ts (dbVersion is auto-derived from MIGRATIONS[0]), and the schema lives at packages/trilium-core/src/assets/schema.sql. Covers the full file chain…

Its SKILL.md is about 2.1k tokens, which your agent loads only when the skill is triggered. The skill folder holds 7 other files, including reference files and assets (for example `assets/0NNN__migration.template.ts`, `assets/migration-spec.template.ts` and `assets/sql-migration.snippet.md`).

It sits in Databases, covering SQL and Database migrations. It works with SQL. The repository describes itself as: Build your personal knowledge base with Trilium Notes. The licence is AGPL-3.0.

When your agent uses it

  • Adding a DB migration
  • A new column/field to a Becca entity in Trilium (add a migration
  • New column on notes/attributes
  • Add a field to BNote/BAttribute/BBranch

Example prompts

  • “add a migration”
  • “new column on notes/attributes”
  • “ALTER TABLE”
  • “/evolving-the-data-model”

Requirements

  • Node.js

Workflow steps

2 steps, taken from the first numbered list in SKILL.md.

  1. schema.sql parity. Fresh installs run sql.executeScript(schema) and never replay migrations (sql_init.ts:154, also :288 for sync setup). A…
  2. becca_loader positional misalignment. notes, branches, attributes load via sql.getRawRows(...) (positional arrays) fed to new…

What it can do on your machine

Read from SKILL.md and the folder at commit 134a865. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Ships script files (TypeScript), which the agent can run.

    Shell commands in SKILL.md call:

    • pnpm

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md. Its commands use pnpm, which can reach the network depending on how they are called.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Evolving The Data Model loads about 2.1k tokens when it runs, and up to ~4.8k if it reads all its reference files. Until then it costs about 165 tokens; SKILL.md has 759 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~165
When it runs · the whole SKILL.md, loaded when a task matches
~2.1k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~4.8k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from TriliumNext/Trilium at commit 134a865, republished under its AGPL-3.0 licence (© TriliumNext). 759 words, ~2,117 tokens.

Download SKILL.mdSave it as .claude/skills/evolving-the-data-model/SKILL.md (or your agent's skills folder). This skill also uses 5 other files; get the full folder from GitHub.
name
evolving-the-data-model
description
Use when adding a DB migration or a new column/field to a Becca entity in Trilium ("add a migration", "new column on notes/attributes", "ALTER TABLE", "add a field to BNote/BAttribute/BBranch", schema change). Migrations are NOT dated .sql files — they are integer-versioned entries in the DESCENDING MIGRATIONS array in packages/trilium-core/src/migrations/migrations.ts (dbVersion is auto-derived from MIGRATIONS[0]), and the schema lives at packages/trilium-core/src/assets/schema.sql. Covers the full file chain for a column-add, the hashedProperties cross-instance sync-hash hazard, CLS-wrapped JS migrations, and the spec harness.

Evolving the Trilium data model

Migrations are not dated .sql files — start here

The intuitive guess — dated SQL files under apps/server plus a matching schema.sql there — is wrong on both counts. Neither of these paths exists:

Easy wrong guessReality
apps/server/src/migrations/YYMMDD_HHMM__description.sqlNo such directory. Migrations are not dated .sql files — they're entries in the MIGRATIONS array (below).
apps/server/src/assets/db/schema.sqlNo such file. The schema for fresh installs lives in core.

Verified absent: Glob apps/server/src/migrations/** and Glob apps/server/src/assets/db/schema.sql both return nothing.

Ground truth:

  • Migrations — packages/trilium-core/src/migrations/migrations.ts. One MIGRATIONS array of { version, sql, ignoreErrors? } (SQL) or { version, module } (JS) objects, kept in DESCENDING version order (newest first). Top entry today is version: 240 (migrations.ts:15).
  • Schema for fresh installs — packages/trilium-core/src/assets/schema.sql.
  • dbVersion is auto-derived, never hand-bumped: getMaxMigrationVersion() returns MIGRATIONS[0].version (migrations.ts:6-8) → appInfo.dbVersion (app_info.ts:11) → isDbUpToDate() compares dbVersion >= appInfo.dbVersion (migration.ts:120-130, the comparison at :123).

The two un-guarded hazards (most data-model bugs are one of these)

migrations.spec.ts already asserts unique + descending versions (migrations.spec.ts:5-18), so a misordered/duplicate version IS caught at CI if you run the tests. The genuinely silent traps are:

  1. schema.sql parity. Fresh installs run sql.executeScript(schema) and never replay migrations (sql_init.ts:154, also :288 for sync setup). A column added only via ALTER TABLE in a migration is MISSING on every freshly-created DB unless you hand-mirror it into schema.sql. No test compares fresh-vs-migrated schema.
  2. becca_loader positional misalignment. notes, branches, attributes load via sql.getRawRows(...) (positional arrays) fed to new BAttribute().update(row), whose destructure order must match the SELECT column order exactly (becca_loader.ts:53 ↔ battribute.ts:57). Add a column to one and not the other (or in the wrong position) and every loaded entity silently gets shifted field values — no compile error, no test failure.

A third, deliberate-only hazard: changing hashedProperties breaks cross-instance sync — see below.

Decision: what are you doing?

TaskFiles to touchTemplate / reference
Pure schema/data fix (rename option, drop table, add index, plain ALTER)migrations.ts (top entry) + schema.sql (mirror)assets/sql-migration.snippet.md
Data transform needing becca/note APIsnew 0NNN__*.ts + migrations.ts (module: entry)assets/0NNN__migration.template.ts
Add a column/field to an existing entitymigration + schema.sql + rows.ts Row + entity (property, updateFromRow/update/getPojo) + becca_loader SELECTreferences/column-add-checklist.md
Change which fields are sync-hashedentity hashedProperties only — STOP, read the hazard firstreferences/sync-hash-hazard.md

Recipe: add a migration (SQL)

  1. Append a new object at the TOP of MIGRATIONS with version: <current MIGRATIONS[0].version + 1> (so today, 241).
  2. For ALTER TABLE ... ADD COLUMN, set ignoreErrors: true (re-running over an already-patched DB must not halt the whole transaction — see 238/236, the only two entries that set it, and the ignoreErrors doc at migrations.ts:370-371).
  3. Mirror the column/table change into schema.sql so fresh installs match.
  4. No appInfo bump — dbVersion reads MIGRATIONS[0] automatically.
ts
// migrations.ts — TOP of the MIGRATIONS array
{
    version: 241,
    sql: /*sql*/`
        ALTER TABLE notes ADD COLUMN color TEXT DEFAULT '' NOT NULL;
    `,
    ignoreErrors: true
},
Show full SKILL.md (329 more words)Show less

Recipe: add a migration (JS/TS)

Use this only when the transform needs becca/note APIs (content, attachments, relations). Pure SQL? Stay in SQL.

  1. Create packages/trilium-core/src/migrations/0NNN__<desc>.ts with a default-exported function.
  2. Wrap all becca/note work in getContext().init(() => { becca_loader.load(); ... }) — without CLS context note.save()/setContent() throw. Models: 0233__migrate_geo_map_to_collection.ts:6-8, 0234__migrate_ai_chat_to_code.ts:5-7.
  3. Reference it from MIGRATIONS with { version: N, module: async () => import("./0NNN__<desc>.js") } — note the .js extension (ESM output), exactly like migrations.ts:73-74.
  4. Add a .spec.ts (see the harness below).

The runner preloads JS modules (prepareMigrations, migration.ts:80-101) then runs everything inside one sql.transactional (migration.ts:46); a failure without ignoreErrors crashes the app so the user can stay on the old version.

Spec harness — don't reinvent it

Two proven styles, both already in-tree:

  • Per-migration unit test — fixture test/fixtures/document.db, insert rows, run the migration fn, assert post-state. Model: migrations/0233__migrate_geo_map_to_collection.spec.ts.
  • End-to-end — migration.migrateIfNecessary() against test/fixtures/document_v214.db, assert a post-migration count. Model: services/migration.spec.ts (asserts SELECT count(*) FROM blobs is 118).

Three harness traps, each load-bearing (copy assets/migration-spec.template.ts):

  • Resolve getSql() inside beforeEach, not at describe-collection time — describe callbacks run before the suite's initializeCore beforeAll, so capturing it eagerly throws "SQL not initialized" (0233__*.spec.ts:33-39 has the explanatory comment).
  • sql.rebuildFromBuffer(readFileSync(fixture)) per test to avoid cross-test leakage (0233__*.spec.ts:43-44).
  • Call becca_loader.load() after raw INSERTs and again after running the migration, all inside cls.getContext().init(...), so becca reflects the new DB state (0233__*.spec.ts:112 and :130).

Run a single migration spec:

pnpm --filter server test packages/trilium-core/src/migrations/0233__migrate_geo_map_to_collection.spec.ts

For writing the assertions themselves, see the writing-unit-tests skill (real-DB vs mocked-becca, the cls.init pattern, single-file runner footguns) and analyzing-coverage for chasing the migration's uncovered branches.

Reference map

FileWhen to open
references/column-add-checklist.mdAdding a column/field to notes/attributes/branches — the exact 5-file chain + the SELECT ↔ update([...]) positional diagram, with a full worked attributes example.
references/sync-hash-hazard.mdTouching hashedProperties, or deciding whether a new column should sync-hash. generateHash() → entity_changes → cross-instance content-hash break, with every entity's current hashedProperties list.
assets/sql-migration.snippet.mdCopy-paste SQL MIGRATIONS entries (ALTER ADD COLUMN + generic DDL/data) and the paired schema.sql reminder.
assets/0NNN__migration.template.tsJS/TS migration skeleton with the getContext().init wrapper + the MIGRATIONS entry snippet.
assets/migration-spec.template.tsVitest harness with all three traps pre-handled.

© TriliumNext, AGPL-3.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 5 other files (references, assets) in .claude/skills/evolving-the-data-model of TriliumNext/Trilium.

  • SKILL.md
  • assets/0NNN__migration.template.ts
  • assets/migration-spec.template.ts
  • assets/sql-migration.snippet.md
  • references/column-add-checklist.md
  • references/sync-hash-hazard.md

Open the folder on GitHubat commit 134a865

Compare with similar skills

Evolving The Data Model next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Evolving The Data Model compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Evolving The Data Model this skillTriliumNext/Trilium38k—~2.1kAutomated safety check: PassAGPL-3.0
DB Migrationskurealnum/dotfiles290—~820Automated safety check: PassNone
Forge Business Flow Developmentyaomindong1996/forge-admin125—~1.3kAutomated safety check: PassApache-2.0
Migrationkortix-ai/suna20k—~1.2kAutomated safety check: PassCustom licence
Migrate Createruvnet/ruflo74k—~583Automated safety check: NotesMIT
Data Modelgenkovich/sdd171—~4kAutomated safety check: PassMIT

Similar skills

  • DB Migrations

    kurealnum/dotfiles

    A skill your agent uses when generating or regenerating Drizzle migration files, changing database schema tables or columns, resolving migration sequence conflicts after rebase, reviewing migration…

    290 GitHub stars~820 tokensUpdated 5 mo ago
    DatabasesAuto-check passed
  • Forge Business Flow Development

    yaomindong1996/forge-admin

    Develop Forge business approval workflows backed by Flowable, using the current sample purchase order approval as the reference.

    125 GitHub stars~1.3k tokensUpdated yesterday
    DatabasesAuto-check passed
  • Migration

    kortix-ai/suna

    How to change the database schema in this repo. An agent skill from kortix-ai/suna.

    20k GitHub stars~1.2k tokensUpdated today
    DatabasesAuto-check passed
  • Migrate Create

    ruvnet/ruflo

    Create a new sequentially numbered database migration with up/down SQL files

    74k GitHub stars~583 tokensUpdated today
    DatabasesAuto-check: notes
  • Data Model

    genkovich/sdd

    A skill your agent uses to design the data model AND generate the actual forward + rollback migrations in one pass — shippable SQL, not a plan.

    171 GitHub stars~4k tokensUpdated 1 mo ago
    DatabasesAuto-check passed
  • Cockroachdb Engineer

    FerroxLabs/wayland

    CockroachDB distributed SQL expert covering multi-region deployment, survivability goals, schema design for distributed systems, online schema changes, transaction contention management, follower…

    608 GitHub stars~4k tokensUpdated yesterday
    DatabasesAuto-check passed

More from TriliumNext/Trilium

All 22 skills in this repo
  • Cutting A Release

    TriliumNext/Trilium

    A skill your agent uses when cutting, preparing, or debugging a Trilium release — bumping the monorepo version, tagging, or diagnosing a failed "Release" workflow run.

    38k GitHub stars~3.2k tokensUpdated today
    Auto-check passed
  • Developing Electron Desktop

    TriliumNext/Trilium

    A skill your agent uses when working on the Trilium Electron desktop app (apps/desktop) — adding or changing an electronApi method / IPC channel, touching preload.ts, main.ts, services/window.ts or…

    38k GitHub stars~5.7k tokensUpdated today
    Auto-check passed
  • Adding Internal API Route

    TriliumNext/Trilium

    A skill your agent uses when adding, moving, or wiring an internal REST endpoint in Trilium (a new /api/ route) — choosing between a core-shared handler (packages/trilium-core/src/routes/index.ts…

    38k GitHub stars~3.3k tokensUpdated today
    Auto-check passed
  • Adding LLM MCP Tools

    TriliumNext/Trilium

    A skill your agent uses when adding, changing, or reviewing an LLM/MCP tool in Trilium (the defineTools definitions under packages/trilium-core/src/services/llm/tools/ —…

    38k GitHub stars~2.5k tokensUpdated today
    Auto-check passed
  • Ckeditor5 Plugin Development

    TriliumNext/Trilium

    Write, extend, and review CKEditor 5 plugins in the Trilium (TriliumNext Notes) monorepo — the rich-text-note editor under packages/ckeditor5, whose plugins live in src/plugins/.

    38k GitHub stars~4.8k tokensUpdated today
    Auto-check passed
  • Ckeditor5 Testing

    TriliumNext/Trilium

    Testing CKEditor 5 plugins in the Trilium monorepo. An agent skill from TriliumNext/Trilium.

    38k GitHub stars~3.3k tokensUpdated today
    Auto-check passed

Works with

Categories

Questions about Evolving The Data Model

What does Evolving The Data Model do?

A skill your agent uses when adding a DB migration or a new column/field to a Becca entity in Trilium ("add a migration", "new column on notes/attributes", "ALTER TABLE", "add a field to…. Evolving The Data Model is an agent skill from TriliumNext/Trilium. Use when adding a DB migration or a new column/field to a Becca entity in Trilium ("add a migration", "new column on notes/attributes", "ALTER TABLE", "add a field to BNote/BAttribute/BBranch", schema change).

When should I use Evolving The Data Model?

Evolving The Data Model fits situations like: adding a DB migration; A new column/field to a Becca entity in Trilium (add a migration; new column on notes/attributes; add a field to BNote/BAttribute/BBranch.

How do I install Evolving The Data Model in Claude Code?

Run `npx skills add TriliumNext/Trilium --skill evolving-the-data-model -a claude-code`. Or copy the skill folder (.claude/skills/evolving-the-data-model in TriliumNext/Trilium) into .claude/skills/evolving-the-data-model in your project. Claude Code loads it when a task matches its description.

How do I install Evolving The Data Model in Codex?

Run `npx skills add TriliumNext/Trilium --skill evolving-the-data-model -a codex`. Or copy the skill folder (.claude/skills/evolving-the-data-model in TriliumNext/Trilium) into .agents/skills/evolving-the-data-model in your project. Codex loads it when a task matches its description.

Can I use Evolving The Data Model in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add TriliumNext/Trilium --skill evolving-the-data-model -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/evolving-the-data-model, .gemini/skills/evolving-the-data-model, .github/skills/evolving-the-data-model and .opencode/skills/evolving-the-data-model in your project.

What does Evolving The Data Model need to run?

Going by SKILL.md and its folder, Evolving The Data Model needs TypeScript for the scripts in its folder and the command-line tools its instructions call (pnpm). Our summary lists: Node.js.

Does Evolving The Data Model access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Evolving The Data Model safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Evolving The Data Model use?

Evolving The Data Model is published under the AGPL-3.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Evolving The Data Model use?

About 2.1k tokens (SKILL.md is roughly 8.5k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 2.7k tokens, read only when the agent opens those files.

What are the alternatives to Evolving The Data Model?

Skills that share tags, products or a category with Evolving The Data Model: DB Migrations (kurealnum/dotfiles, 290 stars), Forge Business Flow Development (yaomindong1996/forge-admin, 125 stars), Migration (kortix-ai/suna, 20k stars) and Migrate Create (ruvnet/ruflo, 74k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Evolving The Data Model?

TriliumNext (a GitHub organization) maintains it in TriliumNext/Trilium, which has 38,231 GitHub stars. The repository holds 22 skills in this directory. The repository was last updated on October 7, 2026.

Source: TriliumNext/Trilium on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.