Repository-specific guidance for coding agents working on Svedit.
README.md is the user-facing manual and source of truth for setup, customization, and usage patterns. Consult only the relevant sections when working on those areas; keep agent-specific guidance here.
- For code running from
/in no-backend/Vercel mode, do not add top-level imports of backend-only modules such as#app/api.remote.jsor anything that imports#lib/server/db.js. - In home-route server files, import backend-only code lazily inside the
has_backendguard so static deployments do not evaluate database code at module load time. - Files using Svelte runes (
$state,$derived,$effect, etc.) must use the.svelte.jsor.svelte.tsextension. - Use sentence case for documentation headings and comments; capitalize
Sveditas a proper noun.
-
Use tabs for indentation throughout the project, including code snippets in documentation and design system examples. Preserve spaces only where the file format requires them.
-
Use
snake_casefor project-defined JavaScript and TypeScript identifiers. Keep web platform and Svelte APIs in their nativecamelCaseform. -
Prefer Tailwind classes and minimize custom CSS. For CSS custom properties, use Tailwind's arbitrary-value utilities, such as
text-(--editing)andborder-(--editing), where applicable. -
Prefix all project-defined CSS classes with
ew-, including component, state, and custom utility classes. Standard Tailwind classes and classes required by third-party libraries retain their original names.
- The user manually verifies UI changes. Do not use a browser, screenshots, or computer-use tools to verify the UI unless the user explicitly asks.
- Use appropriate code checks, such as formatting, linting, and Svelte diagnostics, without starting a browser-based verification workflow.
-
Inline formatting styles (emphasis, strong, link, code, and highlight) are mutually exclusive. Never nest them or apply multiple styles to the same text.
-
Consult the design system source before styling UI. With the development server running, the user can open the design system in a browser to inspect typography, spacing, buttons, and editor pills, and inspect the source for their recipes. Shared tokens and typography utilities live in
src/app.css. Follow the UI verification rules above for agent browser use. -
Keep the design system focused on reusable primitives, such as typography, spacing, colors, controls, and cards. Higher-level compositions and behavior belong in application code and components: for example, document the reusable Card primitive in the design system, while galleries and carousels compose it in application components.
-
Keep reference examples as explicit HTML, SVG, and Tailwind classes. Repetition is intentional; application components own behavior and may adapt the recipes when their interaction requires it.
-
Update existing primitive examples when component changes affect those primitives. Do not automatically add examples for every new component or layout. If unsure whether a new example belongs in the design system, ask the user before adding it.
Svedit is a Svelte 5 rich content editor built around a graph-based document model.
Sessionowns document state, transactions, and history;Transactionperforms atomic changes.- Documents are graphs of nodes with properties and references.
- Selection supports text, node, and property selections and maps between the model and the DOM.
Svedit.sveltemanages the editor and selection;NodeArrayProperty.svelterenders node sequences;TextProperty.svelterenders editable text with marks and annotations.
- Give wrappers that scroll editable node arrays
relativepositioning, as inNav.svelte. Svedit's absolutely positioned node gaps and markers need a containing block that moves with the scrolling content. Keep theNodeelements themselves static. - Put horizontal gutters inside the scroll container so the first and last node gaps have space outside the content. Match
scroll-paddingto those gutters so snapped cards retain their alignment. - Put carousel gutters on a track wrapper around
NodeArrayProperty, not on the node array itself. Padding after the final node can trigger Svedit's trailing-gap fill/clamp calculations and place the marker over earlier cards. - Do not add
tabindexto scroll wrappers in editing mode: taking focus from Svedit's canvas prevents it from processing text selections. A focusable scroll region is appropriate in viewing mode.
When adding a property to a node type, update both:
document_schemainsrc/app/document_schema.tsinsertersinsrc/app/document_config.ts
For Svelte or SvelteKit questions, use the Svelte MCP documentation tools:
- Call
list-sectionsfirst. - Use its
use_casesinformation to identify all relevant sections. - Retrieve those sections with
get-documentation. - When writing Svelte code, run
svelte-autofixerand address all reported issues or suggestions before delivery.