d1-patterns

Create encrypted records in D1 databases with TID generation and CRUD operations.

22|4|Updated Feb 7, 2026
One-click install
npx skills add https://github.com/joelhooks/atproto-agent-network --skill d1-patterns
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: d1-patterns
Source: https://github.com/joelhooks/atproto-agent-network/tree/main/.agents/skills/d1-patterns
Command: npx skills add https://github.com/joelhooks/atproto-agent-network --skill d1-patterns

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

D1 stores encrypted records, and applications often need a robust pattern to model secure storage, indexing, migration, and access control across agents. This Skill provides a reusable schema and operational practices for encrypted record storage on D1, including handling of ciphertext, per-record keys, and shared access metadata.

Core Features & Use Cases

  • Core schema: defines a core encrypted records table with per-record keys, nonces, and optional encrypted keys for recipients.
  • Indexing & access: supports queries on did, collection, and rkey for fast lookup while keeping content encrypted.
  • Operational patterns: TID generation, CRUD and batch operations, and agent registry for multi-agent coordination.
  • Use Case: model agent memories or logs where metadata is searchable but content remains encrypted, and provide secure key sharing for collaborators.

Quick Start

Create and manage encrypted records in your D1 database to enable secure storage and querying.

Frequently Asked Questions about d1-patterns

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

FAQPage Schema
How do I store encrypted records in a D1 database while keeping metadata queryable?

You can store encrypted records in a D1 database by using a schema that encrypts content while indexing metadata like did, collection, and rkey for fast lookups. This keeps ciphertext secure while allowing queries on shared access metadata.

What is the best way to manage D1 database migrations for encrypted agent memories?

Manage D1 migrations for encrypted agent memories by applying a reusable schema pattern handling ciphertext, per-record keys, and nonces. This supports secure storage, retrieval, and multi-agent coordination.

How does per-record key encryption work for multi-agent coordination in SQL databases?

Per-record key encryption in SQL databases uses individual keys and nonces for each record, alongside optional encrypted keys for specific recipients. This enables secure key sharing and collaboration among multiple agents accessing the D1 database.

Can I perform batch CRUD operations on encrypted data using D1?

Yes, you can perform batch CRUD operations on encrypted data using D1. This pattern includes TID generation and batch operational practices to securely manage multiple encrypted records efficiently within your database.

Does this encrypted storage pattern support indexing by collection and record key?

Yes, the encrypted storage pattern supports indexing by collection and record key (rkey). It defines a core encrypted records table enabling fast lookup queries on did, collection, and rkey while keeping content fully encrypted.