src/skills/api-database-edgedb/SKILL.md
Graph-relational database with EdgeQL query language, code-first schema, link-based relations, computed properties, and fully typed TypeScript query builder
npx skillsauth add agents-inc/skills api-database-edgedbInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Quick Guide: Gel (formerly EdgeDB) is a graph-relational database built on PostgreSQL. Define schemas in
.gelfiles using SDL with types, links, and computed properties. Usegel migration create+gel migratefor schema changes. Query with EdgeQL (set-based, deeply nested shapes) or the TypeScript query builder (e.select,e.insert). Everything in EdgeQL is a set -- empty sets need explicit casts, and operations on sets produce Cartesian products. Useglobalvariables with access policies for row-level security. The query builder requires a running database for code generation (npx @gel/generate edgeql-js).Naming: EdgeDB was rebranded to Gel in February 2025. The
edgedbnpm package, CLI, and.esdlextension still work via compatibility shims, but new projects should usegel,@gel/generate, and.gelfiles.
<critical_requirements>
All code must follow project conventions in CLAUDE.md (kebab-case, named exports, import ordering,
import type, named constants)
(You MUST run npx @gel/generate edgeql-js after every gel migrate -- the generated query builder is based on the database schema and becomes stale after migrations)
(You MUST cast empty sets explicitly (<str>{}, <int64>{}) -- bare {} is a syntax error because EdgeQL is strongly typed and cannot infer the type of an empty set)
(You MUST understand that all EdgeQL values are sets -- operations on multi-valued expressions produce Cartesian products, not element-wise results)
(You MUST pass the transaction object tx (not client) to ALL query .run() calls inside client.transaction() -- using client inside a transaction runs queries outside the transaction)
(You MUST NOT use volatile functions like datetime_current() in schema-defined computed properties -- use datetime_of_transaction() or datetime_of_statement() instead)
</critical_requirements>
Auto-detection: Gel, gel, EdgeDB, edgedb, EdgeQL, edgeql, .gel, .esdl, dbschema, edgeql-js, createClient, e.select, e.insert, e.update, e.delete, e.params, gel migrate, gel migration, edgedb migrate, SDL schema, backlink, access policy, gel.toml, edgedb.toml
When to use:
Key patterns covered:
createClient, DSN, environment variables)e.select, e.insert, e.update, e.delete)gel migration create, gel migrate)When NOT to use:
Detailed Resources:
Core Patterns:
Query Builder:
Advanced Schema:
Gel is a graph-relational database. It combines the relational model (tables, constraints, ACID) with a graph model (links between objects, deep traversal). The core idea: relationships are first-class citizens, not join tables.
Core principles:
.gel files (or .esdl for legacy projects). Migrations are auto-generated by comparing your schema files against the database state.link to connect types. Gel handles the underlying foreign keys. You never write JOIN -- you traverse links with dot notation.When to use Gel:
When NOT to use:
Create a client with createClient(). Connection details are auto-discovered from gel.toml (or edgedb.toml) or environment variables.
import { createClient } from "gel";
const client = createClient(); // auto-discovers from project config
export { client };
Choose the right query method by expected cardinality: query() for sets, querySingle() for optional single, queryRequiredSingle() when result is guaranteed, execute() for side-effect-only statements. See examples/core.md for full client setup patterns.
Schemas live in dbschema/*.gel files (or *.esdl for legacy projects). Use required for non-null, link for relationships, constraint exclusive for uniqueness, computed backlinks (.<author[is Post]) for reverse traversal.
# dbschema/default.gel
module default {
type User {
required name: str;
required email: str { constraint exclusive; };
multi posts := .<author[is Post]; # computed backlink
}
type Post {
required title: str;
required author: User; # link, not uuid!
}
}
Key rule: Always use link for relationships -- never raw uuid properties. See examples/core.md for complete schema patterns with constraints, indexes, and enums.
SELECT uses shapes for projection (like GraphQL), INSERT assigns links via subqueries, UPDATE uses +=/-=/:= for multi link manipulation.
select User {
name, email,
posts: { title, status } filter .status = Status.published,
} filter .email = '[email protected]';
See examples/core.md for SELECT/INSERT/UPDATE/DELETE patterns and parameterized queries.
Gel compares your .gel files against the database and auto-generates migrations.
gel migration create # generate migration from schema diff (interactive)
gel migrate # apply pending migrations (idempotent)
npx @gel/generate edgeql-js # regenerate query builder
Never edit the database with DDL directly -- always modify .gel files and use the migration workflow. See examples/core.md for the full workflow including gel watch --migrate for prototyping.
Pass tx (not client) to ALL operations inside client.transaction(). Using client inside the callback runs queries outside the transaction.
await client.transaction(async (tx) => {
await tx.execute(`update Account ...`); // tx, not client!
});
See examples/core.md for transaction patterns and examples/query-builder.md for query builder transactions.
</patterns><red_flags>
High Priority Issues:
client instead of tx inside client.transaction() -- queries run outside the transaction and cannot be rolled backnpx @gel/generate edgeql-js after gel migrate -- query builder types are stale and TypeScript won't catch schema mismatchesuuid properties instead of link -- defeats Gel's graph traversal and referential integritydatetime_current() in schema-defined computed properties -- volatile functions are forbidden in schema computeds; use datetime_of_statement() or datetime_of_transaction()Medium Priority Issues:
{} for empty sets -- EdgeQL requires explicit type cast (<str>{}, <array<int64>>[]) because the type cannot be inferred from an empty literal:= when you mean += on multi links in UPDATE -- := replaces the entire set, += adds to it, -= removes from itfilter on UPDATE/DELETE -- without a filter, the operation applies to ALL objects of that type.gel files + migrations -- causes schema drift between files and databaseCommon Mistakes:
{1, 2} + {10, 20} produces {11, 21, 12, 22} (Cartesian product), not {11, 22}select on a single link returns an object (not an ID) -- you do not need to JOIN; just traverse with .select count(MyType) and expecting querySingle to work -- count() always returns exactly one value, so use queryRequiredSingle.<author without [is Post] returns all types that have an author linkGotchas & Edge Cases:
required on a multi link means "at least one" -- an empty set violates the constraint, which can be surprising++ not + -- the + operator is for arithmetic onlyLIMIT 1 does NOT make a query return a singleton for cardinality purposes -- use filter .id = <uuid>$id (exclusive constraint) for the query builder to infer singleton cardinalityorder by in your query or use an intermediate type with an order property.<link_name) default to multi cardinality -- use single keyword explicitly if you know the relationship is one-to-one</red_flags>
<critical_reminders>
All code must follow project conventions in CLAUDE.md (kebab-case, named exports, import ordering,
import type, named constants)
(You MUST run npx @gel/generate edgeql-js after every gel migrate -- the generated query builder is based on the database schema and becomes stale after migrations)
(You MUST cast empty sets explicitly (<str>{}, <int64>{}) -- bare {} is a syntax error because EdgeQL is strongly typed and cannot infer the type of an empty set)
(You MUST understand that all EdgeQL values are sets -- operations on multi-valued expressions produce Cartesian products, not element-wise results)
(You MUST pass the transaction object tx (not client) to ALL query .run() calls inside client.transaction() -- using client inside a transaction runs queries outside the transaction)
(You MUST NOT use volatile functions like datetime_current() in schema-defined computed properties -- use datetime_of_transaction() or datetime_of_statement() instead)
Failure to follow these rules will cause stale types, silent data bugs, or transaction isolation failures.
</critical_reminders>
development
Material Design component library for Vue 3
development
VitePress 1.x — Vue-powered static site generator for documentation sites, built on Vite
tools
Docusaurus 3.x documentation framework — site configuration, docs/blog plugins, sidebars, versioning, MDX, swizzling, and deployment
development
TanStack Form patterns - useForm, form.Field, validators, arrays, linked fields, createFormHook, type safety