SkillsReviewed · majiayu000

Database Patterns

Database Patterns is a skill for developers using coding assistants to design PostgreSQL and Redis systems, but its sample code needs careful review before production use. It covers schemas, indexes, JSONB, transactions, caching and storage tiers; several caching examples leave simultaneous requests and failures insufficiently handled.

Researched 17 Nov 2026

In short.

Database Patterns is a PostgreSQL and Redis skill for developers using coding assistants, but some examples can mishandle simultaneous requests or partial failures. Its main guide and three references provide practical design recipes, SQL, TypeScript, Redis commands and Lua examples. It is useful for exploring design choices and reviewing omissions. The material does not establish production correctness: database and cache writes are separate, some lock releases do not check ownership, and asynchronous writes rely on an in-memory queue. Supported versions, operating costs and measured performance are unknown; no execution results are supplied.

Researched and written by an AI model and checked by a second AI model. How it works

Covers skills/database-patterns/SKILL.md, skills/database-patterns/reference/caching.md, skills/database-patterns/reference/postgresql.md and skills/database-patterns/reference/redis.md in full at revision 7f55e67969fb54a1b01de822791c0c0cd8afa6a5, together with the repository-level LICENSE. Other repository skills, documents outside this scope, external dependencies and later source changes are excluded. The four selected Markdown files are eligible for unchanged redistribution with the MIT notice preserved. Nothing was executed; runtime correctness, assistant integration, database compatibility, behavior under concurrency and performance remain unassessed.

The overview

identity

