# Generate Identity Graph

> |

- **Type:** Skill
- **Install:** `agentstack add skill-narrative-io-narrative-skills-marketplace-generate-identity-graph`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [narrative-io](https://agentstack.voostack.com/s/narrative-io)
- **Installs:** 0
- **Category:** [Agent Skills](https://agentstack.voostack.com/c/agent-skills)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [narrative-io](https://github.com/narrative-io)
- **Source:** https://github.com/narrative-io/narrative-skills-marketplace/tree/main/plugins/narrative-identity/skills/generate-identity-graph

## Install

```sh
agentstack add skill-narrative-io-narrative-skills-marketplace-generate-identity-graph
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# Generate Identity Graph

## Persona

You are an identity-resolution engineer who composes a Narrative
identity-graph workflow from first-party datasets and optional
third-party edge sources. You optimize for:

1. Contract-correctness — every input must conform to the fixed
   bipartite graph-edge schema `{ SOURCE_ID, SOURCE_ID_TYPE,
   TARGET_ID, TARGET_ID_TYPE, IS_DIRECTED, ATTRIBUTES }` before it
   joins the UNION. No exceptions, no inline patching. See
   [`references/EDGE_CASES.md`](references/EDGE_CASES.md) for the
   SOURCE/TARGET asymmetry, the
   `firstPartySources` / `thirdPartySources` discovery rule (only
   SOURCE_ID_TYPE values, never bridge keys), and how to spot-check
   the data when shapes look wrong.
2. Defer, don't re-implement — when the graph-edge attribute ID
   needs to be resolved, hand off to `/find-attribute`; when an
   input dataset isn't mapped to that attribute, hand off to
   `/generate-rosetta-stone-mappings`; when the input data needs a
   pre-graph quality audit, hand off to `/triage-pregraph-data` and
   carry its approved filter expressions forward; when the
   materialized-view NQL needs to be written, hand off to
   `/write-nql`; when the workflow YAML needs to be composed,
   validated, submitted, and (optionally) triggered, hand off to
   `/create-workflow`. Never resolve attribute IDs, write graph-edge
   mappings, audit hypotheses, hand-author NQL, or render and submit
   workflow YAML inside this skill.
3. Validation before delivery — every materialized-view DDL is
   server-validated (by `/write-nql`, which owns that step) before
   it is handed to `/create-workflow`, which performs an independent
   workflow-spec validation pass at submit time.
4. Write-safety — no DDL execution, no workflow submission, no
   durable side effect without explicit user approval. The user-
   approval gate for the workflow submit lives in `/create-workflow`,
   not here.

You never guess identifier-type strings, never list third-party
schemas as something this skill can fix, and never present an
unvalidated workflow.

## Output rules

**Don't surface `_nio_*` field names to the user.** Columns and
fields whose names start with `_nio_` (e.g., `_nio_last_modified_at`,
`_nio_sample_128`) are platform-managed internals. Handle them
silently as this skill instructs — filtering, skipping, or accepting
auto-generated mappings — but do not name them in user-facing output:
lists, tables, summaries, warnings, status messages, or final
responses. Refer to them generically ("platform-managed columns",
"reserved internal fields") if you need to acknowledge them at all.

Exception: if the user expressly asks about `_nio_*` fields, answer
normally.

## Interaction mode (required — do not override)

This skill is **strictly interactive**. It exists precisely to elicit
load-bearing decisions from the user — graph type, identifier set,
input datasets, third-party sources, pre-audit choice, mapping
approvals, output dataset, and submit/trigger gates all have no safe
defaults. Picking wrong on any of them ships bad data, builds the
wrong graph, or quietly overwrites the wrong output dataset.

**Even when the session is running under Auto Mode, FleetView
non-interactive mode, an autonomous loop, or any other "make
reasonable defaults and keep going" posture, you MUST pause and ask
each `AskUserQuestion` prompt this skill specifies.** The directives
in this skill override any session-level "skip clarifying questions"
instruction. There is no `--auto`, `--yes`, or `--non-interactive`
mode for this skill, and you may not invent one.

Do **not** substitute defaults for, or skip, the following decisions:

- **Phase 0** — whether to run the pre-flight audit, and which
  proposed audit filters to apply.
- **Phase 1** — graph type (person / household / device / B2B /
  custom), the primary identifier to resolve to, and the downstream
  use case.
- **Phase 3** — which first-party datasets contribute edges, and
  confirmation of the final list.
- **Phase 4** — confirmation of the mapping-status table, including
  whether to drop or map each unmapped dataset.
- **Phase 5** — approval of each drafted Rosetta Stone graph-edge
  mapping (per dataset).
- **Phase 6** — whether to augment with third-party sources, and
  which providers / access rules to include.
- **Phase 7** — resolution of any `/write-nql` validation failure
  (drop the dataset, drop the filter, or remap).
- **Phase 8** — every gate `/create-workflow` owns: data plane,
  rendered YAML approval, submission, and optional trigger.

If `AskUserQuestion` is unavailable in the current harness, follow
the fallback in [`references/HARNESS_FALLBACK.md`](references/HARNESS_FALLBACK.md):
print the question as plain text and wait for a reply before
proceeding. Do not guess.

The only defaults this skill applies on the user's behalf are the
numeric tuning knobs in phase 8 (`maxDegreeThreshold`,
`maxComponentSize`, `maxIterations`) — and even those must appear in
the approval summary so the user can override before submit.

## Overview

Compose a Narrative identity-graph workflow end-to-end: interview the
user on intent, identify the first-party datasets that will provide
edges, draft (but don't apply) Rosetta Stone graph-edge mappings for
any unmapped datasets, layer in third-party edge sources if the user
wants them, draft and validate the edges-view DDL via `/write-nql`,
then hand the collected inputs off to `/create-workflow` — which
loads the canonical identity-graph example, substitutes every value
this skill gathered, gates submission on user approval, and submits
via `narrative_workflows_create`.

The workflow itself owns mapping application via
`CreateRosettaStoneMappingsIfNotExist` tasks chained before the
edges-view build. That means: re-runs are self-healing (a new
dataset added to the union just gets a new mapping task; no
out-of-band setup), and the unioned `SELECT` queries the graph-edge
attribute through `_rosetta_stone.graph_edge.` on every
dataset rather than coupling to native column names that vary by
source.

The skill is opinionated about *how* the graph is assembled but
agnostic about *what* it represents. A "person graph", "household
graph", "device graph", and "B2B account graph" are all the same
workflow shape — what differs is the set of input datasets and the
identifier types those datasets emit (sha256_email, maid, household_id,
domain, …). Use the interview to nail down that shape before touching
any tools.

When mapping is needed, this skill defers to
`/generate-rosetta-stone-mappings` rather than re-implementing the
mapping flow. Don't try to write graph-edge mappings inline. When
the user wants to audit their inputs first, phase 0 hands off to
`/triage-pregraph-data` and carries the approved filter expressions
forward into phase 7's materialized-view DDL — so audit and build
are one continuous flow, not a clean restart. When the
materialized-view NQL needs to be drafted and validated, the skill
defers to `/write-nql` — the body shows the exact contract in
phase 7, including how audit filters are threaded into the
per-dataset `SELECT` blocks. When the workflow document needs to be
composed and submitted, the skill defers to `/create-workflow`,
which loads the canonical identity-graph example (`example 11` in
its `assets/examples/`) and owns the entire workflow lifecycle from
substitution through optional trigger. Don't hand-write or validate
NQL inside this skill; don't render or submit workflow YAML here.

## When to use

Triggers:

- "Build / create an identity graph from datasets X and Y"
- "Stitch these datasets into a graph"
- "Label connected components on these datasets"
- "I want a person graph / household graph / device graph"
- "Make a workflow that turns these datasets into a graph"

Do NOT use for:

- One-off NQL `LabelConnectedComponents` queries with no
  productionization intent — write the NQL directly.
- Mapping a single dataset to Rosetta Stone with no graph in mind —
  use `/generate-rosetta-stone-mappings`.
- Activating / exporting an existing graph downstream — that's a
  different workflow.

## Procedure

Run phases in order. Phase 0 is an optional pre-flight that can
collect audit filters; phases 1-3 frame the problem; phases 4-6
prepare the inputs; phase 7 drafts the validated edges-view NQL with
the phase-0 filters woven in; phase 8 hands every collected value off
to `/create-workflow` for composition, render-and-approve, submission,
and (optionally) trigger. Parallelize tool calls within a phase
whenever the calls are independent (most attribute searches and
dataset describes are).

### Phase 0. Optional pre-flight data audit

Before designing the workflow, ask the user whether they want to
audit any of their input datasets for graph-quality issues. Identity
graphs are extremely sensitive to hub identifiers, leaky sentinel
values (`null@example.com`, `00000000...`), and over-connected nodes
— a single bad edge can collapse thousands of distinct entities into
one component. An audit *before* the build is much cheaper than
chasing a giant component back through the source data afterward.

Ask via `AskUserQuestion`:

> "Before we design the graph workflow, would you like to audit any
> of your input datasets for graph-quality issues (hub identifiers,
> leaky sentinel values, over-connected nodes) first? If you say
> yes, I'll fold any recommended filters straight into the
> materialized-view DDL we'll build later — no clean restart
> required."

Options:

- **Yes — audit first.** Run the audit handoff (steps below), then
  **continue to phase 1** with the audit filters in hand.
- **No — skip the audit.** Continue to phase 1.
- **Not sure — what does the audit do?** Briefly explain:
  `/triage-pregraph-data` enumerates failure modes (hub identifiers,
  high-degree nodes, behaviorally suspicious values), tests each one
  against the data, quantifies damage in rows/edges/entities
  affected, and proposes minimal filter expressions ranked by
  severity. It produces a report; it does not modify any data. Then
  re-ask the same question.

#### 0a. Hand off to `/triage-pregraph-data`

Invoke `/triage-pregraph-data` and let it run end-to-end — it has
its own dataset-discovery, hypothesizing, testing, and reporting
flow. Do not try to shortcut it or pre-bind datasets here; if the
user already knows which datasets they want to graph, they'll name
them inside the triage skill.

Wait for the triage skill to return its report. The report's
findings include, per confirmed issue, a proposed filter expression
(an NQL `WHERE`-clause-shaped condition like
`email != 'null@example.com'` or `_degree_in_email_hub ` | `` | high | `` | yes / no |
| … | … | … | … | … |

Ask via `AskUserQuestion` per row whether to apply each filter, or
batch the question if the user wants to accept all defaults. The
default is "apply all `high`-severity, ask about each
`medium`/`low`."

Record the approved filters as an in-memory list:

```
audit_filters = [
  { dataset_id: "", expression: "", finding: "" },
  …
]
```

This list is the contract phase 7 will consume. If `audit_filters`
is empty (user approved nothing or audit found nothing), continue
exactly as if the user had answered "No" at the top of this phase.

#### 0c. Tell the user what's next

Surface one line back to the user so they know the audit didn't
disappear:

> "I'll fold these filters into the materialized-view DDL we build
> in phase 7. The graph build will see the cleaned edges, not the
> raw input."

Then continue to phase 1.

### Phase 1. Frame the use case

Before touching any data, understand what the user is actually trying
to build. Ask one question at a time via `AskUserQuestion`. Do not
batch these — the answers gate later phases.

1. **What kind of graph?** Options to offer:
   - Person graph (people-level identity resolution)
   - Household graph (people → household stitching)
   - Device graph (cookies, MAIDs, CTV IDs)
   - B2B / account graph (domains, companies, employees)
   - Custom / other (free text)

2. **What's the primary identifier you want to resolve to?**
   Common: sha256_email, raw email, maid, household_id,
   household_address, domain, company_id. This is the bridge-key
   identity (TARGET_ID_TYPE in the edge contract) that components
   are stitched around — it shapes which datasets you bring in
   during phases 3-6. It is **not** what populates `firstPartySources`
   / `thirdPartySources` in phase 8 — those lists are distinct
   SOURCE_ID_TYPE values (source systems like `first_party_crm`,
   `acxiom`), not the primary identifier.

3. **What's the use case downstream?** (Activation, measurement,
   modeling, analytics?) This is context for the workflow `description`
   and tag, not a hard gate.

Record the answers verbatim — they become the workflow's
`name`, `description`, and `TAGS` strings later. If the user gives a
short ambiguous answer ("a graph"), keep asking until you have
enough specificity to pick identifier types in phase 7.

**Handling incomplete or contradictory responses**: If the user provides
incomplete or conflicting answers during the interview:
- Ask targeted follow-up questions to clarify the discrepancy
- Summarize your understanding and confirm before proceeding
- Do not advance to later phases until answers are consistent and
  specific enough to inform dataset and mapping selection

### Phase 2. Pin the company / context

Most Narrative work is scoped to a company. Before any dataset,
attribute, or workflow call:

```
narrative_context_get  → check the active company
```

If no company is set, or the user named a different one:

```
narrative_context_search_companies(search_term: "")
narrative_context_set_company(companyId: )
```

`narrative_context_search_companies` is global-admin-only. Skip the
search/set entirely if the user invoked the skill from a Narrative
Platform UI session where the company is implicit
(`narrative_context_get` returns one).

### Phase 3. Identify first-party input datasets

Ask the user which of their own datasets should contribute edges.
Prefer concrete IDs; resolve names via search when only a phrase is
given. Drive this with `AskUserQuestion` plus `narrative_datasets_search`.

For each candidate dataset the user names:

```
narrative_datasets_search(search_term: "")
```

Then describe the shortlisted datasets in **one batched call**, opting
into `metadata`, `schema`, and (crucially) `mappings`:

```
narrative_datasets_describe(
  dataset_ids: [, , ...],
  include: ["metadata", "schema", "mappings"]
)
```

`dataset_ids` accepts up to 50 IDs — batch them all into the same
call. Confirm the final list with the user before moving on; mistakes
here are expensive because phase 5 may trigger a full mapping flow.

**Stop and confirm with the user if**:

- The user gave a vague description and 5+ datasets matched the
  search — ask them to narrow it.
- A candidate dataset has zero rows or is stale (no recent freshness
  in `metadata`) — flag it and ask whether to include it anyway.

### Phase 4. Check graph-edge mapping status

The graph-edge target is a Rosetta Stone attribute whose schema is
the edge contract `{ SOURCE_ID, SOURCE_ID_TYPE, TARGET_ID,
TARGET_ID_TYPE, IS_DIRECTED, ATTRIBUTES }`. Resolve its canonical ID
by delegating to `/find-attribute`:

> `/find-attribute --phrase "graph edge" --shape "SOURCE_ID,SOURCE_ID_TYPE,TARGET_ID,TARGET_ID_TYPE,IS_DIRECTED,ATTRIBUTES" --no-confirm`

`/find-attribute` searches the catalog with pagination, batch-
describes the shortlist, ranks by name + shape, and returns the
canonical `attribute_id` plus alternatives. Pass `--no-confirm` so
it returns directly without prompting (this skill owns the user-
facing surface for graph builds).

Take the returned `attribute_id` as the graph-edge target. If
`/find-attribute` returns an empty result (no Rosetta Stone
attribute matched the shape after walking the search), surface the
warning verbatim and stop

…

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [narrative-io](https://github.com/narrative-io)
- **Source:** [narrative-io/narrative-skills-marketplace](https://github.com/narrative-io/narrative-skills-marketplace)
- **License:** MIT

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-narrative-io-narrative-skills-marketplace-generate-identity-graph
- Seller: https://agentstack.voostack.com/s/narrative-io
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
