Logo de Schema Design

Schema Design

Comunidade
nahid-sparktales
schema-design

Turn what a system must guarantee into tables, keys and constraints — normalization judgement, nullability, foreign key behaviour, and naming that survives. Use when designing new tables, reviewing ORM models or a migration's DDL, or when a bug reduces to "the database allowed a row that should be impossible". Not for tuning a slow query, not for engine-specific syntax and features, and not for writing or running the migration that ships the change.

Visão geral

Publicado pornahid-sparktales
Repositórioagent-dispatcher
Nome da habilidadeschema-design
Estrelas
58
Forks
5
Arquivos incluídos
1
LicençaMIT
Links
  • Instruções em Markdown

    Um arquivo SKILL.md que o modelo carrega sob demanda, consumindo tokens apenas quando uma solicitação é realmente relevante para a habilidade.

  • Funciona com qualquer LLM

    As habilidades de IA são escritas em Markdown simples, não em código específico de um provedor. Por isso, funcionam com GPT, Claude, Gemini, Grok ou um modelo local.

  • Arquivos incluídos: 1

    Scripts, templates e referências que o modelo pode ler enquanto trabalha. Os arquivos são somente para leitura e nunca são executados.

  • Código aberto

    Publicada por nahid-sparktales no GitHub. Leia os arquivos da habilidade antes de instalá-la.

Instalação

Instale a habilidade de IA Schema Design no TypingMind para usá-la com qualquer LLM ou adicione-a a outro agente que leia SKILL.md.

1

Instalar no TypingMind

O TypingMind instala uma habilidade diretamente da pasta dela no GitHub — lê o arquivo SKILL.md, reúne os arquivos de recursos em um pacote e armazena o resultado localmente.

  1. Abra o app e vá para Plugins → Habilidades.
  2. Escolha "Instalar do GitHub".
  3. Cole a URL abaixo, que aponta para a pasta da habilidade, e confirme.
    https://github.com/nahid-sparktales/agent-dispatcher/tree/main/skills/database/schema-design
  4. Ative a habilidade em cada chat em que quiser disponibilizá-la.
Plugins → Habilidades → Adicionar habilidade → Via URL do GitHub. Depois, cole a URL da pasta e pressione Continuar.
2

Instalar em outro agente

Qualquer agente que leia o formato Agent Skills pode usar esta habilidade — copie a pasta para o diretório de habilidades desse agente.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/nahid-sparktales/agent-dispatcher.git /tmp/agent-dispatcher
mkdir -p .claude/skills
cp -r /tmp/agent-dispatcher/skills/database/schema-design .claude/skills/schema-design
Reinicie Claude Code após copiar para que a nova habilidade seja reconhecida.

Use no TypingMind

Ative Schema Design em qualquer chat do TypingMind e o modelo cuida do resto. O nome e a descrição da habilidade ficam no prompt do sistema e, assim que uma solicitação relevante aparece, o modelo carrega as instruções completas automaticamente — sem precisar de acionamento manual e sem consumir tokens até que ela seja realmente usada.

O modelo carrega Schema Design automaticamente assim que uma solicitação é relevante para essa habilidade.

Funciona com qualquer modelo de IA

Habilidades de IA são instruções em Markdown simples, não código específico de um provedor. Por isso, Schema Design não fica vinculada ao modelo para o qual foi criada. Instale-a uma vez no TypingMind e use-a com GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama ou um modelo local executado por conta própria — tudo com suas próprias chaves de API.

  • Carregada apenas quando necessário

    O prompt do sistema contém apenas o nome e a descrição. As instruções são buscadas na primeira solicitação relevante, então uma habilidade sem uso não gera custo.

  • Troque de modelo durante a conversa

    Como a habilidade é composta de instruções, não de código, trocar de modelo não afeta seu funcionamento — o próximo modelo lê o mesmo arquivo SKILL.md.

Instruções da habilidade

Este é o conteúdo de SKILL.md que o modelo carrega. Leia antes de instalar — uma habilidade é um conjunto de instruções que seu modelo seguirá.

Schema design

The schema is the last place a rule is still enforced. Application code, a background job, a psql session and next year's import script all write to the same tables; only the constraints apply to all of them.

When this fires

