agentleFS
Sorcha-PlatformSorcha-Platform/Sorcha/.claude/skills/postgresql/SKILL.md

postgresql

Skill2 starsChanged 10 months agoMITView on GitHub

Manages PostgreSQL databases and Entity Framework Core integration. Use when: configuring database connections, writing migrations, creating DbContext classes, optimizing queries, or integrating with .NET Aspire.

12 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

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

  • 0

    Common

    Most of the 11 edited versions we read keep these.

  • 0

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use mcp__context7__resolve-library-id to search for "postgresql" or "npgsql efcore"

    line 123

“Common” is measured: kept by at least 6 in 10 of the 11 edited versions of this file we could read. “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

PostgreSQL Skill

PostgreSQL database management for Sorcha's decentralised register platform. This project uses PostgreSQL 17 with Npgsql 8.0+ and Entity Framework Core 10, featuring dedicated schemas (wallet, public), JSONB columns for metadata, and .NET Aspire service discovery for connection management.

Quick Start

DbContext with PostgreSQL Schema

// src/Core/Sorcha.Wallet.Core/Data/WalletDbContext.cs
public class WalletDbContext : DbContext
{
    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        modelBuilder.HasDefaultSchema("wallet");
        
        modelBuilder.Entity<Wallet>(entity =>
        {
            entity.ToTable("wallets");
            entity.HasKey(e => e.Address);
            
            // JSONB for metadata
            entity.Property(e => e.Metadata)
                .HasColumnType("jsonb");
            
            // Soft delete filter
            entity.HasQueryFilter(e => e.DeletedAt == null);
        });
    }
}

Npgsql Configuration with Retry

// src/Services/Sorcha.Wallet.Service/Extensions/WalletServiceExtensions.cs
services.AddNpgsqlDataSource(connectionString, dataSourceBuilder =>
{
    dataSourceBuilder.EnableDynamicJson();  // Required for Dictionary serialization
});

services.AddDbContext<WalletDbContext>(options =>
{
    options.UseNpgsql(connectionString, npgsqlOptions =>
    {
        npgsqlOptions.EnableRetryOnFailure(
            maxRetryCount: 10,
            maxRetryDelay: TimeSpan.FromSeconds(30),
            errorCodesToAdd: null);
        npgsqlOptions.MigrationsHistoryTable("__EFMigrationsHistory", "wallet");
    });
});

Aspire Service Discovery

// src/Apps/Sorcha.AppHost/AppHost.cs
var postgres = builder.AddPostgres("postgres").WithPgAdmin();
var walletDb = postgres.AddDatabase("wallet-db", "sorcha_wallet");

builder.AddProject<Projects.Sorcha_Wallet_Service>("wallet-service")
    .WithReference(walletDb);  // Auto-injects connection string

Key Concepts

ConceptUsageExample
Schema isolationSeparate domainsmodelBuilder.HasDefaultSchema("wallet")
JSONB columnsFlexible metadataHasColumnType("jsonb")
Soft deletesQuery filtersHasQueryFilter(e => e.DeletedAt == null)
Row versioningConcurrencyProperty(e => e.RowVersion).IsRowVersion()
Composite indexesQuery performanceHasIndex(e => new { e.Owner, e.Tenant })
UUID generationPrimary keysHasDefaultValueSql("gen_random_uuid()")

Common Patterns

High-Precision Decimal for Crypto

When: Storing cryptocurrency amounts

entity.Property(e => e.Balance)
    .HasColumnType("numeric(28,18)")
    .HasPrecision(28, 18);

Timestamp with Timezone

When: Audit trails with timezone awareness

entity.Property(e => e.CreatedAt)
    .HasColumnType("timestamp with time zone")
    .HasDefaultValueSql("CURRENT_TIMESTAMP");

See Also

  • patterns - DbContext configuration, indexing strategies
  • workflows - Migrations, health checks, initialization

Related Skills

  • entity-framework - ORM patterns and repository implementations
  • aspire - Service discovery and connection string injection
  • docker - PostgreSQL container configuration

Documentation Resources

Fetch latest PostgreSQL documentation with Context7.

How to use Context7:

  1. Use mcp__context7__resolve-library-id to search for "postgresql" or "npgsql efcore"
  2. Prefer website documentation (IDs starting with /websites/) over source code repositories
  3. Query with mcp__context7__query-docs using the resolved library ID

Library IDs:

  • PostgreSQL: /websites/postgresql (61K snippets, High reputation)
  • Npgsql EF Core: /websites/npgsql_efcore_index_html
  • EF Core: /dotnet/entityframework.docs (4K snippets, High reputation)

Recommended Queries:

  • "Index creation strategies"
  • "JSONB operators and functions"
  • "Connection pooling configuration"
  • "Query performance optimization"

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.