api-resource-lifecycle

Implement CRUD flows with cascading deletes and orphan prevention for API resources.

Updated Apr 26, 2026
One-click install
npx skills add https://github.com/awardsapp/tambo-genui --skill api-resource-lifecycle
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: api-resource-lifecycle
Source: https://github.com/awardsapp/tambo-genui/tree/main/.claude/skills/api-resource-lifecycle
Command: npx skills add https://github.com/awardsapp/tambo-genui --skill api-resource-lifecycle

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps teams implement reliable CRUD flows for API-backed resources by preventing orphan records, handling cascading deletes correctly, and turning raw database/provider failures into consistent, user-actionable errors.

Core Features & Use Cases

  • Cascading deletes (schema-first + manual fallback): Choose onDelete: "cascade" for parent-child FK relationships, and use transaction-wrapped manual cascades when external API cleanup or cross-reference logic is required.
  • Validation and error-code conventions: Produce descriptive validation messages and map domain outcomes to the correct tRPC codes (e.g., CONFLICT for duplicates, NOT_FOUND for missing resources).
  • Duplicate detection and robust exception mapping: Rely on DB unique constraints with specific handling for PostgreSQL unique violations (e.g., 23505), avoiding leaky raw DB errors.
  • Orphan prevention on external sync: Persist to the database first, then roll back the DB record if the external provider sync fails.
  • Replacement hygiene for external keys: When replacing provider keys, clear dependent external skill metadata to avoid stale references and resync issues.

Quick Start

Use the api-resource-lifecycle skill when you need to add or modify delete/remove operations, introduce cascading behavior, implement duplicate detection and validation, or ensure external-provider sync failures roll back cleanly.

Frequently Asked Questions about api-resource-lifecycle

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I prevent orphan records when implementing cascading deletes in an API?

Prevent orphan records during cascading deletes by using schema-level cascade constraints for parent-child relationships, and apply transaction-wrapped manual cascades when external API cleanup or cross-reference logic is required.

What is the best way to handle duplicate detection and database errors in CRUD APIs?

Handle duplicate detection in CRUD APIs by relying on database unique constraints, catching specific violations like PostgreSQL error 23505, and mapping these domain outcomes to consistent user-actionable errors instead of leaking raw database errors.

How do I roll back database changes when an external provider sync fails?

Roll back database changes on external sync failure by persisting the record to the database first, then executing a transaction-safe cleanup and rollback of the DB record if the external provider sync operation fails.

How should API validation errors map to tRPC error codes?

API validation errors should map to tRPC codes based on domain outcomes, producing descriptive validation messages and returning codes like CONFLICT for duplicates or NOT_FOUND for missing resources to ensure consistent error handling.

When do I need to clear external metadata during a resource replacement workflow?

Clear external metadata during resource replacement workflows when replacing provider keys, which prevents stale references and resync issues by ensuring dependent external skill metadata stays consistent with the new keys.