Communitygithub.com

YepAPI/skills

Verschachtelte Kommentare, @Erwähnungen, Reaktionen, Moderationswarteschlange, optimistische UI und Cursor-Paginierung.

Was ist skills?

Diese Fähigkeit implementiert ein vollständiges, verschachteltes Kommentarsystem mit erweiterten Funktionen, das in modernen Webanwendungen und KI-Agenten integriert werden kann. Es unterstützt Threaded Comments durch eine `parent_id`-Fremdschlüsselspalte, optimistische UI-Updates über React Query für sofortige Benutzerrückmeldungen, sowie @Erwähnungen mit Server-seitiger Validierung und Benachrichtigungen. Ein separates `reactions`-Table mit Unique Constraints verhindert Duplikate, während die Moderation über ein `status`-Feld (published, flagged, removed) und eine automatische Wortliste gesteuert wird. Cursor-Paginierung ermöglicht effizientes Laden großer Diskussionen, und Soft Deletes mit Platzhaltern erhalten die Thread-Integrität. Die Fähigkeit ist ideal für Entwickler, die mit React, TypeScript und Datenbanken wie PostgreSQL oder SQLite arbeiten, und kann in Plattformen wie Claude Code, Cursor oder Codex eingesetzt werden.

Funktioniert mit~Claude Code~Codex CLI✓Cursor
npx skills add https://github.com/YepAPI/skills/tree/HEAD/skills/comments-discussions

In Ihrer bevorzugten KI fragen

Öffnet einen neuen Chat, in dem dieser Agent-Skill bereits geladen ist.

Dokumentation

Kommentare & Diskussionen

Regeln

  • Verschachtelte Kommentare: parent_id Fremdschlüssel in der Kommentartabelle — null für oberste Ebene, verweist auf das übergeordnete Element bei Antworten
  • Optimistische UI: Kommentar sofort zur UI hinzufügen, mit Serverantwort bestätigen, bei Fehler rückgängig machen
  • @Erwähnungen: @benutzername im Kommentartext parsen — Dropdown zur Benutzersuche bei @-Tastendruck auslösen, erwähnte Benutzer benachrichtigen
  • Reaktionen: Separates reactions-Table (commentId, userId, emoji) — Unique Constraint auf (commentId, userId, emoji)
  • Moderation: status-Feld (published, flagged, removed) — Moderationswarteschlange für markierte Inhalte, automatische Markierung mit Wortliste
  • Soft Delete: deletedAt-Zeitstempel setzen — „Gelöscht“-Platzhalter für Kommentare mit Antworten anzeigen, verwaiste gelöschte Kommentare vollständig ausblenden
  • Cursor-Paginierung: cursor (commentId) + limit — sortiert nach createdAt, ältere Kommentare beim Scrollen laden
  • Bearbeitungsverlauf: Änderungen in separatem Table oder JSON-Array speichern — „Bearbeitet“-Indikator mit letztem Bearbeitungszeitpunkt anzeigen

Patterns

// Kommentar-Datenmodell
// comments: id, postId, authorId, parentId (nullable), body, status, deletedAt, createdAt, updatedAt
// reactions: id, commentId, userId, emoji, createdAt (unique: [commentId, userId, emoji])
// mentions: id, commentId, mentionedUserId, createdAt

// Verschachtelte Abfrage – oberste Ebene + verschachtelte Antworten abrufen
const comments = await db.query.comments.findMany({
  where: and(eq(comments.postId, postId), isNull(comments.parentId)),
  with: {
    author: { columns: { id: true, name: true, avatar: true } },
    replies: {
      with: { author: { columns: { id: true, name: true, avatar: true } } },
      orderBy: [asc(comments.createdAt)],
    },
    reactions: true,
  },
  orderBy: [desc(comments.createdAt)],
  limit: 20,
});

// Optimistisches Hinzufügen eines Kommentars (React Query)
const addComment = useMutation({
  mutationFn: (body: string) => api.post(`/posts/${postId}/comments`, { body }),
  onMutate: async (body) => {
    await queryClient.cancelQueries({ queryKey: ["comments", postId] });
    const previous = queryClient.getQueryData(["comments", postId]);
    queryClient.setQueryData(["comments", postId], (old: Comment[]) => [
      { id: `temp-${Date.now()}`, body, author: currentUser, createdAt: new Date() },
      ...old,
    ]);
    return { previous };
  },
  onError: (_err, _body, context) => {
    queryClient.setQueryData(["comments", postId], context?.previous);
  },
  onSettled: () => queryClient.invalidateQueries({ queryKey: ["comments", postId] }),
});

Vermeiden

  • Unbegrenzte Verschachtelungstiefe — auf 2-3 Ebenen begrenzen, tiefere Antworten dann abflachen
  • Alle Kommentare auf einmal laden — Cursor-Paginierung verwenden, besonders bei aktiven Diskussionen
  • Nur clientseitige Erwähnungsparsung — Erwähnungen serverseitig validieren und extrahieren für Benachrichtigungen
  • Kommentare mit Antworten hart löschen — dadurch wird der Thread verwaist; stattdessen Soft Delete und Platzhalter anzeigen
  • Reaktionen ohne Unique Constraints — ermöglicht doppelte Reaktionen vom selben Benutzer

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

YepAPI/skills

WCAG 2.1 AA — semantic HTML, keyboard navigation, screen readers.

YepAPI/skills

Experiment setup, variant splitting, statistical significance, and feature flag integration.

YepAPI/skills

CRUD generators, data tables, user management, role-based access, and bulk operations.

YepAPI/skills

Monitor what ChatGPT and Gemini say about your brand using YepAPI.

YepAPI/skills

Queue workers with BullMQ/Inngest/Trigger.dev, job retries, dead letter queues, concurrency.

YepAPI/skills

Commander.js, interactive prompts with Clack, spinners, colors, config files, exit codes, and npm publishing.

YepAPI/skills

cmdk integration, Cmd+K trigger, fuzzy search, grouped actions, keyboard navigation, and dynamic action registration.

YepAPI/skills

Content planning with trend and sentiment data from YepAPI.

YepAPI/skills

Content calendar, keyword-driven planning, and content briefs.

YepAPI/skills

Theme switching with CSS variables, system preference detection, next-themes, and persistence.

YepAPI/skills

Competitive analysis between domains using YepAPI.

YepAPI/skills

Layout grids, KPI cards, data tables with sorting/filtering, sidebar navigation, and responsive breakpoints.

YepAPI/skills

Data encryption — TLS everywhere, AES-256-GCM for PII, bcrypt passwords, encrypted backups.

YepAPI/skills

Chart patterns with Recharts/Nivo/D3, responsive containers, color scales, and accessibility.

YepAPI/skills

Drizzle schema definition, push vs migrate, type-safe queries, relations, transactions, and prepared statements.

YepAPI/skills

Upload handling, resize/compress, CDN delivery, blur placeholders, and next/image patterns.

YepAPI/skills

Local business and Google Maps research using YepAPI.

YepAPI/skills

Cursor-based pagination, IntersectionObserver, virtualized lists with @tanstack/react-virtual, and scroll position restoration.

YepAPI/skills

Tenant isolation (row-level vs schema), subdomain routing, per-tenant config, and data partitioning.

YepAPI/skills

Chat UI components, streaming responses with AI SDK, context window management, and RAG patterns.

Verwandte Skills