Skip to content

Add Trilium-specific Claude Code skills + fix CLAUDE.md path-rot#10148

Open
eliandoran wants to merge 12 commits into
mainfrom
feature/claude_skills
Open

Add Trilium-specific Claude Code skills + fix CLAUDE.md path-rot#10148
eliandoran wants to merge 12 commits into
mainfrom
feature/claude_skills

Conversation

@eliandoran

Copy link
Copy Markdown
Contributor

Summary

A repo-wide audit for ways to improve AI-assistant capabilities (Claude Code / Copilot) surfaced two things: our always-loaded instruction files had rotted, and several recurring, footgun-dense workflows had no captured guidance. This PR fixes the docs and adds seven Trilium-specific custom skills.

1. Fix stale paths in CLAUDE.md + .github/copilot-instructions.md

Server services were relocated apps/server/ → packages/trilium-core/, but the instruction files still cited the old paths. Verified dead and corrected: the DB-migration recipe (it described creating apps/server/src/migrations/*.sql — a path that no longer exists; real migrations are the descending MIGRATIONS array in packages/trilium-core/src/migrations/migrations.ts), schema.sql, options_init, the options route, hidden_subtree, ws, and cls.

2. Seven new skills (.claude/skills/)

Each is footgun-first, carries on-demand reference files, and (where useful) a runnable script:

Skill Covers
evolving-the-data-model DB migrations + Becca entity fields; the hashedProperties cross-instance sync-hash hazard; migration/spec templates
building-client-ui the Preact-hooks model — which froca-reactive hook for which job + the loadResults filter each wires; Modal/LazyDialog wiring
adding-llm-mcp-tools tools exposed to both chat and MCP; why execute must be sync (NotAPromise guard); mutates→transaction; spec harness
adding-internal-api-route core-shared (runs under WASM) vs server-only; the apiRoute sync-transactional trap; implicit return conventions; CoreApiTester
electron-desktop-bridge the contextBridge wiring across 7 handler modules; crash-safety; renderer-input validation. Ships scripts/ipc-parity.mjs
cutting-a-release the two divergent version scripts; the CI gate that checks only 5 of 8 files; release-notes path; RELEASE_PAT. Ships scripts/preflight-release-check.mts
trilium-ckeditor5-integration wiring a CKEditor plugin into Trilium's bundle (the 5 plugin arrays, slash/translation wiring, persistence pipeline, the real GPL+webdriverio test harness)

3. Refresh three existing skills

  • writing-unit-tests — correct the stale "@vitest/browser unconfigured" line (it is configured), add a browser-mode row + a "core specs run twice (server + standalone WASM)" footgun.
  • analyzing-coverage — add the standalone (sqlite-wasm) suite as a third coverage source.
  • translating-locales — distinguish filling vs registering a locale; replace hardcoded coverage figures with measure-first.

How it was verified

Every skill was authored from a spec verified against live code, then reviewed by a second pass that spot-checked citations and ran the scripts (ipc-parity.mjs exits 0; preflight-release-check.mts passes 5 scenarios). The review caught and fixed real citation drift (e.g. a false migration example, inflated hook counts).

Not included / follow-ups

  • The remaining ranked skills (llm-providers-and-streaming has a ready spec; e2e, etapi, standalone-providers, note-types, hidden-subtree, docs, options, packaging, search-modifier).
  • Merging the three upstream ckeditor5-* draft skills (this PR's trilium-ckeditor5-integration is their Trilium companion).

🤖 Generated with Claude Code

@dosubot dosubot Bot added the size:XXL This PR changes 1000+ lines, ignoring generated files. label Jun 13, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a comprehensive suite of Claude "skills" (developer guides, reference documents, templates, and helper scripts) under .claude/skills/ to document and streamline development workflows in Trilium. These cover key areas such as adding internal API routes, LLM/MCP tools, building client UI, release management, Electron desktop bridge, database migrations, and CKEditor 5 integration. It also aligns CLAUDE.md and .github/copilot-instructions.md with these updated guidelines. The feedback on the ipc-parity.mjs script is constructive, suggesting a regex improvement to robustly support asynchronous setup functions.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +174 to +178
for (const fn of matchAll(
text,
/export\s+function\s+((?:setup|register)\w+)\s*\(/g,
(m) => m[1]
)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The regex currently expects synchronous functions (export function ...). If any setup or registration function is made asynchronous in the future (e.g., export async function setupX()), it will be silently skipped by this script. Supporting optional async makes the parser more robust.

Suggested change
for (const fn of matchAll(
text,
/export\s+function\s+((?:setup|register)\w+)\s*\(/g,
(m) => m[1]
)) {
for (const fn of matchAll(
text,
/export\s+(?:async\s+)?function\s+((?:setup|register)\w+)\s*\(/g,
(m) => m[1]
)) {

@eliandoran eliandoran force-pushed the feature/claude_skills branch from 532db4f to aeadd08 Compare June 13, 2026 08:41
@greptile-apps

greptile-apps Bot commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes rotted paths in CLAUDE.md and .github/copilot-instructions.md (server services relocated from apps/server/ to packages/trilium-core/), then adds seven new Trilium-specific Claude Code skills covering migrations, client UI, LLM/MCP tools, API routes, Electron IPC, releases, and CKEditor integration, while refreshing three existing skills.

  • Path fixes: migrations, schema, WebSocket, options, hidden-subtree, and CLS paths are all updated to their current packages/trilium-core/src/ locations; each fix was verified against the live codebase.
  • Seven new skills: each is footgun-first, cites real file:line anchors, and ships runnable scripts where useful (preflight-release-check.mts validates all 9 package.jsons the CI gate misses; ipc-parity.mjs diffs the Electron bridge end-to-end).
  • Three refreshed skills: writing-unit-tests corrects the stale "browser mode unconfigured" claim and documents the core-specs-run-twice footgun; analyzing-coverage adds the standalone WASM suite; translating-locales separates filling vs. registering a locale.

Confidence Score: 5/5

All changes are documentation only — no runnable application code was modified. The two bundled scripts are developer tooling (pre-flight checks and IPC parity analysis) that run outside the application. Safe to merge.

Every corrected path was verified against the live repo. The seven new skills cite real file:line anchors and were validated before submission. The bundled scripts contain no application logic. The only open items are stale paths in copilot-instructions.md sections untouched by this PR, which a follow-up can clean up.

.github/copilot-instructions.md still has a handful of stale apps/server/src/ references in sections not touched by this PR (becca, events, search, Shaca on line 14).

Important Files Changed

Filename Overview
CLAUDE.md Corrects stale paths across migrations, schema, options, hidden-subtree, websocket, and electron sections; adds a Custom Skills section. All verified path changes look accurate.
.github/copilot-instructions.md Fixes REST API, WebSocket, migrations, schema, and options paths. Several stale apps/server/src/ references remain in untouched sections (becca, events, search, Shaca on line 14).
.claude/skills/evolving-the-data-model/SKILL.md Comprehensive migration skill covering the MIGRATIONS array, schema.sql parity, becca_loader alignment, and sync-hash hazard; frontmatter CLAUDE.md is WRONG claim is now stale since CLAUDE.md was fixed in this same PR.
.claude/skills/cutting-a-release/SKILL.md Well-verified release recipe covering the two version scripts, CI gate gaps, release-notes doubled path, rc/beta labeling, and PAT requirements. Matches what update-version.ts and release.yml actually do.
.claude/skills/electron-desktop-bridge/SKILL.md Accurate 5-place wiring recipe for the contextBridge IPC, transport decision table, module map, and crash-safety guidance. Correctly identifies preload.spec.ts co-location and the dead-module-until-setup footgun.
.claude/skills/building-client-ui/SKILL.md New skill covering froca-reactive hooks, entitiesReloaded filter taxonomy, reusable component rules, and the LazyDialog 5-step registration. Hook table and reload-predicate distinctions are accurate.
.claude/skills/cutting-a-release/scripts/preflight-release-check.mts Pre-flight script checks all 9 package.jsons (verified against update-version.ts), confirms release-notes doubled path, and warns on rc/beta labeling. Logic is correct and the CI_GATE_FILES subset matches the actual check-version-consistency.ts.
.claude/skills/electron-desktop-bridge/scripts/ipc-parity.mjs Direction-aware IPC parity checker validating preload/ipcMain sync across 5 finding classes. Repo-root detection uses both path traversal and package.json name guard; regex-based static analysis is reasonable for this use case.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Developer task] --> B{Which skill?}
    B --> C[evolving-the-data-model]
    B --> D[building-client-ui]
    B --> E[adding-llm-mcp-tools]
    B --> F[adding-internal-api-route]
    B --> G[electron-desktop-bridge]
    B --> H[cutting-a-release]
    B --> I[trilium-ckeditor5-integration]
    C --> C1[MIGRATIONS array / schema.sql parity / sync-hash hazard]
    D --> D1[54 froca-reactive hooks / entitiesReloaded filters / LazyDialog]
    E --> E1[NotAPromise guard / mutates=true / allToolRegistries]
    F --> F1[core-shared ~140 routes / apiRoute sync trap]
    G --> G1[5-place wiring recipe / transport table / ipc-parity.mjs]
    H --> H1[2 version scripts / CI gate 5 of 9 / preflight-release-check.mts]
    I --> I1[5 plugin arrays / slash wiring / GPL webdriverio harness]
Loading

Fix All in Claude Code

Reviews (3): Last reviewed commit: "docs: document the chore(skills) commit ..." | Re-trigger Greptile

Comment thread .claude/skills/evolving-the-data-model/SKILL.md Outdated
Comment thread .claude/skills/adding-internal-api-route/SKILL.md
Migrations, schema.sql, options_init, the options route, hidden_subtree, ws
and cls moved from apps/server into packages/trilium-core. The DB-migration
recipe in particular described creating apps/server/src/migrations/*.sql, a
path that no longer exists (migrations are now integer-versioned entries in
the descending MIGRATIONS array in packages/trilium-core). Re-resolve each
moved path and mirror the fix into .github/copilot-instructions.md.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@eliandoran eliandoran force-pushed the feature/claude_skills branch from aeadd08 to a253a11 Compare June 13, 2026 08:52
@codecov

codecov Bot commented Jun 13, 2026

Copy link
Copy Markdown

Bundle Report

Bundle size has no change ✅

Affected Assets, Files, and Routes:

view changes for bundle: client-esm

Assets Changed:

Asset Name Size Change Total Size Change (%)
src/dist-*.js 6 bytes 63 bytes 10.53% ⚠️
src/dist-*.js -6 bytes 57 bytes -9.52%
src/dist-*.js 7 bytes 63 bytes 12.5% ⚠️
src/dist-*.js -7 bytes 56 bytes -11.11%
src/src-*.js -105 bytes 104 bytes -50.24%
src/src-*.js 105 bytes 209 bytes 100.96% ⚠️

eliandoran and others added 11 commits June 13, 2026 12:17
Add/extend DB migrations and Becca entity fields: the descending MIGRATIONS array, schema.sql parity, the hashedProperties cross-instance sync-hash hazard, CLS-wrapped JS migrations, and the spec harness. Ships migration + spec templates.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Author client UI the Preact-hooks way: which froca-reactive hook for which job and the loadResults filter each wires, the reusable-component/per-component-CSS rules, and the Modal/LazyDialog summon+register wiring.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add an LLM/MCP tool exposed to both chat and the MCP server: the synchronous-execute NotAPromise guard, mutates->transaction wiring, the allToolRegistries registration point, the return-{error} contract, protected-note guards, and the getTool()/cls.init() spec harness.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Wire an internal REST route: core-shared (runs under WASM) vs server-only, the apiRoute/asyncApiRoute sync-transactional trap, the implicit 200/204/[status,body] return conventions, convertEntitiesToPojo, and CoreApiTester.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Wire a window.electronApi.* method across the contextBridge (the 7 handler modules each registered from main.ts), the send/sendSync/invoke decision, crash-safety, and renderer-input validation. Ships scripts/ipc-parity.mjs and a protocol/security triage reference.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Cut/debug a release: the two divergent version scripts, the CI consistency gate that checks only 5 of 8 files, the exact release-notes path the publish step requires, rc/beta latest labeling, and RELEASE_PAT. Ships scripts/preflight-release-check.mts.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Wire a CKEditor 5 plugin into Trilium's own bundle: the 5 plugin arrays in plugins.ts, toolbar/slash/translation_overrides wiring, the data-trilium-* persistence pipeline through markdown/share, and the real webdriverio+GPL test harness. Companion to the upstream ckeditor5-* skills.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…runtime specs

Correct the stale '@vitest/browser unconfigured' line (browser mode IS configured for the ckeditor5 bundles via webdriverio+Chrome), add a CKEditor browser-mode row, pointers to the new migration/LLM-tool/preload spec harnesses, and a 'core specs run twice (server + standalone WASM)' footgun.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ng-coverage

trilium-core coverage is collected through BOTH the server and the standalone suites; add the standalone suite as a third coverage-source row with its lcov path and run command.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…guide

Distinguish filling an existing locale from registering a brand-new one (pointer to the dev-guide), and replace the hardcoded Romanian coverage figures with a measure-first instruction.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add a Custom Skills section to CLAUDE.md noting where skills live and that adding/updating one is committed with the chore(skills) prefix (one skill per commit).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@eliandoran eliandoran force-pushed the feature/claude_skills branch from a253a11 to c3d53eb Compare June 13, 2026 09:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XXL This PR changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant