/kavo-skills:soft-deletefrom Kavo Developer Skills
Reference for Kavo's soft delete, restore, and purge behavior — strategy resolution (auto/soft/hard), enabling restoreOne/purgeOne, read semantics and withDeleted, and edge cases (unique constraints, cascades).
Ships in Kavo Developer Skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Deleting a row can mean two things. Kavo resolves which one per entity, at
bootstrap, and every layer downstream reads that one answer instead of
re-deciding. Full detail: docs/internals/architecture/11-soft-delete.md.
Wire-level withDeleted=true grammar is in the query-grammar skill;
config precedence is in the global-config skill.
@Entity()
class Owner implements SoftDeletable {
@DeleteDateColumn() deletedAt!: Date | null;
}
That's the whole opt-in for the common case — no @Kavo config needed.
DELETE /owners/:id now stamps the marker instead of removing the row, and
every read excludes stamped rows.
resolveSoftDelete)| Settings | Result |
|---|---|
delete: false | hard |
delete.strategy: "hard" | hard |
delete.strategy: "soft" | soft — no marker field on the entity is a config error |
delete.strategy: "auto" (default) | soft when a marker field exists, else hard |
The marker field is the configured delete.field (default
"deletedAt") if the entity has that column, otherwise whatever the ORM
declares (@DeleteDateColumn in @kavo/typeorm). Explicit config wins over
detection; an entity with neither costs nothing.
This resolves at every settings scope, so one operation or a single call can narrow it:
@Kavo(Owner, {
operations: { deleteOne: { delete: { strategy: "hard" } } },
})
| Operation | Behavior |
|---|---|
deleteOne | Hard or soft per the resolved strategy. Soft-deleting an already-deleted row → 409 KAVO_ALREADY_DELETED. |
restoreOne | Clears the marker, returns the revived row in the item slot (no new DTO shape). A live row → 409 KAVO_NOT_DELETED. |
purgeOne | Permanently removes an already-soft-deleted row. A live row → 409 KAVO_NOT_DELETED. Under hard it's just a delete. |
Enablement is config-declared, not metadata-driven (ADR-0013) —
restoreOne/purgeOne don't just appear because the entity has a marker
column:
@Kavo(Owner, {
delete: { strategy: "soft" }, // enables PATCH /:id/restore
operations: { purgeOne: true }, // enables DELETE /:id/purge
})
Enabling either on an entity that resolves to hard is a bootstrap
ConfigurationException. Reads and deleteOne adapt with no config at
all — it's only the restore/purge routes that need an explicit opt-in.
Soft-deleted rows are invisible by default — to findOne, findMany,
count, and to updateOne/patchOne (a write never touches a deleted
row; reviving one is restoreOne's job, not a side effect of a write).
withDeleted=true opts back in on both wire and programmatic paths (on
the wire, only with delete.allowDeletedReads, below). On an
entity that is not soft-deletable, the parameter is rejected
(KAVO_QUERY_UNSUPPORTED_PARAM), never silently ignored — a client that
believes it's seeing deleted rows should be told it isn't.
From a client, withDeleted/onlyDeleted also need an opt-in:
delete: { allowDeletedReads: true } (default false, issue #517). Without
it the flags are the same 400, so a soft-deleted row stays gone from the
client's side. Set it on the entity, or per read with
operations: { findMany: { delete: { allowDeletedReads: true } } }. A
programmatic service.findMany({ withDeleted: true }) is server code and
is never gated.
In @kavo/typeorm: for a real @DeleteDateColumn, TypeORM already excludes
deleted rows and the adapter opts in with .withDeleted(); for an ordinary
column named through config, the adapter adds <alias>.<field> IS NULL
itself.
CREATE UNIQUE INDEX owner_email_live ON owner (email) WHERE deleted_at IS NULL;
(Postgres/SQLite support this directly; MySQL needs a generated column.)DELETE
silently stamping rows across several tables is a footgun. Write an
explicit cascade yourself (an @Override'd operation, or a fully custom
route) — that also lets you decide ordering and what happens when one leg
fails.withDeleted applies to the root only — it never widens what an
included relation returns.restoreMany, deleteMany, …) is the optional half of soft
delete and is not built — those registry entries stay disabled and
calling one raises OperationDisabledException. The single-item surface
is complete without it.What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub kavo-labs/kavo --plugin kavo-skills15 skills in this plugin
/composite-primary-keysReference for composite primary key support in @kavo/typeorm — the compositeIdFields metadata field, the ~-delimited route-id encoding, the creatable/updatable split, and every place composite keys don't yet work (other ORM adapters, many-to-many array-mutation, @kavo/graphql). Use when an entity has more than one @PrimaryColumn, or when a route id, association, or array-mutation write on such an entity behaves unexpectedly./dto-slotsReference for Kavo's six optional schema slots (create/update/patch/query/item/list) — entity-derived defaults, the schemaShapeKeys narrowing rule, and serialization order. Use when configuring a DTO class or validator on @Kavo's schema option, or answering "why isn't my field showing/hiding" or "what shape does this response have" questions./error-handlingReference for Kavo's exception hierarchy, KAVO_* error-code catalog, and the RFC 9457 problem-details wire shape every generated route returns on failure. Use when handling/mapping a Kavo error, deciding which exception to throw from a custom handler/@Override, or answering "what does the error response look like" questions./global-configReference for Kavo's global configuration — the KavoSettings precedence chain, built-in defaults table, KavoModule.forRoot/forRootAsync options, and the operations.<id> global-default caveat (ADR-0015). Use when wiring createKavo/KavoModule.forRoot, setting app-wide defaults, or answering "what can I configure globally" questions./graphql-bindingReference for @kavo/graphql and its Nest binding — building a schema over an existing createCrud service, the raw-AST filter/sort args, multi-entity merging, the process-wide type registry, and the zero-code KavoModule graphql option. Use when exposing an entity over GraphQL, or answering "how do I add GraphQL to this entity" questions./kavo-decoratorReference for what @Kavo(Entity, config?) generates and how to configure/override it — routes table, EntityConfig shape (schema/allowed/operations), manual-method-wins, @Override, and fully custom routes. Use when writing or reviewing a @Kavo-decorated controller, or answering "how do I configure/override this route" questions.Other plugins' skills for the same job