Designing new tables, adding columns to existing ones, reviewing ORM models or DDL in a migration, or when a defect traces back to the data model permitting an impossible state. It does not fire for a query that is merely slow — that is a plan problem, not a modelling one.

Procedure

  1. Read the existing schema before proposing anything. Get the real DDL, constraints and indexes for the tables involved — \d+ in psql, information_schema, or the migration files if that is all the access you have. Note the conventions already in use: plural or singular table names, key style, timestamp columns. You are joining a schema, not starting one.
  2. Write each invariant as one sentence. "An order belongs to exactly one customer." "A subscription has at most one active period at a time." "An email identifies at most one account." Derive these from behaviour and from what breaks when they are violated, not from the nouns in the request. Each will become a constraint or fail to; the ones that fail are your risk list.
  3. Separate entities from attributes. A thing that is only ever reached through its parent and is never queried, counted or referenced on its own is a column, not a table. A thing with its own lifecycle, identity or history is a table even when there is currently one of them.
  4. Normalize to third normal form by default — one fact, one place. Denormalize only with a measured read problem and a written mechanism that keeps the copy honest (generated column, trigger, materialized view, or an application invariant plus a reconciliation job that can detect drift). "It will be faster" with no measurement is not a reason, and the measured answer is usually an index, not a duplicated column.
  5. Choose keys deliberately. Every table gets a primary key. A surrogate key is the default because natural keys change — but adding one does not excuse you from declaring the natural uniqueness as its own UNIQUE constraint, or duplicates become legal and will appear. For a pure join table the composite of the two foreign keys is usually the right primary key.
  6. Encode invariants as constraints, not intentions. NOT NULL for anything the system cannot operate without; UNIQUE, including a partial unique index for "at most one active X per Y"; CHECK for ranges, allowed values and cross-column rules; FOREIGN KEY with an ON DELETE action chosen on purpose, since RESTRICT, CASCADE and SET NULL are three different operational promises. Any invariant you cannot express declaratively gets named in the design along with where it is enforced instead.
  7. Decide what NULL means for each nullable column. "Not yet known", "not applicable" and "none" are three different facts and at most one of them should be NULL; the others want a sentinel, a separate flag, or a separate table. Remember NULL compares equal to nothing, including itself, so uniqueness and CHECK behave differently around it than readers expect.
  8. Pick types for meaning, not convenience. Instants as timezone-aware timestamps, dates as dates, money as exact decimal and never float, identifiers as the type they actually are. For what a specific engine offers, read the engine's own skill rather than guessing.
  9. Name so the name survives. Follow the existing convention over your preference. snake_case, foreign keys as <referenced_table>_id, no type in the name, no abbreviation only you understand, no reserved words, no column called data or info. Renaming later is a coordinated change across every reader in every deployed version.
  10. Check the model against the queries it will serve. List the three to five real access patterns. If a common one needs a join no key supports, or a scan of an unbounded table, or a column that does not exist yet, the model is wrong — fix it now, not with an index later.
  11. Make the change shippable. Expand then contract: add the new nullable or defaulted column, backfill, start writing both, move reads, then drop the old one — with each step deployable while the previous application version is still running. Applying any of it to a shared or production database is a separate authorized step: hand over the DDL and stop there.

Checklist

  • Current DDL, constraints and indexes read, not inferred from models
  • Every invariant written down, and each mapped to the constraint that enforces it
  • Invariants that cannot be enforced declaratively are named, with where they are enforced
  • Primary key on every table; natural uniqueness declared even where a surrogate key exists
  • Every foreign key has a deliberate ON DELETE action
  • Every nullable column has a stated meaning for NULL
  • Naming matches the conventions already in the schema
  • The real access patterns were checked against the model
  • The rollout is expand/contract and compatible with the running application version
  • Nothing was applied to a shared database