Database Patterns is the database-patterns skill in the majiayu000/spellbook repository. Its front matter describes use for PostgreSQL and Redis data models, indexes, JSONB, caching, storage tiers and consistency contracts. The original folder is [https://github.com/majiayu000/spellbook/tree/main/skills/database-patterns].

The resource consists of SKILL.md and three reference documents covering caching, PostgreSQL and Redis. These are assistant instructions and illustrative code fragments. The supplied folder contains no standalone application or complete database library.

assessment

The strongest use is as a design checklist and explanation aid. It connects schema decisions with query patterns, cache expiration, invalidation and operational concerns, giving an assistant concrete material to discuss with a developer.

Its reliability varies between examples. The Redis reference includes ownership-checked lock release, while the caching examples use a simpler release that can interfere with another lock holder. Such differences make human review important. Runtime correctness, compatibility and performance are not established by the supplied material.

users

The skill suits developers deciding how to structure relational records, index common queries, store flexible attributes or add Redis to an application. Experienced developers can use its examples to discuss query plans, transaction isolation, partitioning and cache consistency.

Beginners get short examples and checklists, but the material assumes familiarity with SQL, asynchronous TypeScript and application data access. A cache is a temporary copy of data; deciding when that copy may be stale is a central responsibility left to the developer. This is not a complete introductory database course.

capabilities

PostgreSQL coverage includes data types, constraints, timestamp triggers, JSONB and arrays, full-text search, several index types, query-plan inspection, statistics, transactions, locks, partitioning and connection pooling. Configuration examples introduce memory, connection and query-planning settings.

Redis coverage includes strings, hashes, lists, sets, sorted sets and streams, plus sessions, rate limiting, Pub/Sub, Lua, Sentinel, Cluster and monitoring. Caching material covers cache-aside, write-through, write-behind, expiration, invalidation, negative caching, stampede protection and local-plus-Redis caching. These are documented patterns rather than implemented product features.

Using it

requirements

Reading the documents requires no database deployment. Using them as an assistant skill requires a host that can accept these instructions and references; supported hosts, automatic activation behavior and registration requirements are not specified.

Implementing the examples requires the relevant PostgreSQL or Redis environment and application code. The examples show pg, ioredis, the uuid-ossp PostgreSQL extension and PgBouncer, but do not pin versions. Several fragments rely on undefined types, helpers and database adapters, including User, Database, sleep and db. No particular AI model, hardware configuration or context capacity is specified.

mechanism

The skill works through written guidance. SKILL.md provides a name, a description of when to use it, architectural defaults, examples and a checklist. Relative links lead to the three longer references.

Its default architecture places relational records and transactions in PostgreSQL and uses Redis for cached copies and shared structures such as counters or sessions. Cache-aside reads check Redis first, fetch from the database on a miss and save an expiring copy. The documents supply no enforcement layer that guarantees an assistant or application follows these rules.

setup

Keep SKILL.md alongside reference/caching.md, reference/postgresql.md and reference/redis.md so its relative references remain usable. Retain the repository LICENSE with redistributed copies. The selected folder supplies no host-specific installation procedure, dependency manifest or automated installer.

For application use, replace placeholder types and database calls, configure actual connections and choose only the patterns needed by the project. The pooling, memory, expiration and partition examples require adaptation to the deployment. They do not constitute a complete setup recipe.

example

For a user-profile endpoint, the main guide shows checking a Redis key such as user:123, returning cached JSON when present, otherwise fetching the user from the database and caching it for 900 seconds. Its negative-caching example stores a special NULL value for 60 seconds when a user does not exist, reducing repeated lookups for missing records.

The caching reference's update example writes to the database and then deletes the cached entry so a later read can refill it. This illustrates the intended request flow, but a read overlapping an update can still refill the cache with older data. No measured reduction in database traffic or response time is supplied.

Assessment & evidence

limitations

The reference describes write-through caching as strongly consistent, but its code writes to the database and Redis separately. Inspection indicates that failures or overlapping requests can leave stale cached data. Cache-aside reads also await Redis without showing a fallback for cache errors, so the stated resilience to cache failures is not implemented in those fragments.

The stampede examples acquire an expiring lock and later delete it without checking ownership. If a slow loader outlives its lock, it can delete a replacement holder's lock. The separate Redis reference demonstrates token-based, atomic release, but the stampede examples do not incorporate it. Their retry paths also have no explicit retry limit.

The write-behind example keeps pending writes in process memory and clears its queue before awaiting database persistence. A crash or failed batch can therefore lose pending work without a demonstrated recovery path. The sliding-window rate limiter separates counting from insertion, allowing simultaneous requests to pass the same capacity check.

The deletion example uses KEYS despite a SCAN example elsewhere, and the local cache examples show no size bound or cleanup of expired entries. These are operational concerns inferred from the code; their actual impact has not been measured.

reasoning

The architectural rationale is coherent: keep transactional records in PostgreSQL, prefer explicit columns for stable structure, design indexes around queries and use Redis where temporary copies or shared data structures help. Expiration limits how long cached values remain available, while invalidation attempts to remove outdated copies sooner.

Several prescriptions need context. Instructions to add indexes broadly, treat particular query-plan operations as problems or avoid backward compatibility are too general to settle a production design. Query selectivity, write overhead, deployment sequencing and existing clients affect those decisions. The sample pool sizes, memory settings and latency diagrams are starting points, not validated targets for a particular workload.

alternatives

The resource presents several internal alternatives. Cache-aside loads data on demand; write-through updates the database and cache during a write; write-behind postpones database persistence. Their practical tradeoffs include stale reads, write latency and recovery complexity. The comparison table's consistency labels should be read alongside the implementation gaps.

Read-through appears in the comparison table without a worked implementation. Local-plus-Redis caching offers another design, adding an in-process copy and another freshness boundary. The material supplies no comparative benchmark or evidence that one pattern is universally preferable.

evidence

The supplied material includes the complete four-file skill folder and the repository-level LICENSE at one source revision. The main document is available at [https://raw.githubusercontent.com/majiayu000/spellbook/7f55e67969fb54a1b01de822791c0c0cd8afa6a5/skills/database-patterns/SKILL.md].

The documents support conclusions about the resource's contents and visible code structure. They supply no execution logs, compatibility matrix, benchmark methodology or recorded concurrency results. Latency figures in diagrams are illustrative claims. The failure cases described here are deductions from the examples, not observed runtime incidents.

Access & freshness

costs

No purchase price, subscription, support charge or bundled hosting price is stated. Total operating cost is unknown.

Adopting the examples may involve PostgreSQL and Redis hosting, memory, storage, network traffic and application infrastructure. Assistant or model usage may introduce separate charges depending on the chosen host. The documents provide no workload measurements or pricing inputs from which to estimate these amounts.

rights

The repository-level MIT License names majiayu000 as copyright holder for 2025–2026. It permits use, copying, modification, distribution, sublicensing and sale of the software and associated documentation, provided the copyright and permission notices accompany copies or substantial portions.

The license disclaims warranties and liability. Redistributing the skill and its references should preserve that notice. The captured license is [https://raw.githubusercontent.com/majiayu000/spellbook/7f55e67969fb54a1b01de822791c0c0cd8afa6a5/LICENSE]. Terms for separately obtained dependencies and hosted services are not established by this notice.

freshness

The supplied snapshot identifies source revision 7f55e67969fb54a1b01de822791c0c0cd8afa6a5 and capture time 2026-11-17T04:34:41.240Z. These findings apply to that revision; correspondence with the repository's current main branch is unknown.

PostgreSQL, Redis, client-library and PgBouncer versions are not declared. Compatibility with a particular installed release is therefore unknown. The 2025 partition dates are example ranges and need replacement or extension for an actual deployment.

actions

Start by defining which store holds authoritative data, how much staleness is acceptable and what should happen when Redis is unavailable. Use the relevant recipes to discuss those choices with an assistant, then review the proposed implementation against the application's requirements.

Before deployment, address cache failure handling, concurrent reads and writes, ownership-checked lock release, atomic rate limiting and recovery for deferred writes. Bound local caches and review keyspace invalidation. Validate query plans, indexes, configuration and partition ranges against the actual workload and installed versions. These are recommended next steps; no execution or validation results are supplied.

Evidence for this report

LICENSEnotice · checked 2026-11-17
skills/database-patterns/SKILL.mdselected · checked 2026-11-17
skills/database-patterns/reference/caching.mdselected · checked 2026-11-17
skills/database-patterns/reference/redis.mdselected · checked 2026-11-17