agentleFS
charanjit-singhcharanjit-singh/lovable-skills/skills/soft-delete-and-archiving/SKILL.md

soft-delete-and-archiving

Skill10 starsChanged 6 months agoMITView on GitHub

Use when implementing soft deletes (deleted_at), restoring records, archiving instead of hard delete, or filtering active vs deleted rows in queries and RLS. Not for GDPR hard-delete requests that must purge data.

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Default every app query:

    line 26

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Soft delete and archiving

Column pattern

alter table public.projects add column deleted_at timestamptz;
create index projects_active_idx on public.projects (organization_id)
  where deleted_at is null;
  • Active: deleted_at is null
  • Deleted: deleted_at is not null (set to now() on delete)

Optional: deleted_by uuid references auth.users(id).

Queries

Default every app query:

.from("projects").select("*").is("deleted_at", null)

Views can encapsulate:

create view public.projects_active as
  select * from public.projects where deleted_at is null;

RLS

Policies should exclude soft-deleted rows for normal users:

using (deleted_at is null and /* membership check */)

Admins may select deleted via separate policy or service role.

Restore

update projects set deleted_at = null, deleted_by = null where id = $1 — only owner/admin.

Hard delete

Reserve for legal/GDPR: edge function + service role after retention period; document in audit log.

Avoid

  • Unique constraints broken by soft delete — use partial unique index:
create unique index projects_org_slug_active_idx
  on public.projects (organization_id, slug) where deleted_at is null;
  • Cascading hard delete when product expects archive.

Checklist

  • All list queries filter deleted_at is null
  • Partial unique indexes where needed
  • Restore path tested

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.