Failure handling

  • Only the ORM models are visible. Design against them, and say plainly that the live schema was not inspected — ORM definitions drift from the database, and indexes and CHECK constraints often exist in only one of the two.
  • Existing rows violate a constraint you want to add. Count them first. The count decides the plan: clean the data, scope the constraint with a partial index, or enforce it only for new rows. Adding a constraint that the current data fails is a failed deployment, not a design.
  • An invariant needs cross-row or cross-table logic. Say so rather than pretending a CHECK can do it. Name the alternative — a partial unique index, an exclusion constraint, a trigger, or a serializable transaction — and its cost.
  • Pressure to add a column "for later". Do not. An unused nullable column is a claim nobody maintains; add it when the behaviour arrives.
  • Disagreement about normalization. Resolve it with the invariant, not with taste: if two copies of a fact can disagree and nothing detects it, that settles it.

Evidence to report

The proposed DDL; the invariant list with the constraint enforcing each; the invariants left unenforced and where they are enforced instead; row counts for anything an existing table would have to satisfy; the access patterns checked. Be exact about status — a schema that has been designed or reviewed is not one that has been applied, and neither is one that has been tested against representative data.

Arquivos incluídos

O modelo lê esses arquivos sob demanda enquanto a habilidade está carregada. Eles são disponibilizados para leitura e nunca são executados.

Perguntas frequentes

O que a habilidade de IA Schema Design faz?

Turn what a system must guarantee into tables, keys and constraints — normalization judgement, nullability, foreign key behaviour, and naming that survives. Use when designing new tables, reviewing ORM models or a migration's DDL, or when a bug reduces to "the database allowed a row that should be impossible". Not for tuning a slow query, not for engine-specific syntax and features, and not for writing or running the migration that ships the change.

Por que usar Schema Design no TypingMind?

Porque basta instalar uma vez para usar com qualquer modelo. A habilidade Schema Design é escrita em Markdown simples, e não em código específico de um provedor, então a mesma habilidade funciona com GPT-5, Claude, Gemini, Grok ou um modelo local — e é possível trocar de modelo no meio do chat sem que ela deixe de funcionar. No TypingMind, você usa suas próprias chaves de API e paga diretamente aos provedores, em vez de pagar uma assinatura por licença de usuário. Suas habilidades e chats permanecem no seu próprio armazenamento.

Como instalar Schema Design no TypingMind?

Abra Plugins → Habilidades → Instalar do GitHub no TypingMind e cole https://github.com/nahid-sparktales/agent-dispatcher/tree/main/skills/database/schema-design. O TypingMind lê o arquivo SKILL.md, reúne os arquivos da habilidade e a instala para que possa ser ativada em cada chat.

Quais modelos de IA podem usar Schema Design?

Qualquer modelo conectado no TypingMind. As habilidades de IA são instruções em Markdown simples, e não código específico de um provedor. Assim, GPT, Claude, Gemini, Grok e modelos locais podem carregar esta habilidade quando uma solicitação corresponder a ela.

Quantos modelos de IA posso usar com Schema Design?

Quantos quiser. Desde que o modelo ofereça suporte a habilidades, é possível usar Schema Design com ele — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama e outros — tudo no TypingMind com suas próprias chaves de API.

A habilidade de IA Schema Design é gratuita?

Sim. A habilidade é publicada no GitHub por nahid-sparktales sob a licença MIT. O pagamento é feito apenas ao seu provedor de IA pelos tokens usados.

O que são habilidades de IA?

Uma habilidade de IA é um conjunto reutilizável de instruções que ensina um modelo de IA a realizar uma tarefa específica. Ela segue o formato aberto Agent Skills: um arquivo SKILL.md com nome e descrição, além de scripts, templates ou arquivos de referência de que o modelo possa precisar. O modelo lê as instruções apenas quando sua solicitação corresponde à habilidade, então uma habilidade instalada não gera custos até ser usada.

Qual é a diferença entre habilidades de IA e plugins ou servidores MCP?

Um plugin ou servidor MCP oferece ao modelo novas ferramentas que ele pode acionar — código que é executado em algum lugar e retorna um resultado. Já uma habilidade de IA dá ao modelo o conhecimento e as orientações de que ele precisa: como abordar uma tarefa, quais etapas seguir e como deve ser um bom resultado. As habilidades são escritas em Markdown simples, por isso não precisam de servidor, chave de API nem ambiente de execução, e funcionam com qualquer modelo.

Ver lista completa

Crie seu próprio espaço de trabalho com IA agora

Inscreva-se na nossa newsletter para receber avisos sobre novos recursos e futuros sorteios 👇