entity-normalization
When data crosses a system boundary into my code, I normalise it into a typed entity with a __type discriminator and a fixed common shape.
Skill by mateonunez
Chalk Labs
Need help deploying entity-normalization?
Chalk Labs sets up agents like this inside real teams: connected to your tools, tested on your data, with a human in the loop where it matters.
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/mateonunez-entity-normalization
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: backend, data
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/entity-normalization
What's inside
- Skill name
entity-normalization- Description
- When data crosses a system boundary into my code, I normalise it into a typed entity with a __type discriminator and a fixed common shape. The vendor's wire format is not my domain model. Use when ingesting external API data, when adding a new connector, when proposing entity types, or when user mentions "normalize", "entity", "ETL", "__type", or "mapper".
- License
- MIT
- Instructions
- 125 lines in SKILL.md · view on GitHub
Files (1)
- SKILL.md
SKILL.md (first lines)
# Entity normalisation
> The vendor's wire format is not my domain model.
External APIs return whatever they want — Spotify returns `external_urls.spotify`, GitHub returns `html_url`, Linear returns `url`. If raw vendor responses leak into the rest of the codebase, every consumer ends up special-casing every vendor. The fix is to normalise at the boundary: one shape, one discriminator, vendor-specific noise tucked into a `metadata` bag.
This is the [`ait`](../../personal/ait/SKILL.md) ETL pattern. It's the **data-channel** counterpart to [`result-not-throw`](../result-not-throw/SKILL.md) (the error channel). Together they make the type system useful: errors are typed, data is typed, the boundary is the only place either lives in the wild.
## When this skill is active
You are about to:
- Pull data from an external API and store / index / process it
- Add a new connector or integration
- Define a new entity type
- Write a mapper from vendor response → internal type
- Touch the `EntityType` union or its `VALID_ENTITY_TYPES` set
## The contract
```typescript
export type EntityType =
| 'spotify_track' | 'spotify_artist' | 'spotify_album'
| 'github_repository' | 'github_pull_request' | 'github_issue'
| 'linear_issue' | 'notion_page' | 'slack_message'
// ...
;
export interface NormalizedEntity {
__type: EntityType;
id: string; // namespaced: `${__type}_${externalId}`
externalId: string; // vendor's ID, untouched
title: string;
description?: string;
url?: string;
metadata: Record<string, unknown>; // vendor-specific extras
createdAt: Date;
updatedAt: Date;
}
```
Two invariants:
- **`__type` is the discriminator** the rest of the system switches on. Format: `<vendor>_<resource>`. Lowercase, snake_case. No exceptions — `SpotifyTrack` is wrong, `spotify-track` is wrong.
- **`id` is namespaced**: `${__type}_${externalId}`. Two vendors can have the same `externalId`; the namespaced `id` is globally unique.
## The mapper pattern
Every connector exports a function per resource: `map<Vendor><Resource>(raw) → NormalizedEntity`.
```typescript
// packages/connectors/src/domain/mappers/spotify.mapper.ts
export function mapSpotifyTrack(raw: SpotifyApi.TrackObject): NormalizedEntity {
return {
__type: 'spotify_track',
id: `spotify_track_${raw.id}`,
externalId: raw.id,
title: raw.name,
description: `${raw.artists.map(a => a.name).join(', ')} — ${raw.album.name}`,
url: raw.external_urls.spotify,
metadata: {
duration_ms: raw.duration_ms,
popularity: raw.popularity,
album: raw.album.name,
artists: raw.artists.map(a => a.name),
},
createdAt: new Date(),
updatedAt: new Date(),
};
}
```
Mappers are **pure**. No IO, no logging, no side effects — just `vendor → domain`. That makes them trivial to test and trivial to compose.
## Adding a new entity type
1. **Add the literal to the `EntityType` union.** Stable name: `<vendor>_<resource>`.
2. **Add it to the `VALID_ENTITY_TYPES` set.** That's the runtime validator.
3. **Write the mapper** in `packages/connectors/src/domain/mappers/<vendor>.mapper.ts`.
4. **Add the vendor-specific raw type** under `packages/core/src/types/integrations/<vendor>.ts`.
5. **Register the mapper** in the connector's service layer.
Five steps, every time, in that order. Skipping any of them creates silent failure modes downstream.
## Querying across vendors
Because every entity has the same shape, downstream code can be vendor-agnostic:
```typescript
function summarise(entities: NormalizedEntity[]): string {
return entities
.map(e => `${e.__type}: ${e.title}`)
.join('\n');
}
```
The discriminator is there when you want to specialise:
```typescript
switch (entity.__type) {
case 'spotify_track': return formatTrack(entity);
case 'github_pull_request': return formatPR(entity);
// ...
}
```
Exhaustiveness is checked by the compiler when you add a new `EntityType`.
## Anti-patterns
- **`__type: 'SpotifyTrack'`** (PascalCase) — break the convention. `__type` strings are kebab-style with `_` separators. The compiler doesn't enforce this; the convention does.
- **Putting vendor-specific fields at the top level** instead of in `metadata`. `entity.album` is wrong for a track that's also an album field on a playlist — vendor-specific extras live in `metadata`.
- **Mappers that throw.** If the raw payload is invalid, return `Result<NormalizedEntity, ValidationError>` (see `result-not-throw`) — don't throw inside a pure mapper.
- **Mappers that do IO** (fetch related data, hit the DB, log). Pure transformation only. If you need related data, fetch it before calling the mapper.
- **Forgetting to update `VALID_ENTITY_TYPES`** when adding a new literal. The TypeScript union is compile-time; the set is runtime. Both have to move together.
- **Different `id` formats per vendor.** `spotify_${id}` vs `gh-${id}` vs raw `id` — pick one (`${__type}_${externalId}`) and never deviate.
- **Storing the raw vendor payload alongside the entity** "just in case". It's `metadata` or it's gone. The vendor payload is not part of the domain.
## Cross-referencesFrom mateonunez/skills, MIT.
More from mateonunez/skills
- 0.536score
fastify-plugin-shape
mateonunez
How I write Fastify plugins — fastify-plugin wrapper, idempotency guard, decorator pattern, withX() helper for TS narrowing, module augmentation.
SkillCFreshness: C★ 8Claude Code +9 - 0.536score
result-not-throw
mateonunez
I return Result<T, E extends Error> from business logic — never throw.
SkillCFreshness: C★ 8Claude Code +9 - 0.536score
vertical-slices
mateonunez
I organise code by feature, not by layer.
SkillCFreshness: C★ 8Claude Code +9 - 0.536score
code-review
mateonunez
Review a diff or PR against my conventions — Result not throw, vertical slices, AItError codes, node:test, Biome, entity normalisation, a11y.
SkillCFreshness: C★ 8Claude Code +9 - 0.536score
single-tool-per-job
mateonunez
Biome is enough.
SkillCFreshness: C★ 8Claude Code +9 - 0.536score
production-observability
mateonunez
Include error telemetry, request context, and queue visibility in production code.
SkillCFreshness: C★ 8Claude Code +9 - 0.536score
prototyping
mateonunez
Build a throwaway prototype to flush out a design before committing.
SkillCFreshness: C★ 8Claude Code +9 - 0.536score
setup-mateonunez-skills
mateonunez
Scaffold the per-repo conventions my other engineering skills assume — pnpm + corepack, Biome (1.9 legacy or 2.x new), node:test posture, CONTEXT.md, docs/adr/.
SkillCFreshness: C★ 8Claude Code +9 - 0.536score
node-native-tests
mateonunez
I use node:test + borp + c8, not Jest or Vitest.
SkillCFreshness: C★ 8Claude Code +9 - 0.535score
fastify-orama
mateonunez
Knowledge pack for fastify-orama — a Fastify plugin that integrates Orama full-text search with persistence support.
SkillCFreshness: C★ 8Claude Code +9 - 0.531score
grill-me-mateo
mateonunez
Grill me on a plan or change before I write code, but with my canonical four questions baked in — package boundary, error code, vertical slice, ADR.
SkillCFreshness: C★ 8Claude Code +9 - 0.511score
triage
mateonunez
Triage issues through a state machine driven by triage roles.
SkillCFreshness: C★ 8Claude Code +9
Signals
- Stars
- 8
- Forks
- 0
- Open issues
- 0
- Last commit (this folder)
- May 7, 2026 (5 months ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/mateonunez/skills
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from mateonunez
- 0.536score
fastify-plugin-shape
mateonunez
How I write Fastify plugins — fastify-plugin wrapper, idempotency guard, decorator pattern, withX() helper for TS narrowing, module augmentation.
SkillCFreshness: C★ 8Claude Code +9 - 0.536score
code-review
mateonunez
Review a diff or PR against my conventions — Result not throw, vertical slices, AItError codes, node:test, Biome, entity normalisation, a11y.
SkillCFreshness: C★ 8Claude Code +9 - 0.536score
result-not-throw
mateonunez
I return Result<T, E extends Error> from business logic — never throw.
SkillCFreshness: C★ 8Claude Code +9 - 0.536score
prototyping
mateonunez
Build a throwaway prototype to flush out a design before committing.
SkillCFreshness: C★ 8Claude Code +9 - 0.536score
production-observability
mateonunez
Include error telemetry, request context, and queue visibility in production code.
SkillCFreshness: C★ 8Claude Code +9 - 0.536score
node-native-tests
mateonunez
I use node:test + borp + c8, not Jest or Vitest.
SkillCFreshness: C★ 8Claude Code +9
Done for you
Rather not set it up yourself?
Chalk Labs scopes, builds and runs agents for your team: the task audit, the eval harness, the integrations and the weekly ops report. Fixed scope, priced before we start.
See how we build AI agents →Read the case studies
Chalk Labs is a two-founder AI and growth studio. We build AI agents, CRMs and MVPs for Web3 and AI companies, and have shipped 50+ product and token launches.
- launches shipped
- 50+
- launches shipped
- media placements
- 500+
- media placements
- founders on every account
- 2
- founders on every account
Press we've placed: Forbes · CoinDesk · Decrypt · Cointelegraph · The Block
Rahil Jain, Co-founder, Chalk Labs. Ex-Goldman Sachs engineer. You talk to the person who builds it.
Get entity-normalization running in your business
Tell us what you want to automate. A founder replies within one working day with a plan, not a pitch deck.
Cite this page
entity-normalization skill. Agent Mart. https://agentmart.dev/skills/mateonunez-entity-normalization (last updated 2026-10-24)